function axc(enviar, idrecibir, btn){
	var divrecibir=$(idrecibir);
	var botonsub=$(btn);
	var prueboRequest = new Request({
		method: 'get', 
		url: enviar,
		onRequest: function() {divrecibir.innerHTML='<img src="images/loader.gif" />'; botonsub.disabled=true;}, 
		onSuccess: function(texto, xmlrespuesta){divrecibir.innerHTML = texto; botonsub.disabled=false;},
		onFailure: function(){ alert('Could not complete the operation, try again later\nDetails:\n\nDatabase conection failed.');return 0;}
	}).send(); 
}

function accion(enviar, idrecibir, btn){
	var divrecibir=$(idrecibir);
	var botonsub=$(btn);
	var prueboRequest = new Request({
		method: 'get', 
		url: enviar,
		onRequest: function() {divrecibir.innerHTML='<img src="images/loading.gif" />';botonsub.style.display='none';}, 
		onSuccess: function(texto, xmlrespuesta){divrecibir.innerHTML = texto; botonsub.style.display='inline';},
		onFailure: function(){ alert('No se pudo completar la operacion, intentelo otra vez');return 0;}
	}).send(); 
}

function axcountry(idrecibir, country, control, idrecibir2, control2, idrecibir3){
	axc('ajax/states.php?name='+control+'&country='+country+'&name2='+control2+'&recibir='+idrecibir2, idrecibir, 'bsubmit');
	//only USA shows cities
	$(idrecibir2).innerHTML="<select name='"+control2+"' id='"+control2+"' class='register_employer'><option value=''>Select City</option></select>";
	if(country=='United States'){
		$(idrecibir3).style.display='block';
	}
	else {
		$(idrecibir3).style.display='none';
	}
}

