


// This function checks for valid product namevar weekend = [0,6];
var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

Months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];

// Non-Leap year Month days..
DOMonth = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
lDOMonth = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function get_month(monthNo) {
	return Months[monthNo];
}

function getDaysOfMonth(monthNo, p_year) {
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return DOMonth[monthNo];

		return lDOMonth[monthNo];
	} else
		return DOMonth[monthNo];
}

function trim(str) {
 if (str == null)
  return "";
 if (str.length <1)
    return "";
 var i =0;
 while (str.charAt(i) == ' ')
        i++;
 str = str.substr(i);
 i = str.length;
 while (str.charAt(--i) == ' ')
        ;
 str = str.substr(0, (str.length + 1 + (i - str.length)));
 return str;
}//end of trim()
/*************************/
/**
* This function trims all text fields of the given form
*/
function trimFormFields(frm) {
  if (typeof(frm) != 'object'){
    alert("The argument supplied if not an object.\nThis function requires a document.form object.");
    return;
  }
  var i=0, len = frm.elements.length;
  for (i=0; i < len; i++){
    if (frm.elements[i].type == 'text' || frm.elements[i].type == 'textarea') {
       frm.elements[i].value = trim(frm.elements[i].value);
    }
  }
}//end of trimFormFields
/*************************/
/*
* This function returns true if 
* string contains " or '.
* Returns false otherwise
*/
function isContainsQuotes(str){
 str = trim(str);
 if (str.length < 1)
    return false;
 if (str.indexOf('\'')  >= 0)
    return true;
 if (str.indexOf('\"')  >= 0)
    return true;
   
  return false;

}
function isContainsAddition(str){
 str = trim(str);
for (i=0; i < str.length; i++){
if (str.charAt(i) == '+')
      continue;
    if (str.charAt(i) == '-')
       continue;
   
  return false;
}
}


/*************************/
/*
* This function returns true if 
* string contains A-Z, a-Z, space, and a dot (.).
* Returns false otherwise
*/
function isValidName(str){
 str = trim(str);
 if (str.length < 1)
    return false;
 for (i=0; i < str.length; i++){
   	if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
     continue;
	  // return true;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
     continue;
	if (str.charAt(i) == ' ')
      continue;
  if (str.charAt(i) == '.')
      return false;
	if (str.charAt(i) == "'")
       return false;
	if (str.charAt(i) == "!")
        return false;
    if (str.charAt(i) == "@")
     return false;
	 if (str.charAt(i) == "#")
     return false;
	 if (str.charAt(i) == "$")
     return false;
	 if (str.charAt(i) == "%")
     return false;
	  if (str.charAt(i) == "^")
     return false;
	  if (str.charAt(i) == "~")
     return false;
	  if (str.charAt(i) == "&")
     return false;
	 if (str.charAt(i) == "(")
     return false;
	  if (str.charAt(i) == ")")
     return false;
	  if (str.charAt(i) == "+")
     return false;
	  if (str.charAt(i) == "=")
     return false;
	  if (str.charAt(i) == "_")
     return false;
	  if (str.charAt(i) == "|")
     return false;
	  if (str.charAt(i) == "/")
     return false;
	   if (str.charAt(i) == "\\")
     return false;
	   if (str.charAt(i) == '"')
     return false;
	  if (str.charAt(i) == ":")
     return false;
	  if (str.charAt(i) == ";")
     return false; 
	 
	  if (str.charAt(i) == "`")
     return false; 
	  if (str.charAt(i) == "<")
     return false;
	  if (str.charAt(i) == ">")
     return false;
	  if (str.charAt(i) == ",")
     return false;
	  if (str.charAt(i) == "?")
     return false;
	  if (str.charAt(i) == "[")
     return false;
	  if (str.charAt(i) == "]")
     return false;
	  if (str.charAt(i) == "{")
     return false;
	  if (str.charAt(i) == "}")
     return false;
	  if (str.charAt(i) == "-")
     return false;
	  if (str.charAt(i) == "*")
     return false;
	  if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      return false;
	  var code = str.charCodeAt(i);
	  if(code>=128)
    	return false;
	 }

	  return true; 
  if (str.indexOf('.') != str.lastIndexOf('.'))
    return false;
  if ((str.charAt(0) == '.') || (str.charAt(str.length-1) == '.'))
    return false;
 
}
function isValidQuestion(str){
 str = trim(str);
 if (str.length < 1)
    return false;
 for (i=0; i < str.length; i++){
   	if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
     continue;
	  // return true;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
     continue;
  if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
     continue;
	if (str.charAt(i) == ' ')
      continue;
    if (str.charAt(i) == '.')
       continue;
	if (str.charAt(i) == "'")
        continue;
    if (str.charAt(i) == ",")
        continue;
	if (str.charAt(i) == "/")
        continue;
	if (str.charAt(i) == ":")
        continue;
	if (str.charAt(i) == "?")
        continue;
	if (str.charAt(i) == "-")
        continue;
	if (str.charAt(i) == "_")
        continue;
	if (str.charAt(i) == "(")
        continue;
	if (str.charAt(i) == ")")
        continue;
	if (str.charAt(i) == "!")
        return false;
    if (str.charAt(i) == "@")
     return false;
	 if (str.charAt(i) == "#")
     return false;
	 if (str.charAt(i) == "$")
     return false;
	 if (str.charAt(i) == "%")
     return false;
	  if (str.charAt(i) == "^")
     return false;
	  if (str.charAt(i) == "&")
     return false;
	  if (str.charAt(i) == "*")
     return false;
	  if (str.charAt(i) == "+")
     return false;
	  if (str.charAt(i) == "=")
     return false;
	  if (str.charAt(i) == "|")
     return false;
	  if (str.charAt(i) == "<")
     return false;
	  if (str.charAt(i) == ">")
     return false;
	  if (str.charAt(i) == "~")
     return false;
	  if (str.charAt(i) == "`")
     return false;
	 if(str.charCodeAt(i) =='13')
       continue;
	   if(str.charCodeAt(i) =='10')
        continue;
	  var code = str.charCodeAt(i);
	  if(code>=128)
    	return false;
		 return false;
	 }
	if (str.indexOf('\'')  >= 0)
    return true;
    if (str.indexOf('\"')  >= 0)
    return true;
    if ((str.charAt(0) == '.') || (str.charAt(str.length-1) == '.'))
    return false;
   if ((str.charAt(0) == '?') || (str.charAt(str.length-1) == '?'))
    return false;
	if (str.indexOf('\n')==true)
   return false;
   if (str.lastIndexOf('\n')==true)
   return true;

	
	return true;
}

