function ajaxFunctionfile1(){
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
		   //  alert(ajaxRequest.responseText);
			// document.getElementById('time').innerHTML= ajaxRequest.responseText;
		  if(ajaxRequest.responseText == 1)
		    {
			alert("Username already exists");
		    document.user_registration.username.focus();
		    flag = 1;
			return flag;
		   }
		}
	}
	var pat_file_no = document.getElementById('pat_file_no').value;
	var queryString = "?uname=" + pat_file_no;
	// alert(queryString);
	if(pat_file_no != "")
	 {
	ajaxRequest.open("GET", "../avail_check.php" + queryString, true);
	ajaxRequest.send(null); 
     }
}


// JavaScript Document
 	//Intenational Phone Validation
	// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
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 displayGroup()
{
	alert();
	var 	a	=	document.user_registration.group.value;
		alert(a);
	var 	t	=	document.getElementById("crm_details");
	if(a==1)
	{
		t.style.display='none';
	}
	if(a==2)
	{
		t.style.display='inline';
	}
	if(a==2)
	{
		t.style.display='none';
		
	}
	
}

function DisableEnableRadio (val1,val2,yeno)
 {
  
  if (yeno =="y")
 {
  val2.style.display =  'inline';
 }
 else if (yeno =="n")
 {
  val2.style.display="none"; 
 }
  
 }


function ischar_char(svalue)
{
	var checkOK = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 !@#$%^&*()/";
	var checkStr = svalue;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
			//alert(msg);
			//eval("document."+frmpage+"."+ctrlname+"."+"focus();")
			return false;
			break;
		}
			allNum += ch;
	}
}



function ischar(svalue)
{
	var checkOK = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var checkStr = svalue;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
			//alert(msg);
			//eval("document."+frmpage+"."+ctrlname+"."+"focus();")
			return false;
			break;
		}
			allNum += ch;
	}
}
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++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}  
	
				// Declaring required variables
			/*var digits = "0123456789";
			// non-digit characters which are allowed in phone numbers
			var phoneNumberDelimiters = "()- ";
			// characters which are allowed in international phone numbers
			// (a leading + is OK)
			var validWorldPhoneChars = phoneNumberDelimiters + "+";
			// Minimum no of digits in an international phone no.
			var minDigitsInIPhoneNumber = 6;
			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++)
				{   
					// Check that current character isn't whitespace.
					var c = s.charAt(i);
					if (bag.indexOf(c) == -1) returnString += c;
				}
				return returnString;
			}
			function checkInternationalPhone(strPhone){
			s=stripCharsInBag(strPhone,validWorldPhoneChars);
			return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
			}*/

	
	
	//International phone number validation 
/////////Url validation

			function checkUrl(theUrl)
			{
			  if(theUrl.value.match(/^w+([\.\-]\w+)*\.\w{2,4}(\:\d+)*([\/\.\-\?\&\%\#]\w+)*\/?$/i) ||
				 theUrl.value.match(/^mailto\:\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w{2,4}$/i))
			      {
				      return true;
			      } else {
								return false;
			             }
			}

//////////URL validation

function trim(s) {
	while (s.substring(0,1) == ' ') {
	s = s.substring(1,s.length);
  	}
	while (s.substring(s.length-1,s.length) == ' ') {
 	s = s.substring(0,s.length-1);
  	}
	 return s;		
}	
	function isEmail(email) {
		invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;";
		// Check for invalid characters as defined above
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i);
			if (email.indexOf(badChar,0) > -1) {
				return false;
			}
		}
		lengthOfEmail = email.length;
		if ((email.charAt(lengthOfEmail - 1) == ".") || (email.charAt(lengthOfEmail - 2) == ".")) {
			return false;
		}
		Pos = email.indexOf("@",1);
		if (email.charAt(Pos + 1) == ".") {
			return false;
		}
		while ((Pos < lengthOfEmail) && ( Pos != -1)) {
			Pos = email.indexOf(".",Pos);
			if (email.charAt(Pos + 1) == ".") {
				return false;
			}
			if (Pos != -1) {
				Pos++;
			}
		}
		// There must be at least one @ symbol
		atPos = email.indexOf("@",1);
		if (atPos == -1) {
			return false;
		}
		// But only ONE @ symbol
		if (email.indexOf("@",atPos+1) != -1) {
			return false;
		}
		// Also check for at least one period after the @ symbol
		periodPos = email.indexOf(".",atPos);
		if (periodPos == -1) {
			return false;
		}
		if (periodPos+3 > email.length) {
			return false;
		}
		return true;
}

function alphaNumeric(sText)
	  {
   	var ValidChars = "1234567890";
  	 var IsNumber=true;
  	 var Char; 
  	 for (i = 0; i < sText.length && IsNumber == true; i++) 
   	 { 
   	  Char = sText.charAt(i); 
   	  if (ValidChars.indexOf(Char) == -1) 
   	  {
    	     IsNumber = false;
      	   }
     	 }
   return IsNumber;   
   }
   
   function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }	

   function IsNumericPhone(sText)
{
   var ValidChars = "0123456789-";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }	

   
