function ShowHideMenuof(menu,control)
{		var TotalLength = control.src.length;
		var startPos = control.src.lastIndexOf("/")+1;
		var Length = TotalLength-startPos;
		var string = control.src;
		
		if(string.substr(startPos,Length)=="menu_open1.gif")
		{
			document.getElementById(menu).style.display = '';
			control.src = 'images/menu_close1.gif';
		}
		else
		{
			document.getElementById(menu).style.display = 'none';
			control.src = 'images/menu_open1.gif';		
		}
}			
function getXMLHTTP() {
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
					print("there is problem in ur browser");
				}
			}
		}		 	
		return xmlhttp;
	}

function enablebtn(terms,btn)
{ if(document.getElementById(terms).checked==true)
  {
    document.getElementById(btn).disabled=false;
  }
  if(document.getElementById(terms).checked==false)
  {
     document.getElementById(btn).disabled=true;  
  }
}

function ajax_show_prod(strURL)
	{  
		var req = getXMLHTTP();
		alert(strURL);
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{	//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('storetype').innerHTML=req.responseText;			
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
	}	
function ajax_acc_type(strURL)
	{ 
	  //$('#acc_type').load(strURL);
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						//alert(req.responseText);
						document.getElementById('acc_type').innerHTML=req.responseText;	
						getAjaxCaptchaValue();						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
	}	
function getAjaxCaptchaValue()
	{  
	strURL="Ajs/create_image.php?sesval=yes"	
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						//alert(req.responseText);	
						document.getElementById('secimageval').value=req.responseText;				
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
	}		
function getAjaxResetCaptchaValue()
	{  
	strURL="Ajs/create_image.php?sesval=reset"	
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						//alert(req.responseText);	
						document.getElementById('secimageval').value=req.responseText;				
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}	}	
function ajax_query_topic(strURL)
{ // to make the txt stauts active if status selected other

  //alert(strURL);
  if(document.getElementById('sel_status').value=='other')
    {
	document.getElementById('txt_status').disabled=false;	  
	} 
  else	
   document.getElementById('txt_status').disabled=true;	
     
   ////////////////////////////////////////////////////////////////
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('choose_topic').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}		
		if(document.getElementById('seltopic').value=='other')
          {
	      document.getElementById('txttopic_written').disabled=false;		  
	      } 
        else	
          document.getElementById('txttopic_written').disabled=true;
	
}	
	