function isValidCompany(str){
 str = trim(str);
 if (str.length < 1)
    return false;
    
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
      continue;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
      continue;
	if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
	   if (str.charAt(i) == ' ')
      continue;
    if (str.charAt(i) == '.')
      continue;
	  
	  if(str.charCodeAt(i) >=128)
       return false;
  }
 
  if (str.indexOf('.') != str.lastIndexOf('.'))
    return false;
  if (str.charAt(0) == '0')
    return false;
   
  return true;

}
function isValidComment(str){
 str = trim(str);
 if (str.length < 1)
    return false;
    
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
      continue;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
      continue;
	if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
	   if (str.charAt(i) == ' ')
      continue;
    if (str.charAt(i) == '.')
      continue;
	  if (str.charAt(i) == ',')
      continue;
	  if (str.charAt(i) == '(')
      continue;
	  if (str.charAt(i) == ')')
      continue;
	  if (str.charAt(i) == '-')
      continue;
	  if (str.charAt(i) == '!')
      continue;
	  if (str.charAt(i) == '/')
      continue;
	  if (str.charAt(i) == ':')
      continue;
	  if (str.charAt(i) == ';')
      continue;
	  if (str.charAt(i) == '"')
      continue;
	   if (str.charAt(i) == "'")
      continue;
	 if(str.charCodeAt(i) =='13')
       continue;
	 if(str.charCodeAt(i) =='10')
        continue;
		
	  if(str.charCodeAt(i) >=128)
       return false;
	   return false;
  }
 if (str.indexOf('\'')  >= 0)
    return true;
 if (str.indexOf('\"')  >= 0)
    return true;
if (str.indexOf('\n')==true)
 return false;
if (str.lastIndexOf('\n')==true)
 return true;

/*if (str.indexOf('\n')==str.lastIndexOf('\n'))
    return false;
	else if(str.charAt())
	else if(str.lastIndexOf('\n')>=str.indexOf('\n'))
	return true;
	else
	return false;*/
 if (str.charAt(0) == '0')
    return false;
   
  return true;

}

