// form validation function //


function validate_paidService()
{
 var YES = document.getElementById("ctl00_MainContent_chkPaidSericeYes");
  var NO = document.getElementById("ctl00_MainContent_chkPaidSericeNo");
  
    var dispservice = document.getElementById("ctl00_MainContent_dispservice");

  if((YES.checked)||(NO.checked))
 return true;
  else  
   inlineMsg('ctl00_MainContent_dispservice','You must select service type.',2);
   return false;
// if(YES.value != "")
// {
// return true;
// }
// else
// {
// inlineMsg('ctl00_MainContent_drpIndustry','You must select industry.',2);
// return false;
// }
}

function validate_Industry()
{
 var country = document.getElementById("ctl00_MainContent_drpIndustry");
 if(country.value != "")
 {
 return true;
 }
 else
 {
 inlineMsg('ctl00_MainContent_drpIndustry','You must select industry.',2);
 return false;
 }
}


function validate_step0()
{

   chosen = ""
    len = 4
    
    for (i = 0; i <len; i++) 
    {
        if (document.getElementById("ctl00_MainContent_rdSessionType_" + i).checked) 
        {
            chosen = document.getElementById("ctl00_MainContent_rdSessionType_" + i).value;
        }
    }

    if (chosen == "")
     {
         
        inlineMsg('fee','You must choose a product.',2);
        
            // VISIBILITY: hidden; WIDTH: 1px
        return false;
        
    }

 
}











var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	 var txtLastWorkDate = document.getElementById("ctl00_MainContent_txtLastWorkDate").value

	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
	
	    inlineMsg('ctl00_MainContent_txtLastWorkDate','The date format should be : mm/dd/yyyy.',2)

		
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
	inlineMsg('ctl00_MainContent_txtLastWorkDate','Please enter a valid month',2)
		
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		
			inlineMsg('ctl00_MainContent_txtLastWorkDate','Please enter a valid day',2)

		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		inlineMsg('ctl00_MainContent_txtLastWorkDate','Please enter a valid 4 digit year between '+minYear+' and '+maxYear,2)

		
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			inlineMsg('ctl00_MainContent_txtLastWorkDate','Please enter a valid date',2)

		return false
	}
return true
}