function axcountrycity(idrecibir, country, control, idrecibir2, control2){
	axc('ajax/states.php?name='+control+'&country='+country+'&name2='+control2+'&recibir='+idrecibir2, idrecibir, 'bsubmit');
	
	if(country=='United States'){
	//only USA shows cities
		$(idrecibir2).innerHTML="<select name='"+control2+"' id='"+control2+"' class='campo'><option value=''>Select City</option></select>";
	}
	else {
		$(idrecibir2).innerHTML="<input name='"+control2+"' id='"+control2+"' type=text size=25 maxlength=40 >";

	}
}
function axcountry2(idrecibir, country, control, clase){
	axc('ajax/states2.php?name='+control+'&country='+country+'&clase='+clase, idrecibir, 'bsubmit');
}
function axcountry3(idrecibir, country, control, clase, idrecibir2, control2, clase2, idrecibir3) {
    axc('ajax/states3.php?name=' + control + '&country=' + country + '&name2=' + control2 + '&recibir=' + idrecibir2 + '&clase=' + clase + '&clase2=' + clase2, idrecibir, 'bsubmit');
	//only USA shows cities
    $(idrecibir2).innerHTML = "<select name='" + control2 + "' id='" + control2 + "' class='" + clase2 + "'><option value=''>All Cities</option></select>";
    if (country == 'United States') {
        $(idrecibir3).style.display = 'block';
    }
    else {
        $(idrecibir3).style.display = 'none';
    }
}
function axstate(idrecibir, state, control){
	axc('ajax/cities.php?name='+control+'&state='+state, idrecibir, 'bsubmit');
}
function axstate2(idrecibir, state, control, clase) {
    axc('ajax/cities2.php?name=' + control + '&state=' + state + '&clase=' + clase, idrecibir, 'bsubmit');
}
function axstateadv(country) {
    axc('ajax/states_adv.php?country=' + country, 'advanced_search_state_right', 'bsubmit');
}
function axstateadv2(country) {
    axc('ajax/states_adv2.php?country=' + country, 'job_agent_mult_locations_right', 'bsubmit');
}
function check_availability(login){	
	axc('ajax/check.php?login='+login,'check_username','available');
	/*document.getElementById('check_username').innerHTML = '<img src="images/check.png" height="15" width="15"/>';*/
}
function check_pass(pass){
	if(pass==""){
		document.getElementById('check_pass').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	}
	else{
		if(pass.length>=3){
			document.getElementById('check_pass').innerHTML = '<img src="images/check.png" height="15" width="15"/>';		
		}
		else{
			document.getElementById('check_pass').innerHTML = '<span class="mensaje">Your password is not secure</span>';		
		}
	}
}
function check_pass_confirm(pass1,pass2){
	
		if(pass1==pass2)	
			if(pass1==""){
				document.getElementById('check_pass_confirm').innerHTML = '';
			}
			else{	document.getElementById('check_pass_confirm').innerHTML = '<img src="images/check.png" height="15" width="15"/>';}
		else{		
				document.getElementById('check_pass_confirm').innerHTML = '<span class="mensaje">The passwords do not match</span>';
		}
}
function check_email_confirm(email1,email2){	
		if(email1==email2)	
			if(email1==""){
				document.getElementById('check_email_confirm').innerHTML = '';
			}
			else{	document.getElementById('check_email_confirm').innerHTML = '<img src="images/check.png" height="15" width="15"/>';}
		else{		
				document.getElementById('check_email_confirm').innerHTML = '<span class="mensaje">The email do not match</span>';
		}
}
function validate_email(v) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3,4})+$/.test(v)){
		return true;
	} else {
		return false;
	}
}
function check_email(value){
	if(value=="")
		document.getElementById('check_email').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else {
			document.getElementById('check_email').innerHTML = '<img src="images/check.png" height="15" width="15"/>';					
	}
}
function check_firstname(value){
	if(value=="")
		document.getElementById('check_firstname').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else
		document.getElementById('check_firstname').innerHTML = '<img src="images/check.png" height="15" width="15"/>';				
}
function check_lastname(value){
	if(value=="")
		document.getElementById('check_lastname').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else
		document.getElementById('check_lastname').innerHTML = '<img src="images/check.png" height="15" width="15"/>';				
}
function check_partner(value){
	if(value=="")
		document.getElementById('check_partner').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else
		document.getElementById('check_partner').innerHTML = '<img src="images/check.png" height="15" width="15"/>';				
}
function check_response(value){
	if(value=="")
		document.getElementById('check_response').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else
		document.getElementById('check_response').innerHTML = '<img src="images/check.png" height="15" width="15"/>';				
}
function check_squestion(value){
	if(value=="")
		document.getElementById('check_squestion').innerHTML = '<span class="mensaje">Required field cannot be left blank </span>';		
	else
		document.getElementById('check_squestion').innerHTML = '<img src="images/check.png" height="15" width="15"/>';				
}

function addFeature(idrecibir, idProduct){
	accion('controllers/agregarcar.php?id='+idProduct,idrecibir,'boton');
	
}
function deleteFeature(idrecibir, idProduct){
	accion('controllers/borrarcar.php?id='+idProduct,idrecibir,'boton');
	
}

/*======================== Scripts para partner system =====================*/
function add_invoice(idrecibir,idProduct){
	accion('ajax/agregar_invoice.php?id='+idProduct,idrecibir,'boton');
	}
function delete_invoice(idrecibir,idProduct){
	accion('ajax/borrar_invoice.php?id='+idProduct,idrecibir,'boton');
	}
	
function show_description(divrecibir,value)
{
	if(value=="receive_check")
	{
		if($(divrecibir).style.display=='none')
			dplieg(divrecibir);
		$(divrecibir).innerHTML="<span style='font-weight:bold;font-size:0.9em;color:#464646'> With this option BigJobsBoard.com will send your comission payment via check to the address on file for your account.</span>";
		plieg(divrecibir);
		}
	else if(value=="advertising_credit")
	{
		if($(divrecibir).style.display=='none')
			dplieg(divrecibir);
		$(divrecibir).innerHTML="<span style='font-weight:bold;font-size:0.9em;color:#464646'> With this option BigJobsBoard.com will credit your comission payment to your account for advertising purchases.</span>";
		plieg(divrecibir);
		}
	else if(value=="")
		dplieg(divrecibir);
	}
