// JavaScript Document

function changeCapa(){
	document.getElementById('mod_2').style.display="none";
	document.getElementById('mod_3').style.display="block";
}

function muestraResultadosvo(form){
	/*frm = document.getElementById(form);
	frm.action='cochesOcasion.php';
	frm.method='GET';
	frm.buscado.value='1';
	frm.submit();*/
	
	//
	
	return false;
}

function ordenaLista (id, parametro, orden, porpagina, pagina){	
	frm = document.getElementById(id);
	//alert(frm);
	xajax_ordena(xajax.getFormValues(frm), parametro, orden, porpagina, pagina);
	return false;
}

function ordenaListaPublicados (parametro, orden){	
	xajax_ordena (parametro, orden, 'u');
	return false;
}

function ordenaListaVisitados (parametro, orden){		
	xajax_ordena (parametro, orden, 'v');
	return false;
}


function goToFicha(id){

	if (id=="frmBuscadorVOHome"){
		frm = document.getElementById(id);
		frm.submit();
	}else{
		document.location.href = id;
		return false;
	}
	
}

function goToFichaNuevo(id){
  parent.location.href = id;
	return false;
}
	



function loadBigImg(id){
	document.getElementById('imgBig').src = id;
}
	
/* --------------- Ficha Menu Setup -------------------*/
function changeMenu(id){
	
	for (var i=1; i<=4; i++) {
		if(document.getElementById('fmenu_'+i) != null)	document.getElementById('fmenu_'+i).style.display="none";
		if(document.getElementById('fmenuLink_'+i) != null) document.getElementById('fmenuLink_'+i).className = "";
	}
		
	document.getElementById('fmenu_'+id).style.display = "block";
	document.getElementById('fmenuLink_'+id).className = "current";
	
	return false;
}

function changeEqMenu(id){
	
	for (var i=0; i<=6; i++) {
		if(document.getElementById('eqS_'+i) != null)	document.getElementById('eqS_'+i).style.display="none";
		if(document.getElementById('eqSFlecha_'+i) != null) document.getElementById('eqSFlecha_'+i).src = "img/ficha/eqFlechDown.gif";
	}
		
	document.getElementById('eqS_'+id).style.display = "block";
	document.getElementById('eqSFlecha_'+id).src = "img/ficha/eqFlechUp.gif";
	
	return false;
}


function showRes1(combustible,version){
	
		/* $("#mod_2").fadeTo("slow", 0, function(){
		    $(this).css("display","none");
		 });
		 $("#mod_3").fadeTo("slow", 0, function(){
		    $(this).css("display","none");
		 });
		  $("#mod_4").fadeTo("slow", 1, function(){
		    $(this).css("display","block");
		 });*/
		  
		  $("#mod_2").slideUp( function(){
		    $(this).css("display","none");
		 });
		 $("#mod_3").slideUp( function(){
		    $(this).css("display","none");
		 });
		 
    document.getElementById("framemodelos").src="modelos.php?mod=sandero&ver="+version+"&com="+combustible;
    
		 $("#mod_4").slideDown(function(){
		    $(this).css("display","block");
		 });

}


// Mostramos la lista de los modelos con los colorcitos

function showRes2(combustible,version){
	
		 $("#mod_1").slideUp( function(){
		    $(this).css("display","none");
		 });
		 $("#mod_3").slideUp( function(){
		    $(this).css("display","none");
		 });	
		 
		 $("#mod_2").animate({left: "300px"},"fast", function(){ $(this).css("display","block");} );

      document.getElementById("framemodelos").src="modelos.php?mod=loganmvc&ver="+version+"&com="+combustible;
      
		  $("#mod_4").slideDown(function(){
		    $(this).css("display","block");
		 });

}

function showRes3(combustible,version){
	
		 $("#mod_1").slideUp( function(){
		    $(this).css("display","none");
		 });
		 $("#mod_2").slideUp( function(){
		    $(this).css("display","none");
		 });	
		 
		 $("#mod_3").animate({left: "600px"},"fast", function(){ $(this).css("display","block");} );

     document.getElementById("framemodelos").src="modelos.php?mod=logan&ver="+version+"&com="+combustible;
     
		  $("#mod_4").slideDown(function(){
		    $(this).css("display","block");
		 });

}


function OpenBigGallery(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 

function isNoCampoVacio (theElement){
	 if (theElement.value == ''){
	        document.getElementById('error_form').innerHTML="Por favor, rellene todos los campos obligatorios";
	        theElement.focus();
	        return false;        
	    }
	 else{
	  return true;
	 }
	  
	}

	function isEmailAddress(theElement){
	    var email = theElement.value;
	    var filter=/^[A-Za-z][.A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
	    if (filter.test(email))
	        return true;
	    document.getElementById('error_form').innerHTML="Proporcione una dirección de eMail válida";
	    theElement.focus();
	    return false;
	}

	function isPhoneNumber(theElement){
	    if (theElement.value=='') return true;
		var filter = /[0-9]{3}[-]?[0-9]{3}[-]?[0-9]{3}/;
	    if (!filter.test(theElement.value)){
	     document.getElementById('error_form').innerHTML="Proporcione un teléfono válido";
	     theElement.focus();
	     return false;
	    }
	    return true;
	}

	function isAcepted(theElement){
	    return true;
		if (!theElement.checked){
	   	 document.getElementById('error_form').innerHTML="Acepte recibir información";
	   	 theElement.focus();
	        return false;
	    }
	    return true;
	}
	
	
	function interesa(f){
		document.getElementById('error_form').innerHTML="";
	frm=document.getElementById(f);
	if (isAcepted(frm.acepto)){
	  if (isEmailAddress(frm.email)){   
	   if (isNoCampoVacio(frm.nombre) && isNoCampoVacio(frm.email)){ 
	    if (isPhoneNumber(frm.tel)){     
	     xajax_mailInteresa(xajax.getFormValues(frm));
	    }	    
	   }
	  }
	} 
	 return false;
	}


function submitImpr(art,ruta){
 window.open("http://reagroup.testmotorflash.com/rn_ficha_vo_print02.php?art="+art+"&val1=1&val2=1&val3=1&val4=1&ruta="+ruta,'Renault','toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width=600,height=auto')
}



function changePvMenu(id){
	
	for (var i=1; i<=13; i++) {
		if(document.getElementById('pv_'+i) != null)	document.getElementById('pv_'+i).style.display="none";
		if(document.getElementById('pv_menu_'+i) != null) document.getElementById('pv_menu_'+i).className = "";
	}
		
	document.getElementById('pv_'+id).style.display = "block";
	document.getElementById('pv_menu_'+id).className = "currentPv";
	
	return false;
}