function validateRegistration()
{
var retValue=true;
 var txtFName = document.getElementById("ctl00_MainContent_txtFirstName").value;
 var txtLName = document.getElementById("ctl00_MainContent_txtLastName").value;
 var txtAddress = document.getElementById("ctl00_MainContent_txtAddress").value;
 var txtCity = document.getElementById("ctl00_MainContent_txtCity").value;
 var txtState = document.getElementById("ctl00_MainContent_txtState").value;
 var txtPostalCode = document.getElementById("ctl00_MainContent_txtPostalCode").value;
 var txtHomePhNo = document.getElementById("ctl00_MainContent_txtHomePhNo").value;
 var txtCellNo = document.getElementById("ctl00_MainContent_txtCellNo").value;
 var txtOfficePhNo = document.getElementById("ctl00_MainContent_txtOfficePhNo").value;
 
 
 var txtEmailAddress = document.getElementById("ctl00_MainContent_txtEmailAddress").value;
 var txtSponserCompany = document.getElementById("ctl00_MainContent_txtSponserCompany").value;
 var txtEmployeeID = document.getElementById("ctl00_MainContent_txtEmployeeID").value;
 var txtWorkLocation = document.getElementById("ctl00_MainContent_txtWorkLocation").value;
 var txtHRRepresentative = document.getElementById("ctl00_MainContent_txtHRRepresentative").value;
 var txtHRRepresentPhNo = document.getElementById("ctl00_MainContent_txtHRRepresentPhNo").value;
 
 
  var txtMgrName = document.getElementById("ctl00_MainContent_txtMgrName").value;
 var txtMgrPhNo = document.getElementById("ctl00_MainContent_txtMgrPhNo").value;
 var txtJobTitle = document.getElementById("ctl00_MainContent_txtJobTitle").value;
 var rdStillWorking = document.getElementById("ctl00_MainContent_rdStillWorking").value;
 var txtLastWorkDate = document.getElementById("ctl00_MainContent_txtLastWorkDate").value;
 var txtComments = document.getElementById("ctl00_MainContent_txtComments").value;
 var disp_Position = document.getElementById("ctl00_MainContent_disp_Position").value;
 
 
   var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;


 
   if(txtFName == "") {
    inlineMsg('ctl00_MainContent_txtFirstName','You must enter your first name.',2);
     
    return false;
  }
  else  if(!txtFName.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtFirstName','You have entered an invalid first name.',2);
     
    return false;
  }
 
   if(txtLName == "") {
    inlineMsg('ctl00_MainContent_txtLastName','You must enter your last name.',2);
      
    return false;
  }
  else  if(!txtLName.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtLastName','You have entered an invalid last name.',2);
     
    return false;
  }
 
  if(txtAddress == "") {
    inlineMsg('ctl00_MainContent_txtAddress','You must enter your address.',2);
    return false;
  }
  if(txtCity == "") {
    inlineMsg('ctl00_MainContent_txtCity','You must enter your city.',2);
    return false;
  }
  else if(!txtCity.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtCity','You have entered an invalid city name.',2);
    return false;
  }
  
   if(txtState == "") {
    inlineMsg('ctl00_MainContent_txtState','You must enter your state.',2);
    return false;
  }
  else  if(!txtState.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtCity','You have entered an invalid state name.',2);
    return false;
  }
  
  
   if(txtPostalCode == "") {
    inlineMsg('ctl00_MainContent_txtPostalCode','You must enter your postal code.',2);
    return false;
  }
  else  if(!txtPostalCode.match(zipRegex)) {
    inlineMsg('ctl00_MainContent_txtPostalCode','You have entered an invalid postal code.',2);
    return false;
  }
  
  if((txtHomePhNo == "")&&(txtCellNo == "")&&(txtOfficePhNo == ""))
  {
  
   inlineMsg('ctl00_MainContent_disp_Position','You must enter phone number.',2);
    return false;
  }
  
  if(txtHomePhNo != "")
  {
    
     if(!txtHomePhNo.match(phoneRegex)) 
     {
    inlineMsg('ctl00_MainContent_txtHomePhNo','You have entered an invalid phone number.',2);
    return false;
    }
  }
  
  if(txtOfficePhNo != "")
  {
    
     if(!txtOfficePhNo.match(phoneRegex)) 
     {
    inlineMsg('ctl00_MainContent_txtOfficePhNo','You have entered an invalid phone number.',2);
    return false;
    }
  }
  
   if(txtCellNo != "")
  {
    
     if(!txtCellNo.match(numberRegex)) 
     {
    inlineMsg('ctl00_MainContent_txtCellNo','You have entered an invalid phone number.',2);
    return false;
    }
  }
  
  
   if(txtEmailAddress == "") {
    inlineMsg('ctl00_MainContent_txtEmailAddress','You must enter your email address.',2);
    return false;
  }
  else if(!txtEmailAddress.match(emailRegex)) 
     {
    inlineMsg('ctl00_MainContent_txtEmailAddress','You have entered an invalid email.',2);
    return false;
    }
    
   
    if(txtSponserCompany == "") {
    inlineMsg('ctl00_MainContent_txtSponserCompany','You must enter sponser Company name.',2);
    return false;
  }
  else if(!txtSponserCompany.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtSponserCompany','You have entered an invalid name.',2);
    return false;
  }
  
  
  if(txtEmployeeID != "")
  {
   if(!txtEmployeeID.match(numberRegex)) 
     {
    inlineMsg('ctl00_MainContent_txtEmployeeID','You have entered an invalid Employee ID.',2);
    return false;
    }
   } 
    
    if(txtHRRepresentative != "")
    {
    if(!txtHRRepresentative.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtHRRepresentative','You have entered an invalid name.',2);
    return false;
  }
  }
  
  if(txtHRRepresentPhNo != "")
  {
  if(!txtHRRepresentPhNo.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_txtHRRepresentPhNo','You have entered an invalid phone number.',2);
    return false;
  }
  }
  
  if(txtMgrName != "")
  {
  if(!txtMgrName.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtMgrName','You have entered an invalid name.',2);
    return false;
  }
  }
  
  if(txtMgrPhNo != "")
  {
  if(!txtMgrPhNo.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_txtMgrPhNo','You have entered an invalid phone number.',2);
    return false;
  }
  }
  
  if(txtJobTitle != "")
  {
  if(!txtJobTitle.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_txtJobTitle','You have entered an invalid job title.',2);
    return false;
  }
  }
   
   
    if (document.getElementById("ctl00_MainContent_rdStillWorking_" + 0).checked) 
    {
        if(txtLastWorkDate=="")
            {
            inlineMsg('ctl00_MainContent_txtLastWorkDate','You must enter last working date.',2);
            return false;
            }
            
              if(!isDate(txtLastWorkDate))
    {
     document.getElementById("ctl00_MainContent_txtLastWorkDate").value="";
     document.getElementById("ctl00_MainContent_txtLastWorkDate").focus();
     return false;
    }
    }
    
    
   
  
return  retValue;
 
}









   





