function validate_email()
{
	t = document.getElementById('email_address').value;
	if( t == "your@company.com" || t == "" || t.indexOf("@") == -1 || t.indexOf(".") == -1 || t.indexOf(" ")!=-1 || t.length < 6 || t.indexOf("xyz.com") > 0 || t.indexOf("abc.com") > 0 || t.indexOf("jagatniwaspalace.com") > 0 ) {
		 document.getElementById('email_status').innerHTML='<img src="images/notavailable.png" height="16" width="16" />';
		return false;
	}
	var xmlHttp;
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest(); 
  }
catch (e)
  {  // Internet Explorer  
  try
    {    
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
  catch (e)
    {   
	try
      {     
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
	  }
    catch (e)
      {      
	  alert("Your browser does not support AJAX!");      
	  return false;      
	  }    
	  }  
  }
	 
	 var email=document.getElementById('email_address').value;
	 if(email=="")
	 {
		 return false;
	 }
	url='available.php?email='+email;
	//alert(url);
	
  xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	xmlHttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
 xmlHttp.send(null);
 
  xmlHttp.onreadystatechange=function()
    {
		
    if(xmlHttp.readyState==4)
      {
		  if(xmlHttp.responseText!=""){
		 document.getElementById('email_status').innerHTML='<img src="images/notavailable.png" height="16" width="16" onmouseover="alert(\'This Mail ID Already In Use Please Choose Another\');"/>';
		 document.getElementById('check_id').value='no';
		 document.getElementById('email_address').focus();
		  }
		 else{
			 document.getElementById('check_id').value='yes';
		 document.getElementById('email_status').innerHTML='<img src="images/available.png" height="16" width="16" />';
		 }
		}
      
      }
}


function validate(theForm)
{
	
	//check password
	
	t1=theForm.password;
	if(t1.value==""){
	alert("Please Enter Password");
	theForm.password.focus();
	return false;
	}
	
	//check re-password
	
	t2=theForm.confirmation;
	if(t2.value==""){
	alert("Please Enter Confirm Password");
	theForm.confirmation.focus();
	return false;
	}
	
	if(t1.value!=t2.value){
	alert("Password And Confirm Password Should Be Same");
	theForm.password.focus();
	return false;
	}
	
	t=theForm.referralid;
	if(t.value==""){
	alert("Please Select Referral ID");
	theForm.referralid.focus();
	return false;
	}
t=theForm.mem_no;
	if(t.value==""){
	alert("Please Enter Referral Code");
	theForm.mem_no.focus();
	return false;
	}
	
	t=document.getElementById('check_referral').value;
	if(t=='no'){
	alert("This Is Not Valid Referral Code");
		theForm.mem_no.focus();
		return (false);
	}
	
	/*t=theForm.secquestion;
	if(t.value==""){
	alert("Please Select Security Question");
	t.focus();
	return false;
	}
	check_referral
	t=theForm.sanswer;
	if(t.value==""){
	alert("Please Select Security Answer");
	t.focus();
	return false;
	}*/
	//check gender
	t=document.getElementById('gender-male');
	t1=document.getElementById('gender-female');
	if(t.checked==false && t1.checked==false){
	alert("Please Select Gender");
	document.getElementById('gender-male').focus();
	return false;
	}
	
	//check first name
	
	t=theForm.firstname;
	if(t.value==""){
	alert("Please Enter Your First Name");
	theForm.firstname.focus();
	return false;
	}
	
	
	//check last name
	
	t=theForm.lastname;
	if(t.value==""){
	alert("Please Enter Your Last Name");
	theForm.lastname.focus();
	return false;
	}
	
	
	//dob
	t=theForm.dob;
	if(t.value==""){
	alert("Please Select Your Date Of Birth");
	theForm.dob.focus();
	return false;
	}
	
	//business name
	t=theForm.company;
	if(t.value==""){
	alert("Please Enter Your Business Name");
	theForm.company.focus();
	return false;
	}
	
	//check email
	t = theForm.email_address.value;
	if( t == "your@company.com" || t == "" || t.indexOf("@") == -1 || t.indexOf(".") == -1 || t.indexOf(" ")!=-1 || t.length < 6 || t.indexOf("xyz.com") > 0 || t.indexOf("abc.com") > 0 || t.indexOf("jagatniwaspalace.com") > 0 ) {
		alert("Your Email seems to be invalid!");
		theForm.email_address.focus();
		return (false);
	}
	/////
	if(document.sign_up_member["company_category[]"].value == "")
			{
			alert('Select Business Category');
			return false;
			}



	//check Street Address
	
	t=theForm.street_address;
	if(t.value==""){
	alert("Please Enter Your Address");
	theForm.street_address.focus();
	return false;
	}
	
	//check city
	
	t=theForm.city;
	if(t.value==""){
	alert("Please Enter Your City");
	theForm.city.focus();
	return false;
	}
	
	//check state
	
	t=theForm.state;
	if(t.value==""){
	alert("Please Enter Your State");
	theForm.state.focus();
	return false;
	}
	
	//check state
	
	t=theForm.postcode;
	if(t.value==""){
	alert("Please Enter Your Post/Zip Code");
	theForm.postcode.focus();
	return false;
	}
	
	t=theForm.telephone;
	if(t.value==""){
	alert("Please Select Your Telephone Number");
	theForm.telephone.focus();
	return false;
	}
	
	t=theForm.tos_agreed;
	if(t.checked==false){
	alert("Please Accepts Terms and Conditions.");
	theForm.tos_agreed.focus();
	return false;
	}
	t=document.getElementById('check_id').value;
	if(t=='no'){
	alert("This Mail Id Already Taken Please Choose Another Mail Id");
		theForm.email.focus();
		return (false);
	}
	
}

