/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function ValidAgent(){    
    var F = document.YourAgent;

    if(F.Password.value.length <= 0){
        $("#ErrorPwdVacio").css("display", "block");
        return false;
    }
    $("#ErrorPwdVacio").css("display", "none");
	$("#ErrorPwd").css("display", "none");
	
	rutaAux=patAbsolta()+"includes/ValidAgentMayorista.php";

    var datos=$("#YourAgent").serialize();
		$.ajax({
			async:false,
			cache:false,
	        type: "POST",
	        url:rutaAux,
	        data: datos,
	        success:  function(data){
			    if(data != ''){
  		    	   mayoristaAgency=parseFloat(data);
		           F.Password.value="";
		           $("#ErrorPwd").css("display", "none");
		           tb_remove();
		           
		       }else{
		       	   mayoristaAgency=0;
		           $("#ErrorPwd").css("display", "block");
		           //tb_show('', "#TB_inline?height=105&width=300&inlineId=No_exist&modal=true", '');
		       }
			}
	});
	if(mayoristaAgency==1){
		//window.location.reload();
		//return true;
		cambiarPropiedadesHome();
	}
	onSelectChange();
	
}

function patAbsolta(){
		var auxPathname=location.pathname;
 		var carpetas=auxPathname.split('/');
 		var numCarpetas=carpetas.length-2;
 		var rutaAux="";
 		for(i=1 ;i<=numCarpetas ;i++)
 	   		rutaAux=rutaAux+'../';
 		return rutaAux;  
	}

function cambiarPropiedadesHome(){
	var datos="Language="+tipoLanguage;
	var rutaAux=patAbsolta()+"includes/homeMayorista/homeAgenciasMayorista.php";
	$.ajax({
		async:false,
		cache:false,
        type: "POST",
        url:rutaAux, 
        data: datos,
        success:  function(data){
            $("#casasAgencia").html(data);
        }
     });
}