function checkdate(input){
var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //Basic check for format validity
var returnval=false
if (validformat.test(input.value))
{
alert("Invalid Date Format. Please correct and submit again.")
return false;
}
else
{
//Detailed check for valid date ranges
var yearfield=input.value.split("/")[0]
var monthfield=input.value.split("/")[1]
var dayfield=input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Invalid Day, Month, or Year range detected. Please correct and submit again.")
else
returnval=true
}
if (returnval==false) input.select()
return returnval
}


















function validate_step1()
{
var contact_name = document.getElementById("ctl00_MainContent_contact_name").value;
  
  var contact_lastname = document.getElementById("ctl00_MainContent_contact_lastname").value;
 var contact_email = document.getElementById("ctl00_MainContent_contact_email").value;
  var contact_address = document.getElementById("ctl00_MainContent_contact_address").value;
   var contact_city = document.getElementById("ctl00_MainContent_contact_city").value;
  var contact_state = document.getElementById("ctl00_MainContent_contact_state").value;
  var contact_zip = document.getElementById("ctl00_MainContent_contact_zip").value;
   var contact_country = document.getElementById("ctl00_MainContent_contact_country").value;
   var contact_phone = document.getElementById("ctl00_MainContent_contact_phone").value;
  
   var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;
  
  
   if(contact_name == "") {
    inlineMsg('ctl00_MainContent_contact_name','You must enter your name.',2);
    return false;
  }
  if(!contact_name.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_name','You have entered an invalid name.',2);
    return false;
  }
  // CONTACT LAST NAME
  if(contact_lastname == "") {
    inlineMsg('ctl00_MainContent_contact_lastname','You must enter your last name.',2);
    return false;
  }
  if(!contact_lastname.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_lastname','You have entered an invalid last name.',2);
    return false;
  }
  // CONTACT EMAIL
  if(contact_email == "") {
    inlineMsg('ctl00_MainContent_contact_email','You must enter your email.',2);
    return false;
  }
  if(!contact_email.match(emailRegex)) {
    inlineMsg('ctl00_MainContent_contact_email','You have entered an invalid email.',2);
    return false;
  }
  // CONTACT ADDRESS
  if(contact_address == "") {
    inlineMsg('ctl00_MainContent_contact_address','You must enter your address.',2);
    return false;
  }
  // CONTACT CITY
  if(contact_city == "") {
    inlineMsg('ctl00_MainContent_contact_city','You must enter your city.',2);
    return false;
  }
  if(!contact_city.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_city','You have entered an invalid city name.',2);
    return false;
  }
  // CONTACT STATE
  if(contact_state == "") {
    inlineMsg('ctl00_MainContent_contact_state','You must select your state.',2);
    return false;
  }
  // CONTACT ZIP
  if(contact_zip == "") {
    inlineMsg('ctl00_MainContent_contact_zip','You must enter your zip code.',2);
    return false;
  }
  if(!contact_zip.match(zipRegex)) {
    inlineMsg('ctl00_MainContent_contact_zip','You have entered an invalid zip code.',2);
    return false;
  }
  // CONTACT COUNTRY

  
  if(contact_country == 'Please select') {
    inlineMsg('ctl00_MainContent_contact_country','You must select your country.',2);
    return false;
  }
  
  //United States
  //Km.soomro
  if(contact_country == 'United States') {
      if(contact_state == 'Please Select State') {
        inlineMsg('ctl00_MainContent_contact_state','You must select your state.',2);
        return false;
      }
       
  }
  else
    phoneRegex = numberRegex // replace phone regular expression
  
  
  
  
  // CONTACT PHONE NUMBER
  if(contact_phone == "") {
    inlineMsg('ctl00_MainContent_contact_phone','You must enter your phone number.',2);
    return false;
  }
  if(!contact_phone.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_contact_phone','You have entered an invalid phone number.',2);
    return false;
  }
  
}
function validate() 
{
   
  //var product = form.product.value;
  var cardtype = document.getElementById("cardtype").value;
  
 
 

 
 
 
  var credit_card = document.getElementById("ctl00_MainContent_credit_card").value;
  var csc = document.getElementById("ctl00_MainContent_csc").value;
  var address = document.getElementById("ctl00_MainContent_address").value;
  var name = document.getElementById("ctl00_MainContent_name").value;
  var expmonth = document.getElementById("ctl00_MainContent_expmonth").value;
  var expyear = document.getElementById("ctl00_MainContent_expyear").value;
  var lastname = document.getElementById("ctl00_MainContent_lastname").value;
  var city = document.getElementById("ctl00_MainContent_city").value;
  var state = document.getElementById("ctl00_MainContent_state").value;
  var zip = document.getElementById("ctl00_MainContent_zip").value;
  var country = document.getElementById("ctl00_MainContent_country").value;
  var phone = document.getElementById("ctl00_MainContent_phone").value;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;
  // PRODUCT
 
  
  


  //if(product == "") {
  //  inlineMsg('product','You must choose a product.',2);
    // VISIBILITY: hidden; WIDTH: 1px
  //  return false;
 // }

//alert(contact_name);
  // CONTACT NAME
 
  // CREDIT CARD TYPE
  //if(cardtype == "") {
  //  inlineMsg('cardtype','You must select your card type.',2);
  //  return false;
  //}
  
  
  // CREDIT CARD NUMBER
  if(credit_card == "") {
    inlineMsg('ctl00_MainContent_credit_card','You must enter your credit card number.',2);
    return false;
  }
  if(!credit_card.match(numberRegex)) {
    inlineMsg('ctl00_MainContent_credit_card','You have entered an invalid credit card number.',2);
    return false;
  }
  // EXPIRATION DATE - MONTH
  if(expmonth == 'Please Select Month') {
    inlineMsg('ctl00_MainContent_expmonth','You must select your card expiration month.',2);
    return false;
  }
  // EXPIRATION DATE - YEAR
  if(expyear == 'Please Select Year') {
    inlineMsg('ctl00_MainContent_expyear','You must select your card expiration year.',2);
    return false;
  }
  // CSC
  if(csc == "") {
    inlineMsg('ctl00_MainContent_csc','You must enter your CSC number.',2);
    return false;
  }
  // PAYMENT ADDRESS
  if(address == "") {
    inlineMsg('ctl00_MainContent_address','You must enter your address.',2);
    return false;
  }
  // PAYMENT NAME
  if(name == "") {
    inlineMsg('ctl00_MainContent_name','You must enter your name.',2);
    return false;
  }
  if(!name.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_name','You have entered an invalid name.',2);
    return false;
  }
  // PAYMENT LAST NAME
  if(lastname == "") {
    inlineMsg('ctl00_MainContent_lastname','You must enter your last name.',2);
    return false;
  }
  if(!lastname.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_lastname','You have entered an invalid last name.',2);
    return false;
  }
  // PAYMENT CITY
  if(city == "") {
    inlineMsg('ctl00_MainContent_city','You must select your city.',2);
    return false;
  }
  if(!city.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_city','You have entered an invalid city name.',2);
    return false;
  }
  // PAYMENT STATE
  if(state == "") {
    inlineMsg('ctl00_MainContent_state','You must select your state.',2);
    return false;
  }
  // PAYMENT ZIP
  if(zip == "") {
    inlineMsg('ctl00_MainContent_zip','You must enter your zip code.',2);
    return false;
  }
  if(!zip.match(zipRegex)) {
    inlineMsg('ctl00_MainContent_zip','You have entered an invalid zip code.',2);
    return false;
  }
  // PAYMENT COUNTRY
  if(country == 'Please select') {
    inlineMsg('ctl00_MainContent_country','You must select your country.',2);
    return false;
  }
  
  if(country == 'United States') {
      if(state == 'Please Select State') {
        inlineMsg('ctl00_MainContent_state','You must select your state.',2);
        return false;
      }
  }
  else
    phoneRegex = numberRegex // replace phone regular expression

  
  
  // PAYMENT PHONE NUMBER
  if(phone == "") {
    inlineMsg('ctl00_MainContent_phone','You must enter your phone number.',2);
    return false;
  }
  if(!phone.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_phone','You have entered an invalid phone number.',2);
    return false;
  }


  // END
  return true;
}