/* 
  Check the validity of the titles 
  Is Valid Title
  Mr & Mrs
  */
  function isValidTitle(str){
	  str=trim(str);
  		if((str.equals("MR"))||(str.equals("MRS"))||(str.equals("MS"))){
		return true;
		}else{
		return false;
		}
  	}
  
/*
* For use valid city and state name.
* This function returns true if 
* string contains A-Z, a-Z, and space
* Returns false otherwise
*/
function isValidCity(str){
 str = trim(str);
 if (str.length < 1)
    return false;
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
      continue;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
      continue;
    if (str.charAt(i) == ' ')
      continue;
	if(str.charAt(i) =="'") 
	  return false;
	if (str.charAt(i) == "!")
        return false;
    if (str.charAt(i) == "@")
     return false;
	 if (str.charAt(i) == "#")
     return false;
	 if (str.charAt(i) == "$")
     return false;
	 if (str.charAt(i) == "%")
     return false;
	  if (str.charAt(i) == "^")
     return false;
	  if (str.charAt(i) == "&")
     return false;
	 if (str.charAt(i) == "(")
     return false;
	  if (str.charAt(i) == "*")
     return false;
	 var code = str.charCodeAt(i);
	  if(code>=128)
    	return false;
	    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
			return false;
  }
  return true;
}
/*************************/
/*
* This function returns true if 
* string contains A-Z, a-Z, 0-9, _.
* Returns false otherwise
*/
function isValidUID(str){
 str = trim(str);
 if (str.length < 1)
    return false;
    
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
      continue;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
      continue;
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
    if (str.charAt(i) == '_')
      continue;
     
    return false;
    
  }
 
  return true;

}

/*************************/
function isANumber(str){
  str = trim(str);
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
    if (str.charAt(i) == '.')
      continue;
    return false;
  }
 
  //Can not have two dots (.)
  if (str.indexOf('.') != str.lastIndexOf('.'))
    return false;
   
  return true;

}

/*************************/
function isValidTelNum(str){
  if (str == null)
     return false;
  str = trim(str);
  var txtstr=str;   
  for (var i=0; i < txtstr.length; i++){
  str=txtstr;
   if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
    return false;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
    return false;
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
  /*  if (str.charAt(i) == '-')
      continue;*/
   
      
    if(str.substring(0,1)=='+')
	continue;
	if(str.substring(0,1)=='-')
	return false;
	  if (str.substring(0,1) == '*')
     return false;
	 if (str.substring(str.length-1,str.length) == '-')
     return false;
     
  //str=txtstr.substring(1,txtstr.length); 
  if(i==0)
  i=1;
     if (str.substring(str.length-1,str.length) == '+')
     return false;
	// if (str.charAt(i) == '+')
     //continue;
	if(str.charAt(i)==" ")
	return false;
	if(str.charAt(i) =="'")
	return false;
	    if (str.charAt(i) == "!")
        return false;
    if (str.charAt(i) == "@")
     return false;
	 if (str.charAt(i) == "#")
     return false;
	 if (str.charAt(i) == "$")
     return false;
	 if (str.charAt(i) == "%")
     return false;
	  if (str.charAt(i) == "^")
     return false;
	  if (str.charAt(i) == "&")
     return false;
	 if (str.charAt(i) == "(")
     return false;
   
	  if (str.charAt(i) == "*")
     return false;
     if (str.charAt(i) == "+")
     return false;
    /*if (str.lastIndexOf('+')) 
	  return false;*/
	  /*if (str.lastIndexOf('-')) 
	  return false;*/
	} 
	
	//if (str.length < 7 )
     //return false;
	
	    
  return true;

}
/*************************/
function isValidMobile(str){
  if (str == null)
     return false;
  str = trim(str);
    
  if (str.length < 10 || str.length > 10)
     return false;
    
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
    return false;
  }
    
  return true;

}

function isComma(str){
	for (i=0; i < str.length; i++){
	if(str.charAt(i) =="'")
	return false; 
	var code = str.charCodeAt(i);
	  if(code>=128)
	  return false;
	}
	  return true;
}
/*************************/
function isInteger(str){
  if (!isANumber(str))
   return false;
  if (str.indexOf('.') != -1)
    return false;
  if (str.indexOf("'") != -1)
    return false;
   
  return true;

}
/*************************/
function isValidZip(str){
  str = trim(str);

  if (str.length < 5)
   return false;
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
    return false;
  }
   
  return true;

}
/******************************/

