function validate()
{


   if(trim(document.register_form.fname.value)=='')
	{
	 alert("Please enter first name!");
	 document.register_form.fname.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkfname').innerHTML!='')	
	{
		 alert(document.getElementById('checkfname').innerHTML);
		 document.register_form.fname.focus();
		 return false;
	}
	
	if(trim(document.register_form.lname.value)=='')
	{
	 alert("Please enter last name!");
	 document.register_form.lname.focus();
	 return false;
	}
	
	

	if(document.getElementById('checklname').innerHTML!='')	
	{
		 alert(document.getElementById('checklname').innerHTML);
		 document.register_form.lname.focus();
		 return false;
	}
	
	
	
	if(trim(document.register_form.email.value)=='')
	{
	 alert("Please enter email!");
	 document.register_form.company.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkemail').innerHTML!='')	
	{
		 alert(document.getElementById('checkemail').innerHTML);
		 document.register_form.company.focus();
		 return false;
	}
	
	
	
	
	
	if(trim(document.register_form.company.value)=='')
	{
	 alert("Please enter company name!");
	 document.register_form.company.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkcompany').innerHTML!='')	
	{
		 alert(document.getElementById('checkcompany').innerHTML);
		 document.register_form.company.focus();
		 return false;
	}
	
	if(document.register_form.job_title.value=='')
	{
	 alert("Please select job title!");
	 document.register_form.job_title.focus();
	 return false;
	}
	
	if(document.register_form.job_title.value=='other')
	{
		if(document.register_form.other_job_title.value=='')
		{
		 alert("Please enter job title!");
		 document.register_form.other_job_title.focus();
		 return false;
		}
		if(document.getElementById('checkother_job_title').innerHTML!='')	
		{
			 alert(document.getElementById('checkother_job_title').innerHTML);
			 document.register_form.other_job_title.focus();
			 return false;
		}
	}
	
	
	if(document.register_form.job_function.value=='')
	{
	 alert("Please select Job Function!");
	 document.register_form.job_function.focus();
	 return false;
	}
	
	
	if(document.register_form.job_function.value=='other')
	{
		if(document.register_form.other_job_function.value=='')
		{
		 alert("Please enter Job Function!");
		 document.register_form.other_job_function.focus();
		 return false;
		}
		if(document.getElementById('checkother_job_function').innerHTML!='')	
		{
			 alert(document.getElementById('checkother_job_function').innerHTML);
			 document.register_form.other_job_function.focus();
			 return false;
		}
	}

	
	
	/*if(document.register_form.industry.value=='')
	{
	 alert("Please select Industry!");
	 document.register_form.industry.focus();
	 return false;
	}
	
	
	if(document.register_form.company_size.value=='')
	{
	 alert("Please select Company Size!");
	 document.register_form.company_size.focus();
	 return false;
	}*/
	
	
	if(trim(document.register_form.phone.value)=='')
	{
	 alert("Please enter Business Telephone!");
	 document.register_form.phone.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkphone').innerHTML!='')	
	{
		 alert(document.getElementById('checkphone').innerHTML);
		 document.register_form.phone.focus();
		 return false;
	}
	
	
	
	
	if(trim(document.register_form.address.value)=='')
	{
	 alert("Please enter address!");
	 document.register_form.address.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkaddress').innerHTML!='')	
	{
		 alert(document.getElementById('checkaddress').innerHTML);
		 document.register_form.address.focus();
		 return false;
	}
	
	if(trim(document.register_form.city.value)=='')
	{
	 alert("Please select city!");
	 document.register_form.city.focus();
	 return false;
	}
	
	if(document.register_form.city.value=='other')
	{
		if(document.register_form.other_city.value=='')
		{
		 alert("Please enter city!");
		 document.register_form.other_city.focus();
		 return false;
		}
		if(document.getElementById('checkother_city').innerHTML!='')	
		{
			 alert(document.getElementById('checkother_city').innerHTML);
			 document.register_form.other_city.focus();
			 return false;
		}
	}
	
	

	/*if(document.getElementById('checkcity').innerHTML!='')	
	{
		 alert(document.getElementById('checkcity').innerHTML);
		 document.register_form.city.focus();
		 return false;
	}*/
	
/*	if(document.register_form.state.value=='')
	{
	 alert("Please select State/County!");
	 document.register_form.state.focus();
	 return false;
	}*/
	
	if(document.register_form.country.value=='')
	{
	 alert("Please select Country !");
	 document.register_form.country.focus();
	 return false;
	}
	
	if(trim(document.register_form.zip.value)=='')
	{
	 alert("Please enter Zip/Postal code!");
	 document.register_form.zip.focus();
	 return false;
	}
	
	

	if(document.getElementById('checkzip').innerHTML!='')	
	{
		 alert(document.getElementById('checkzip').innerHTML);
		 document.register_form.city.focus();
		 return false;
	}
	
	

else
{
	return true;
}	
	
}


function other(jobtitle)
{

  if(jobtitle=='Other')
  {
    document.getElementById('show').style.display='block';
  }else
  {
  document.getElementById('show').style.display='none';
  }
  }
  
  

function checkcountry(countryid)
{
if(countryid=='Other')
  {
    document.getElementById('contshow').style.display='block';
  }else
  {
  document.getElementById('contshow').style.display='none';
  }
}


function checkvalidate(jobname)
{

var xmlHttpReq = false;
 
	if (window.XMLHttpRequest)
	{
		xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
     {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlHttpReq.onreadystatechange = function()
       {
	   if (xmlHttpReq.readyState == 4)
	   {
	   // alert(xmlHttpReq.responseText);
	    document.getElementById('checkjobname').innerHTML=xmlHttpReq.responseText;
	    
		}
	}
	
	 xmlHttpReq.open('GET', 'checkjobtitle.php?jobname='+jobname, true);
	 xmlHttpReq.send(null);	
}


function checkdata(fval,ftype,dispid){
	var xmlHttpReq = false;
 
	if (window.XMLHttpRequest)
	{
		xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
     {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlHttpReq.onreadystatechange = function()
       {
	   if (xmlHttpReq.readyState == 4)
	   {
	   // alert(xmlHttpReq.responseText);
	    document.getElementById(dispid).innerHTML=xmlHttpReq.responseText;
	    
		}
	}
	
	 xmlHttpReq.open('GET', 'check_data.php?fval='+fval+'&f_type='+ftype, true);
	 xmlHttpReq.send(null);	
}

function checkcompanyname(companyname)
{
var xmlHttpReq = false;
 
	if (window.XMLHttpRequest)
	{
		xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
     {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlHttpReq.onreadystatechange = function()
       {
	   if (xmlHttpReq.readyState == 4)
	   {
	   // alert(xmlHttpReq.responseText);
	    document.getElementById('checkcompanynames').innerHTML=xmlHttpReq.responseText;
	    
		}
	}
	
	 xmlHttpReq.open('GET', 'checkcompanyname.php?companyname='+companyname, true);
	 xmlHttpReq.send(null);	
}






function otherField(val,id)
{
if(val=='other')
  {
    document.getElementById(id+'_show').style.display='block';
  }else
  {

  document.getElementById(id+'_show').style.display='none';
  }
}




/*************************************
*  Javascript trim, ltrim, rtrim
*************************************/
 
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