// form validation function //
function validate_logedin() 
{
  var cardtype = document.getElementById("cardtype").value;
  var contact_name = document.getElementById("ctl00_MainContent_contact_name").value;
  var contact_lastname = document.getElementById("ctl00_MainContent_contact_lastname").value;
  var contact_email = document.getElementById("ctl00_MainContent_contact_email").value;
  var contact_address = document.getElementById("ctl00_MainContent_contact_address").value;
  var contact_city = document.getElementById("ctl00_MainContent_contact_city").value;
  var contact_state = document.getElementById("ctl00_MainContent_contact_state").value;
  var contact_zip = document.getElementById("ctl00_MainContent_contact_zip").value;
  var contact_country = document.getElementById("ctl00_MainContent_contact_country").value;
  var contact_phone = document.getElementById("ctl00_MainContent_contact_phone").value;
  var credit_card = document.getElementById("ctl00_MainContent_credit_card").value;
  var csc = document.getElementById("ctl00_MainContent_csc").value;
  var address = document.getElementById("ctl00_MainContent_address").value;
  var name = document.getElementById("ctl00_MainContent_name").value;
  var expmonth = document.getElementById("ctl00_MainContent_expmonth").value;
  var expyear = document.getElementById("ctl00_MainContent_expyear").value;
  var lastname = document.getElementById("ctl00_MainContent_lastname").value;
  var city = document.getElementById("ctl00_MainContent_city").value;
  var state = document.getElementById("ctl00_MainContent_state").value;
  var zip = document.getElementById("ctl00_MainContent_zip").value;
  var country = document.getElementById("ctl00_MainContent_country").value;
  var phone = document.getElementById("ctl00_MainContent_phone").value;
  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;


  // CONTACT NAME
  if(contact_name == "") {
    inlineMsg('ctl00_MainContent_contact_name','You must enter your name.',2);
    return false;
  }
  if(!contact_name.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_name','You have entered an invalid name.',2);
    return false;
  }
  // CONTACT LAST NAME
  if(contact_lastname == "") {
    inlineMsg('ctl00_MainContent_contact_lastname','You must enter your last name.',2);
    return false;
  }
  if(!contact_lastname.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_lastname','You have entered an invalid last name.',2);
    return false;
  }
  // CONTACT EMAIL
  if(contact_email == "") {
    inlineMsg('ctl00_MainContent_contact_email','You must enter your email.',2);
    return false;
  }
  if(!contact_email.match(emailRegex)) {
    inlineMsg('ctl00_MainContent_contact_email','You have entered an invalid email.',2);
    return false;
  }
  // CONTACT ADDRESS
  if(contact_address == "") {
    inlineMsg('ctl00_MainContent_contact_address','You must enter your address.',2);
    return false;
  }
  // CONTACT CITY
  if(contact_city == "") {
    inlineMsg('ctl00_MainContent_contact_city','You must enter your city.',2);
    return false;
  }
  if(!contact_city.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_contact_city','You have entered an invalid city name.',2);
    return false;
  }
  // CONTACT STATE
  if(contact_state == "") {
    inlineMsg('ctl00_MainContent_contact_state','You must select your state.',2);
    return false;
  }
  // CONTACT ZIP
  if(contact_zip == "") {
    inlineMsg('ctl00_MainContent_contact_zip','You must enter your zip code.',2);
    return false;
  }
  if(!contact_zip.match(zipRegex)) {
    inlineMsg('ctl00_MainContent_contact_zip','You have entered an invalid zip code.',2);
    return false;
  }
  // CONTACT COUNTRY
  if(contact_country == 'Please select') {
    inlineMsg('ctl00_MainContent_contact_country','You must select your country.',2);
    return false;
  }
  
  if(contact_country == 'United States') {
      if(contact_state == 'Please Select State') {
        inlineMsg('ctl00_MainContent_contact_state','You must select your state.',2);
        return false;
      }
       
  }
  else
    phoneRegex = numberRegex // replace phone regular expression

  
  
  
  // CONTACT PHONE NUMBER
  if(contact_phone == "") {
    inlineMsg('ctl00_MainContent_contact_phone','You must enter your phone number.',2);
    return false;
  }
  if(!contact_phone.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_contact_phone','You have entered an invalid phone number.',2);
    return false;
  }
  
  // CREDIT CARD TYPE
  //if(cardtype == "") {
  //  inlineMsg('cardtype','You must select your card type.',2);
  //  return false;
  //}
  
  
  // CREDIT CARD NUMBER
  if(credit_card == "") {
    inlineMsg('ctl00_MainContent_credit_card','You must enter your credit card number.',2);
    return false;
  }
  if(!credit_card.match(numberRegex)) {
    inlineMsg('ctl00_MainContent_credit_card','You have entered an invalid credit card number.',2);
    return false;
  }
  // EXPIRATION DATE - MONTH
  if(expmonth == 'Please Select Month') {
    inlineMsg('ctl00_MainContent_expmonth','You must select your card expiration month.',2);
    return false;
  }
  // EXPIRATION DATE - YEAR
  if(expyear == 'Please Select Year') {
    inlineMsg('ctl00_MainContent_expyear','You must select your card expiration year.',2);
    return false;
  }
  // CSC
  if(csc == "") {
    inlineMsg('ctl00_MainContent_csc','You must enter your CSC number.',2);
    return false;
  }
  // PAYMENT ADDRESS
  if(address == "") {
    inlineMsg('ctl00_MainContent_address','You must enter your address.',2);
    return false;
  }
  // PAYMENT NAME
  if(name == "") {
    inlineMsg('ctl00_MainContent_name','You must enter your name.',2);
    return false;
  }
  if(!name.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_name','You have entered an invalid name.',2);
    return false;
  }
  // PAYMENT LAST NAME
  if(lastname == "") {
    inlineMsg('ctl00_MainContent_lastname','You must enter your last name.',2);
    return false;
  }
  if(!lastname.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_lastname','You have entered an invalid last name.',2);
    return false;
  }
  // PAYMENT CITY
  if(city == "") {
    inlineMsg('ctl00_MainContent_city','You must select your city.',2);
    return false;
  }
  if(!city.match(nameRegex)) {
    inlineMsg('ctl00_MainContent_city','You have entered an invalid city name.',2);
    return false;
  }
  // PAYMENT STATE
  if(state == "") {
    inlineMsg('ctl00_MainContent_state','You must select your state.',2);
    return false;
  }
  // PAYMENT ZIP
  if(zip == "") {
    inlineMsg('ctl00_MainContent_zip','You must enter your zip code.',2);
    return false;
  }
  if(!zip.match(zipRegex)) {
    inlineMsg('ctl00_MainContent_zip','You have entered an invalid zip code.',2);
    return false;
  }
  // PAYMENT COUNTRY
  if(country == 'Please select') {
    inlineMsg('ctl00_MainContent_country','You must select your country.',2);
    return false;
  }
  
  if(country == 'United States') {
      if(state == 'Please Select State') {
        inlineMsg('ctl00_MainContent_state','You must select your state.',2);
        return false;
      }
  }
  else
    phoneRegex = numberRegex // replace phone regular expression
    
  
  // PAYMENT PHONE NUMBER
  if(phone == "") {
    inlineMsg('ctl00_MainContent_phone','You must enter your phone number.',2);
    return false;
  }
  if(!phone.match(phoneRegex)) {
    inlineMsg('ctl00_MainContent_phone','You have entered an invalid phone number.',2);
    return false;
  }


  // END
  return true;
}