function isValidAddress(str){
if(str==null) return false;

if(str.indexOf('@') != -1) return false;
if(str.indexOf('<')!= -1) return false;
if(str.indexOf('>')!=-1)return false;
if(str.indexOf('\"')!=-1)return false;
if(str.indexOf('{')!=-1)return false;
if(str.indexOf('}')!=-1)return false;
if(str.indexOf('&')!=-1)return false;
if(str.indexOf("'")!=-1)return false;
if(str.indexOf('"')!=-1)return false;
if(str.indexOf('$')!=-1)return false;
if(str.indexOf('!')!=-1)return false;
if(str.indexOf('%')!=-1)return false;
 for (i=0; i < str.length; i++){
   if(str.charCodeAt(i)>=128)return false;
  }

return true;
}
function isValidCarName(str){
if(str==null) return false;
if(str.length<2) return false;
if(str.indexOf('@') != -1) return false;
if(str.indexOf('<')!= -1) return false;
if(str.indexOf('>')!=-1)return false;
if(str.indexOf('\"')!=-1)return false;
if(str.indexOf('{')!=-1)return false;
if(str.indexOf('}')!=-1)return false;
 
return true;
}
/*************************/
function isValidEMail(str) {
 if (str == null)
  return false;
  str = trim(str);
  if (str.length<6)    return false; 
  var count=0;
  for (i=0; i < str.length; i++){
	if(str.charAt(i) ==" ")
	  return false; 
	
	var code = str.charCodeAt(i);
	//alert(code);
	if(code>=128){
//	alert(code);
	return false;
	//alert('Please enter the valid email id');
	}
	}
	//var st = str.charAt(i);
	




 if (str.indexOf('@') == -1)    return false;
 if (str.indexOf('@') == 0)    return false;
 if (str.indexOf('@') == (str.length-1))    return false;
 if (str.indexOf("@@") != -1)    return false;
 if (str.indexOf('@') != str.lastIndexOf('@'))    return false;
 if (str.indexOf('.@') != -1)    return false;
 if (str.indexOf('@.') != -1)    return false;
 if (str.indexOf(' ') != -1)    return false;
 if (str.indexOf('.') == -1)    return false;
 if (str.indexOf('.') == 0)    return false;
 if (str.indexOf('.') == (str.length-1))    return false;
 if (str.indexOf('..') != -1)    return false;
 if (str.indexOf('<') != -1)    return false;
 if (str.indexOf('>') != -1)    return false;
 if (str.indexOf('=') != -1)    return false;
 if (str.indexOf('~') != -1)    return false;
 if (str.indexOf('^') != -1)    return false;
 if (str.indexOf('%') != -1)    return false;
 if (str.indexOf('+') != -1)    return false;
 if (str.indexOf('$') != -1)    return false;
 if (str.indexOf('#') != -1)    return false;
 if (str.indexOf('!') != -1)    return false;
 if (str.indexOf('(') != -1)    return false;
 if (str.indexOf(')') != -1)    return false;
 if (str.indexOf('\\') != -1)    return false;
 if (str.indexOf('/') != -1)    return false;
 if (str.indexOf('\"') != -1)    return false;
 if (str.indexOf('\'') != -1)    return false;
 if (str.indexOf('?') != -1)    return false;
 if (str.indexOf(';') != -1)    return false;
 if (str.indexOf(',') != -1)    return false;
 if (str.indexOf('\t') != -1)    return false;
 if (str.indexOf('*') != -1)    return false;
 if (str.indexOf('`') != -1)    return false;
 if (str.indexOf('"') != -1)    return false;
 if (str.indexOf('|') != -1)    return false;
 if (str.indexOf("'") != -1)    return false;
  if (str.indexOf("&") != -1)    return false;
 
var ptr=str.substring((str.lastIndexOf("@")+1));

for (i=0; i < ptr.length; i++)
 {
  if(ptr.charAt(i)=='.')
     count++;
	if(count>2)
	  {
		
	    return false; 
	  }
    
	if(count==1 && ptr.indexOf(".")==ptr.lastIndexOf("."))
  	 {	
       if((ptr.substring(ptr.lastIndexOf(".")+1)).length!=3 && (ptr.substring(ptr.lastIndexOf(".")+1)).length!=2)
        return false;

     }
	
    if(count==2)
      {
        if((ptr.indexOf(".")+1)==ptr.lastIndexOf(".")) 
	      return false;

	    if(((ptr.lastIndexOf("."))-(ptr.indexOf(".")))!=3 && ((ptr.lastIndexOf("."))-(ptr.indexOf(".")))!=4)
		  return false;
          
        if((ptr.substring(ptr.lastIndexOf(".")+1)).length!=2)
		   return false;
	  }

    if(ptr.charAt(i)!='.' && !((ptr.charCodeAt(i)>=65 && ptr.charCodeAt(i)<=90) || (ptr.charCodeAt(i)>=97 && ptr.charCodeAt(i)<=122)))
      return false;

  }


 return true;
 
}//end of isValidEMail()
/*************************/
/*
*for valid Text
*/
function isValidText(str){
 str = trim(str);
 if (str.length < 1)
    return false;
    
  for (i=0; i < str.length; i++){
    if ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z'))
      continue;
    if ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))
      continue;
    if ((str.charAt(i) >= '0') && (str.charAt(i) <= '9'))
      continue;
    if (str.charAt(i) == '_')
      continue;
      if (str.charAt(i) == '-')
      continue; 
	  if (str.charAt(i) == '.')
      continue; 
	   if (str.charAt(i) == ' ')
      continue; 
	   if(str.charCodeAt(i) >=128)
       return false;
	  
	  return false;
    }
   return true;
}
/*
* This function returns true is the given date parameters
* form a valid date. else returns false.
*/
function isValidDate(dd,mm,yyyy){
  if (mm < 0 || mm > 12)
     return false;
  if (dd < 0 || dd > 31)
     return false;
  if (getDaysOfMonth(mm,yyyy) < dd) 
     return false;
  return true; 
}

