function IsItPresent(s,explanation)

{

	// developed by willmaster.com

	s = StripSpacesFromEnds(s);

	if(s.length) return s;

	alert('Please enter ' + explanation + '.');

	return '';

}
function StripSpacesFromEnds(s)

{

	// developed by willmaster.com

	while((s.indexOf(' ',0) == 0) && (s.length > 1))

	{

		s = s.substring(1,s.length);

	}

	while((s.lastIndexOf(' ') == (s.length - 1) && (s.length > 1)))

	{

		s = s.substring(0,(s.length - 1));

	}

	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';

	return s;

}


function CheckEmail(s_email)

{

	// developed by willmaster.com

	s_email = IsItPresent(s_email,'your email address');

	if(! s_email) return false;

	var i = s_email.indexOf(' ',0);

	while(i > -1)

	{

		s_email = s_email.substring(0,i) + 

			s_email.substring((i + 1),s_email.length);

		i = s_email.indexOf(' ',0);

	}

	document.frm_subscribe.Email_Address.value = s_email;

	if((s_email.length < 6) ||

	   (s_email.indexOf('@',0) < 1) ||

	   (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||

	   (s_email.lastIndexOf('@') > (s_email.length - 5)) ||

	   (s_email.lastIndexOf('.') > (s_email.length - 3)) ||

	   (s_email.lastIndexOf('.') < (s_email.length - 4)) ||

	   (s_email.indexOf('..',0) > -1) ||

	   (s_email.indexOf('@.',0) > -1) ||

	   (s_email.indexOf('.@',0) > -1) ||

	   (s_email.indexOf(',',0) > -1))

	{

		alert('The email address "' + s_email + '" is not valid.');

		return false;

	}

	return true;
}
/*function CheckEmail (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) 
	{
		 alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			 alert("Ths username contains invalid characters.");
		return false;
		}
	}
	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			 alert("Ths domain name contains invalid characters.");
		return false;
		}
	}

	if (user.match(userPat)==null) 
	{
		 alert("The username doesn't seem to be valid.");
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				 alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			 alert("The domain name does not seem to be valid.");
			return false;
		}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
	{
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}

	if (len<2) 
	{
		 alert("This address is missing a hostname!");
		return false;
	}

	return true;
}*/

/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// 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 trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
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){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


function general_validate()
{
	
		if(document.frm_general.intRows.value=="")
	 {
	 
	 alert("Please Enter Number Of Rows Displayed Per Page");
	 
	 document.frm_general.intRows.focus();
	 
			 return false;
		}
		else
			 
			   if(!isInteger(document.frm_general.intRows.value))
			 {
			 document.frm_general.intRows.focus();
			 
			 return false;
	 			}   
				
	if(document.frm_general.intFrontRows.value=="")
	 {

	alert("Please Enter Number Of Rows Displayed Per Page");
	 
	 document.frm_general.intFrontRows.focus();
	 
			 return false;
		}else
			 if(!isInteger(document.frm_general.intFrontRows.value))
			 {
			
			 document.frm_general.intFrontRows.focus();
			 	 return false;
			 }
	  if(document.frm_general.varAdminPage.value=="")
	 {
	 document.frm_general.varAdminPage.focus();
	 
	 alert("Please Enter Admin Page Title");
	 return false;
	 } 
	   if(document.frm_general.varHomePage.value=="")
	 {
	 document.frm_general.varHomePage.focus();
	 alert("Please Enter Home Page Title");

	 return false;
	 } 
	   if(document.frm_general.Heading.value=="")
	 {
	 document.frm_general.Heading.focus();

	alert("Please Enter Heading");
	 return false;
	 } 
	 if(document.frm_general.Keyword.value=="")
	 {
	 document.frm_general.Keyword.focus();

	 alert("Please Enter Meta Keyword");
	 return false;
	 } 
	 
	   if(document.frm_general.Description.value=="")
	 {
	 document.frm_general.Description.focus();

	 alert("Please Enter Meta Description");
	 return false;
	 } 
	 if(document.frm_general.copy.value=="")
	 {
	 document.frm_general.copy.focus();
	 alert("Please Enter copy Right");
	 return false;
	 }  
	 
	if(document.frm_general.fee.value=="")
	 {
	 alert("Please Enter Dealer Registration Fee");
	 document.frm_general.fee.focus();
			 return false;
}else if(!isInteger(document.frm_general.fee.value))
			 {
			
			 document.frm_general.fee.focus();
			 return false;
	 			}   
		if(document.frm_general.leadfee.value=="")
	 {
	 alert("Please Enter Dealer Registration Fee");
	 document.frm_general.leadfee.focus();
			 return false;
}else if(!isInteger(document.frm_general.leadfee.value))
			 {
			
			 document.frm_general.leadfee.focus();
			 return false;
	 			}   
	return true;
}


 function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');	

	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) 	

		  alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) 
		  alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) 
	   alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db)
	  alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db)
	   alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) 
	   alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) 

	   alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) 
	   alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) 
	  alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum' && suffix != 'COM') {
	   if (db) 