/*AJ*/

// form validation function //
function validate_PasswordReset() {
 
  
  var txtEmailAddress = document.getElementById("ctl00_MainContent_txtEmailAddress").value;
  
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;


  // CONTACT EMAIL
  if(txtEmailAddress == "") {
    inlineMsg('ctl00_MainContent_txtEmailAddress','You must enter your email.',2);
    return false;
  }
  if(!txtEmailAddress.match(emailRegex)) {
    inlineMsg('ctl00_MainContent_txtEmailAddress','You have entered an invalid email.',2);
    return false;
  }

  // END
  return true;
}

//validate_ForgetPassword


// form validation function //
function validate_ForgetPassword() {
   
  var email = document.getElementById("ctl00_MainContent_email").value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  // CONTACT EMAIL
  if(email == "") {
    inlineMsg('ctl00_MainContent_email','You must enter your email.',2);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('ctl00_MainContent_email','You have entered an invalid email.',2);
    return false;
  }
  
  return true;
}





// form validation function //
function validate_ChangePassword() {
 
  
  var txtOldPassword = document.getElementById("ctl00_MainContent_txtOldPassword").value;
  var txtNewPassword = document.getElementById("ctl00_MainContent_txtNewPassword").value;
  var txtConfirmPassword = document.getElementById("ctl00_MainContent_txtConfirmPassword").value;
  
  
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;


  // Old Password
  if(txtOldPassword == "") {
    inlineMsg('ctl00_MainContent_txtOldPassword','You must enter your Old Password.',2);
    return false;
  }
  
  // New Password
  if(txtNewPassword == "") {
    inlineMsg('ctl00_MainContent_txtNewPassword','You must enter your New Password.',2);
    return false;
  }
  
  // Confirm Password
  if(txtConfirmPassword == "") {
    inlineMsg('ctl00_MainContent_txtConfirmPassword','You must enter your Confirm Password.',2);
    return false;
  }
  
  if(!txtNewPassword.match(txtConfirmPassword)) {
    inlineMsg('ctl00_MainContent_txtNewPassword','You must enter Confirm and new passwords same.',2);
    return false;
  }
  
//  if(!txtConfirmPassword.match(txtNewPassword)) {
//    inlineMsg('txtConfirmPassword','You must enter Confirm and new passwords same.',2);
//    return false;
//  }
  
  
  
//  if(!txtEmailAddress.match(emailRegex)) {
//    inlineMsg('txtEmailAddress','You have entered an invalid email.',2);
//    return false;
//  }

  // END
  return true;
}
/*AJ*/

// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) 
  {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  

  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "msg_arrow.gif"; 
}

function validateCheckupForm() 
{
   
  //var product = form.product.value;
  var cardtype = document.getElementById("cardtype").value;
  var contact_name = document.getElementById("txtFName").value;
  
  var contact_lastname = document.getElementById("txtLName").value;
  var contact_email = document.getElementById("txtEmail").value;
  var contact_address = document.getElementById("txtBillingAddr1").value;
  var contact_city = document.getElementById("txtCity").value;
  var contact_state = document.getElementById("contactState").value;
  var contact_zip = document.getElementById("txtZipCode").value;
  var contact_country = document.getElementById("contactCountry").value;
  var contact_phone = document.getElementById("txtHomeTelePh").value;
  var credit_card = document.getElementById("txtCreditCard").value;
  var csc = document.getElementById("txtSecurityCd").value;  
  var expmonth = document.getElementById("expMonth").value;
  var expyear = document.getElementById("expYear").value;
  var Qty = document.getElementById("txtQty").value;
   
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^[0-9]\d{2}-\d{3}-\d{4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;
  // PRODUCT
 
  
    chosen = ""
    
   
  if(contact_name == "") {
    inlineMsg('txtFName','You must enter your name.',2);
    return false;
  }
  if(!contact_name.match(nameRegex)) {
    inlineMsg('txtFName','You have entered an invalid name.',2);
    return false;
  }
  // CONTACT LAST NAME
  if(contact_lastname == "") {
    inlineMsg('txtLName','You must enter your last name.',2);
    return false;
  }
  if(!contact_lastname.match(nameRegex)) {
    inlineMsg('txtLName','You have entered an invalid last name.',2);
    return false;
  }
  
  // CONTACT PHONE NUMBER
  if(contact_phone == "") {
    inlineMsg('txtHomeTelePh','You must enter your phone number.',2);
    return false;
  }
  if(!contact_phone.match(phoneRegex)) {
    inlineMsg('txtHomeTelePh','You have entered an invalid phone number.',2);
    return false;
  }
  
  // CONTACT EMAIL
  if(contact_email == "") {
    inlineMsg('txtEmail','You must enter your email.',2);
    return false;
  }
  if(!contact_email.match(emailRegex)) {
    inlineMsg('txtEmail','You have entered an invalid email.',2);
    return false;
  }
  
  // CREDIT CARD TYPE
//  if(cardtype == "") {
//  alert(cardtype.value);
//    return false;
//  }
  
  // CREDIT CARD NUMBER
  if(credit_card == "") {
    inlineMsg('txtCreditCard','You must enter your credit card number.',2);
    return false;
  }
  if(!credit_card.match(numberRegex)) {
    inlineMsg('txtCreditCard','You have entered an invalid credit card number.',2);
    return false;
  }
  
  // EXPIRATION DATE - MONTH
  if(expmonth == 'Please Select Month') {
    inlineMsg('expmonth','You must select your card expiration month.',2);
    return false;
  }
  // EXPIRATION DATE - YEAR
  if(expyear == 'Please Select Year') {
    inlineMsg('expyear','You must select your card expiration year.',2);
    return false;
  }
  
  // CSC
  if(csc == "") {
    inlineMsg('txtSecurityCd','You must enter your CSC number.',2);
    return false;
  }
  
  // CONTACT ADDRESS
  if(contact_address == "") {
    inlineMsg('txtBillingAddr1','You must enter your address.',2);
    return false;
  }
  // CONTACT CITY
  if(contact_city == "") {
    inlineMsg('txtCity','You must enter your city.',2);
    return false;
  }
  if(!contact_city.match(nameRegex)) {
    inlineMsg('txtCity','You have entered an invalid city name.',2);
    return false;
  }
  // CONTACT STATE
  if(contact_state == "") {
    inlineMsg('contact_state','You must select your state.',2);
    return false;
  }
  // CONTACT ZIP
  if(contact_zip == "") {
    inlineMsg('txtZipCode','You must enter your zip code.',2);
    return false;
  }
  if(!contact_zip.match(zipRegex)) {
    inlineMsg('txtZipCode','You have entered an invalid zip code.',2);
    return false;
  }
  // CONTACT COUNTRY

  
  if(contact_country == 'Please select') {
    inlineMsg('contact_country','You must select your country.',2);
    return false;
  }
  
  //United States
  //Km.soomro
  if(contact_country == 'United States') {
      if(contact_state == 'Please Select State') {
        inlineMsg('contact_state','You must select your state.',2);
        return false;
      }
       
  }
  else
    phoneRegex = numberRegex // replace phone regular expression
  
  
  
  
  
  
  
  
  
  
  if(Qty=="0")
  {
   inlineMsg('txtQty','You must enter quantity .',2);
    return false;
  }
  if(!Qty.match(numberRegex)) {
    inlineMsg('txtQty','You have entered an invalid quantity.',2);
    return false;
  }

  // END
  return true;
}


function validateCheckupForm() 
{
   
  //var product = form.product.value;
  var cardtype = document.getElementById("cardtype").value;
  var contact_name = document.getElementById("txtFName").value;
  
  var contact_lastname = document.getElementById("txtLName").value;
  var contact_email = document.getElementById("txtEmail").value;
  var contact_address = document.getElementById("txtBillingAddr1").value;
  var contact_city = document.getElementById("txtCity").value;
  var contact_state = document.getElementById("contactState").value;
  var contact_zip = document.getElementById("txtZipCode").value;
  var contact_country = document.getElementById("contactCountry").value;
  var contact_phone = document.getElementById("txtHomeTelePh").value;
  var credit_card = document.getElementById("txtCreditCard").value;
  var csc = document.getElementById("txtSecurityCd").value;  
  var expmonth = document.getElementById("expMonth").value;
  var expyear = document.getElementById("expYear").value;
  var Qty = document.getElementById("txtQty").value;
   
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  var phoneRegex = /^[0-9]\d{2}-\d{3}-\d{4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  var numberRegex =  /([0-9]+)/;
  // PRODUCT
 
  
    chosen = ""
    
   
  if(contact_name == "") {
    inlineMsg('txtFName','You must enter your name.',2);
    return false;
  }
  if(!contact_name.match(nameRegex)) {
    inlineMsg('txtFName','You have entered an invalid name.',2);
    return false;
  }
  // CONTACT LAST NAME
  if(contact_lastname == "") {
    inlineMsg('txtLName','You must enter your last name.',2);
    return false;
  }
  if(!contact_lastname.match(nameRegex)) {
    inlineMsg('txtLName','You have entered an invalid last name.',2);
    return false;
  }
  
  // CONTACT PHONE NUMBER
  if(contact_phone == "") {
    inlineMsg('txtHomeTelePh','You must enter your phone number.',2);
    return false;
  }
  if(contact_phone.match(numberRegex)) {
  if(contact_phone.length !=10)
  {
  if(!contact_phone.match(phoneRegex))
  {
    inlineMsg('txtHomeTelePh','Phone number must be entered as 123-345-5678 or 1234567890.',2);
    return false;
    }
  }
  }
 
  // CONTACT EMAIL
  if(contact_email == "") {
    inlineMsg('txtEmail','You must enter your email.',2);
    return false;
  }
  if(!contact_email.match(emailRegex)) {
    inlineMsg('txtEmail','You have entered an invalid email.',2);
    return false;
  }
  
  // CREDIT CARD TYPE
//  if(cardtype == "") {
//  alert(cardtype.value);
//    return false;
//  }
  
  // CREDIT CARD NUMBER
  if(credit_card == "") {
    inlineMsg('txtCreditCard','You must enter your credit card number.',2);
    return false;
  }
  if(!credit_card.match(numberRegex)) {
    inlineMsg('txtCreditCard','You have entered an invalid credit card number.',2);
    return false;
  }
  
  // EXPIRATION DATE - MONTH
  if(expmonth == 'Please Select Month') {
    inlineMsg('expmonth','You must select your card expiration month.',2);
    return false;
  }
  // EXPIRATION DATE - YEAR
  if(expyear == 'Please Select Year') {
    inlineMsg('expyear','You must select your card expiration year.',2);
    return false;
  }
  
  // CSC
  if(csc == "") {
    inlineMsg('txtSecurityCd','You must enter your CSC number.',2);
    return false;
  }
  
  // CONTACT ADDRESS
  if(contact_address == "") {
    inlineMsg('txtBillingAddr1','You must enter your address.',2);
    return false;
  }
  // CONTACT CITY
  if(contact_city == "") {
    inlineMsg('txtCity','You must enter your city.',2);
    return false;
  }
  if(!contact_city.match(nameRegex)) {
    inlineMsg('txtCity','You have entered an invalid city name.',2);
    return false;
  }
 
  // CONTACT ZIP
  if(contact_zip == "") {
    inlineMsg('txtZipCode','You must enter your zip code.',2);
    return false;
  }
  if(!contact_zip.match(zipRegex)) {
    inlineMsg('txtZipCode','You have entered an invalid zip code.',2);
    return false;
  }
  // CONTACT COUNTRY

  
  if(contact_country == 'Please select') {
    inlineMsg('contactCountry','You must select your country.',2);
    return false;
  }
  
  //United States
  //Km.soomro
  if(contact_country == 'United States') {
      if(contact_state == "") {
        inlineMsg('contact_state','You must select your state.',2);
        return false;
      }
       
  }
  else
    phoneRegex = numberRegex // replace phone regular expression
  
  
  
  
  
  
  
  
  
  
  if(Qty=="0")
  {
   inlineMsg('txtQty','You must enter quantity .',2);
    return false;
  }
  if(!Qty.match(numberRegex)) {
    inlineMsg('txtQty','You have entered an invalid quantity.',2);
    return false;
  }

  // END
  return true;
}