function checkNumeric(e)
{	//With FireFox Support
	var KeyID = (window.event) ? event.keyCode : e.which;	
	//alert(KeyID);
	if((KeyID >= 48 && KeyID <= 57)  || (KeyID == 43) || (KeyID == 45)|| (KeyID == 8) || (KeyID == 32) || (KeyID == 37) || (KeyID == 39) || (KeyID == 46))
	{				
		return true;			
	}                       
	return false;
}


function sect_tocken()
{
	
	var xmlHttp;
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest(); 
  }
catch (e)
  {  // Internet Explorer  
  try
    {    
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
  catch (e)
    {   
	try
      {     
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
	  }
    catch (e)
      {      
	  alert("Your browser does not support AJAX!");      
	  return false;      
	  }    
	  }  
  }
	 
	  //document.getElementById('report_detail').innerHTML='Please Wait Loding Content';
	url='cart/index.php?tct=sec_code';
	//alert(url);
	
  xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	xmlHttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
 xmlHttp.send(null);
 
  xmlHttp.onreadystatechange=function()
    {
		//alert(xmlHttp.responseText)
    if(xmlHttp.readyState==4)
      {
		  //alert(xmlHttp.responseText);
		 document.getElementById('sct').value=xmlHttp.responseText;
		 //document.getElementById('data_school_lunch').focus();
		 
		}
      
      }
    
	
	
	


}

function add_category(mod)
{
	if(mod=='cat_add')
	{
		str='<input type="text" name="add_category" id="add_category">&nbsp;&nbsp;<input type="button" name="add_new_cat" id="add_new_cat" value="Add" onclick="return sub_category(\'sub_cat\');" style="height:auto; cursor:pointer">&nbsp;&nbsp;<a href="javascript: add_category(\'cat_cancel\');">Cancel</a>';
	}
	else{
		str='<a href="javascript: add_category(\'cat_add\');">Add New Category</a>';
	}
	
	//alert(str);
	document.getElementById('business_cat_add').innerHTML=str;
}

function sub_category(mod)
{
if(mod=='sub_cat')
	{
		cat_val=document.getElementById('add_category').value;
		if(cat_val=="")
		{
		alert('Please enter category');
		return false;
		}
		else{
			add_category_new(cat_val);
		//window.location='cart/index.php?main_page=create_account&mod=add_cat&cat_val='+cat_val+'';	
		}
	}	
}

function add_category_new(cat_val)
{
	var xmlHttp;
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest(); 
  }
catch (e)
  {  // Internet Explorer  
  try
    {    
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
  catch (e)
    {   
	try
      {     
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
	  }
    catch (e)
      {      
	  alert("Your browser does not support AJAX!");      
	  return false;      
	  }    
	  }  
  }
	 
	  //document.getElementById('report_detail').innerHTML='Please Wait Loding Content';
	url='add_cat.php?cat_val='+cat_val+'&mod=add_cat';
	//alert(url);
	
  xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	xmlHttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
 xmlHttp.send(null);
 
  xmlHttp.onreadystatechange=function()
    {
		//alert(xmlHttp.responseText)
    if(xmlHttp.readyState==4)
      {
		  //alert(xmlHttp.responseText);
		 document.getElementById('business_cat').innerHTML=xmlHttp.responseText;
		 add_category('');
		 //document.getElementById('data_school_lunch').focus();
		 
		}
      
      }
    	
}


function validate_referral(mem_no)
{
	t = document.getElementById('referralid').value;
	
	r_m=t.split(':');
	referral_mail=r_m[1];
	//alert(referral_mail);
	if(mem_no==""){
	document.getElementById('referral_status').innerHTML='<img src="images/notavailable.png" height="16" width="16" />';
		return false;
	}
	
	var xmlHttp;
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest(); 
  }
catch (e)
  {  // Internet Explorer  
  try
    {    
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
  catch (e)
    {   
	try
      {     
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
	  }
    catch (e)
      {      
	  alert("Your browser does not support AJAX!");      
	  return false;      
	  }    
	  }  
  }
	 
	 
	url='available.php?ref_mail='+referral_mail+'&ref_code='+mem_no+'&mod=ref_che';
	//alert(url);
	
  xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	xmlHttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
 xmlHttp.send(null);
 
  xmlHttp.onreadystatechange=function()
    {
		
    if(xmlHttp.readyState==4)
      {
		  //alert(xmlHttp.responseText);
		  if(xmlHttp.responseText!=""){
		   document.getElementById('referral_status').innerHTML='<img src="images/notavailable.png" height="16" width="16" onmouseover="alert(\'This Is Not A Valide Referral Code\');"/>';
		 document.getElementById('check_referral').value='no';
		 document.getElementById('referral_status').focus();
		  }
		 else{		 
		 document.getElementById('check_referral').value='yes';
		  document.getElementById('referral_status').innerHTML='<img src="images/available.png" height="16" width="16" />';
		 }
		}
      
      }
}
