	function nuevoAjax(){
		var xmlhttp=false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
		
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}	


	//function for delete one job published
	function supjob(idenj){
		if (confirm('Are you sure you want to remove this job from this list?')){
			var opc = $('#nidjob').val();			
				ajax=nuevoAjax();
				ajax.open("GET", "../templates/emupdate.php?opc="+opc+"&idenj="+idenj,true);
				ajax.onreadystatechange=function() {
					if (ajax.readyState==4) {		
						if(ajax.responseText == 'deleted'){
							alert('Job removed from the list.');
							$("#"+idenj).remove();
						}
						else{
							alert("Problems with conect, try again");						
						}			
					}
				}
				ajax.send(null);													
		}			
	}
	function supsear(idenj){
		if (confirm('Are you sure deleted this job of recent list?')){
			$("#"+idenj).remove();			
		}			
	}


//on click submit and register validate
		
			$('#signuphome').click(function() { 
				$.blockUI({ message: $('#content_log') }); 
				$('.blockOverlay').click($.unblockUI); 
				//setTimeout($.unblockUI, 2000); 
			}); 
		
		
		$(document).ready(function() { 
			$('#log_top').click(function() { 
				$.blockUI({ message: $('#content_log') }); 
				$('.blockOverlay').click($.unblockUI); 				
			}); 
		}); 
		
		$(document).ready(function() { 
			$('#registerform').click(function() { 
				$.blockUI({ message: $('#content_register') }); 
				$('.blockOverlay').click($.unblockUI); 				
			}); 
		});
		
		$(document).ready(function() { 
			$('#reg_top').click(function() { 
				$.blockUI({ message: $('#content_register') }); 
				$('.blockOverlay').click($.unblockUI); 				
			}); 
		});
		//on click validate end--------		
				
		//Function valid category select register	employer
		function validcat(object){
				var categem =object.value;
				categem2 = categem.split("::");				
				$("#selectview").val(categem2[1]);
				$("#category_idem").val(categem2[0]);
		}
		//End function select------		
		
		
		//Function valid category select register	jobseeker	
		function validcatjs(object){
				var categjs =object.value;
				categjs2 = categjs.split("::");				
				$("#selectviewj").val(categjs2[1]);
				$("#category_idjs").val(categjs2[0]);
		}
		//End function select------		
		
		//Function valid category select register	employer
		function validcatbu(object){
				var buss =object.value;
				buss2 = buss.split("::");				
				$("#selectbu").val(buss2[1]);
				$("#bus_id").val(buss2[0]);
		}
		//End function select------		
		
		//Function valid subcategory select add job
		function validcatsu(object){
			var subc=sb.getActualValue();
			//document.getElementById('state_id').value=categep;
			$("#subcat_id").val(subc);
		}
		//End function select------
		
		//Function valid duration select add job
		function validcatdur(object){
				var jobdur =object.value;
				jobdur2 = jobdur.split("::");				
				$("#selectdur").val(jobdur2[1]);
				$("#dura_id").val(jobdur2[0]);
		}
		//End function select------
		
		//Function valid duration select add job
		function validcatra(object){
				var subca =object.value;
				subca2 = subca.split("::");				
				$("#selectra").val(subca2[0]);				
		}
		//End function select------
		
		//Function valid state addmore
		function selstate2(object,cont){			
			var jstates =object.value;
			jstates2 = jstates.split("::");				
			$("#jstate"+cont).val(jstates2[0]);
			$("#state_id"+cont).val(jstates2[1]);						
		}
		//end function
		
		//Function valid state addmore
		function selhear(object,cont){			
			var jhear =object.value;
			jhear2 = jhear.split("::");				
			$("#hear").val(jhear2[0]);
			$("#hear_id").val(jhear[1]);						
		}
		//end function
		
		function createacc(){
			//$.unblockUI();
			$(document).ready(function() {
				$.blockUI({ message: $('#content_register') });
				$('.blockOverlay').click($.unblockUI);
			});
		}
		
		
		//Function charge subcat profile job		
		function selsubcatjs(object){
				var categjs =object.value;
				categjs2 = categjs.split("::");				
				$("#selectviewj").val(categjs2[1]);				
				document.getElementById('cati').value=categjs2[0];
				document.getElementById('seli').value=categjs2[1];
				$("#category_idjs").val(categjs2[0]);				
				
				var listsub=Array();
				var valorcj = $('#category_idjs').val();
				var valorig = $('#cat_orig').val();
				if(valorcj != ""){
					ajax=nuevoAjax();
					ajax.open("GET", "../ajaxunico.php?cat=jsub&val="+valorcj+"&valorig="+valorig,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {														
							$('#subjax').html(ajax.responseText);
							document.getElementById('category_idjs').value=categjs2[0];
						}
					}
					ajax.send(null);										
				}
		}
		//End function select------		
		
		//Function charge subcat profile employer		
		function selsubcatem(object){
				var categem =object.value;
				categem2 = categem.split("::");				
				$("#selectview").val(categem2[1]);
				$("#category_idem").val(categem2[0]);
				
				var listsub=Array();
				var valorce = $('#category_idem').val();
				if(valorce != ""){
					ajax=nuevoAjax();
					ajax.open("GET", "../ajaxunico.php?cat=emsub&val="+valorce,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {							
							$('#subjax').html(ajax.responseText);
						}
					}
					ajax.send(null);										
				}
				$('#category_idem').val(valorce);
				document.getElementById('category_idem').value=valorce;
		}
		//End function select------		
		
		function selstate(object){
			var st=s1.getActualValue();
			//document.getElementById('state_id').value=categep;
			$("#state_id").val(st);						
		}
		
		
		//Functions not empty files register jobseeker
		function logjs(){		  
			var sw=true;						
			if($("#nameseek").val()=="") {		sw=false;			}  
			if($("#lastseek").val()=="") {		sw=false;   	}
			if($("#pwseek").val()=="")   {		sw=false;   	}
			if($("#category_idjs").val()=="")   {		sw=false;   	}
			
			
			if(!sw) alert('Fields are mandatory');
			else{document.getElementById("regseek-form").submit();
			}			
		}		
		
		//verification login-registration jobseeker
		function verlogjs(){
			var sw2=true;
			var valor = $('#userseek').val();
			if(valor != ""){				
				var reg = new RegExp("^[0-9a-zA-Z._-]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
    		if(reg.test(valor)==false){
					alert('The mail is invalid, review');	
				}								
				else{
					ajax=nuevoAjax();
					ajax.open("GET", "ajaxunico.php?cat=j&val="+valor,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {
							if(ajax.responseText == 'yesa'){
								alert("The mail exist. Please review.");
							}
							else{
								logjs();						
							}
						}
					}
					ajax.send(null);										
				}				
			}
		}
		
		
		function logemp(){		  
			var sw=true;				
			if($("#nameemp").val()=="") {		sw=false;			}  			
			if($("#pwemp").val()=="")   {		sw=false;   	}
			if($("#category_idem").val() == "") {   sw=false;   	}	
			
			if(!sw) alert('Fields are mandatory');
			else{document.getElementById("regemploy-form").submit();
			}			
		}		
		
		//verification login(registration) employer
		function verlogemp(){
			var sw2=true;
			var valor = $('#useremp').val();
			if(valor != ""){
				var reg = new RegExp("^[0-9a-zA-Z._-]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
    		if(reg.test(valor)==false){
						alert('The mail is invalid');	
				}
				else{				
					ajax=nuevoAjax();
					ajax.open("GET", "ajaxunico.php?cat=em&val="+valor,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {
							if(ajax.responseText == 'yesa'){
								alert("The mail exist. Please review.");
							}
							else{
								logemp();						
							}
						}
					}
					ajax.send(null);														
				}				
			}
		}
		
		//Function validate fields login
		function valLog(){
			var sw=true;			
			var ut = $('input[name=tuser]:checked').attr('value');
			if(ut){	document.getElementById("userreg").value=ut;}
			
			var luser= $("#usertact").val();
			var lpw=   $("#pwtact").val();
			var typ=   $("#userreg").val();
			var valor= $("#usertact").val() 
			if((luser=="") || (lpw=="") || (typ==""))		{			 sw=false			}
			else{	
				var reg = new RegExp("^[0-9a-zA-Z._-]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
    		if(reg.test(valor)==false){
					alert('The mail is invalid');	
				}
				else{						
					if(ut){
						ajax=nuevoAjax();
						ajax.open("GET", "/templates/ajaxlog.php?cat="+ut+"&val1="+luser+"&val2="+lpw,true);
						ajax.onreadystatechange=function() {
							if (ajax.readyState==4) {
								if(ajax.responseText == "nou"){
									alert("The mail or pw are incorrected");
								}
								else{ document.getElementById("alog-form").submit();	}
							}
						}
						ajax.send(null);					
					}	
				}
			}			
			if(!sw) { alert('Fields are mandatory'); }
		} //End function valLog	
		
		//End functions empty fields------				
		
		
		//Validate and catch values form jsedit profile
		function savejs(){			 
			var sw=true;															
			var	swe=true;
			
			id=document.getElementById("lestate");
			var lest="";
  		for (i=0; ele = id.options[i]; i++)		{    if (ele.selected == true) {  lest+=ele.value+',';  }  } 
			var lest2=lest.substring(0, lest.length - 1);
			document.getElementById("valstate").value=lest2;			
			if( ($("#fname").val()=="") || ($("#lname").val()=="") ) {		sw=false;			}  
			else{
				var valor=$("#jemail").val();
				var reg = new RegExp("^[0-9a-zA-Z._-]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
    		if(reg.test(valor)==false){
					alert('The mail is invalid');	
				}
			}
						
			if(!sw) {	alert('Fields are mandatory');		}			
			else{		document.getElementById("containerjs").submit();		
			}					
		}
		
		//Validate and catch values form emedit profile
		function saveem(){			 
			var sw=true;															
			var	swe=true;
			
			if ($("#ecompany").val()=="")  {		sw=false;			}  
			else{
				var valor=$("#eemail").val();
				var reg = new RegExp("^[0-9a-zA-Z._-]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
    		if(reg.test(valor)==false){
					alert('The mail is invalid');	
				}
			}		
			
			if(!sw) {	alert('Fields are mandatory');		}			
			else {		document.getElementById("containerem").submit();		}					
		}
		
		//Validate and catch values form jmedit profile
		function savejob(){			 
			var sw=true;															
			var	swe=true;
			if ( ($("#jobtitle").val()=="") || ($("#categoid").val()=="") || ($("#subcat_id").val()=="") || ($("#jobdesc").val()=="")|| ($("#bus_id").val()=="") || ($("#cityjo").val()=="") || ($("#state_id").val()=="")) 
			{		sw=false;			}  
				
			if(!sw) {	alert('Fields are mandatory');		}			
			else {		document.getElementById("containjob").submit();		}
		}
		
		//Function valid subcategory select add job
		function categoa(object){
			var ct=c1.getActualValue();
			//document.getElementById('state_id').value=categep;
			$("#categoid").val(ct);				
				
				var listsub=Array();
				var valorcj = $('#categoid').val();
				var valorig = $('#jcate').val();
				if(valorcj != ""){
					ajax=nuevoAjax();
					ajax.open("GET", "ajaxunico.php?cat=emsub&val="+valorcj,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {
							//listsub=eval(ajax.responseText);
							//alert(listsub[0][0]);
							$('#subjax').html(ajax.responseText);
							sb=dhtmlXComboFromSelect("subcat");
					  	sb.readonly(1);
						}
					}
					ajax.send(null);
				}
		}
		//End function select------

		//Function for validate jobseeker postulation job
		function valesend(){
			var seek = $('#jsid').val();
			var trab = $('#workid').val();
			var opc= 'send';
				ajax=nuevoAjax();
				ajax.open("GET", "../ajaxunico.php?opc="+opc+"&seek="+seek+"&trab="+trab,true);
				ajax.onreadystatechange=function() {
					if (ajax.readyState==4) {
						if(ajax.responseText == 'exists'){
							alert("You have already applied for this position.");
						}
						else{							
							window.location="sendres.php?op="+trab;
						}
					}
				}
				ajax.send(null);
		}
	
		function valejob(){
			var seek = $('#jsid').val();
			var trab = $('#workid').val();
			var opc= 'sav';
				ajax=nuevoAjax();
				ajax.open("GET", "../templates/psavlist.php?opc="+opc+"&seek="+seek+"&job="+trab,true);
				ajax.onreadystatechange=function() {
					if (ajax.readyState==4) {
						if(ajax.responseText == 'exist'){
							alert("You was save this job.");
						}
						else{
							//window.location='sendres.php?op=<?php echo $varquery['JobID']?>';
							alert("This Job has been saved, now you can see it at anytime directly from your account.");
						}
					}
				}
				ajax.send(null);
		}
	
		//Function valid subcategory select add job
		function validcatsu2(object){
				var subcat =object.value;
				subca2 = subcat.split("::");								
				$("#subcat_id").val(subca2[0]);
		}
		//End function select------
		
		
		//function for delete one job saved
		function delsav(idenj){
			if (confirm('Are you sure you want to remove this job from this list?')){				
					ajax=nuevoAjax();
					ajax.open("GET", "../templates/emupdate.php?opc=delsa&idenj="+idenj,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {		
							if(ajax.responseText == 'deleted'){
								alert("Job removed from the list.");
								$("#"+idenj).remove();
							}
							else{
								alert("Error");						
							}			
						}
					}
					ajax.send(null);													
			}			
		}
		
		//function for delete one job esend resume
		function delesend(idenj){
			if (confirm('Are you sure deleted this eSend?')){				
					ajax=nuevoAjax();
					ajax.open("GET", "../templates/emupdate.php?opc=delsend&idenj="+idenj,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {		
							if(ajax.responseText == 'deleted'){
								alert("esend was deleted.");
								$("#"+idenj).remove();
							}
							else{
								alert("Error");						
							}			
						}
					}
					ajax.send(null);													
			}			
		}

		function valogem(){				
			$(document).ready(function() {			
				$.blockUI({ message: $('#content_log') }); 
				$('.blockOverlay').click($.unblockUI); 
				//setTimeout($.unblockUI, 2000); 
			});	
		}
		
		function categore(object){
				var cate =object.value;
				cater = cate.split("::");
				$("#categoid").val(cater[1]);
				$("#jcate").val(cater[1]);
		}		
		
		function categoab(object){
				var cate =object.value;
				cater = cate.split("::");
				$("#categoid").val(cater[0]);
				$("#jcate").val(cater[1]);
				
				var listsub=Array();
				var valorcj = $('#categoid').val();
				var valorig = $('#jcate').val();
				if(valorcj != ""){
					ajax=nuevoAjax();
					ajax.open("GET", "../ajaxunico.php?cat=emsubb&val="+valorcj+"&valorig="+valorig,true);
					ajax.onreadystatechange=function() {
						if (ajax.readyState==4) {
							//listsub=eval(ajax.responseText);
							//alert(listsub[0][0]);
							$('#subjax').html(ajax.responseText);
						}
					}
					ajax.send(null);
				}
		}
		
		function validcatsub(object){
				var subcat =object.value;
				subca2 = subcat.split("::");				
				$("#selectsub").val(subca2[1]);
				$("#subcat_id").val(subca2[0]);
		}
		
		function selstateb(object){
			var jstates =object.value;
			jstates2 = jstates.split("::");				
			$("#jstate").val(jstates2[0]);
			$("#state_id").val(jstates2[1]);						
		}
		
		function only_numbers(evt) {
			var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
           {return false;}
				 else { return true;}
		}
		
		function selmiles(object){			
			var mt=m1.getActualValue();			
			$("#jmiles").val(mt);						
		}