/*
* This function returns true if first date is before second date
* other wise  returns false.
*/
function isDate1BeforeDate2(d1,m1,y1, d2,m2,y2){
  date1 = new Date(y1, m1,d1);
  date2 = new Date(y2, m2,d2);
  if (date1.getTime() < date2.getTime())
     return true; 
  return false;
}

function isDate1BeforeOrEqualToDate2(d1,m1,y1, d2,m2,y2){
  date1 = new Date(y1, m1,d1);
  date2 = new Date(y2, m2,d2);
  if (date1.getTime() <= date2.getTime())
     return true; 
  return false;
}

function isDate1AfterDate2(d1,m1,y1, d2,m2,y2){
  date1 = new Date(y1, m1,d1);
  date2 = new Date(y2, m2,d2);
  if (date1.getTime() > date2.getTime())
     return true; 
  return false;
}


function isDate1AfterOrEqualToDate2(d1,m1,y1, d2,m2,y2){
  date1 = new Date(y1, m1,d1);
  date2 = new Date(y2, m2,d2);
  if (date1.getTime() >= date2.getTime())
     return true; 
  return false;
}



function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
		 //Alert ("Only numeric characters allowed");
         }
      }
   return IsNumber;
   
   }
   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&   Credit Card Validation &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&////
var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {

     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [4] = {name: "AmEx", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "Enroute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
	// alert("Unknown card type");
	//document.form1.CardType.focus();
	  
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
	// alert("No card number provided");
	//  document.form1.ccno.focus();
	 
     return false; 
  }
  
  // Check that the number is numeric, although we do permit a space to occur  
  // every four digits. 
  var cardNo = cardnumber
  var cardexp = /^([0-9]{4})\s?([0-9]{4})\s?([0-9]{4})\s?([0-9]{1,4})$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
	// alert("Credit card number is in invalid format");
	//  document.form1.ccno.focus();
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardexp.exec(cardNo);
  cardNo = RegExp.$1 + RegExp.$2 + RegExp.$3 + RegExp.$4;
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
	// alert("Credit card number is in invalid !");
	//  document.form1.ccno.focus();
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
	 // alert ("Credit card number is invalid");
	  //document.form1.ccno.focus();
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
	 //alert ("Credit card number has an inappropriate number of digits");
     return false; 
  };   
    // The credit card is in the required format.
  return true;
}


function isDate1AfterOrEqualToDate2(d1,m1,y1, d2,m2,y2){
  date1 = new Date(y1, m1,d1);
  date2 = new Date(y2, m2,d2);
  if (date1.getTime() >= date2.getTime())
     return true; 
  return false;
}

// for open a prormo popup

function promoPopup(str)
{
 alert(str);
 open(str);
}

function productLead(str)
{
 open(str,"a","width=600,height=700,scrollbars=yes")
}