alert('invalid primary domain in email address');
	   return false;
	}
return true;
}


function formvalidate()
{
		if(CheckEmail(deal.varEmail.value))
	{
		deal.varEmail.focus();
		return false;
	}
	 if(document.deal.txtfieldPassword1.value=="")
	 {
	 document.deal.txtfieldPassword1.focus();
	 return false;
	 } 
	
	 return true;
}
function password()
{	
	
	 if(document.form.old.value=="")
	 {
	 document.form.old.focus();
	alert("Please Enter Old Password");
	 return false;
	 } 
	  if(document.form.new1.value=="")
	 {
	 document.form.new1.focus();
	alert("Please Enter New Password");
	 return false;
	 } 
	  if(document.form.confirm1.value=="")
	 {
	 document.form.confirm1.focus();
	 alert("Please Enter Confirm Password");
	 return false;
	 } 
return true;}
function contactformvalid()
{
	alert();
	 if(document.contactform.applicantname.value=="")
	 {
	 document.contactform.applicantname.focus();
	alert("Please Enter Applicant Name");
	 return false;
	 }
	 	 if(document.contactform.applicantnumber.value=="")
	 {
	 document.contactform.applicantnumber.focus();
	 alert("Please Enter Applicant Number");
	 return false;
	 } 
	 	 if(document.contactform.comments.value=="")
	 {
	 document.contactform.comments.focus();
	alert("Please Enter Comments");
	 return false;
	 } 
	
	 return true;
}
function requestformvalid()
{
	alert();
	 if(document.requestform.applicantname.value=="")
	 {
	 document.requestform.applicantname.focus();
	alert("Please Enter Applicant Name");
	 return false;
	 }
	 	 if(document.requestform.applicantnumber.value=="")
	 {
	 document.requestform.applicantnumber.focus();
	 alert("Please Enter Applicant Number");
	 return false;
	 } 
	 	 if(document.requestform.comments.value=="")
	 {
	 document.requestform.comments.focus();
	alert("Please Enter Comments");
	 return false;
	 } 
	
	 return true;
}


 
 function membervalidate()
{
	if(document.addmem.txtfieldFirstname.value=="")
      {
		
	  document.addmem.txtfieldFirstname.focus();
	  alert("Please Enter The Contact Name");
	  return false;
	  }
	  if(document.addmem.CompanyName.value=="")
      {
	  document.addmem.CompanyName.focus();
	  alert("Please Enter The Company Name");
	  return false;
	  }
	  if (CheckEmail(document.addmem.varEmail.value)) 
	 {
	 document.addmem.varEmail.focus();
	 return false;
	 }	 
	  if (CheckEmail(document.addmem.varEmail2.value)) 
	 {
	 document.addmem.varEmail2.focus();
	 return false;
	 }	 
	 if(document.addmem.varEmail2.value!=document.addmem.varEmail.value)
	 {
		alert("Mismatched the email address");
		  document.addmem.varEmail2.focus();
		  return false;
	}
	 
	 if(document.addmem.Address.value=="")
      {
	  document.addmem.Address.focus();
	  alert("Please Enter The Address");
	  return false;
	  }
	 if(document.addmem.City.value=="")
	 {
	 document.addmem.City.focus();
	 alert("Please Enter City");
	 return false;
	 } 
	 
	 if(document.addmem.State.value=="")
      {
	  document.addmem.State.focus();
	  alert("Please Enter State");
	  return false;
	  }
	
		if(document.addmem.Zipcode.value=="")
	 {
	alert("Please Enter Zip Code");
	 
	 document.addmem.Zipcode.focus();
	 
			 return false;
		}
		else
	if(!isInteger(document.addmem.Zipcode.value))
	 {
	 document.addmem.Zipcode.focus();
	 return false;
	 } 
	 
	  if(document.addmem.leadradius.value=="")
      {
	  document.addmem.leadradius.focus();
	  alert("Please Select mile radius From Your Terrirtory");
	  return false;
	  }
	 
	 	if(document.addmem.Work.value=="")
	 {
	 
	alert("Please Enter Work Phone");
	 document.addmem.Work.focus();
	 
			 return false;
		}
		else
	 
	  if(!isInteger(document.addmem.Work.value))
	 {
		
	 document.addmem.Work.focus();
	 return false;
	 } 
	  if(document.addmem.leadpermonth.value=="")
	 {
	 document.addmem.leadpermonth.focus();
	 alert("Please Select The Option For Lead Recieved Per Month");
	 return false;
	 } 
	  if(document.addmem.txtfieldPassword1.value=="")
	 {
	 document.addmem.txtfieldPassword1.focus();
	alert("Please Enter The Password");
	 return false;
	 } 
	  if(document.addmem.receiving.value=="")
	 {
	 document.addmem.receiving.focus();
	 alert("Please Enter The Lead receiving option");
	 return false;
	 } 
	 return true;
}
function isInteger(s)
{
      var i;

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
		 
         if (isNaN(c)) 
	   {
	   
		alert("Given value is not a number");
		

		return false;
	   }
	   
      }
      return true;
}
function fpassword()
{	
if(CheckEmail(formforget.mail.value))
	{
		formforget.mail.focus();
		return false;
	}
	  if(document.formforget.zipcode.value=="")
	 {
	 document.formforget.zipcode.focus();
	 		

	alert("Please Enter The Correct Zip Code");
	 return false;
	 } 
	 
return true;
}
function account_validate()
{
if(document.frm_accountinfo.varCompany.value=="")
      {
	  document.frm_accountinfo.varCompany.focus();
	
	  alert("Please Enter Company Name");
	  return false;
	  }
	 if(document.frm_accountinfo.varContactPerson.value=="")
	 {
	 document.frm_accountinfo.varContactPerson.focus();
	
	 alert("Please Enter Contact Person Name");
	 return false;
	 } 
	 
	 if (CheckEmail(document.frm_accountinfo.varAdminEmail.value)) 
	{
		document.frm_accountinfo.varAdminEmail.focus();
		return false;
	}
	  var theurl=document.frm_accountinfo.varAdminWebsite.value;
	  var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
	if(theurl!="")
	{ 
    	if (document.frm_accountinfo.varAdminWebsite.value.indexOf ('www.', 0) == -1 || document.frm_accountinfo.varAdminWebsite.value.length < 10)
		{ 
		 if(document.frm_accountinfo.varAdminWebsite.value.indexOf ('.com', 0) == -1 || document.frm_accountinfo.varAdminWebsite.value.length < 10)
	 		 {
	 		 	 
                  alert ("Enter A Valid URL")
                    document.frm_accountinfo.varAdminWebsite.focus();
					return false;
              }
	     }
	}
else	{
    	  document.frm_accountinfo.varAdminWebsite.focus();
	 		 	
		 window.alert("Please Enter URL Name");
		  return false;
		}

	 return true;
	 
}

