function isEmpty(str,name)
{
	var retval=true;
	var count=0;
	if (str.value=="")
		{
			alert("Please Enter " + name + "");
			str.focus();
			retval=false;
		}
	else
		{
			for(i=0;i<str.value.length;i++)
			{
				if(str.value.charAt(i)==" ")
				count++;
			}
			if (count==str.value.length)
			{
				alert("Please Enter " + name + "");
				str.focus();
				retval=false;
			}
		}
	return retval;
}

function isValidChars(str)
{
	var invalidchars=",#$%^&*()!~`+\|=[{]};:'<>?/";
	var retval=true;
	var i;
	for (i=0;i<invalidchars.length;i++)
		if (str.value.indexOf(invalidchars.charAt(i)) > -1)
		{
			alert("Please Enter valid EmailID");
			str.value="";
			str.focus();
			retval=false;
		}
	return retval;
}	

function IsEmailValid(str)
{
	var retval=true;
	var AtSym=str.indexOf('@');				
	var Period=str.lastIndexOf('.');		
	var Space=str.indexOf(' ');				
	var Length=str.length-1;
	var index = str.indexOf('@');
    var substr = str.substring(index+1);
    var index2 = substr.indexOf('@');
	if ((AtSym<1)||(str.charAt(0)=='_')||(str.charAt(Length)=="_")||				
		(str.indexOf(".")<=AtSym+1)||
		(str.indexOf("_")==AtSym+1)||(str.charAt(AtSym-1)=="_")||
		(Period==Length)||				
		(Period<=AtSym+1)||						
		((Space>0) && (Space!=Length))||
		(index2 != -1))                       
		 retval=false; 
	return retval;
}
function matching(str1,str2,name)
{
	var retval=true;
	if (str1.value != str2.value)
	{
		alert(name + " and Re-enter " + name + " not matched");
		str2.focus();
		retval=false;
	}
	return retval;
}

function checkval(eld,young,mbro,info)
{
	var retval = true;
	var mbrothers = eld.value + young.value;
	if(mbrothers != mbro.value)
		{
		alert("Please check " + info + " !");
		mbro.focus();
		retval = false;
		}
	return retval;


}

function isEmptyLbox(str,name)
{

	var retval=true;
	
	if (str.value=="0" || str.value=="" || str.value=="-")
	{
		alert("Please Select " + name + "");
		str.focus();
		retval=false;
	}
  	return retval;
}

function isDOBvalid(Day,Month,Year,name)
{
var ArrDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if (Year.value%4==0)													
{
	ArrDays[1]=29;			
}
if ( Day.value > ArrDays[Month.value-1])			
{
		ArrDays[1]=28;
		alert("Enter Valid Date " + name);
		Day.focus();
		return false;
}
}

function isValidLength(string, min, max) {	
	var retval=true;
   if (string.length < min || string.length > max) { 
   alert ("Password should contain minumum of "+min+" characters");   
   retval=false; }
   return retval;
}

// Check that a string contains only letters and numbers
function isAlphanumeric(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^\w\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\W/) != -1)) return false;
   }
   return true;
}

// Check that a string contains only letters
function isAlphabetic(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) || (!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) return false;
   }
   return true;
}

// Check that a string contains only numbers
function isNumeric(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
   }
   return true;
}

// Check that a credit card number is valid based using the LUHN formula (mod10 is 0)
function isValidCreditCard(number) {
   number = '' + number;
   if (number.length > 16 || number.length < 13 ) return false;
   else if (getMod10(number) != 0) return false;
   else if (arguments[1]) {
      var type = arguments[1];
      var first2digits = number.substring(0, 2);
      var first4digits = number.substring(0, 4);
      
      if (type.toLowerCase() == 'visa' && number.substring(0, 1) == 4 &&
         (number.length == 16 || number.length == 13 )) return true;
      else if (type.toLowerCase() == 'mastercard' && number.length == 16 &&
         (first2digits == '51' || first2digits == '52' || first2digits == '53' || first2digits == '54' || first2digits == '55')) return true;
      else if (type.toLowerCase() == 'american express' && number.length == 15 && 
         (first2digits == '34' || first2digits == '37')) return true;
      else if (type.toLowerCase() == 'diners club' && number.length == 14 && 
         (first2digits == '30' || first2digits == '36' || first2digits == '38')) return true;
      else if (type.toLowerCase() == 'discover' && number.length == 16 && first4digits == '6011') return true;
      else if (type.toLowerCase() == 'enroute' && number.length == 15 && 
         (first4digits == '2014' || first4digits == '2149')) return true;
      else if (type.toLowerCase() == 'jcb' && number.length == 16 &&
         (first4digits == '3088' || first4digits == '3096' || first4digits == '3112' || first4digits == '3158' || first4digits == '3337' || first4digits == '3528')) return true;
      
    // if the above card types are all the ones that the site accepts, change the line below to 'else return false'
    else return false;
   }
   else return true;
}


function expired( month, year ) {
	var now = new Date();							// this function is designed to be Y2K compliant.
	var expiresIn = new Date(year,month,0,0,0);		// create an expired on date object with valid thru expiration date
	expiresIn.setMonth(expiresIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of expired month
	if( now.getTime() < expiresIn.getTime() ) return false;
	return true;									// then we get the miliseconds, and do a long integer comparison
}


function isValidLengthcc(string, min, max) {	
	var retval=true;
   if (string.length < min || string.length > max) { 
   retval=false; }
   return retval;
}

function validateKeyPress( e ) {
		if ( !e ) var e = window.event;
		if ( e.charCode ) {
			if ( e.charCode == 0 || e.charCode == 46 || ( e.charCode > 47 && e.charCode < 58 ) ) {
				return true;
			} else {
				if (e.preventDefault) e.preventDefault();
				e.cancelBubble = true;
				return false;
			}
		} else {
			if ( e.keyCode == 0 || e.keyCode == 46 || ( e.keyCode > 47 && e.keyCode < 58 ) ) {
				return true;
			} else {
				e.returnValue = false;
				e.cancelBubble = true;
				return false;
			}
		}
	}
	
function KeyPress(what,e,max,action) {
    if (document.layers) {
        if (e.target.value.length >= max)
            eval(action);
    }
    else if (document.all) {
        if (what.value.length > (max-1))
            eval(action);
    }
}

function isNumeric_decimal(string, ignoreWhiteSpace) {   
    if (string.search) {     
        if ((ignoreWhiteSpace && string.search(/[\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) 
            return false;   
     }   
        return true;
}
  
var alertTimerId = 0;  
  
function show_subnav(id){
    
   if (document.getElementById){
       document.getElementById(id).style.display = 'block'; 
   }     
}

function hide_subnav(id){
    
   if (document.getElementById){
       document.getElementById(id).style.display = 'none'; 
   }     
}

function clear_timeout(){
    
   clearTimeout(alertTimerId);    
}

function set_timeout(id){
    str = "hide_subnav('"+id+"')";
    alertTimerId = setTimeout(str, 700);
}