// form validation function //
function showMessageLogin()
{

  var txtUserName=document.getElementById("txtLoginId");
    
  var txtPassword=document.getElementById("txtPassword");
    var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  if(txtUserName.value=="")
  {
  
   inlineMsg('txtLoginId','Please enter user name .',2);
     return false;
  }
  else  if(!txtUserName.value.match(nameRegex)) 
  {
    inlineMsg('txtLoginId','You have entered an invalid user name.',2);
     
    return false;
  }
   if(txtPassword.value=="")
  {
   inlineMsg('txtPassword','Please enter password .',2);
     return false;
  }
  return true;
}
//index page login message
function indexMessage()
{
var txtUserName=document.getElementById("ctl00_txtUserName");
 
  var txtPassword=document.getElementById("ctl00_txtPassword");
    var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  if(txtUserName.value=="")
  {
  
   inlineMsg('ctl00_txtUserName','Please enter user name .',2);
     return false;
  }
  else  if(!txtUserName.value.match(nameRegex)) 
  {
    inlineMsg('ctl00_txtUserName','You have entered an invalid user name.',2);
     
    return false;
  }
   if(txtPassword.value=="")
  {
   inlineMsg('ctl00_txtPassword','Please enter password .',2);
     return false;
  }
  return true;
}
//default edit cms page error messege
function defaultEditMessage()
{
var text=document.getElementById("ctl00_ContentPlaceHolder1_txtContent").value;
alert(text)
if(text.value=="")
{
    inlineMsg('ctl00_ContentPlaceHolder1_txtContent','Please enter text.',2);
     return false;
}
 return true;
}
function ForgotPasswordMessage()
{
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var txtUserName=document.getElementById("txtUserName");
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
 if(txtUserName.value=="")
  {
   inlineMsg('txtUserName','Please enter email address.',2);
     return false;
  }
  else if(!txtUserName.value.match(emailRegex)) 
     {
    inlineMsg('txtUserName','You have entered an invalid email address.',2);
    return false;
    }
   return true;
}


