function createRequestObject()
{
	var request_o; 
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_o = new XMLHttpRequest();
	}
	return request_o; 
}

var http = createRequestObject(); 

function change(page)
{
	//alert("in");
	http.open('get','change.php?page='+page);
	//alert("yes");
	http.onreadystatechange = handleSC1; 
	http.send(null);
	return false;
}

function changeSuccess(page, succ)
{
	//alert("in");
	http.open('get','change.php?page='+page+ '&succ='+succ);
	//alert("yes");
	http.onreadystatechange = handleSC1; 
	http.send(null);
	return false;
}



function characteronly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if(unicode!=9 && unicode!=13 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=46){
//if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if ((unicode<64||unicode>122)&&(unicode!=32)&&(unicode!=8)){ //if not a number
alert("Please enter only the characters and space.");
return false //disable key press
}
}
}
//character only Only Validation ends here
//Numbers Only Validation starts here
function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert("");

if (unicode==8||unicode==9||unicode==46){ }
else{//if the key isn't the backspace key (which we should allow)
if(unicode!=9 && unicode!=13 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40){
if (unicode<48||unicode>57){ //if not a number
alert("Please enter only the Numbers.");
return false //disable key press
}
}
}
}
//Numbers Only Validation ends here
//Numbers Only Validation (accepts +) starts here
function numbersonly1(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert("");

if (unicode==8||unicode==9||unicode==46){ }
else{//if the key isn't the backspace key (which we should allow)
if(unicode!=9 && unicode!=13 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=43){
if (unicode<48||unicode>57){ //if not a number
alert("Please enter only the Numbers.");
return false //disable key press
}
}
}
}
//Numbers Only Validation (accepts +) ends here


//Numbers Only Validation starts here
function numbersonlyTest(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert("");
	//alert(unicode);
if (unicode==8||unicode==9){ }
else{//if the key isn't the backspace key (which we should allow)
if(unicode!=9 && unicode!=13 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=46 && unicode!=61){
if (unicode<48||unicode>57){ //if not a number
alert("Please enter only the Numbers.");
return false //disable key press
}
}
}
}
//Numbers Only Validation ends here

function validation(){
 var msg="";
 var msg1="";
 var j=0;
 var k=0;
 var m=0;
 if(document.onlinejobs.first_name.value==""){
  msg="First name\n";
 }
 if(document.onlinejobs.last_name.value==""){
  msg+="Last name\n";
 }
 if(document.onlinejobs.contact_email.value==""){
  msg+="Email Address\n";
 }
	if(document.onlinejobs.contact_email.value!=""){
		 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   var address = document.onlinejobs.contact_email.value;

   if(reg.test(address) == false) 
  {
   msg+="Please enter a valid Email Address\n";
  }
 }
 if(document.onlinejobs.contact_email.value!=document.onlinejobs.rcontact_email.value){
  msg+="Email Addresses do not match\n";
 }
if(document.onlinejobs.contact_phone1_mobile.value=="" && document.onlinejobs.countrycode.value==""){
  msg+="Enter either Phone or Mobile\n";
}
 if(document.onlinejobs.contact_phone1_mobile.value=="" && document.onlinejobs.contact_mobile_sms.checked==true){
  msg+="For receiving sms alerts enter Mobile no\n";
 }
  if(document.onlinejobs.contact_phone1_mobile.value!=""){
   if(document.onlinejobs.contact_phone1_mobile.value.length <10 ||  document.onlinejobs.contact_phone1_mobile.value.length >12){
      msg+="Please enter valid Mobile number\n";
		}
 }
 if(document.onlinejobs.state.value==""){
  msg+="Currently reside at\n";
 }
 if(document.onlinejobs.street_address.value==""){
  msg+="Street address\n";
 }
 if(document.onlinejobs.city.value==""){
  msg+="City\n";
 }
 if(document.onlinejobs.country.value==""){
  msg+="Country\n";
 }
 if(document.onlinejobs.position_applied_for.value==""){
  msg+="Interested Position\n";
 }
   for (i=0;i<document.onlinejobs.exp1_type_work.length;i++)
		{
			if(document.onlinejobs.exp1_type_work[i].checked==true)
			{
		      k=k+1;
			}
		}

 if(k>1){
	 msg+="Current Experience - select any one Type of work\n";
 }	 
 
   for (j=0;j<document.onlinejobs.exp2_type_work.length;j++)
		{
			if(document.onlinejobs.exp2_type_work[j].checked==true)
			{
		      m=m+1;
			}
		}

 if(m>1){
	 msg+="Prior Experience - select any one Type of work";
 }	 
 if(msg!=""){
  msg1="Please enter the following information.\n" + msg;
  alert(msg1);
  return false;
 }
 else{
  jobsubmit();
 }
}