function order_form_validation()
{

    var firstname = document.CustomersForm.txt_first.value;
							 if (firstname == "" )
							 { 
										 
										 alert ("Please enter the firstname");
										document.CustomersForm.txt_first.focus();
										 return false;
	 							}

    var emailid    = document.CustomersForm.txt_email.value;
	 		if(emailid == "")
		{
								
										alert ("Please enter the email");
										document.CustomersForm.txt_email.focus();
										 return false;
		}	
		else		if (!CheckEmail(emailid)) 
		{
		   document.CustomersForm.txt_email.focus();
		   return false;	
		}	
     var txt_companys = document.CustomersForm.txt_company.value;
	 if (txt_companys == "" )
	 { 
										alert ("Please enter the company name");
										 document.CustomersForm.txt_company.focus();
										 return false;
	 }
	var Phone			       =document.CustomersForm.txt_workphone;
	if ((Phone.value==null)||(Phone.value=='')){
										alert ("Please enter the work phone number");
										Phone.focus();
										 return false;

											}
											if (checkInternationalPhone(Phone.value)==false){
										alert ("Please enter the work phone number");
										Phone.focus();
										 return false;
									
											} 
	 if (document.CustomersForm.txt_address1.value=="")
	 {alert("Please enter the address");
	 document.CustomersForm.txt_address1.focus();
	 return false;
	 }	
 if (document.CustomersForm.txt_city.value=="")
	 {alert('Please enter the city');
					 document.CustomersForm.txt_city.focus();
	 return false;
	 }	
	 
	  var zipcode = document.CustomersForm.txt_postcode.value;
	 if (zipcode == "" )
	 { alert('Please enter the  zip code');
	 document.CustomersForm.txt_postcode.focus();
	 return false;
	 }	
	 else
	 if(!isInteger(document.CustomersForm.txt_postcode.value))
	 {
	 document.CustomersForm.txt_postcode.focus();
	 return false;
	 } 
	 var county = document.CustomersForm.txt_county.value;
	 if (county == "" )
	 { alert('Please enter the Country');
	 document.CustomersForm.txt_county.focus();
	 return false;
	 }	
	  var source1 = document.CustomersForm.txt_source.value;
	 if (source1 == "" )
	 { alert('Where did you hear about us?');
	 document.CustomersForm.txt_source.focus();
	 return false;
	 }	
	 

	return true;

}	