function validateRegistration()
{

var retValue=true;
 var txtFName = document.getElementById("ctl00_ContentPlaceHolder1_txtFirstName").value;
 var txtLName = document.getElementById("ctl00_ContentPlaceHolder1_txtLastName").value;

 var txtCity = document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value;

 var txtPostalCode = document.getElementById("ctl00_ContentPlaceHolder1_txtPostalCode").value;
 var txtCountry=document.getElementById("ctl00_ContentPlaceHolder1_txtCountry").value;
 
 
 var txtEmailAddress = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value;
 var txtSelectUserName = document.getElementById("ctl00_ContentPlaceHolder1_txtSelectUserName").value;
 var txtSelectPassword = document.getElementById("ctl00_ContentPlaceHolder1_txtSelectPassword").value;
 var txtReEnteredPassword = document.getElementById("ctl00_ContentPlaceHolder1_txtReTypePassword").value;

 
 
 
   var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(\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_ContentPlaceHolder1_txtFirstName','Please enter your first name.',2);
     
    return false;
  }
  else  if(!txtFName.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtFirstName','You have entered an invalid first name.',2);
     
    return false;
  }
 
   if(txtLName == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtLastName','Please enter your last name.',2);
      
    return false;
  }
  else  if(!txtLName.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtLastName','You have entered an invalid last name.',2);
     
    return false;
  }
 
 
  if(txtCity == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCity','Please enter your city.',2);
    return false;
  }
  else if(!txtCity.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCity','You have entered an invalid city name.',2);
    return false;
  }
  

  
  
   if(txtPostalCode == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtPostalCode','Please enter your postal code.',2);
    return false;
  }
  else  if(!txtPostalCode.match(zipRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtPostalCode','You have entered an invalid postal code.',2);
    return false;
  }
  
  
  if(txtCountry == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCountry','Please enter your country.',2);
    return false;
  }
  else if(!txtCountry.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCountry','You have entered an invalid city name.',2);
    return false;
  }
 
  
  
   if(txtEmailAddress == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtEmail','Please enter your email address.',2);
    return false;
  }
  else if(!txtEmailAddress.match(emailRegex)) 
     {
    inlineMsg('ctl00_ContentPlaceHolder1_txtEmail','You have entered an invalid email.',2);
    return false;
    }
    
    if(txtSelectUserName == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtSelectUserName','Please enter your user name.',2);
    return false;
    }
  
     if(txtSelectPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtSelectPassword','Please enter your password.',2);
    return false;
    }
    
     if(txtReEnteredPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtReTypePassword','Please enter your re-type password.',2);
    return false;
    }
   
    if(!txtReEnteredPassword.match(txtSelectPassword)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtReTypePassword','Please enter password and re-type password same.',2);
    return false;
  }
   
   
    
    
   
  
return  retValue;
 
}



function UpdateUserInformationMsg()
{

var retValue=true;
 var txtFName = document.getElementById("ctl00_ContentPlaceHolder1_txtFirstName").value;
 var txtLName = document.getElementById("ctl00_ContentPlaceHolder1_txtLastName").value;

 var txtCity = document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value;

 var txtPostalCode = document.getElementById("ctl00_ContentPlaceHolder1_txtPostalCode").value;
 var txtCountry=document.getElementById("ctl00_ContentPlaceHolder1_txtCountry").value;
 
 
 var txtEmailAddress = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value;
 var txtSelectUserName = document.getElementById("ctl00_ContentPlaceHolder1_txtSelectUserName").value;
 

 
 
 
   var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var zipRegex = /(\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_ContentPlaceHolder1_txtFirstName','Please enter your first name.',2);
     
    return false;
  }
  else  if(!txtFName.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtFirstName','You have entered an invalid first name.',2);
     
    return false;
  }
 
   if(txtLName == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtLastName','Please enter your last name.',2);
      
    return false;
  }
  else  if(!txtLName.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtLastName','You have entered an invalid last name.',2);
     
    return false;
  }
 
 
  if(txtCity == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCity','Please enter your city.',2);
    return false;
  }
  else if(!txtCity.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCity','You have entered an invalid city name.',2);
    return false;
  }
  

  
  
   if(txtPostalCode == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtPostalCode','Please enter your postal code.',2);
    return false;
  }
  else  if(!txtPostalCode.match(zipRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtPostalCode','You have entered an invalid postal code.',2);
    return false;
  }
  
  
  if(txtCountry == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCountry','Please enter your country.',2);
    return false;
  }
  else if(!txtCountry.match(nameRegex)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCountry','You have entered an invalid city name.',2);
    return false;
  }
 
  
  
   if(txtEmailAddress == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtEmail','Please enter your email address.',2);
    return false;
  }
  else if(!txtEmailAddress.match(emailRegex)) 
     {
    inlineMsg('ctl00_ContentPlaceHolder1_txtEmail','You have entered an invalid email.',2);
    return false;
    }
    
    if(txtSelectUserName == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtSelectUserName','Please enter your user name.',2);
    return false;
    }
  
     if(txtSelectPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtSelectPassword','Please enter your password.',2);
    return false;
    }
    
     if(txtReEnteredPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtReTypePassword','Please enter your re-type password.',2);
    return false;
    }
   
    if(!txtReEnteredPassword.match(txtSelectPassword)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtReTypePassword','Please enter password and re-type password same.',2);
    return false;
  }
   
   
    
    
   
  
return  retValue;
 
}



function errorChangePassword()
{
var txtOldPassword = document.getElementById("ctl00_ContentPlaceHolder1_txtCurrentPassword").value;
  var txtNewPassword = document.getElementById("ctl00_ContentPlaceHolder1_txtNewPassword").value;
  var txtConfirmPassword = document.getElementById("ctl00_ContentPlaceHolder1_txtConfirmNewPassword").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_ContentPlaceHolder1_txtCurrentPassword','please enter your Old Password.',2);
    return false;
  }
  
  // New Password
  if(txtNewPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtNewPassword','Please enter your New Password.',2);
    return false;
  }
  
  // Confirm Password
  if(txtConfirmPassword == "") {
    inlineMsg('ctl00_ContentPlaceHolder1_txtConfirmNewPassword','Please enter your Confirm Password.',2);
    return false;
  }
  
  if(!txtNewPassword.match(txtConfirmPassword)) {
    inlineMsg('ctl00_ContentPlaceHolder1_txtConfirmNewPassword','Please enter confirm and new passwords same.',2);
    return false;
  }
  
}
function rulesErrorMessage()
{
 
 
 var fromAge=document.getElementById("ctl00_ContentPlaceHolder1_txtFromAge");
 var toAge=document.getElementById("ctl00_ContentPlaceHolder1_txtToAge");
 var ddlAgeGroup=document.getElementById("ctl00_ContentPlaceHolder1_ddlAgeGroup").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]+)/;

 
    if(fromAge.value=="")
    {
     inlineMsg('ctl00_ContentPlaceHolder1_txtFromAge','Please enter from age.',2);
     return false;
    }
    else if(fromAge.value !="")
 {
     if(!fromAge.value.match(numberRegex)) 
        {
        inlineMsg('ctl00_ContentPlaceHolder1_txtFromAge','You have entered an invalid from age.',2);
        return false;
        }
 }
    if(toAge.value=="")
    {
     inlineMsg('ctl00_ContentPlaceHolder1_txtToAge','Please enter to age.',2);
     return false;
    }
       else if(toAge.value !="")
 {
     if(!toAge.value.match(numberRegex)) 
        {
        inlineMsg('ctl00_ContentPlaceHolder1_txtToAge','You have entered an invalid to age.',2);
        return false;
        }
 }

    if(ddlAgeGroup == "0")
    {
    inlineMsg('ctl00_ContentPlaceHolder1_ddlAgeGroup','Please select age group.',2);
     return false;
    }
 

}
function ErrorTransactionBtAge()
{
  
  var startdate=document.getElementById("ctl00_ContentPlaceHolder1_txtDateRange");
  var enddate=document.getElementById("ctl00_ContentPlaceHolder1_txtDateRangeTo");
  
  if(startdate.value!="" && enddate.value!="")
  { 
  
  var fromAge=startdate.value;
   var toAge=enddate.value;
   if(Date.parse(fromAge)> Date.parse(toAge))
  {
 
    inlineMsg('ctl00_ContentPlaceHolder1_txtDateRangeTo','end date should greater than start date.',2);
      return false;
  }
  }
   return true;
}
function transactionByAgeErrorMessage()
{
var startdate=document.getElementById("ctl00_ContentPlaceHolder1_txtDateRange");
  var enddate=document.getElementById("ctl00_ContentPlaceHolder1_txtDateRangeTo");
  
  if(startdate.value!="" && enddate.value!="")
  { 
  
  var fromAge=startdate.value;
   var toAge=enddate.value;
   if(Date.parse(fromAge)> Date.parse(toAge))
  {
 
    inlineMsg('ctl00_ContentPlaceHolder1_txtDateRangeTo','end date should greater than start date.',2);
      return false;
  }
  }
   return true;
}
 function display()
 {
  
  
  
   var txtAdvertiser=document.getElementById("ctl00_ContentPlaceHolder1_txtAdvertiser");
   var txtCampaignsName=document.getElementById("ctl00_ContentPlaceHolder1_txtCampaignsName");
   var txtCampaignsDescription=document.getElementById("ctl00_ContentPlaceHolder1_txtCampainsDescription");
   
    var txtStartDate=document.getElementById("ctl00_ContentPlaceHolder1_txtStartDate");
    var txtEndDate=document.getElementById("ctl00_ContentPlaceHolder1_txtEndDate");
     var txtMaximumImpression=document.getElementById("ctl00_ContentPlaceHolder1_txtMaximumImpression");
    var txtMaximumDailyImpression=document.getElementById("ctl00_ContentPlaceHolder1_txtMaximumDailyImpression");
   var numberRegex =  /([0-9]+)/;


  if(txtAdvertiser.value=="")
  {
     inlineMsg('ctl00_ContentPlaceHolder1_txtAdvertiser','Please enter advertiser .',2);
     return false;

   }
   
  if(txtCampaignsName.value=="")
  {
    inlineMsg('ctl00_ContentPlaceHolder1_txtCampaignsName','Please enter campaigns name .',2);
      return false;
}
  if(txtCampaignsDescription.value=="")
  {
      inlineMsg('ctl00_ContentPlaceHolder1_txtCampainsDescription','Please enter campains description.',2);
      return false;
}


if(txtStartDate.value=="")
{
      inlineMsg('ctl00_ContentPlaceHolder1_txtStartDate','Please select start date.',2);
      return false;
}
if(txtEndDate.value=="")
{
      inlineMsg('ctl00_ContentPlaceHolder1_txtEndDate','Please select end date.',2);
      return false;
}
if(txtStartDate.value!="" && txtEndDate.value!="")
{
  var startDate=txtStartDate.value;
  var endDate=txtEndDate.value;
  if(Date.parse(startDate)>Date.parse(endDate))
  {
  
    inlineMsg('ctl00_ContentPlaceHolder1_txtEndDate','End date should greater than start date.',2);
      return false;
  }
}
if(txtMaximumImpression.value=="")
{
     inlineMsg('ctl00_ContentPlaceHolder1_txtMaximumImpression','Please enter maximum impression.',2);
      return false;
}
else if(txtMaximumImpression.value !="")
 {
     if(!txtMaximumImpression.value.match(numberRegex)) 
        {
        inlineMsg('ctl00_ContentPlaceHolder1_txtMaximumImpression','You have entered an invalid maximum impression.',2);
        return false;
        }
 }

if(txtMaximumDailyImpression.value=="")
{
     inlineMsg('ctl00_ContentPlaceHolder1_txtMaximumDailyImpression','Please enter maximum daily impression.',2);
      return false;
}
else if(txtMaximumDailyImpression.value !="")
 {
     if(!txtMaximumDailyImpression.value.match(numberRegex)) 
        {
        inlineMsg('ctl00_ContentPlaceHolder1_txtMaximumDailyImpression','You have entered an invalid maximum daily impression.',2);
        return false;
        }
 }
 if(txtMaximumImpression.value !="" && txtMaximumDailyImpression.value !="")
 {
    var maxImpression=txtMaximumImpression.value;
    var maxDailyImpression=txtMaximumDailyImpression.value;
    if(parseInt(maxImpression) > parseInt(maxDailyImpression))
    {
     
     inlineMsg('ctl00_ContentPlaceHolder1_txtMaximumDailyImpression','Maximum Daily Impressions should greater than Maximum Impressions.',2);
      return false;
    }
 }

return true;
}
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 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';
    msg.nowrap="nowrap";
    msg.setAttribute("WIDTH","500PX");
    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 TransactionDateValidation()
{
 

var rdDate = document.getElementById("ctl00_ContentPlaceHolder1_rdodate").checked;
 var rdDateRange = document.getElementById("ctl00_ContentPlaceHolder1_rdoDateRangeTo").checked;
 var fromDate = document.getElementById("ctl00_ContentPlaceHolder1_txtDateRangeFrom").value; 
 var toDate = document.getElementById("ctl00_ContentPlaceHolder1_txtDateRangeTo").value; 
 if(rdDate== false && rdDateRange == false )
 {
  inlineMsg('ctl00_ContentPlaceHolder1_rdodate','Please select atleast one radio button',2);
    return false;
 }
 
if(rdDateRange ==true )
{
    if(fromDate == "")
    {
        inlineMsg('ctl00_ContentPlaceHolder1_txtDateRangeFrom','Please enter from date',2);
        return false;
    }
    else if(toDate == "")
    {
        inlineMsg('ctl00_ContentPlaceHolder1_txtDateRangeTo','Please enter to date',2);
        return false;
    }
}
   //return true ;
}