function jobsubmit()
{
	var i;
	var exp1_type_workp;
	var exp2_type_workp;

   for (i=0;i<document.onlinejobs.exp1_type_work.length;i++)
		{
			if(document.onlinejobs.exp1_type_work[i].checked==true)
			{
				exp1_type_workp=document.onlinejobs.exp1_type_work[i].value;
			}
		}

 for (i=0;i<document.onlinejobs.exp2_type_work.length;i++)
		{
			if(document.onlinejobs.exp2_type_work[i].checked==true)
			{
				exp2_type_workp=document.onlinejobs.exp2_type_work[i].value;
			}
		}


	http.open('get','pricejob/jobAction.php?first_name=' + document.onlinejobs.first_name.value + '&last_name=' + document.onlinejobs.last_name.value + '&contact_email=' + document.onlinejobs.contact_email.value + '&countrycode=' + document.onlinejobs.countrycode.value + '&areacode=' + document.onlinejobs.areacode.value + '&phno=' + document.onlinejobs.phno.value + '&contact_phone1_mobile=' + document.onlinejobs.contact_phone1_mobile.value + '&contact_mobile_sms=' + document.onlinejobs.contact_mobile_sms.value + '&state=' + document.onlinejobs.state.value + '&street_address=' + document.onlinejobs.street_address.value + '&city=' + document.onlinejobs.city.value + '&country=' + document.onlinejobs.country.value + '&other_country_desc=' + document.onlinejobs.other_country_desc.value + '&position_applied_for=' + document.onlinejobs.position_applied_for.value + '&other_position_desc=' + document.onlinejobs.other_position_desc.value + '&comptency_roto=' + document.onlinejobs.comptency_roto.value + '&comptency_roto_defoc=' + document.onlinejobs.comptency_roto_defoc.value + '&comptency_roto_mblur=' + document.onlinejobs.comptency_roto_mblur.value + '&comptency_roto_hair=' + document.onlinejobs.comptency_roto_hair.value + '&comptency_touchup=' + document.onlinejobs.comptency_touchup.value + '&comptency_paint=' + document.onlinejobs.comptency_paint.value + '&comptency_mm=' + document.onlinejobs.comptency_mm.value + '&comptency_cmm=' + document.onlinejobs.comptency_cmm.value + '&comptency_omm=' + document.onlinejobs.comptency_omm.value + '&comptency_mm_lenswarp=' + document.onlinejobs.comptency_mm_lenswarp.value + '&exp1_company_name=' + document.onlinejobs.exp1_company_name.value + '&exp1_website=' + document.onlinejobs.exp1_website.value + '&exp1_city=' + document.onlinejobs.exp1_city.value + '&exp1_type_work=' + exp1_type_workp + '&year1=' + document.onlinejobs.year1.value + '&month1=' + document.onlinejobs.month1.value + '&exp1_month_from=' + document.onlinejobs.exp1_month_from.value + '&exp1_year_from=' + document.onlinejobs.exp1_year_from.value + '&exp1_month_to=' + document.onlinejobs.exp1_month_to.value + '&exp1_year_to=' + document.onlinejobs.exp1_year_to.value + '&exp1_pos1_titile=' + document.onlinejobs.exp1_pos1_titile.value + '&exp1_pos1_months=' + document.onlinejobs.exp1_pos1_months.value + '&exp1_pos1_supervision=' + document.onlinejobs.exp1_pos1_supervision.value + '&exp1_pos2_titile=' + document.onlinejobs.exp1_pos2_titile.value + '&exp1_pos2_months=' + document.onlinejobs.exp1_pos2_months.value + '&exp1_pos2_supervision=' + document.onlinejobs.exp1_pos2_supervision.value + '&exp1_pos3_title=' + document.onlinejobs.exp1_pos3_title.value + '&exp1_pos3_months=' + document.onlinejobs.exp1_pos3_months.value + '&exp1_pos3_supervision=' + document.onlinejobs.exp1_pos3_supervision.value + '&exp1_description=' + document.onlinejobs.exp1_description.value + '&exp2_company_name=' + document.onlinejobs.exp2_company_name.value + '&exp2_website=' + document.onlinejobs.exp2_website.value + '&exp2_city=' + document.onlinejobs.exp2_city.value + '&exp2_type_work=' + exp2_type_workp + '&year2=' + document.onlinejobs.year2.value + '&month2=' + document.onlinejobs.month2.value + '&exp2_month_from=' + document.onlinejobs.exp2_month_from.value + '&exp2_year_from=' + document.onlinejobs.exp2_year_from.value + '&exp2_month_to=' + document.onlinejobs.exp2_month_to.value + '&exp2_year_to=' + document.onlinejobs.exp2_year_to.value + '&exp2_pos1_title=' + document.onlinejobs.exp2_pos1_title.value + '&exp2_pos1_months=' + document.onlinejobs.exp2_pos1_months.value + '&exp2_pos1_supervision=' + document.onlinejobs.exp2_pos1_supervision.value + '&exp2_pos2_titile=' + document.onlinejobs.exp2_pos2_titile.value + '&exp2_pos2_months=' + document.onlinejobs.exp2_pos2_months.value + '&exp2_pos2_supervision=' + document.onlinejobs.exp2_pos2_supervision.value + '&exp2_pos3_titile=' + document.onlinejobs.exp2_pos3_titile.value + '&exp2_pos3_months=' + document.onlinejobs.exp2_pos3_months.value + '&exp2_pos3_supervision=' + document.onlinejobs.exp2_pos3_supervision.value + '&exp2_description=' + document.onlinejobs.exp2_description.value + '&other_exp_desc=' + document.onlinejobs.other_exp_desc.value + '&acedemic_desc=' + document.onlinejobs.acedemic_desc.value);
	http.onreadystatechange = handleSC2; 
	http.send(null);
	return false;
}
function handleSC1(){
	
	if(http.readyState == 1){};//alert(http.readyState+"ikik"+response);
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			}else{				
					//alert(response);
					document.getElementById('change12').innerHTML=response;				
			}
	}
}
function handleSC2(){
	
	if(http.readyState == 1){};//alert(http.readyState+"ikik"+response);
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			}else{				
					document.getElementById('djob').style.display="block";					
					document.getElementById('djob').innerHTML=response;	
					alert('Thank you! Your application has been submitted successfully. We will revert back to you shortly.');
					 document.onlinejobs.first_name.value='' 
 document.onlinejobs.last_name.value='' 
 document.onlinejobs.contact_email.value='' 
 document.onlinejobs.countrycode.value='' 
 document.onlinejobs.areacode.value='' 
 document.onlinejobs.phno.value='' 
 document.onlinejobs.contact_phone1_mobile.value='' 
 document.onlinejobs.contact_mobile_sms.value='' 
 document.onlinejobs.state.value=''
 document.onlinejobs.street_address.value='' 
 document.onlinejobs.city.value='' 
 document.onlinejobs.country.value='' 
 document.onlinejobs.other_country_desc.value='' 
 document.onlinejobs.position_applied_for.value=''
 document.onlinejobs.other_position_desc.value='' 
 document.onlinejobs.comptency_roto.value='' 
 document.onlinejobs.comptency_roto_defoc.value='' 
 document.onlinejobs.comptency_roto_mblur.value='' 
 document.onlinejobs.comptency_roto_hair.value='' 
 document.onlinejobs.comptency_touchup.value='' 
 document.onlinejobs.comptency_paint.value='' 
 document.onlinejobs.comptency_mm.value='' 
 document.onlinejobs.comptency_cmm.value='' 
 document.onlinejobs.comptency_omm.value='' 
 document.onlinejobs.comptency_mm_lenswarp.value='' 
 document.onlinejobs.exp1_company_name.value='' 
 document.onlinejobs.exp1_website.value=''
 document.onlinejobs.exp1_city.value=''
 document.onlinejobs.year1.value='' 
 document.onlinejobs.month1.value='' 
 document.onlinejobs.exp1_month_from.value='' 
 document.onlinejobs.exp1_year_from.value='' 
 document.onlinejobs.exp1_month_to.value='' 
 document.onlinejobs.exp1_year_to.value='' 
 document.onlinejobs.exp1_pos1_titile.value='' 
 document.onlinejobs.exp1_pos1_months.value='' 
 document.onlinejobs.exp1_pos1_supervision.value='' 
 document.onlinejobs.exp1_pos2_titile.value='' 
 document.onlinejobs.exp1_pos2_months.value='' 
 document.onlinejobs.exp1_pos2_supervision.value='' 
 document.onlinejobs.exp1_pos3_title.value='' 
document.onlinejobs.exp1_pos3_months.value='' 
 document.onlinejobs.exp1_pos3_supervision.value='' 
 document.onlinejobs.exp1_description.value='' 
 document.onlinejobs.exp2_company_name.value='' 
 document.onlinejobs.exp2_website.value='' 
 document.onlinejobs.exp2_city.value='' 
 document.onlinejobs.year2.value='' 
document.onlinejobs.month2.value='' 
 document.onlinejobs.exp2_month_from.value='' 
 document.onlinejobs.exp2_year_from.value='' 
 document.onlinejobs.exp2_month_to.value='' 
 document.onlinejobs.exp2_year_to.value='' 
 document.onlinejobs.exp2_pos1_title.value=''
 document.onlinejobs.exp2_pos1_months.value='' 
 document.onlinejobs.exp2_pos1_supervision.value='' 
 document.onlinejobs.exp2_pos2_titile.value='' 
 document.onlinejobs.exp2_pos2_months.value='' 
 document.onlinejobs.exp2_pos2_supervision.value='' 
 document.onlinejobs.exp2_pos3_titile.value=''
 document.onlinejobs.exp2_pos3_months.value='' 
 document.onlinejobs.exp2_pos3_supervision.value='' 
 document.onlinejobs.exp2_description.value='' 
 document.onlinejobs.other_exp_desc.value='' 
 document.onlinejobs.acedemic_desc.value=''
 return false;
			}
	}
}