//function for displaying country and  states	
function ajaxFunction_state_country(strURL)
 { 
		var req = getXMLHTTP();
		//alert(strURL);
		//req=false;
		if (req) 
		{ //req.onreadystatechange = processReqChange;
		  req.onreadystatechange = function() {
		  if (req.readyState == 4) 
			{ 	//alert(req.responseText);
				// only if "OK"
			 if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('state_country').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }//end of ajax funtioin to display country
 
 function ajax_mailing_state_country(strURL)
 {  	
		var req = getXMLHTTP();
		//alert(strURL);
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('mailing_state_country').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }//end of ajax funtioin to display country
 
 

//function for displaying country and  states in  banking information page
function ajaxFunction_state_country_bank1(strURL)
 {  
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('state_country_bank1').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }
function ajaxFunction_state_country_bank2(strURL)
 {  
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('state_country_bank2').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }
//end of ajax funtioins to display country in banking information page


//start of ajax funtion for mailing_state_country
function ajaxFunction_mailing_state_country(strURL)
{  
//alert(strURL);
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('mailing_state').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
		document.getElementById('getmailstate').value = document.getElementById('getstate').value;
}//end of mailing state country function

//start of ajaxFunction_display_mail_address
function ajaxFunction_display_mail_address(strURL)
{
	
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('mail_address').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
}//end of ajaxFunction_display_mail_address function
////////////////////////////for captcha code javascript///////////////////////////////////////////////////////////////
function update()  //to change the captcha code
{ 
//Get a reference to CAPTCHA image
   img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src ='Ajs/create_image.php?' + Math.random(); 
   getAjaxResetCaptchaValue();
}
function getParam(theForm) // for checking the captcha code 
{ 
    if(theForm.txtCaptcha.value=="")
   { 
     document.getElementById('result').innerHTML="Please fill the Captcha code"; 
	 return false;
   }   
  else if(theForm.secimageval.value!=theForm.txtCaptcha.value)
  { 
    document.getElementById('result').innerHTML="Captcha Code Mismatched...";
    return false;
  }  
  else if(theForm.secimageval.value==theForm.txtCaptcha.value)     
  {  
    if(theForm.sel_personal_type.value==1)
	{
		
	//location.replace("index.php");
	}//document.personal_acc.submit();   
     //location.href="registration.php";
  }
}

function getParam_retailer(theForm) // for checking the captcha code 
{ //alert(theForm.secimageval.value);  
    var ok=true;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation

 	if(theForm.txtfirstname.value=="")
	{ document.getElementById('errfirstname').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirstname').innerHTML="";

	if(theForm.txtlastname.value=="")
	{ document.getElementById('errlastname').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlastname').innerHTML="";  
   
   if(theForm.txtcountry.value=="")
	{ document.getElementById('errcountry').innerHTML="Please provide Country Name";
	  ok=false;
	}
   else document.getElementById('errcountry').innerHTML="";
   
   if(theForm.selcomptype.value=="sel")
	{ document.getElementById('errselcomptype').innerHTML="Please provide Company Type";
	  ok=false;
	}
   else document.getElementById('errselcomptype').innerHTML="";
   
   if(theForm.txtemail.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email Address";
	  ok=false;
	}
   else document.getElementById('erremail').innerHTML="";
   if (!filter.test(theForm.txtemail.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML="";
   
   if(theForm.txtmonth.value=="0" || theForm.txtday.value=="0" || theForm.txtyear.value=="0")
	{ document.getElementById('errdate').innerHTML="Please provide Valid Date of Birth";
	  ok=false;
	}
   else document.getElementById('errdate').innerHTML="";   
   
 if(theForm.txtCaptcha.value=="")
   { 
     document.getElementById('result').innerHTML="Please fill the Captcha code"; 
	 ok=false;
   } 
 
 else if(theForm.secimageval.value!=theForm.txtCaptcha.value)
  { 
    document.getElementById('result').innerHTML="Captcha Code Mismatched...";
	  ok=false;
  } 
else if(theForm.secimageval.value==theForm.txtCaptcha.value)     
  { 
  document.getElementById('result').innerHTML=""; 
	//document.personal_acc.submit();   
   //location.href="registration.php";
  }

return ok;  
}
function getParam_retailer_first(theForm) // for checking the retailer_first page
{ 
   var ok=true;
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation
   var phone_filter=/^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$/; 
   var zipcode_filter_us=/^([0-9]{5})(-[0-9]{4})?$/;
   var zipcode_filter_canada=/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/;
   var taxid=/^[0-9]{2}-[0-9]{7}$/;
   var ssn=/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/;
   var pin_filter=/^\w*(?=\w*\d)(?=\w*[A-Za-z])\w*$/; //atleast 1 no. and atleat 1 char(capital or small)//
   var pwd_filter=/^.{8,}$/;
   var pin_filter_length=/^.{3,5}$/;
	//alert("testing");
   if(theForm.business_name.value=="")
	{ document.getElementById('errbusiness_name').innerHTML="Please provide Business Name";
	  ok=false;
	}
   else document.getElementById('errbusiness_name').innerHTML="";
/* if(theForm.doi_month.value=="0" || theForm.doi_day.value=="0" || theForm.doi_year.value=="0")
	{ document.getElementById('errdoi_date').innerHTML="Please provide Date of Incorporation";
	  ok=false;
	}
   else document.getElementById('errdoi_date').innerHTML="";  
*/
   if(theForm.Ftax_id.value=="")
	{ document.getElementById('errFtax_id').innerHTML="Please provide Federal TAX ID/SSN";
	  ok=false;
	}
  else if(theForm.Ftax_id.value!="")
	{
		if(!taxid.test(theForm.Ftax_id.value) && !ssn.test(theForm.Ftax_id.value))
		 {document.getElementById('errFtax_id').innerHTML="Please provide Valid Tax ID/SSN"; 
		 ok=false;}		
	    else if(ssn.test(theForm.Ftax_id.value) || taxid.test(theForm.Ftax_id.value) )
		 {document.getElementById('errFtax_id').innerHTML=""; 
		 ok=true;}
	}
   	if(theForm.contact_person.value=="")
	{ document.getElementById('errcontact_person').innerHTML="Please provide Contact Person";
	  ok=false;
	}
   else document.getElementById('errcontact_person').innerHTML="";  
   
   if(theForm.first_name.value=="")
	{ document.getElementById('errfirst_name').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirst_name').innerHTML="";
   
   if(theForm.last_name.value=="")
	{ document.getElementById('errlast_name').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlast_name').innerHTML="";
   if(theForm.dob_month.value=="0" || theForm.dob_day.value=="0" || theForm.dob_year.value=="0")
	{ document.getElementById('errdob_date').innerHTML="Please provide Date of Birth";
	  ok=false;
	}
   else document.getElementById('errdob_date').innerHTML="";  
    if(theForm.addressLine1.value=="")
	{ document.getElementById('erraddressLine1').innerHTML="Please provide Address";
	  ok=false;
	}
   else document.getElementById('erraddressLine1').innerHTML="";
  
  if(theForm.country.value=="sel")
	{ document.getElementById('errcountry').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errcountry').innerHTML="";   
   
    if(theForm.getstate.value=="sel")
	{ document.getElementById('errstate').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errstate').innerHTML="";   
   
    if(theForm.postal_code1.value=="")
	{ document.getElementById('errpostal_code1').innerHTML="Please provide Postal Code";
	  ok=false;
	}
   else
   { 
	   if(theForm.country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.postal_code1.value) )
		 {document.getElementById('errpostal_code1').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errpostal_code1').innerHTML="";
	   }  
	   
	  else if(theForm.country.value==1)
	   {     
		if(!zipcode_filter_us.test(theForm.postal_code1.value) )
		 {document.getElementById('errpostal_code1').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errpostal_code1').innerHTML="";
	   } 
	   else document.getElementById('errpostal_code1').innerHTML="";
	 } 
  
    if(theForm.city.value=="")
	{ document.getElementById('errcity').innerHTML="Please provide City Name";
	  ok=false;
	}
   else document.getElementById('errcity').innerHTML="";


   if(theForm.phone1.value=="" || theForm.phone2.value=="" || theForm.phone3.value=="")
	{
	document.getElementById('errphone').innerHTML="Please provide your Phone No"; 
	 ok=false;}
	 
  else if(isNaN(theForm.phone1.value) || isNaN(theForm.phone2.value) || isNaN(theForm.phone3.value) )//
   {
    document.getElementById('errphone').innerHTML="Phone No should be number"; 
	ok=false;}
	
   else
   {
	 if(theForm.country.value==2)
	   {
	   if(!phone_filter.test(theForm.phone1.value+"-"+theForm.phone2.value+"-"+theForm.phone3.value))
   		{
	    document.getElementById('errphone').innerHTML="Phone No not valid for Canada"; 
		ok=false;
	   	}  
  		else document.getElementById('errphone').innerHTML="";
	   }
	 if(theForm.country.value==1)
	   {
	   if(!phone_filter.test(theForm.phone1.value+"-"+theForm.phone2.value+"-"+theForm.phone3.value))
   		{
	    document.getElementById('errphone').innerHTML="Phone No not valid for USA"; 
		ok=false;
	   	}  
  		else document.getElementById('errphone').innerHTML="";
	   }
	}
		
    if(theForm.email.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email";
	  ok=false;
	}
   else document.getElementById('erremail').innerHTML="";  

   
   if (!filter.test(theForm.email.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML=""; 
   //mailing address section//
    if(theForm.mail_add_1.value=="")
	{ document.getElementById('errmail_add_1').innerHTML="Please Provide Mailing Address";
	  ok=false;
	}
   else document.getElementById('errmail_add_1').innerHTML="";  

   if(theForm.ma_country.value=="")
	{ document.getElementById('errma_country').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errma_country').innerHTML="";
   
    if(theForm.mailstate.value=="sel")
	{ document.getElementById('errselmailstate').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errselmailstate').innerHTML="";
   
   if(theForm.ma_postal_code1.value=="")
	{ document.getElementById('errma_postal_code').innerHTML="Please provide Postal Code";
	  ok=false;
	}
	else
   	{ 
	   if(theForm.ma_country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.ma_postal_code1.value) )
		 {document.getElementById('errma_postal_code').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errma_postal_code').innerHTML="";
	   }  
	   
	  if(theForm.ma_country.value==1)
	   {     
		if(!zipcode_filter_us.test(theForm.ma_postal_code1.value) )
		 {document.getElementById('errma_postal_code').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errma_postal_code').innerHTML="";
	   }    
	 } 
 
     
  if(theForm.ma_city.value=="")
	{ document.getElementById('errma_city').innerHTML="Please Provide City";
	  ok=false;
	}
   else document.getElementById('errma_city').innerHTML="";

   if(theForm.user_name.value=="")
	{ document.getElementById('erruser_name').innerHTML="Please Provide Username";
	  ok=false;
	}
   else document.getElementById('erruser_name').innerHTML="";

   if(theForm.password.value=="")
	{ document.getElementById('errpassword').innerHTML="Please Provide Password";
	  ok=false;
	}
	else if(theForm.password.value!="")
   		{     
		if(!pwd_filter.test(theForm.password.value) )
		 {document.getElementById('errpassword').innerHTML="Password must be 8 chars long"; 
		 ok=false;}
		 else document.getElementById('errpassword').innerHTML="";
	   } 
   //else document.getElementById('errpassword').innerHTML="";

   if(theForm.repassword.value=="")
	{ document.getElementById('errrepassword').innerHTML="Please Retype Password";
	  ok=false;
	}
	else if(theForm.repassword.value!=theForm.password.value)
	{ document.getElementById('errrepassword').innerHTML="Password Mismatch";
	  ok=false;
	}
   else document.getElementById('errrepassword').innerHTML=""; 
   
  if(theForm.pin.value=="")
	{ document.getElementById('errpin').innerHTML="Please Type Pin";
	  ok=false;
	}
  else document.getElementById('errpin').innerHTML=""; 
   if(theForm.pin.value!="")
	  {     
		if(!pin_filter.test(theForm.pin.value) || !pin_filter_length.test(theForm.pin.value) )
		 {document.getElementById('errpin').innerHTML="Invalid Pin format"; 
		 ok=false;}
		 else document.getElementById('errpin').innerHTML="";
	  } 
	   
  if(theForm.repin.value=="")
	{ document.getElementById('errrepin').innerHTML="Please Retype Pin";
	  ok=false;
	}
  else if(theForm.repin.value!=theForm.pin.value)
	{ document.getElementById('errrepin').innerHTML="Pin Mismatch";
	  ok=false;
	}
   else document.getElementById('errrepin').innerHTML="";    
 return ok;   
}

function change()//for changing captcha for the form that is not loaded thru ajax
{
	img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src ='Ajs/create_image.php?' + Math.random();
}
function popup(ID)
{
 window.open("review_show.php?ID="+ID,'Preview','width=400,height=400,toolbar=no,location=0,status=0,menubar=0,titlebar=0,scrollbars=0,resizable=0'); 
}
//end of retailer_first validation//

//Start of Retailer_second Validation//
function getParam_retailer_second(theForm) // for checking the retailer_second page
{  
   var filter_visa=/^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_mastercard=/^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_discover=/^6011-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_amex=/^3[4,7]\d{13}$/; 
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation
   var phone_filter=/^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$/; 
   var zipcode_filter_us=/^([0-9]{5})(-[0-9]{4})?$/;
   var zipcode_filter_canada=/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/;
   var ok=true;	
   
   if(theForm.storefront.value=="")
	{ 
	  document.getElementById('errstorefront').innerHTML="Please Provide StoreFront";
	  ok=false;
	}
   else document.getElementById('errstorefront').innerHTML="";
  
  if(theForm.primary_business.value=="sel")
	{ 
	  document.getElementById('errprimary_business').innerHTML="Please Select Primary Business";
	  ok=false;
	}
   else document.getElementById('errprimary_business').innerHTML="";
	
 if(theForm.secondary_business.value=="sel")
	{ document.getElementById('errsecondary_business').innerHTML="Please Select Secondary Business";
	  ok=false;
	}
   else document.getElementById('errsecondary_business').innerHTML="";

  if( theForm.c1.checked==false && theForm.c2.checked==false && theForm.c3.checked==false && theForm.c4.checked==false)
	{ 
	  document.getElementById('errselling_methods').innerHTML="Please Select atleast One Option";
	  ok=false;
	}
   else document.getElementById('errselling_methods').innerHTML="";
   	
	if(theForm.location.value=="sel")
	{ document.getElementById('errlocation').innerHTML="Please Select Your Location";
	  ok=false;
	}
   else document.getElementById('errlocation').innerHTML="";
  
   if( theForm.ps1.checked==false && theForm.ps2.checked==false && theForm.ps3.checked==false && theForm.ps4.checked==false)
	{ 
	  document.getElementById('errproduct_shown').innerHTML="Please Select Product Shown method";
	  ok=false;
	}
   else document.getElementById('errproduct_shown').innerHTML="";

   if( theForm.offer1.checked==false && theForm.offer2.checked==false && theForm.offer3.checked==false)
	{ 
	  document.getElementById('erroffer').innerHTML="Please Select atleast One Offer";
	  ok=false;
	}
   else document.getElementById('erroffer').innerHTML="";
    
   // start of third party validation for retailer//
  if( theForm.prhandling2.checked==true)
   {
   if(theForm.tp_name.value=="")
	{ document.getElementById('errtp_name').innerHTML="Please provide Third Party Name";
	  ok=false;
	}
   else document.getElementById('errtp_name').innerHTML=""; 
   
   if(theForm.tp_country.value=="sel")
	{ document.getElementById('errtp_country').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errtp_country').innerHTML="";   
  
    if(theForm.tp_getstate.value=="sel")
	{ document.getElementById('errtp_state').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errtp_state').innerHTML="";  
   //for validation of postal code for third party/////////// 
     
    if(theForm.tp_postalcode.value=="")
	{ document.getElementById('errtp_postalcode').innerHTML="Please provide Postal Code";
	  ok=false;
	}
   else
   { 
   
   if(theForm.tp_country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.tp_postalcode.value) )
		 {document.getElementById('errtp_postalcode').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errtp_postalcode').innerHTML="";
	   }  
	   
	  else if(theForm.tp_country.value==1)
	   {   
		if(!zipcode_filter_us.test(theForm.tp_postalcode.value) )
		 {document.getElementById('errtp_postalcode').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errtp_postalcode').innerHTML="";
	   } 
	   else document.getElementById('errtp_postalcode').innerHTML="";
	 } 
    ///////////////////////////end of postal code/////////////////////////////
 	if(theForm.tp_city.value=="")
	{ document.getElementById('errtp_city').innerHTML="Please provide City";
	  ok=false;
	}
    else document.getElementById('errtp_city').innerHTML="";  
	//alert("hi");
   if(theForm.tp_phone1.value=="" || theForm.tp_phone2.value=="" || theForm.tp_phone3.value=="")
	{
	document.getElementById('errtp_phone').innerHTML="Please provide Phone No"; 
	 ok=false;}
   else if(isNaN(theForm.tp_phone1.value) || isNaN(theForm.tp_phone2.value) || isNaN(theForm.tp_phone3.value))
   {
    document.getElementById('errtp_phone').innerHTML="Phone No should be number"; 
	ok=false;}
    else
   {
	if(theForm.tp_country.value==2)
	   {
	   if(!phone_filter.test(theForm.tp_phone1.value+"-"+theForm.tp_phone2.value+"-"+theForm.tp_phone3.value))
   		{
	    document.getElementById('errtp_phone').innerHTML="Phone No not valid for Canada"; 
		ok=false;
	   	}  
  		else document.getElementById('errtp_phone').innerHTML="";
	   }
	 if(theForm.tp_country.value==1)
	   {
	   if(!phone_filter.test(theForm.tp_phone1.value+"-"+theForm.tp_phone2.value+"-"+theForm.tp_phone3.value))
   		{
	    document.getElementById('errtp_phone').innerHTML="Phone No not valid for USA"; 
		ok=false;
	   	}  
  		else document.getElementById('errtp_phone').innerHTML="";
	   }
	}
	if(theForm.tp_email.value=="")
	{ document.getElementById('errtp_email').innerHTML="Please provide Email";
	  ok=false;
	}
   else document.getElementById('errtp_email').innerHTML="";  
   if (!filter.test(theForm.tp_email.value))
   {document.getElementById('errtp_email').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('errtp_email').innerHTML=""; 
   }
   //End of third party validation retailer//
   
	if(theForm.compbusiness.value=="sel")
	{ document.getElementById('errcompbusiness').innerHTML="Please Select One";
	  ok=false;
	}
   else document.getElementById('errcompbusiness').innerHTML="";   
  
	if(theForm.payby.value=="sel")
	{ document.getElementById('errpayby').innerHTML="Please Select Pay By";
	  ok=false;
	}
   else document.getElementById('errpayby').innerHTML="";
   if(theForm.payby.value=="1")
   {
		if(theForm.paypal_acc.value=="")
		{ document.getElementById('errpaypal_acc').innerHTML="Please provide Paypal ID";
		  ok=false;
		}
		else
		{
			  if (!filter.test(theForm.paypal_acc.value))
			  {
				  document.getElementById('errpaypal_acc').innerHTML="Please provide Valid Paypal ID"; 
				  ok=false;
			  }
			  else document.getElementById('errpaypal_acc').innerHTML="";
		}
   }

   if(theForm.payby.value=="2")
	{
	if(theForm.cc_type.value=="sel")
	{ document.getElementById('errcc_type').innerHTML="Please Select Credit Card";
	  ok=false;
	}
   else document.getElementById('errcc_type').innerHTML="";
  if(theForm.cnumber.value=="")
	{ document.getElementById('errcnumber').innerHTML="Please Write Card Number";
	  ok=false;
	}
   else 
   { if(theForm.cc_type.value==1)
      { if(!filter_mastercard.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";
	  }
	 if(theForm.cc_type.value==2)
	 { if(!filter_visa.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML=""; 
     }	 
	 if(theForm.cc_type.value==3)
	 { if(!filter_discover.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";
	 }
	 if(theForm.cc_type.value==4)
	 { if(!filter_amex.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";		 
	 }	    
   } 
   if(theForm.cardpin.value=="")
	{ document.getElementById('errcardpin').innerHTML="Please provide Card PIN";
	  ok=false;
	}
	else if(isNaN(theForm.cardpin.value))
	{
		document.getElementById('errcardpin').innerHTML="Card PIN should be Numeric";
	 	ok=false;
	}
	else document.getElementById('errcardpin').innerHTML="";
	
   if(theForm.txtmonth.value=="0" || theForm.txtyear.value=="0")
	{ document.getElementById('errdate').innerHTML="Please provide Correct Expiry Date";
	  ok=false;
	}
   else document.getElementById('errdate').innerHTML="";
	}

   if( theForm.terms.checked==false )
	{ 
	  document.getElementById('errterms').innerHTML="Please accept Terms of Agreeement to proceed";
	  ok=false;
	}
   else document.getElementById('errterms').innerHTML="";
   if(theForm.yes_no.value=="yes")
   {
	    if(theForm.club_membership.value=="sel")
 		{
			 document.getElementById('errclub_membership').innerHTML="Please select a membership option";
	  		 ok=false;
		}
	   else document.getElementById('errclub_membership').innerHTML="";
   }
   
   return ok;
  
}
//End of Retailer_second Validation//


// Start of Initial_wholesaler validation //
function getParam_wholesaler(theForm) // for checking the captcha code 
{ 
    var ok=true;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation

 	if(theForm.txtfirstname.value=="")
	{ document.getElementById('errfirstname').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirstname').innerHTML="";

	if(theForm.txtlastname.value=="")
	{ document.getElementById('errlastname').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlastname').innerHTML="";  
   
   if(theForm.txtcompany.value=="")
	{ document.getElementById('errcompany').innerHTML="Please provide Company Name";
	  ok=false;
	}
   else document.getElementById('errcompany').innerHTML="";
   
   if(theForm.txtemail.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email Address";
	  ok=false;
	}
   //else document.getElementById('erremail').innerHTML="";
   else if (!filter.test(theForm.txtemail.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML="";
   
/*   if(theForm.txtmonth.value=="0" || theForm.txtday.value=="0" || theForm.txtyear.value=="0")
	{ document.getElementById('errdate').innerHTML="Please provide Valid Date of Birth";
	  ok=false;
	}
   else document.getElementById('errdate').innerHTML="";   
   */
   
 if(theForm.txtCaptcha.value=="")
   { 
     document.getElementById('result').innerHTML="Please fill the Captcha code"; 
	 ok=false;
   } 
 
 else if(theForm.secimageval.value!=theForm.txtCaptcha.value)
  { 
    document.getElementById('result').innerHTML="Captcha Code Mismatched...";
	  ok=false;
  } 
else if(theForm.secimageval.value==theForm.txtCaptcha.value)     
  { 
  document.getElementById('result').innerHTML=""; 
  }

return ok;  
}
//end of initial_wholesaler validation//

//start of wholesaler_first validation//
function getParam_wholesaler_first(theForm) // for checking the wholesaler_first page
{ 
   var ok=true;
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation
   var phone_filter=/^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$/; 
   var zipcode_filter_us=/^([0-9]{5})(-[0-9]{4})?$/;
   var zipcode_filter_canada=/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/;
   var taxid=/^[0-9]{2}-[0-9]{7}$/;
   var ssn=/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/;
   var pwd_filter=/^.{8,}$/;
   var pin_filter=/^\w*(?=\w*\d)(?=\w*[A-Za-z])\w*$/; //atleast 1 no. and atleat 1 char(capital or small)//
   var pin_filter_length=/^.{3,5}$/;
	
   if(theForm.business_name.value=="")
	{ document.getElementById('errbusiness_name').innerHTML="Please provide Business Name";
	  ok=false;	 
	}
   else document.getElementById('errbusiness_name').innerHTML="";
/*
	if(theForm.name.value=="")
	{ document.getElementById('errname').innerHTML="Please provide Name";
	  ok=false;	   
	}
   else document.getElementById('errname').innerHTML="";  
 */ 
   if(theForm.Ftax_id.value=="")
	{ document.getElementById('errFtax_id').innerHTML="Please provide Federal TAX ID/SSN";
	  ok=false;	  
	}
	else if(theForm.Ftax_id.value!="")
	{
		if(!taxid.test(theForm.Ftax_id.value) && !ssn.test(theForm.Ftax_id.value))
		 {document.getElementById('errFtax_id').innerHTML="Please provide Valid Tax ID/SSN"; 
		 ok=false;		 
		 }		
	    else if(ssn.test(theForm.Ftax_id.value) || taxid.test(theForm.Ftax_id.value) )
		 {document.getElementById('errFtax_id').innerHTML=""; 
		 ok=true;
		 }
	} 	
   if(theForm.contact_person.value=="")
	{ document.getElementById('errcontact_person').innerHTML="Please provide Contact Person";
	  ok=false;
	}
   else document.getElementById('errcontact_person').innerHTML="";   


  if(theForm.first_name.value=="")
	{ document.getElementById('errfirst_name').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirst_name').innerHTML="";
   
   if(theForm.last_name.value=="")
	{ document.getElementById('errlast_name').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlast_name').innerHTML="";
   if(theForm.dob_month.value=="0" || theForm.dob_day.value=="0" || theForm.dob_year.value=="0")
	{ document.getElementById('errdob_date').innerHTML="Please provide Date of Birth";
	  ok=false;
	}
   else document.getElementById('errdob_date').innerHTML="";   
    if(theForm.addressLine1.value=="")
	{ document.getElementById('erraddressLine1').innerHTML="Please provide Address";
	  ok=false;
	}
   else document.getElementById('erraddressLine1').innerHTML="";
     
  if(theForm.country.value=="sel")
	{ document.getElementById('errcountry').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errcountry').innerHTML="";   
 
    if(theForm.getstate.value=="sel")
	{ document.getElementById('errstate').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errstate').innerHTML="";  
    if(theForm.city.value=="")
	{ document.getElementById('errcity').innerHTML="Please provide City Name";
	  ok=false;
	}
   else document.getElementById('errcity').innerHTML="";
  
    if(theForm.postal_code1.value=="")
	{ document.getElementById('errpostal_code1').innerHTML="Please provide Postal Code";
	  ok=false;
	}
   else
   { if(theForm.country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.postal_code1.value) )
		 {document.getElementById('errpostal_code1').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errpostal_code1').innerHTML="";
	   }  
	   
	  else if(theForm.country.value==1)
	   {     
		if(!zipcode_filter_us.test(theForm.postal_code1.value) )
		 {document.getElementById('errpostal_code1').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errpostal_code1').innerHTML="";
	   } 
	   else document.getElementById('errpostal_code1').innerHTML="";
	 } 
 
   if(theForm.phone1.value=="" || theForm.phone2.value=="" || theForm.phone3.value=="")
	{
	document.getElementById('errphone').innerHTML="Please provide Phone No"; 
	 ok=false;}
	 
  else if(isNaN(theForm.phone1.value) || isNaN(theForm.phone2.value) || isNaN(theForm.phone3.value))
   {
    document.getElementById('errphone').innerHTML="Phone No should be number"; 
	ok=false;}
	
   else
   {
	 if(theForm.country.value==2)
	   {
	   if(!phone_filter.test(theForm.phone1.value+"-"+theForm.phone2.value+"-"+theForm.phone3.value))
   		{
	    document.getElementById('errphone').innerHTML="Phone No not valid for Canada"; 
		ok=false;
	   	}  
  		else document.getElementById('errphone').innerHTML="";
	   }
	 if(theForm.country.value==1)
	   {
	   if(!phone_filter.test(theForm.phone1.value+"-"+theForm.phone2.value+"-"+theForm.phone3.value))
   		{
	    document.getElementById('errphone').innerHTML="Phone No not valid for USA"; 
		ok=false;
	   	}  
  		else document.getElementById('errphone').innerHTML="";
	   }
	}
	
    if(theForm.email.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email";
	  ok=false;
	}
   else document.getElementById('erremail').innerHTML="";  
   if (!filter.test(theForm.email.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML=""; 
	  
  //mailing address section//
    if(theForm.mail_add_1.value=="")
	{ document.getElementById('errmail_add_1').innerHTML="Please Provide Mailing Address";
	  ok=false;
	}
   else document.getElementById('errmail_add_1').innerHTML="";  
 
   if(theForm.ma_country.value=="sel")
	{ document.getElementById('errma_country').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errma_country').innerHTML="";
   
    if(theForm.mailstate.value=="sel")
	{ document.getElementById('errselmailstate').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errselmailstate').innerHTML="";
 
   if(theForm.ma_postal_code.value=="")
	{ document.getElementById('errma_postal_code').innerHTML="Please provide Postal Code";
	  ok=false;
	}
	else
   	{ 
	   if(theForm.ma_country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.ma_postal_code.value) )
		 {document.getElementById('errma_postal_code').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errma_postal_code').innerHTML="";
	   }  
	   
	  if(theForm.ma_country.value==1)
	   {     
		if(!zipcode_filter_us.test(theForm.ma_postal_code.value) )
		 {document.getElementById('errma_postal_code').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errma_postal_code').innerHTML="";
	   }    
	 } 
 

  if(theForm.ma_city.value=="")
	{ document.getElementById('errma_city').innerHTML="Please Provide City";
	  ok=false;
	}
   else document.getElementById('errma_city').innerHTML="";
 
   if(theForm.user_name.value=="")
	{ document.getElementById('erruser_name').innerHTML="Please Provide Username";
	  ok=false;
	}
   else document.getElementById('erruser_name').innerHTML="";

   if(theForm.password.value=="")
	{ document.getElementById('errpassword').innerHTML="Please Provide Password";
	  ok=false;
	}
   else if(theForm.password.value!="")
   		{     
		if(!pwd_filter.test(theForm.password.value) )
		 {document.getElementById('errpassword').innerHTML="Password must be 8 chars long"; 
		 ok=false;}
		 else document.getElementById('errpassword').innerHTML="";
	   } 
   //document.getElementById('errpassword').innerHTML="";
   
   if(theForm.repassword.value=="")
	{ document.getElementById('errrepassword').innerHTML="Please Retype Password";
	  ok=false;
	}
	else if(theForm.repassword.value!=theForm.password.value)
	{ document.getElementById('errrepassword').innerHTML="Password Mismatch";
	  ok=false;
	}
   else document.getElementById('errrepassword').innerHTML=""; 
  if(theForm.pin.value=="")
	{ document.getElementById('errpin').innerHTML="Please Type Pin";
	  ok=false;
	}
  else document.getElementById('errpin').innerHTML=""; 
  
  if(theForm.pin.value!="")
	   {     
		if(!pin_filter.test(theForm.pin.value) || !pin_filter_length.test(theForm.pin.value) )
		 {document.getElementById('errpin').innerHTML="Invalid Pin format"; 
		 ok=false;}
		 else document.getElementById('errpin').innerHTML="";
	   } 
	   
  if(theForm.repin.value=="")
	{ document.getElementById('errrepin').innerHTML="Please Retype Pin";
	  ok=false;
	}
  else if(theForm.repin.value!=theForm.pin.value)
	{ document.getElementById('errrepin').innerHTML="Pin Mismatch";
	  ok=false;
	}
   else document.getElementById('errrepin').innerHTML=""; 

   return ok;   
}
//End of wholesaler_first//


//Start of wholesaler_second//
function getParam_wholesaler_second(theForm) // for checking the wholesaler_second page
{     
   var filter_visa=/^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_mastercard=/^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_discover=/^6011-?\d{4}-?\d{4}-?\d{4}$/;
   var filter_amex=/^3[4,7]\d{13}$/; 
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation
   var phone_filter=/^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$/; 
   var zipcode_filter_us=/^([0-9]{5})(-[0-9]{4})?$/;
   var zipcode_filter_canada=/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/;
   
   var ok=true;	
   
   if(theForm.storefront.value=="")
	{ 
	  document.getElementById('errstorefront').innerHTML="Please Provide StoreFront";
	  ok=false;
	}
   else document.getElementById('errstorefront').innerHTML="";

  if(theForm.primary_business.value=="sel")
	{ 
	  document.getElementById('errprimary_business').innerHTML="Please Select Primary Business";
	  ok=false;
	}
   else document.getElementById('errprimary_business').innerHTML="";
	
 if(theForm.secondary_business.value=="sel")
	{ document.getElementById('errsecondary_business').innerHTML="Please Select Secondary Business";
	  ok=false;
	}
   else document.getElementById('errsecondary_business').innerHTML="";
  
  if( theForm.c1.checked==false && theForm.c2.checked==false && theForm.c3.checked==false && theForm.c4.checked==false && theForm.c5.checked==false)
	{ 
	  document.getElementById('errselling_methods').innerHTML="Please Select atleast One Option";
	  ok=false;
	}
   else document.getElementById('errselling_methods').innerHTML="";
   	
	if(theForm.location.value=="sel")
	{ document.getElementById('errlocation').innerHTML="Please Select Your Location";
	  ok=false;
	}
   else document.getElementById('errlocation').innerHTML="";
   if( theForm.ps1.checked==false && theForm.ps2.checked==false && theForm.ps3.checked==false && theForm.ps4.checked==false)
	{ 
	  document.getElementById('errproduct_shown').innerHTML="Please Select Product Shown method";
	  ok=false;
	}
   else document.getElementById('errproduct_shown').innerHTML="";

   if( theForm.offer1.checked==false && theForm.offer2.checked==false && theForm.offer3.checked==false)
	{ 
	  document.getElementById('erroffer').innerHTML="Please Select atleast One Offer";
	  ok=false;
	}
   else document.getElementById('erroffer').innerHTML="";

   if( theForm.sm1.checked==false && theForm.sm2.checked==false && theForm.sm3.checked==false)
	{ 
	  document.getElementById('errsales_method').innerHTML="Please Select Sales Method";
	  ok=false;
	}
   else document.getElementById('errsales_method').innerHTML="";
   //start of third party validation for wholesale
   if( theForm.prhandling2.checked==true)
   {
   if(theForm.tp_name.value=="")
	{ document.getElementById('errtp_name').innerHTML="Please provide Third Party Name";
	  ok=false;
	}
   else document.getElementById('errtp_name').innerHTML="";  
   
   if(theForm.tp_country.value=="sel")
	{ document.getElementById('errtp_country').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errtp_country').innerHTML="";   
  
    if(theForm.tp_getstate.value=="sel")
	{ document.getElementById('errtp_state').innerHTML="Please Select State";
	  ok=false;
	}
  else document.getElementById('errtp_state').innerHTML="";   
  
    if(theForm.tp_postalcode.value=="")
	{ document.getElementById('errtp_postalcode').innerHTML="Please provide Postal Code";
	  ok=false;
	}
   else
   { 
   if(theForm.tp_country.value==2)
	   {    
		if(!zipcode_filter_canada.test(theForm.tp_postalcode.value) )
		 {document.getElementById('errtp_postalcode').innerHTML="Please provide Valid Postal Code for Canada"; 
		 ok=false;}
		 else document.getElementById('errtp_postalcode').innerHTML="";
	   }  
	   
	  else if(theForm.tp_country.value==1)
	   {     
		if(!zipcode_filter_us.test(theForm.tp_postalcode.value) )
		 {document.getElementById('errtp_postalcode').innerHTML="Please provide Valid Postal Code for USA"; 
		 ok=false;}
		 else document.getElementById('errtp_postalcode').innerHTML="";
	   } 
	   else document.getElementById('errtp_postalcode').innerHTML="";
	 } 

//
   if(theForm.tp_phone1.value=="" || theForm.tp_phone2.value=="" || theForm.tp_phone3.value=="")
	{
	document.getElementById('errtp_phone').innerHTML="Please provide Phone No"; 
	 ok=false;}
	 
  else if(isNaN(theForm.tp_phone1.value) || isNaN(theForm.tp_phone2.value) || isNaN(theForm.tp_phone3.value))
   {
    document.getElementById('errtp_phone').innerHTML="Phone No should be number"; 
	ok=false;}
	
   else
   {
	if(theForm.tp_country.value==2)
	   {
	   if(!phone_filter.test(theForm.tp_phone1.value+"-"+theForm.tp_phone2.value+"-"+theForm.tp_phone3.value))
   		{
	    document.getElementById('errtp_phone').innerHTML="Phone No not valid for Canada"; 
		ok=false;
	   	}  
  		else document.getElementById('errtp_phone').innerHTML="";
	   }
	 if(theForm.tp_country.value==1)
	   {
	   if(!phone_filter.test(theForm.tp_phone1.value+"-"+theForm.tp_phone2.value+"-"+theForm.tp_phone3.value))
   		{
	    document.getElementById('errtp_phone').innerHTML="Phone No not valid for USA"; 
		ok=false;
	   	}  
  		else document.getElementById('errtp_phone').innerHTML="";
	   }
	}
	//

   if(theForm.tp_city.value=="")
	{ document.getElementById('errtp_city').innerHTML="Please provide City Name";
	  ok=false;
	}
   else document.getElementById('errtp_city').innerHTML="";
   if(theForm.tp_email.value=="")
	{ document.getElementById('errtp_email').innerHTML="Please provide Email";
	  ok=false;
	}
   else document.getElementById('errtp_email').innerHTML="";  

   
   if (!filter.test(theForm.tp_email.value))
   {document.getElementById('errtp_email').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('errtp_email').innerHTML="";

   }//end of third party validation
   
	if(theForm.compbusiness.value=="sel")
	{ document.getElementById('errcompbusiness').innerHTML="Please Select One";
	  ok=false;
	}
   else document.getElementById('errcompbusiness').innerHTML="";   
  
	if(theForm.payby.value=="sel")
	{ document.getElementById('errpayby').innerHTML="Please Select Pay By";
	  ok=false;
	}
   else document.getElementById('errpayby').innerHTML="";
    if(theForm.payby.value=="1")
   {
	if(theForm.paypal_acc.value=="")
	{ document.getElementById('errpaypal_acc').innerHTML="Please provide Paypal ID";
	  ok=false;
	}
	else
	{
	  if (!filter.test(theForm.tp_email.value))
      {
		  document.getElementById('errpaypal_acc').innerHTML="Please provide Valid Paypal ID"; 
		  ok=false;
	  }
   	  else document.getElementById('errpaypal_acc').innerHTML="";
	}
   }
   
   if(theForm.payby.value=="2")
	{
	if(theForm.cc_type.value=="sel")
	{ document.getElementById('errcc_type').innerHTML="Please Select Credit Card";
	  ok=false;
	}
   else document.getElementById('errcc_type').innerHTML="";
  if(theForm.cnumber.value=="")
	{ document.getElementById('errcnumber').innerHTML="Please Write Card Number";
	  ok=false;
	}
   else 
   { if(theForm.cc_type.value==1)
      { if(!filter_mastercard.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";
	  }
	 if(theForm.cc_type.value==2)
	 { if(!filter_visa.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML=""; 
     }	 
	 if(theForm.cc_type.value==3)
	 { if(!filter_discover.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";
	 }
	 if(theForm.cc_type.value==4)
	 { if(!filter_amex.test(theForm.cnumber.value))
	    document.getElementById('errcnumber').innerHTML="Please provide valid Credit Card No";
		else
		document.getElementById('errcnumber').innerHTML="";		 
	 }	    
   } 
   if(theForm.cardpin.value=="")
	{ document.getElementById('errcardpin').innerHTML="Please provide Card PIN";
	  ok=false;
	}
	else if(isNaN(theForm.cardpin.value))
	{
		document.getElementById('errcardpin').innerHTML="Card PIN should be Numeric";
	 	ok=false;
	}
	else document.getElementById('errcardpin').innerHTML="";
  
   if(theForm.txtmonth.value=="0" || theForm.txtyear.value=="0")
	{ document.getElementById('errdate').innerHTML="Please provide Correct Expiry Date";
	  ok=false;
	}
   else document.getElementById('errdate').innerHTML="";
	}
	
   if( theForm.terms.checked==false )
	{ 
	  document.getElementById('errterms').innerHTML="Please accept Terms of Agreeement to proceed";
	  ok=false;
	}
   else document.getElementById('errterms').innerHTML="";

 if(theForm.yes_no.value=="yes")
   {
		if(theForm.club_membership.value=="sel")
		{
			 document.getElementById('errclub_membership').innerHTML="Please select a membership option";
			 ok=false;
		}
	   else document.getElementById('errclub_membership').innerHTML="";
   }
  return ok;
  
}
//End of wholesaler_second Validation//

// Start of Initial_affiliates validation //
function getParam_affiliates(theForm) // 
{ 
    
	var ok=true;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation

 	if(theForm.firstname.value=="")
	{ 
	document.getElementById('errfirstname').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirstname').innerHTML="";

	if(theForm.lastname.value=="")
	{ document.getElementById('errlastname').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlastname').innerHTML="";  
   if(theForm.email.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email Address";
	  ok=false;
	}
   else document.getElementById('erremail').innerHTML="";
   if (!filter.test(theForm.email.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML="";
   if(theForm.txtmonth.value=="0" || theForm.txtday.value=="0" || theForm.txtyear.value=="0")
	{ document.getElementById('errdate').innerHTML="Please provide Valid Date of Birth";
	  ok=false;
	}
   else document.getElementById('errdate').innerHTML="";   
   
 if(theForm.txtCaptcha.value=="")
   { 
     document.getElementById('result').innerHTML="Please fill the Captcha code"; 
	 ok=false;
   } 
 
 else if(theForm.secimageval.value!=theForm.txtCaptcha.value)
  { 
    document.getElementById('result').innerHTML="Captcha Code Mismatched...";
	  ok=false;
  } 
else if(theForm.secimageval.value==theForm.txtCaptcha.value)     
  { 
  document.getElementById('result').innerHTML=""; 
  }


return ok;  
}
//end of initial_affiliates validation//


// Start of Initial_associates validation //
function getParam_associates(theForm) // 
{ 
    var ok=true;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;//for email validation

 	if(theForm.firstname.value=="")
	{ document.getElementById('errfirstname').innerHTML="Please provide First Name";
	  ok=false;
	}
   else document.getElementById('errfirstname').innerHTML="";

	if(theForm.lastname.value=="")
	{ document.getElementById('errlastname').innerHTML="Please provide Last Name";
	  ok=false;
	}
   else document.getElementById('errlastname').innerHTML="";  
   if(theForm.email.value=="")
	{ document.getElementById('erremail').innerHTML="Please provide Email Address";
	  ok=false;
	}
   else document.getElementById('erremail').innerHTML="";
   if (!filter.test(theForm.email.value))
   {document.getElementById('erremail').innerHTML="Please provide Valid Email Address"; 
	ok=false;}
   else document.getElementById('erremail').innerHTML="";
   if(theForm.re_email.value=="" || theForm.re_email.value!=theForm.email.value)
	{ document.getElementById('errre_email').innerHTML="Please Verify Email Address";
	  ok=false;
	}
   else document.getElementById('errre_email').innerHTML="";


return ok;  
}
//end of initial_associates validation//

//Start of associates_first validation//
function getParam_associates_first(theForm) // 
{ 
    var ok=true;

   if(theForm.postalcode.value=="")
	{ document.getElementById('errpostalcode').innerHTML="Please provide Postalcode";
	  ok=false;
	}
   else document.getElementById('errpostalcode').innerHTML="";
   if(theForm.associate_id.value=="")
	{ document.getElementById('errassociate_id').innerHTML="Please provide Associate ID";
	  ok=false;
	}
   else document.getElementById('errassociate_id').innerHTML="";
	if(theForm.associate_no.value=="")
	{ document.getElementById('errassociate_no').innerHTML="Please provide Associate Number";
	  ok=false;
	}
   else document.getElementById('errassociate_no').innerHTML="";
   if(theForm.password.value=="")
	{ document.getElementById('errpassword').innerHTML="Please provide Password";
	  ok=false;
	}
   else document.getElementById('errpassword').innerHTML="";
   if(theForm.repassword.value=="")
	{ document.getElementById('errrepassword').innerHTML="Please Retype Password";
	  ok=false;
	}
   else document.getElementById('errrepassword').innerHTML="";
   if(theForm.homephone.value=="")
	{ document.getElementById('errhomephone').innerHTML="Please provide Home Phone";
	  ok=false;
	}
   else document.getElementById('errhomephone').innerHTML="";
   if(theForm.officephone.value=="")
	{ document.getElementById('errofficephone').innerHTML="Please provide Office Phone";
	  ok=false;
	}
   else document.getElementById('errofficephone').innerHTML="";
   if(theForm.city.value=="")
	{ document.getElementById('errcity').innerHTML="Please provide City";
	  ok=false;
	}
   else document.getElementById('errcity').innerHTML="";
   if(theForm.country.value=="sel")
	{ document.getElementById('errcountry').innerHTML="Please Select Country";
	  ok=false;
	}
   else document.getElementById('errcountry').innerHTML="";
   if(theForm.getstate.value=="sel")
	{ document.getElementById('errstate').innerHTML="Please Select State";
	  ok=false;
	}
   else document.getElementById('errstate').innerHTML="";

return ok;  
}
//end of associates_first validation//

//------------------------------------------------------------------------------------------//
//function for displaying shiping payment methods	
function tabsInAuction(strURL)
 { 
 //alert(strURL);
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					//alert(req.responseText);
					// only if "OK"
					if (req.status==200) 
					{		
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('shipPay').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }//end of ajax funtioin
 
///////////////////////////////////////////registration process for preview type///////////////////////////////////////////////
function show_company_info(strURL,acc_type)
 { 
		var req = getXMLHTTP();
		//req=false;
		if (req) 
		{
			//req.onreadystatechange = processReqChange;
			req.onreadystatechange = function() {
				if (req.readyState == 4) 
				{
					//alert(req.responseText);
					// only if "OK"
					if (req.status==200) 
					{ 	if(acc_type==1)				
						//document.getElementById('citytr').style.visibility='visible';
						document.getElementById('company_info').innerHTML="";
						else
						document.getElementById('company_info').innerHTML=req.responseText;
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);						
					}
				}				
			}			
			req.open("GET",strURL, true);
			//req.open("POST",strURl,true);
			req.send(null);	
		}
 }
///////////////////////for sending mail ////////////////////////////////////////////////////////
function sendmail(f)
{ 
  var email=f.email.value;
  var fname=f.firstname.value;
  var lname=f.lastname.value;
  var txtquestion=f.txtquestion.value;
 location.replace("send_query.php?email="+email+"&fname="+fname+"&lname="+lname+"&txtquestion="+txtquestion);
}
//////////////////////////////////////////////end of sending mail

//////////////////////////////////////////end of registration process for preview type/////////////////////////////////////////

$(document).ready(function()
 {
	$("td.brown").click(function() 
     {
		$("td.brown").removeClass("yellow");
		$(this).addClass("yellow");
	 });	
  
 
 //toggle the componenet with class msg_body
  $("div[id='category']").hide(); 
  
  $("#catshowhide").click(function()
  {
    $("#category").slideToggle(800);
  }); 
  /*$("a.jTip").hover(function() {  JT_show(this.href,this.id,this.name)}, function(){$('#JT').remove()})
  .click(function(){  return false});	*/	
});

function JT_show(url,linkId,title){	
	
	if(title == false)title="&nbsp;";
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var clickElementy = getAbsoluteTop(linkId) - 3; //set y positionsssssssssssss	
	var queryString = url.replace(/^[^\?]+\??/,'');
	var params = parseQuery( queryString );
	if(params['width'] === undefined){params['width'] = 250};
	if(params['link'] !== undefined){
	$('#' + linkId).bind('click',function(){window.location = params['link']});
	$('#' + linkId).css('cursor','pointer');
	}
	
	if(hasArea>((params['width']*1)+75)){
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_left'></div><div id='JT_close_left'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//right side
		var arrowOffset = getElementWidth(linkId) + 11;
		var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
	}else{
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_right' style='left:"+((params['width']*1)+1)+"px'></div><div id='JT_close_right'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//left side
		var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position
	}
	
	$('#JT').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#JT').show();
	$('#JT_copy').load(url);

}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}

function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function blockEvents(evt) {
              if(evt.target){
              evt.preventDefault();
              }
			  else{
              evt.returnValue = false;
              }
}
//////////////////////////////////////////////////////end of function for tool tip function/////////////////////////////////////
function get_offers(f)
{ 	
 f.action="initial_personal.php";
 f.submit();
}
function ajax_offers_load(strurl,f,loader)
{ 
$.blockUI({ message: '<h1><img src="images/loader.gif" /> Just a moment...</h1>' });//to block the background during processing 
var req= getXMLHTTP();
if(f.approves18.checked==true)
{ var approve18=f.approves18.value;
}
if(f.subscribe_news.checked==true)
{ var news=f.subscribe_news.value;
}
if(f.freecoupon.checked==true)
{ var coupon=f.freecoupon.value;
}
if(f.freebabysitter.checked==true)
{ var sitter=f.freebabysitter.value;
}
var params= "first_name="+f.first_name.value+"&last_name="+f.last_name.value+"&email="+f.email.value+"&btn_freecoupon="+f.btn_freecoupon.value+"&confirm_email="+f.confirm_email.value+"&approves18="+approve18+"&subscribe_news="+news+"&freecoupon="+coupon+"&freebabysitter="+sitter;

 req.open("POST", strurl, true); 
 //Send the proper header information along with the request
 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 req.setRequestHeader("Content-length", params.length);
 req.setRequestHeader("Connection", "close"); 

 if (req) 
		{//req.onreadystatechange = processReqChange;
		   req.onreadystatechange = function()
		   {  	
			if (req.readyState == 4) 
			{  //only if "OK"
			 test();
					if (req.status == 200) 
					{ 
					
					document.getElementById('offers').innerHTML=req.responseText;
					
					} 
					else 
					{ alert("There was a problem while using XMLHTTP:\n" + req.statusText);}
			}				
		   }			
	       req.send(params);
		 }
}