function validate_inforeq()
{
//alert ("here");
var a	=	document.info_req;
//alert(a);
	if(trim(a.companyname.value) == "")
	{
		alert("Please enter the company name");
		a.companyname.focus();
		return false;
	}
/*if(alphaNumeric(trim(a.companyname.value)) == false)
{
	alert "not allao";
	return false;
}*/
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the first name");
		a.firstname.focus();
		return false;
	}
	if(ischar(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}

	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the last name");
		a.lastname.focus();
		return false;
	}
		if(ischar(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}

	if(trim(a.address1.value) == "")
	{
		alert("Please enter  the address");
		a.address1.focus();
		return false;
	}


	if(trim(a.city.value) == "")
	{
		alert("Please enter the city name");
		a.city.focus();
		return false;
	}
		if(ischar(a.city.value) == false)
	{
		alert("Please enter only alphabets for city");
		a.city.focus();
		return false;	
	}

	if(trim(a.stateid.value) == 0)
	{
		alert("Please Select the state");
		a.stateid.focus();
		return false;
	}

	if(trim(a.zipcode.value) == "")
	{
		alert("Please enter the postal code");
		a.zipcode.focus();
		return false;
	}
	if(IsNumeric(trim(a.zipcode.value))== false)
	{
		alert("Please enter the valid postal code in numeric");
		a.zipcode.focus();
		return false;
	}

	if(trim(a.zipcode.value).length< 5)
	{
		alert("Please enter the valid postal code");
		a.zipcode.focus();
		return false;
	}
	
		var Phone=a.phone;

if ((Phone.value==null)||(Phone.value==""))
{
         alert("Please enter Phone number in this format (###-###-####)")
         Phone.focus()

         return false
     }
	
	var checkOK = "0123456789-";
	var checkStr = trim(Phone.value);
	
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }

   if (!allValid)
   {
     alert("Please enter the phone number as numeric");
     Phone.focus();
     return false;
   }


   bill_billing_phone=trim(Phone.value);

   if(trim(Phone.value).length == 12)
     {


for(phone_length=0;phone_length<trim(Phone.value)
.length;phone_length++)
         {

             if((phone_length == 3) || (phone_length == 7))
            {

                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter Phone number in this format (###-###-####)");
                     Phone.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Phone number in this format (###-###-####)");
             Phone.focus();
             return false;
     }
	/*if(trim(phone) == "")
	{
		alert("Please Enter the phone number");
		a.areacode.focus();
		return false;
	}*/
if(trim(a.fax.value) !=  "")
{
	if(checkInternationalPhone(trim(a.fax.value)) == false)
	{
		alert ("Please enter the fax number in a valid format (###-###-####)");
		a.fax.focus();
		return false;
	}
	if(IsNumericPhone(trim(a.fax.value))== false)
	{
		alert("Please enter the fax number in numeric");
		a.fax.focus();
		return false;
	}
	
}

		

	if(trim(a.email.value) == "")
	{
		alert("Please enter the email address");
		a.email.focus();
		return false;
	}
	if(isEmail(trim(a.email.value)) == false)
	{
		alert("Invalid email address");
		a.email.focus();
		return false;
	}
    if(trim(a.web.value) != "")
	{
		if(checkUrl(a.web) == false)
		 {
			  alert("Please enter the  website in a valid format(www.test.com)");
			  a.web.focus();
		      return false;
		}
       
	}
	if(trim(a.powerpoint.value) == 0)
	{
		alert("Please select the option");
		a.powerpoint.focus();
		return false;
	}
	
	if(trim(a.city.value) == "")
	{
		alert("Please enter the city");
		a.city.focus();
		return false;
	}

a.action="info_req_mail.php";
a.submit();
return true;
}
function isEmailAddr(email)
{
  var oRegExp = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g;
  if (oRegExp.test(tri(email)))
 	{
 		return true;
   	}
	else
   	{
	return false;
   	}
}



///User registration form validation
function validate_user_reg()
{
	var a	=	document.user_registration;
	
	if(trim(a.companyname.value) == "")
	{
		alert("Please enter the company name");
		a.companyname.focus();
		return false;
	}
	if(ischar_char(a.companyname.value) == false)
	{
		alert("Please enter only alphabets for company name");
		a.companyname.focus();
		return false;	
	}
	if(trim(a.title.value) == "")
	{
		alert("Please enter the Your Title");
		a.title.focus();
		return false;
	}
	if(ischar_char(a.title.value) == false)
	{
		alert("Please enter only alphabets for title");
		a.title.focus();
		return false;	
	}
	
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the first name");
		a.firstname.focus();
		return false;
	}
	if(ischar_char(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}


	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the last name");
		a.lastname.focus();
		return false;
	}
	if(ischar_char(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}
	
	if(trim(a.gender.value) == 0)
	{
		alert("Please select a gender");
		a.gender.focus();
		return false;
	}
	
	if(trim(a.phone.value) == "")
	{
		alert("Please enter Phone number in this format (###-###-####)");
		a.phone.focus();
		return false;
	}

	/*if(checkInternationalPhone(trim(a.phone.value)) == false)
	{
		alert ("Please enter the Phone Number in a Valid Format(###-###-####)");
		a.phone.focus();
		return false;
	}
	if(IsNumericPhone(trim(a.phone.value))== false)
		{
			alert("Please enter the Phone Number as numeric");
			a.phone.focus();
			return false;
		}*/
				var Phone=a.phone;
	
	

     if ((Phone.value==null)||(Phone.value=="")){
         alert("Please enter Phone number in this format (###-###-####)")
         Phone.focus()

         return false
     }
	
	 var checkOK = "0123456789-";
   var checkStr = trim(Phone.value);

  var allValid = true;
   var decPoints = 0;
   var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }

   if (!allValid)
   {
     alert("Please enter the phone number as numeric");
     Phone.focus();
     return false;
   }


   bill_billing_phone=trim(Phone.value);

   if(trim(Phone.value).length == 12)
     {


for(phone_length=0;phone_length<trim(Phone.value)
.length;phone_length++)
         {

             if((phone_length == 3) || (phone_length == 7))
            {

                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter the phone number in a valid format (###-###-####) ");
                     Phone.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Phone number in this format (###-###-####)");
             Phone.focus();
             return false;
     }

if(trim(a.phone_ext.value) != "")
	{
			// alert(a.phone_ext.value.length);
			if(a.phone_ext.value.length < 5 )
				{
					alert("Please enter a valid Phone extension  number");
					a.phone_ext.focus();
					return false;
				}
	}

if(trim(a.cell_no.value) != "")
 {
	 
	if(trim(a.cell_no.value) == "")
	{
		alert("Please enter Cell number in this format (###-###-####)");
		a.cell_no.focus();
		return false;
	}

	/*if(checkInternationalPhone(trim(a.phone.value)) == false)
	{
		alert ("Please enter the Phone Number in a Valid Format(###-###-####)");
		a.phone.focus();
		return false;
	}
	if(IsNumericPhone(trim(a.phone.value))== false)
		{
			alert("Please enter the Phone Number as numeric");
			a.phone.focus();
			return false;
		}*/
				var cell_no=a.cell_no;
	
	

     if ((cell_no.value==null)||(cell_no.value=="")){
         alert("Please enter Cell number in this format (###-###-####)")
         cell_no.focus()

         return false
     }
	
	 var checkOK = "0123456789-";
   var checkStr = trim(cell_no.value);

  var allValid = true;
   var decPoints = 0;
   var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }

   if (!allValid)
   {
     alert("Please enter the Cell Number as numeric");
   cell_no.focus();
     return false;
   }


   bill_billing_phone=trim(cell_no.value);

   if(trim(cell_no.value).length == 12)
     {


for(phone_length=0;phone_length<trim(cell_no.value)
.length;phone_length++)
         {

             if((phone_length == 3) || (phone_length == 7))
            {

                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter Cell number in this format (###-###-####)");
                     cell_no.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Cell number in this format (###-###-####)");
             cell_no.focus();
             return false;
     } 
	 
	 
 }


	if(trim(a.email.value) == "")
	{
		alert("Please enter the email address");
		a.email.focus();
		return false;
	}
	
	if(isEmail(trim(a.email.value)) == false)
	{
		alert("Invalid email address");
		a.email.focus();
		return false;
	}

var ad	=	trim(a.address1.value) + trim(a.address2.value);

	if(trim(ad) == "")
	{
		alert("Please enter the address");
		a.address1.focus();
		return false;
	}
	if(trim(a.countryid.value) == 0)
	{
		alert("Please Select the Country");
		a.countryid.focus();
		return false;
	}
if(trim(a.stateid.value) == 0)
	{
		alert("Please select the State");
		a.stateid.focus();
		return false;
	}


	if(trim(a.city.value) == "")
	{
		alert("Please enter a city");
		a.city.focus();
		return false;
	}
	if(ischar(a.city.value) == false)
	{
		alert("Please enter only alphabets for City");
		a.city.focus();
		return false;	
	}

	if(trim(a.zipcode.value) == "")
	{
		alert("Please enter the postal code");
		a.zipcode.focus();
		return false;
	}
	if(IsNumeric(trim(a.zipcode.value)) == false)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	if(a.zipcode.value.length < 5)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	
	/*if(trim(a.dob.value) == "")
	{
		alert("Please select date of birth");
		a.dob.focus();
		return false;
	}*/
	var dur = a.dob.value;
	
var mm=dur.substr(0,2);     
var dd=dur.substr(3,2);
var yy=dur.substr(6,9);
today=new Date()
var entered_date=new Date(yy,mm-1,dd) 
var one_day=1000*60*60*24
var day=Math.ceil((today.getTime()-entered_date.getTime())/(one_day))	
var cur_year	=	today.getFullYear();
var	prev_year	=	Math.ceil(cur_year-5);

var ch_year		=	Math.ceil(yy);
//alert ("CHooser year"+ch_year);
//alert ("Previous Year"+prev_year);
if(ch_year > prev_year)
{
	alert ("Please select the valid date of birth");
	a.dob.focus();
	return false;
}

if (day<0)
    {

		alert ("Please select the valid date of birth");
		a.dob.focus();
		return false;
    }

	
	
if(a.payment_select.value == 0)
  {
	    alert("Please select a Payment Type");
		a.payment_select.focus();
		return false;   
  }

if(a.payment_select.value == 2)
  {
	  
// var a = document.user_registration;
	if(trim(a.card_type.value) == 0)
	{
		alert("Please select a Card type");
		a.card_type.focus();
		return false;
	}
	
	if(trim(a.holder.value) == "")
	{
		alert("Please enter the card holder");
		a.holder.focus();
		return false;
	}
	if(ischar(a.holder.value) == "")
	{
		alert("Please enter the alphabets for card holder");
		a.holder.focus();
		return false;
	}
	if(trim(a.first_name.value) == "")
	{
		alert("Please enter the First name");
		a.first_name.focus();
		return false;
	}
	if(ischar(a.first_name.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.first_name.focus();
		return false;	
	}
	if(trim(a.last_name.value) == "")
	{
		alert("Please enter the Last name");
		a.last_name.focus();
		return false;
	}
	if(ischar(a.last_name.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.last_name.focus();
		return false;	
	}
	if(trim(a.accountno.value) == "")
	{
		alert("Please enter the Account number");
		a.accountno.focus();
		return false;
	}
	if(IsNumeric(trim(a.accountno.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.accountno.focus();
		return false;
	}
	if(trim(a.exp_month.value) == 0)
	{
		alert("Please select a Card expairy month");
		a.exp_month.focus();
		return false;
	}
	if(trim(a.exp_year.value) == 0)
	{
		alert("Please select a Card expairy year");
		a.exp_year.focus();
		return false;
	}
	
	var currentTime = new Date();
	var currentMonth = parseInt(currentTime.getMonth()) + 1;
	var currentYear = currentTime.getFullYear();
	//currentYear2 = fixY2K(currentYear);
	cardyear = a.exp_year.value;
	carddate = a.exp_month.value;
	
	if(currentYear == cardyear && currentMonth > carddate)
	{
		alert("Please Check Expiry Date");
		return false;
	} 
		if(trim(a.verefication.value) == "")
	{
		alert("Please enter the Card Verification number");
		a.verefication.focus();
		return false;
	}
	if(IsNumeric(trim(a.verefication.value)) == false)
	{
		alert("Please enter the Card Verfication number in a valid format");
		a.verefication.focus();
		return false;
	}
		if(a.verefication.value.length < 4)
	{
		alert("Please enter the verification number in a valid format");
		a.verefication.focus();
		return false;
	}

  }

// Payment Type End
	
	/*if(trim(a.countryid.value) == 0)
	{
		alert("Please Select a Country");
		a.countryid.focus();
		return false;
	}*/
	
	
	if(trim(a.username.value) == "")
	{
		alert("Please enter the username");
		a.username.focus();
		return false;
	}
	if(ischar(a.username.value) == false)
	{
		alert("Please enter only alphabets for username");
		a.username.focus();
		return false;	
	}
	if(trim(a.password.value) == "")
	{
		alert("Please enter the password");
		a.password.focus();
		return false;
	}
		if(trim(a.password.value).length< 5)
	{
		alert("Please enter the valid password");
		a.password.focus();
		return false;
	}

	if(trim(a.password1.value) == "")
	{
		alert("Please enter the confirm password");
		a.password1.focus();
		return false;
	}
	if(trim(a.password.value) != trim(a.password1.value))
	{
		alert("Password and confirm password must be same");
		a.password.focus();
		return false;
	}
// a.action="register_ins.php";
// a.submit();
return true;
}


//user admin validation

function validate_user_reg_admin()
{
	var a	=	document.user_registration;
	
	if(trim(a.companyname.value) == "")
	{
		alert("Please enter the company name");
		a.companyname.focus();
		return false;
	}
	if(ischar(a.companyname.value) == false)
	{
		alert("Please enter only alphabets for company name");
		a.companyname.focus();
		return false;	
	}
	if(trim(a.title.value) == "")
	{
		alert("Please enter the Your Title");
		a.title.focus();
		return false;
	}
	if(ischar(a.title.value) == false)
	{
		alert("Please enter only alphabets for title");
		a.title.focus();
		return false;	
	}
	
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the first name");
		a.firstname.focus();
		return false;
	}
	if(ischar(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}


	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the last name");
		a.lastname.focus();
		return false;
	}
	if(ischar(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}
	
	if(trim(a.gender.value) == 0)
	{
		alert("Please select a gender");
		a.gender.focus();
		return false;
	}
	
	if(trim(a.phone.value) == "")
	{
		alert("Please enter Phone number in this format (###-###-####)");
		a.phone.focus();
		return false;
	}

	/*if(checkInternationalPhone(trim(a.phone.value)) == false)
	{
		alert ("Please enter the Phone Number in a Valid Format(###-###-####)");
		a.phone.focus();
		return false;
	}
	if(IsNumericPhone(trim(a.phone.value))== false)
		{
			alert("Please enter the Phone Number as numeric");
			a.phone.focus();
			return false;
		}*/
				var Phone=a.phone;
	
	

     if ((Phone.value==null)||(Phone.value=="")){
         alert("Please enter Phone number in this format (###-###-####)")
         Phone.focus()

         return false
     }
	
	 var checkOK = "0123456789-";
   var checkStr = trim(Phone.value);

  var allValid = true;
   var decPoints = 0;
   var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }

   if (!allValid)
   {
     alert("Please enter the phone number as numeric");
     Phone.focus();
     return false;
   }


   bill_billing_phone=trim(Phone.value);

   if(trim(Phone.value).length == 12)
     {


for(phone_length=0;phone_length<trim(Phone.value)
.length;phone_length++)
         {

             if((phone_length == 3) || (phone_length == 7))
            {

                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter the phone number in a valid format (###-###-####) ");
                     Phone.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Phone number in this format (###-###-####)");
             Phone.focus();
             return false;
     }
if(trim(a.phone_ext.value) != "")
	{
			if(a.phone_ext.value.length < 5 )
				{
					alert("Please enter a valid Phone extension  number");
					a.phone_ext.focus();
					return false;
				}
	}

if(trim(a.cell_no.value) != "")
 {
	 
	if(trim(a.cell_no.value) == "")
	{
		alert("Please enter Cell number in this format (###-###-####)");
		a.cell_no.focus();
		return false;
	}

	/*if(checkInternationalPhone(trim(a.phone.value)) == false)
	{
		alert ("Please enter the Phone Number in a Valid Format(###-###-####)");
		a.phone.focus();
		return false;
	}
	if(IsNumericPhone(trim(a.phone.value))== false)
		{
			alert("Please enter the Phone Number as numeric");
			a.phone.focus();
			return false;
		}*/
				var cell_no=a.cell_no;
	
	

     if ((cell_no.value==null)||(cell_no.value=="")){
         alert("Please enter Cell number in this format (###-###-####)")
         cell_no.focus()

         return false
     }
	
	 var checkOK = "0123456789-";
   var checkStr = trim(cell_no.value);

  var allValid = true;
   var decPoints = 0;
   var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }

   if (!allValid)
   {
     alert("Please enter the Cell Number as numeric");
   cell_no.focus();
     return false;
   }


   bill_billing_phone=trim(cell_no.value);

   if(trim(cell_no.value).length == 12)
     {


for(phone_length=0;phone_length<trim(cell_no.value)
.length;phone_length++)
         {

             if((phone_length == 3) || (phone_length == 7))
            {

                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter Cell number in this format (###-###-####) ");
                     cell_no.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Cell number in this format (###-###-####)");
             cell_no.focus();
             return false;
     } 
	 
	 
 }


	if(trim(a.email.value) == "")
	{
		alert("Please enter the email address");
		a.email.focus();
		return false;
	}
	
	if(isEmail(trim(a.email.value)) == false)
	{
		alert("Invalid email address");
		a.email.focus();
		return false;
	}

var ad	=	trim(a.address1.value) + trim(a.address2.value);

	if(trim(ad) == "")
	{
		alert("Please enter the address");
		a.address1.focus();
		return false;
	}
	
	if(trim(a.countryid.value) == 0)
	{
		alert("Please select the Country");
		a.countryid.focus();
		return false;
	}
	
if(trim(a.stateid.value) == 0)
	{
		alert("Please select the State");
		a.stateid.focus();
		return false;
	}


	if(trim(a.city.value) == "")
	{
		alert("Please enter a city");
		a.city.focus();
		return false;
	}
	if(ischar(a.city.value) == false)
	{
		alert("Please enter only alphabets for City");
		a.city.focus();
		return false;	
	}

	if(trim(a.zipcode.value) == "")
	{
		alert("Please enter the postal code");
		a.zipcode.focus();
		return false;
	}
	if(IsNumeric(trim(a.zipcode.value)) == false)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	if(a.zipcode.value.length < 5)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	
	/*if(trim(a.dob.value) == "")
	{
		alert("Please select date of birth");
		a.dob.focus();
		return false;
	}*/
	var dur = a.dob.value;
	
var mm=dur.substr(0,2);     
var dd=dur.substr(3,2);
var yy=dur.substr(6,9);
today=new Date()
var entered_date=new Date(yy,mm-1,dd) 
var one_day=1000*60*60*24
var day=Math.ceil((today.getTime()-entered_date.getTime())/(one_day))	
var cur_year	=	today.getFullYear();
var	prev_year	=	Math.ceil(cur_year-5);

var ch_year		=	Math.ceil(yy);
//alert ("CHooser year"+ch_year);
//alert ("Previous Year"+prev_year);
if(ch_year > prev_year)
{
	alert ("Please select the valid date of birth");
	a.dob.focus();
	return false;
}

if (day<0)
    {

		alert ("Please select the valid date of birth");
		a.dob.focus();
		return false;
    }

	
	
/*if(a.payment_select.value == 0)
  {
	    alert("Please select a Payment Type");
		a.payment_select.focus();
		return false;   
  }

if(a.payment_select.value == 2)
  {
	  
// var a = document.user_registration;
	if(trim(a.card_type.value) == 0)
	{
		alert("Please select a Card type");
		a.card_type.focus();
		return false;
	}

	if(trim(a.holder.value) == "")
	{
		alert("Please enter the card holder");
		a.holder.focus();
		return false;
	}
	if(ischar(a.holder.value) == "")
	{
		alert("Please enter the alphabets for card holder");
		a.holder.focus();
		return false;
	}
	if(trim(a.first_name.value) == "")
	{
		alert("Please enter the First name");
		a.first_name.focus();
		return false;
	}
	if(ischar(a.first_name.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.first_name.focus();
		return false;	
	}
	if(trim(a.last_name.value) == "")
	{
		alert("Please enter the Last name");
		a.last_name.focus();
		return false;
	}
	if(ischar(a.last_name.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.last_name.focus();
		return false;	
	}
	if(trim(a.accountno.value) == "")
	{
		alert("Please enter the Account number");
		a.accountno.focus();
		return false;
	}
	if(IsNumeric(trim(a.accountno.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.accountno.focus();
		return false;
	}
	if(trim(a.exp_month.value) == 0)
	{
		alert("Please select a Card expairy month");
		a.exp_month.focus();
		return false;
	}
	if(trim(a.exp_year.value) == 0)
	{
		alert("Please select a Card expairy year");
		a.exp_year.focus();
		return false;
	}
	
	var currentTime = new Date();
	var currentMonth = parseInt(currentTime.getMonth()) + 1;
	var currentYear = currentTime.getFullYear();
	//currentYear2 = fixY2K(currentYear);
	cardyear = a.exp_year.value;
	carddate = a.exp_month.value;
	
	if(currentYear == cardyear && currentMonth > carddate)
	{
		alert("Please Check Expiry Date");
		return false;
	} 
		if(trim(a.verefication.value) == "")
	{
		alert("Please enter the Card Verification number");
		a.verefication.focus();
		return false;
	}
	if(IsNumeric(trim(a.verefication.value)) == false)
	{
		alert("Please enter the Card Verfication number in a valid format");
		a.verefication.focus();
		return false;
	}
		if(a.verefication.value.length < 4)
	{
		alert("Please enter the verification number in a valid format");
		a.verefication.focus();
		return false;
	}

  }

// Payment Type End
	
	/*if(trim(a.countryid.value) == 0)
	{
		alert("Please Select a Country");
		a.countryid.focus();
		return false;
	}*/
   
	if(trim(a.username.value) == "")
	{
		alert("Please enter the username");
		a.username.focus();
		return false;
	}
/*
	if(ischar(a.username.value) == false)
	{
		alert("Please enter only alphabets for username");
		a.username.focus();
		return false;	
	}
	if(trim(a.username.value))
	{
		ajaxFunctionfile();
		alert(document.getElementById('username_avail').value);
		if(document.getElementById('username_avail').value == 1)
		  {
			 alert("User name already exists asdfasdf");
			 a.username.focus();
			 return false;
		  }
	}
	*/
	if(trim(a.password.value) == "")
	{
		alert("Please enter the password");
		a.password.focus();
		return false;
	}
		if(trim(a.password.value).length< 5)
	{
		alert("Please enter the valid password");
		a.password.focus();
		return false;
	}

	if(trim(a.password1.value) == "")
	{
		alert("Please enter the confirm password");
		a.password1.focus();
		return false;
	}
	if(trim(a.password.value) != trim(a.password1.value))
	{
		alert("Password and confirm password must be same");
		a.password.focus();
		return false;
	}
// a.action="register_ins.php";
// a.submit();
return true;
}



//user login page validation sets
function validate_login()
{
	var a	=	document.login;
	
	if(trim(a.username.value) == "")
	{
		alert("Please enter username");
		a.username.focus();
		return false;
	}
	if(trim(a.password.value) == "")
	{
		alert("Please enter password");
		a.password.focus();
		return false;
	}
	

return true;

}

////////////////////////////////////////
// User profile page validation
/////////////////////////////////////////

function userprofile_upd()
{
  var a 	=	document.user_profile_upd;
	if(trim(a.companyname.value) == "")
	{
		alert("Please enter the company name");
		a.companyname.focus();
		return false;
	}
	if(ischar(a.companyname.value) == false)
	{
		alert("Please enter only alphabets for company name");
		a.companyname.focus();
		return false;	
	}
	
	if(trim(a.title.value) == "")
	{
		alert("Please enter the Your Title");
		a.title.focus();
		return false;
	}
	if(ischar(a.title.value) == false)
	{
		alert("Please enter only alphabets for title");
		a.title.focus();
		return false;	
	}
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the first name");
		a.firstname.focus();
		return false;
	}
	if(ischar(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}
	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the last name");
		a.lastname.focus();
		return false;
	}
	if(ischar(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}
	
  if(trim(a.gender.value) == "")
	{
		alert("Please select the gender");
		a.gender.focus();
		return false;
	}
	
	var Phone=a.phone;
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please enter Phone number in this format (###-###-####)")
		Phone.focus()
		return false
	}
	var checkOK = "0123456789-";
	var checkStr = trim(Phone.value);
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		allNum += ch;
		}
	
	if (!allValid)
	{
		alert("Please enter the phone number as numeric");
		Phone.focus();
		return false;
	}
	
	
	bill_billing_phone=trim(Phone.value);
	
	if(trim(Phone.value).length == 12)
	{
		for(phone_length=0;phone_length<trim(Phone.value).length;phone_length++)
		{
			if((phone_length == 3) || (phone_length == 7))
			{
				if(bill_billing_phone.charAt(phone_length) == "-")
				{
				}
				else
				{	
					alert("Please enter the phone number in a valid format (###-###-####) ");
					Phone.focus();
					return false;
				}
			}
		}
	}
	else
	{
		alert("Please enter Phone number in this format (###-###-####)");
		Phone.focus();
		return false;
	}
	// Cell No
	var Phone=a.cell_no;
	
	if(Phone.value != "")
	 {
	
	/*if ((Phone.value==null)||(Phone.value=="")){
		alert("Please enter Phone number in this format (###-###-####)")
		Phone.focus()
		return false
	}*/
	var checkOK = "0123456789-";
	var checkStr = trim(Phone.value);
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		allNum += ch;
		}
	
	if (!allValid)
	{
		alert("Please enter the phone number as numeric");
		Phone.focus();
		return false;
	}
	
	
	bill_billing_phone=trim(Phone.value);
	
	if(trim(Phone.value).length == 12)
	{
		for(phone_length=0;phone_length<trim(Phone.value).length;phone_length++)
		{
			if((phone_length == 3) || (phone_length == 7))
			{
				if(bill_billing_phone.charAt(phone_length) == "-")
				{
				}
				else
				{	
					alert("Please enter the phone number in a valid format (###-###-####) ");
					Phone.focus();
					return false;
				}
			}
		}
	}
	else
	{
		alert("Please enter the phone number in a valid formatasdf (###-###-####)");
		Phone.focus();
		return false;
	}
	 }
	// End Cell no
	if(isEmail(trim(a.email.value)) == false)
	{
		alert("Invalid email address");
		a.email.focus();
		return false;
	}
	//address	=	trim(a.address1.value) + trim(a.address2.value);
	if(trim(a.address1.value) == "")
	{
		alert("Please enter the address");
		a.address1.focus();
		return false;
	}
	  if(trim(a.countryid.value) == "0")
 {
  alert("Please select the Country name");
  a.countryid.focus();
  return false;
 }
	if(a.stateid.value == 0)
	{
		alert("Please select the state");
		a.stateid.focus();
		return false;
	}
	if(trim(a.city.value) == "")
	{
		alert("Please enter the city");
		a.city.focus();
		return false;
	}
	if(ischar(a.city.value) == false)
	{
		alert("Please enter only alphabets for city");
		a.city.focus();
		return false;	
	}
	if(IsNumeric(trim(a.zipcode.value)) == false)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	if(a.zipcode.value.length < 5)
	{
		alert("Invalid postal code");
		a.zipcode.focus();
		return false;
	}
	var dur = a.dob.value;
	
	var mm=dur.substr(0,2);     
	var dd=dur.substr(3,2);
	var yy=dur.substr(6,9);
	today=new Date()
	var entered_date=new Date(yy,mm-1,dd) 
	var one_day=1000*60*60*24
	var day=Math.ceil((today.getTime()-entered_date.getTime())/(one_day))	
	var cur_year	=	today.getFullYear();
	var	prev_year	=	Math.ceil(cur_year-5);
	var ch_year		=	Math.ceil(yy);
	//alert ("CHooser year"+ch_year);
	//alert ("Previous Year"+prev_year);
	if(ch_year > prev_year)
	{
		alert ("Please select the valid date of birth");
		a.dob.focus();
		return false;
	}
	if (day<0)
	{
		alert ("Please select the valid date of birth");
		a.dob.focus();
		return false;
	}
	/// Payment
	if(a.payment_select.value == 0)
  {
	    alert("Please select a Payment Type");
		a.payment_select.focus();
		return false;   
  }

if(a.payment_select.value == 2)
  {
	  
// var a = document.user_registration;
	if(trim(a.card_type.value) == 0)
	{
		alert("Please select a Card type");
		a.card_type.focus();
		return false;
	}
	
	if(trim(a.holder.value) == "")
	{
		alert("Please enter the card holder");
		a.holder.focus();
		return false;
	}
	if(ischar(a.holder.value) == "")
	{
		alert("Please enter the alphabets for card holder");
		a.holder.focus();
		return false;
	}
	if(trim(a.first_name.value) == "")
	{
		alert("Please enter the First name");
		a.first_name.focus();
		return false;
	}
	if(ischar(a.first_name.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.first_name.focus();
		return false;	
	}
	if(trim(a.last_name.value) == "")
	{
		alert("Please enter the Last name");
		a.last_name.focus();
		return false;
	}
	if(ischar(a.last_name.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.last_name.focus();
		return false;	
	}
	if(trim(a.accountno.value) == "")
	{
		alert("Please enter the Account number");
		a.accountno.focus();
		return false;
	}
	if(IsNumeric(trim(a.accountno.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.accountno.focus();
		return false;
	}
	if(trim(a.exp_month.value) == 0)
	{
		alert("Please select a Card expairy month");
		a.exp_month.focus();
		return false;
	}
	if(trim(a.exp_year.value) == 0)
	{
		alert("Please select a Card expairy year");
		a.exp_year.focus();
		return false;
	}
	
	var currentTime = new Date();
	var currentMonth = parseInt(currentTime.getMonth()) + 1;
	var currentYear = currentTime.getFullYear();
	//currentYear2 = fixY2K(currentYear);
	cardyear = a.exp_year.value;
	carddate = a.exp_month.value;
	
	if(currentYear == cardyear && currentMonth > carddate)
	{
		alert("Please Check Expiry Date");
		return false;
	} 
		if(trim(a.verefication.value) == "")
	{
		alert("Please enter the Card Verification number");
		a.verefication.focus();
		return false;
	}
	if(IsNumeric(trim(a.verefication.value)) == false)
	{
		alert("Please enter the Card Verfication number in a valid format");
		a.verefication.focus();
		return false;
	}
		if(a.verefication.value.length < 4)
	{
		alert("Please enter the verification number in a valid format");
		a.verefication.focus();
		return false;
	}

  }
  //// Payment end
	
	return true;
}
///////////////////////////////////////
//Va;idation for change password
////////////////////////////////////////
function change_pass()
{
	var a	=	document.change_pass_frm;
	if(trim(a.password_old.value) == "")
	{
		alert("Please enter the old password");
		a.password_old.focus();
		return false;
	}
	if(trim(a.password1.value) == "")
	{
		alert("Please enter the  password");
		a.password1.focus();
		return false;
	}
	if(trim(a.password2.value) == "")
	{
		alert("Please enter the confirm password");
		a.password2.focus();
		return false;
	}
	if(trim(a.password1.value) != trim(a.password2.value))
	{
		alert("Password and confirm password must be same");
		a.password1.focus();
		return false;
	}
	return true;
}

////Payment page validation
function payment_validate(Payment_type)
{
	// alert(Payment_type);
	var a = document.billing_frm;
	if(Payment_type == 2)
	 {
		if(trim(a.card_type.value) == 0)
			{
				alert("Please select a Card type");
				a.card_type.focus();
				return false;
			}
	
	if(trim(a.holder.value) == "")
	{
		alert("Please enter the card holder");
		a.holder.focus();
		return false;
	}
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the First name");
		a.firstname.focus();
		return false;
	}
	if(ischar(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}
	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the Last name");
		a.lastname.focus();
		return false;
	}
	if(ischar(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}
	if(trim(a.accountno.value) == "")
	{
		alert("Please enter the Account number");
		a.accountno.focus();
		return false;
	}
	if(IsNumeric(trim(a.accountno.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.accountno.focus();
		return false;
	}
	if(trim(a.exp_month.value) == 0)
	{
		alert("Please select a Card expairy month");
		a.exp_month.focus();
		return false;
	}
	if(trim(a.exp_year.value) == 0)
	{
		alert("Please select a Card expairy year");
		a.exp_year.focus();
		return false;
	}
	
	var currentTime = new Date();
	var currentMonth = parseInt(currentTime.getMonth()) + 1;
	var currentYear = currentTime.getFullYear();
	//currentYear2 = fixY2K(currentYear);
	cardyear = a.exp_year.value;
	carddate = a.exp_month.value;
	
	if(currentYear == cardyear && currentMonth > carddate)
	{
		alert("Please Check Expiry Date");
		return false;
	} 
		if(trim(a.verefication.value) == "")
	{
		alert("Please enter the Account number");
		a.verefication.focus();
		return false;
	}
	if(IsNumeric(trim(a.verefication.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.verefication.focus();
		return false;
	}
		if(a.verefication.value.length < 4)
	{
		alert("Please enter the verification number in a valid format");
		a.verefication.focus();
		return false;
	}
}
if(trim(a.fname.value) == "")
 {
  alert("Please enter the First Name");
  a.fname.focus();
  return false;
 }
 
 if(ischar(a.fname.value) == false)
 {
  alert("Please enter only alphabets for First Name");
  a.fname.focus();
  return false; 
 }
 
 if(trim(a.lname.value) == "")
 {
  alert("Please enter the Last Name");
  a.lname.focus();
  return false;
 }
  if(ischar(a.lname.value) == false)
 {
  alert("Please enter only alphabets for Last Name");
  a.lname.focus();
  return false; 
 }
   if(trim(a.address.value) == "")
 {
  alert("Please enter the Address");
  a.address.focus();
  return false;
 }
 if(trim(a.city.value) == "")
 {
  alert("Please enter the City Name");
  a.city.focus();
  return false;
 }
  if(ischar(a.city.value) == false)
 {
  alert("Please enter only alphabets for City Name");
  a.city.focus();
  return false; 
 } 
 
  if(trim(a.countryid.value) == "0")
 {
  alert("Please select the Country name");
  a.countryid.focus();
  return false;
 }
 
 if(trim(a.stateid.value) == "0")
 {
  alert("Please enter the State");
  a.stateid.focus();
  return false;
 }

  if(trim(a.zipcode.value) == "")
 {
  alert("Please enter the Zip code");
  a.zipcode.focus();
  return false;
 }
 if(IsNumeric(trim(a.zipcode.value))== false)
 {
  alert("Please enter the valid Zip code in numeric");
  a.zipcode.focus();
  return false;
 }
 
 if(trim(a.zipcode.value).length< 5)
 {
  alert("Please enter the valid Zip code");
  a.zipcode.focus();
  return false;
 } 
 if(trim(a.countryid.value) == "")
 {
  alert("Please enter the Country Name");
  a.countryid.focus();
  return false;
 }

 
 var Phone=a.phoneno;
 
if ((Phone.value==null)||(Phone.value==""))
{
         alert("Please enter the phone number")
         Phone.focus()
 
         return false
     }
 
 var checkOK = "0123456789-";
 var checkStr = trim(Phone.value);
 
 var allValid = true;
 var decPoints = 0;
 var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }
 
   if (!allValid)
   {
     alert("Please enter the phone number as numeric");
     Phone.focus();
     return false;
   }
 

   bill_billing_phone=trim(Phone.value);
 
   if(trim(Phone.value).length == 12)
     {
 

for(phone_length=0;phone_length<trim(Phone.value).length;phone_length++)
         {
 
             if((phone_length == 3) || (phone_length == 7))
            {
 
                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter Phone number in this format (###-###-####)");
                     Phone.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Phone number in this format (###-###-####)");
             Phone.focus();
             return false;
     }
 if(trim(a.emailaddress.value) == "")
 {
  alert("Please enter the email address");
  a.emailaddress.focus();
  return false;
 }
 if(isEmail(trim(a.emailaddress.value)) == false)
 {
  alert("Invalid email address");
  a.emailaddress.focus();
  return false;
 }

return true;

	
}
////ajax_payment

function payment_validate_ajax()
{
	var a = document.billing_frm;
	if(trim(a.card_type.value) == 0)
	{
		alert("Please select a Card type");
		a.card_type.focus();
		return false;
	}
	
	if(trim(a.holder.value) == "")
	{
		alert("Please enter the card holder");
		a.holder.focus();
		return false;
	}
	if(trim(a.firstname.value) == "")
	{
		alert("Please enter the First name");
		a.firstname.focus();
		return false;
	}
	if(ischar(a.firstname.value) == false)
	{
		alert("Please enter only alphabets for first name");
		a.firstname.focus();
		return false;	
	}
	if(trim(a.lastname.value) == "")
	{
		alert("Please enter the Last name");
		a.lastname.focus();
		return false;
	}
	if(ischar(a.lastname.value) == false)
	{
		alert("Please enter only alphabets for last name");
		a.lastname.focus();
		return false;	
	}
	if(trim(a.accountno.value) == "")
	{
		alert("Please enter the Account number");
		a.accountno.focus();
		return false;
	}
	if(IsNumeric(trim(a.accountno.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.accountno.focus();
		return false;
	}
	if(trim(a.exp_month.value) == 0)
	{
		alert("Please select a Card expairy month");
		a.exp_month.focus();
		return false;
	}
	if(trim(a.exp_year.value) == 0)
	{
		alert("Please select a Card expairy year");
		a.exp_year.focus();
		return false;
	}
	
	var currentTime = new Date();
	var currentMonth = parseInt(currentTime.getMonth()) + 1;
	var currentYear = currentTime.getFullYear();
	//currentYear2 = fixY2K(currentYear);
	cardyear = a.exp_year.value;
	carddate = a.exp_month.value;
	
	if(currentYear == cardyear && currentMonth > carddate)
	{
		alert("Please Check Expiry Date");
		return false;
	} 
		if(trim(a.verefication.value) == "")
	{
		alert("Please enter the Account number");
		a.verefication.focus();
		return false;
	}
	if(IsNumeric(trim(a.verefication.value)) == false)
	{
		alert("Please enter the account number in a valid format");
		a.verefication.focus();
		return false;
	}
		if(a.verefication.value.length < 4)
	{
		alert("Please enter the verification number in a valid format");
		a.verefication.focus();
		return false;
	}
if(trim(a.fname.value) == "")
 {
  alert("Please enter the First Name");
  a.fname.focus();
  return false;
 }
 
 if(ischar(a.fname.value) == false)
 {
  alert("Please enter only alphabets for First Name");
  a.fname.focus();
  return false; 
 }
 
 if(trim(a.lname.value) == "")
 {
  alert("Please enter the Last Name");
  a.lname.focus();
  return false;
 }
  if(ischar(a.lname.value) == false)
 {
  alert("Please enter only alphabets for Last Name");
  a.lname.focus();
  return false; 
 }
   if(trim(a.address.value) == "")
 {
  alert("Please enter the Address");
  a.address.focus();
  return false;
 }
 if(trim(a.city.value) == "")
 {
  alert("Please enter the City Name");
  a.city.focus();
  return false;
 }
  if(ischar(a.city.value) == false)
 {
  alert("Please enter only alphabets for City Name");
  a.city.focus();
  return false; 
 } 
 if(trim(a.state.value) == "0")
 {
  alert("Please enter the State");
  a.state.focus();
  return false;
 }
 if(a.state.value == "1")
  {
      if(trim(a.state_others.value) == "")
   {
    alert("Please enter the State other filed");
    a.state_others.focus();
    return false;
   }
  
  } 
  if(trim(a.zipcode.value) == "")
 {
  alert("Please enter the Zip code");
  a.zipcode.focus();
  return false;
 }
 if(IsNumeric(trim(a.zipcode.value))== false)
 {
  alert("Please enter the valid Zip code in numeric");
  a.zipcode.focus();
  return false;
 }
 
 if(trim(a.zipcode.value).length< 5)
 {
  alert("Please enter the valid Zip code");
  a.zipcode.focus();
  return false;
 } 
 if(trim(a.country.value) == "")
 {
  alert("Please enter the Country Name");
  a.country.focus();
  return false;
 }
  if(ischar(a.country.value) == false)
 {
  alert("Please enter only alphabets for Country Name");
  a.country.focus();
  return false; 
 } 
 
 var Phone=a.phoneno;
 
if ((Phone.value==null)||(Phone.value==""))
{
         alert("Please enter the phone number")
         Phone.focus()
 
         return false
     }
 
 var checkOK = "0123456789-";
 var checkStr = trim(Phone.value);
 
 var allValid = true;
 var decPoints = 0;
 var allNum = "";
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
     allNum += ch;
   }
 
   if (!allValid)
   {
     alert("Please enter the phone number as numeric");
     Phone.focus();
     return false;
   }
 

   bill_billing_phone=trim(Phone.value);
 
   if(trim(Phone.value).length == 12)
     {
 

for(phone_length=0;phone_length<trim(Phone.value).length;phone_length++)
         {
 
             if((phone_length == 3) || (phone_length == 7))
            {
 
                 if(bill_billing_phone.charAt(phone_length) == "-")
                 {
                 }
                 else
                 {
                     alert("Please enter Phone number in this format (###-###-####)");
                     Phone.focus();
                     return false;
                 }
             }
         }
     }
     else
     {
             alert("Please enter Phone number in this format (###-###-####)");
             Phone.focus();
             return false;
     }
 if(trim(a.emailaddress.value) == "")
 {
  alert("Please enter the email address");
  a.emailaddress.focus();
  return false;
 }
 if(isEmail(trim(a.emailaddress.value)) == false)
 {
  alert("Invalid email address");
  a.emailaddress.focus();
  return false;
 }
//var str123	=	"payment_bill";

return true;
	
}
//ajax