function validate1(){
 var msg=""; 
 if(document.babapplicant.first_name.value==""){
  msg="First name\n";
 }
  if(document.babapplicant.last_name.value==""){
  msg+="Last name\n";
 }

if(document.babapplicant.contact_email.value==""){
  msg+="Email Address\n";
 }
	if(document.babapplicant.contact_email.value!=""){
		 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   var address = document.babapplicant.contact_email.value;

   if(reg.test(address) == false) 
  {
   msg+="Please enter a valid Email Address\n";
  }
 }
if(document.babapplicant.contact_email.value!=document.babapplicant.rcontact_email.value){
  msg+="Email Addresses do not match\n";
 }
 if(document.babapplicant.contact_phone2.value=="" && document.babapplicant.countrycode.value==""){
  msg+="Enter either Phone or Mobile\n";
}
 if(document.babapplicant.contact_phone2.value=="" && document.babapplicant.contact_phone2_mobile.checked==true){
  msg+="For receiving sms alerts enter Mobile no\n";
 }
  if(document.babapplicant.contact_phone2.value!=""){
   if(document.babapplicant.contact_phone2.value.length <10 ||  document.babapplicant.contact_phone2.value.length >12){
      msg+="Please enter valid Mobile number\n";
		}
 }

 if(document.babapplicant.street_addr.value==""){
  msg+="Street address\n";
 }
  if(document.babapplicant.country.value==""){
  msg+="Country\n";
 }

 if(msg!=""){
  msg="Kindly fillup the following mandatory fields\n" + msg;
  alert(msg);
  return false;
 }
 else{
		jobBab();
 }
}


function jobBab()
{

	first_name=document.babapplicant.first_name.value;
	last_name=document.babapplicant.last_name.value;
	contact_email=document.babapplicant.contact_email.value;
	countrycode=document.babapplicant.countrycode.value;
	areacode=document.babapplicant.areacode.value ;
	phno=document.babapplicant.phno.value;
	contact_phone2=document.babapplicant.contact_phone2.value;
	state=document.babapplicant.state.value;
	street_addr=document.babapplicant.street_addr.value;
	city=document.babapplicant.city.value;
	country=document.babapplicant.country.value;
	academic_desc=document.babapplicant.academic_desc.value;
	other_exp_desc=document.babapplicant.other_exp_desc.value;
	http.open('get','pricejob/jobBabAction.php?first_name=' + first_name +'&last_name=' + last_name+'&contact_email=' + contact_email+'&countrycode=' + countrycode+'&areacode=' + areacode+'&phno=' + phno+'&contact_phone2=' + contact_phone2+'&state=' + state+'&street_addr=' + street_addr+'&city=' + city+'&country=' + country+'&academic_desc=' + academic_desc+'&other_exp_desc=' + other_exp_desc);
	http.onreadystatechange = handleSC5; 
	http.send(null);
	return false;
}
function handleSC5(){
	
	if(http.readyState == 1){};//alert(http.readyState+"ikik"+response);
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			}else{		
				//alert(response);
					document.getElementById('3456').style.display="block";	
					document.getElementById('3456').innerHTML="<p><strong><font color='red'>Your application has been successfully submitted .<br><br>You will hear from us shortly.<br>Good luck with your job search!<br><br>The Rotobotic Team</font></strong></p>";	
					alert('Thank you! Your application has been submitted successfully. We will revert back to you shortly.');
	document.babapplicant.first_name.value='';
	document.babapplicant.last_name.value='';
	document.babapplicant.contact_email.value='';
	document.babapplicant.countrycode.value='';
	document.babapplicant.areacode.value='' ;
	document.babapplicant.phno.value='';
	document.babapplicant.contact_phone2.value='';
	document.babapplicant.state.value='';
	document.babapplicant.street_addr.value='';
	document.babapplicant.city.value='';
	document.babapplicant.country.value='';
	document.babapplicant.academic_desc.value='';
	document.babapplicant.other_exp_desc.value='';
	return false;
			}
	}
}
