if ((screen.width == 640) && (screen.height == 480)) 
alert ("ATENCIÓN!!\r\rLa resolución de pantalla que Ud. utiliza actualmente no le permitirá ver bien este sitio.\r\rPor favor, cambie la resolución a 800x600 o más.\r\r\rGracias.")

function popUp(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ano(categoria){
	if (document.formAno.ano_combo.options.value == ""){
		alert("Seleccione un año por favor")
	}else{
		ano=document.formAno.ano_combo.options.value;
		document.location.href("familias.htm?categoria="+categoria+"&ano="+ano);
	}
}

function validabuscar(){
	marca="";
	modelo="";
	ano="";
	categoria="";
	familia="";
	keyword="";
	if (document.buscador.marca.options.value == ""){
		alert("Seleccione una marca por favor")
	}else{
		
		marca=document.buscador.marca.options.value;
		
		modelo=document.buscador.modelo.options.value;
		/*
		ano=document.buscador.ano.options.value;
		categoria=document.buscador.categoria.options.value;
		familia=document.buscador.familia.options.value;
		keyword=document.buscador.keyword.options.value;
		*/
		document.location.href("busqueda.htm?marca="+marca+"&modelo="+modelo+"&ano="+ano+"&categoria="+categoria+"&familia="+familia+"&keyword="+keyword);
	}
}

function fuerzadisplay(ID,estado) {
		cual = document.getElementById(ID).style;
		if (estado=="no") {
			cual.display = "none";
			cual.visibility = "hidden"
		}else {
			cual.display = "block";
			cual.visibility = "visible"
		}
		return false;		
}
function chktipo(tipo){
	switch (tipo){
		case "bnuevos":
		fuerzadisplay('buscanuevos','si');
		fuerzadisplay('buscausados','no');
		break;
		case "busados":
		fuerzadisplay('buscanuevos','no');
		fuerzadisplay('buscausados','si');	
		break;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
if (selObj.options[selObj.selectedIndex].value==0){
		return false;
	}
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}




function cargaMODELOS(url,valor) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url+"&valor="+ valor, true);
        req.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url+"&valor="+ valor, true);
            req.send();
        }
    }
}

function processReqChange(){
// Referencia a nuestro DIV con ID unica:
var detalles = document.getElementById("modelos");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(req.readyState == 4){
detalles.innerHTML = req.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function cargaMODELOS_secundario(url,valor,div) {
	//  Primero vamos a ver si la URL es una URL :)
	div_activa=div;
	if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        req_secundario = new XMLHttpRequest();
        req_secundario.onreadystatechange = processReqChange_secundario;
        req_secundario.open("GET", url+"&valor="+ valor, true);
        req_secundario.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req_secundario = new ActiveXObject("Microsoft.XMLHTTP");
        if (req_secundario) {
            req_secundario.onreadystatechange = processReqChange_secundario;
            req_secundario.open("GET", url+"&valor="+ valor, true);
            req_secundario.send();
        }
    }
}

function processReqChange_secundario(){
// Referencia a nuestro DIV con ID unica:
var detalles = document.getElementById(div_activa); 
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(req_secundario.readyState == 4){
detalles.innerHTML = req_secundario.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function cargaMODELOSUSADOS(url,valor) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqUSADOS = new XMLHttpRequest();
        reqUSADOS.onreadystatechange = processReqChangeUsados;
        reqUSADOS.open("GET", url+"?valor="+ valor, true);
        reqUSADOS.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqUSADOS = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqUSADOS) {
            reqUSADOS.onreadystatechange = processReqChangeUsados;
            reqUSADOS.open("GET", url+"?valor="+ valor, true);
            reqUSADOS.send();
        }
    }
}


function processReqChangeUsados(){
// Referencia a nuestro DIV con ID unica:
var detallesUSADOS = document.getElementById("modelo_usados");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqUSADOS.readyState == 4){
detallesUSADOS.innerHTML = reqUSADOS.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detallesUSADOS.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function cargaMODELOSUSADOS_FILTRO(url,valor,idmodelo) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqUSADOS = new XMLHttpRequest();
        reqUSADOS.onreadystatechange = processReqChangeUsados_filtro;
        reqUSADOS.open("GET", url+"?valor="+valor+"&idmodelo="+idmodelo, true);
        reqUSADOS.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqUSADOS = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqUSADOS) {
            reqUSADOS.onreadystatechange = processReqChangeUsados_filtro;
            reqUSADOS.open("GET", url+"?valor="+valor+"&idmodelo="+idmodelo, true);
            reqUSADOS.send();
        }
    }
}


function processReqChangeUsados_filtro(){
// Referencia a nuestro DIV con ID unica:
var detallesUSADOS = document.getElementById("modelo_usados_filtro");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqUSADOS.readyState == 4){
detallesUSADOS.innerHTML = reqUSADOS.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detallesUSADOS.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}


function cargaTHusados(url,id_usado,id_tipo_foto) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqTH_USADOS = new XMLHttpRequest();
        reqTH_USADOS.onreadystatechange = processReqChangeTH_usado;
        reqTH_USADOS.open("GET", url+"?id_usado="+id_usado+"&id_tipo_foto="+id_tipo_foto, true);
        reqTH_USADOS.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqTH_USADOS = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqTH_USADOS) {
            reqTH_USADOS.onreadystatechange = processReqChangeTH_usado;
            reqTH_USADOS.open("GET", url+"?id_usado="+id_usado+"&id_tipo_foto="+id_tipo_foto, true);
            reqTH_USADOS.send();
        }
    }
}


function processReqChangeTH_usado(){
// Referencia a nuestro DIV con ID unica:
var detallesUSADOS = document.getElementById("container_thumbs");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqTH_USADOS.readyState == 4){
detallesUSADOS.innerHTML = reqTH_USADOS.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detallesUSADOS.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}



function chek_ajax_modelos(url,valor){
	if (valor!=0){
		cargaMODELOS(url,valor)
	}
}

function chek_ajax_marcas(url,valor,div){
	if (valor!=0){
		cargaMODELOS_secundario(url,valor,div)
	}
}

function chek_ajax_modelos_usados(url,valor){
	if (valor!=0){
		cargaMODELOSUSADOS(url,valor)
	}
}

function cargaCOLOR(url,valor) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqCOLOR = new XMLHttpRequest();
        reqCOLOR.onreadystatechange = processReqChangeColor;
        reqCOLOR.open("GET", url+"?valor="+ valor, true);
        reqCOLOR.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqCOLOR = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqCOLOR) {
            reqCOLOR.onreadystatechange = processReqChangeColor;
            reqCOLOR.open("GET", url+"?valor="+ valor, true);
            reqCOLOR.send();
        }
    }
}

function processReqChangeColor(){
// Referencia a nuestro DIV con ID unica:
var detallesCOLOR = document.getElementById("colorcontainer");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqCOLOR.readyState == 4){
detallesCOLOR.innerHTML = reqCOLOR.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detallesCOLOR.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function cargaGENERICA(url,valor,div) {
	//  Primero vamos a ver si la URL es una URL :)
	eldiv=div;
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqgenerico = new XMLHttpRequest();
        reqgenerico.onreadystatechange = processReqGenerico;
        reqgenerico.open("GET", url+"?valor="+ valor, true);
        reqgenerico.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqgenerico = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqgenerico) {
            reqgenerico.onreadystatechange = processReqGenerico;
            reqgenerico.open("GET", url+"?valor="+ valor, true);
            reqgenerico.send();
        }
    }
}


function processReqGenerico(){
// Referencia a nuestro DIV con ID unica:

var detalles = document.getElementById(eldiv); 
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqgenerico.readyState == 4){
	cadena=unescape(reqgenerico.responseText);
	cadenafinal=cadena.replace(/\+/gi," ");
detalles.innerHTML = cadenafinal;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function redirnuevos(idmarca,idmodelo){
if (idmarca == 0){
		idmarca="";
	}
	if (idmarca == 0){
		idmarca="";
	}
	var page = 'modelo.php?id='+idmodelo;
	
	if (idmarca && idmodelo != ""){
		document.location.href = page;
	}else{
		alert("Seleccione una marca y un modelo");
		
	}
	
}

function redirusados(idtipo,idmarca,idmodelo,ano,idprecio){

	if (idtipo == 0){
		idtipo="";
	}
	if (idmarca == 0){
		idmarca="";
	}
	if (idmodelo == 0){
		idmodelo="";
	}

	if (ano == 0){
		ano="";
	}
	if (idprecio == 0){
		idprecio="";
	}
	
	var page = 'buscausados.php?envio=1&idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo+'&ano='+ano+'&idprecio='+idprecio;
	if (idtipo || idmarca || idmodelo || ano || idprecio != ""){
		document.location.href = page;
	}else{
		alert("Seleccione un tipo o marca o modelo o precio o a\u00f1o");
		
	}
	
}

function redirusados_home(idtipo,idmarca,idmodelo,ano,idprecio){
	if (idtipo == 0){
		idtipo="";
	}
	if (idmarca == 0){
		idmarca="";
	}
	if (idmodelo == 0){
		idmodelo="";
	}
	if (idtipo == 0){
		idtipo="";
	}
	if (ano == 0){
		ano="";
	}
	if (idprecio == 0){
		idprecio="";
	}
	
	var page = 'buscausados.php?envio=1&idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo+'&ano='+ano+'&idprecio='+idprecio;
	
	if (idtipo || idmarca || idmodelo || ano || idprecio != ""){
		if(document.filtrousados.aire.checked){
			page=page+'&aire=si';
		}
		if(document.filtrousados.frenosabs.checked){
			page=page+'&frenosabs=si';
		}
		if(document.filtrousados.cd.checked){
			page=page+'&cd=si';
		}
		if(document.filtrousados.mp3.checked){
			page=page+'&mp3=si';
		}
		document.location.href = page;
	}else{
		alert("Seleccione tipo de vehiculo o marca o modelo o precio o a\u00f1o");
		
	}
	
}

function ordena(idtipo,idmarca,idmodelo,ano,idprecio,orden){
	
	var page = 'buscausados.php?envio=1&idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo+'&ano='+ano+'&idprecio='+idprecio;
	//var page = document.location.href ; 

		if(document.filtrousados.aire.checked){
			page=page+'&aire=si';
		}
		if(document.filtrousados.frenosabs.checked){
			page=page+'&frenosabs=si';
		}
		if(document.filtrousados.cd.checked){
			page=page+'&cd=si';
		}
		if(document.filtrousados.mp3.checked){
			page=page+'&mp3=si';
		}
		
		document.location.href = page+"&orden="+orden;

	
}

function ordena2(orden){
	//var page = 'buscausados.php?envio=1&idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo+'&ano='+ano+'&idprecio='+idprecio+'&orden='+orden;
	var page = 'buscausados.php?envio=1&idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo+'&ano='+ano+'&idprecio='+idprecio+'&orden='+orden;

		if(document.filtrousados.aire.checked){
			page=page+'&aire=si';
		}
		if(document.filtrousados.frenosabs.checked){
			page=page+'&frenosabs=si';
		}
		if(document.filtrousados.cd.checked){
			page=page+'&cd=si';
		}
		if(document.filtrousados.mp3.checked){
			page=page+'&mp3=si';
		}
		document.location.href = page;
	
}

function verifica_cotiza_usado(){
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	
	if (document.formcotizacion.region.value=="0"){
		alert("Seleccione una Region");
		document.formcotizacion.region.focus();
		return false;
	}
	
}

function verifica_cotiza_nuevo(){

	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	/*
	if(document.formcotizacion.rut_cliente.value==""){
		alert("Debe escribir su RUT");
		document.formcotizacion.rut_cliente.focus();
		return false;
	}else{
		var rutcompleto=document.formcotizacion.rut_cliente.value;
 		var rut = rutcompleto.substring(0,rutcompleto.length-2); 
		var dv = rutcompleto.substring(rutcompleto.length,rutcompleto.length-1); 
		if (dv=="K"){
			dv="k";
		}
		var count=0;
		var count2=0;
		var factor=2;
		var suma=0;
		var sum=0;
		var digito=0;
		count2=rut.length - 1;
		while(count < rut.length){
			sum = factor * (parseInt(rut.substr(count2,1))); 
			suma = suma + sum;
			sum=0;
			count = count + 1;
			count2 = count2 - 1;
			factor = factor + 1;
			if(factor > 7){
				factor=2; 
			} 
		}
		digito= 11 - (suma % 11)
		if(digito==11){
			digito=0;
		}
		if(digito==10){
			digito="k";
		}
		if(dv!=digito){
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
		}
		if (rut+dv==0){
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
		}
		switch(rut){
			case "11111111":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "22222222":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "33333333":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "44444444":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "55555555":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "66666666":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "77777777":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "88888888":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "99999999":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
		}
	}
	
	if (document.formcotizacion.region.value=="0"){
		alert("Seleccione una Region");
		document.formcotizacion.region.focus();
		return false;
	}
	*/

	
	if (document.formcotizacion.finan[0].checked){
		if (document.formcotizacion.pie.value==""){
		alert("Seleccione un Pie");
		document.formcotizacion.pie.focus();
		return false;
		}
		if (document.formcotizacion.cuotas.value=="0"){
		alert("Seleccione cuotas");
		document.formcotizacion.cuotas.focus();
		return false;
		}
	}
	
	
}

function verifica_cotiza_rent_a_car(){
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	
	if(document.formcotizacion.rut_cliente.value==""){
		alert("Debe escribir su RUT");
		document.formcotizacion.rut_cliente.focus();
		return false;
	}else{
		var rutcompleto=document.formcotizacion.rut_cliente.value;
 		var rut = rutcompleto.substring(0,rutcompleto.length-2); 
		var dv = rutcompleto.substring(rutcompleto.length,rutcompleto.length-1); 
		if (dv=="K"){
			dv="k";
		}
		var count=0;
		var count2=0;
		var factor=2;
		var suma=0;
		var sum=0;
		var digito=0;
		count2=rut.length - 1;
		while(count < rut.length){
			sum = factor * (parseInt(rut.substr(count2,1))); 
			suma = suma + sum;
			sum=0;
			count = count + 1;
			count2 = count2 - 1;
			factor = factor + 1;
			if(factor > 7){
				factor=2; 
			} 
		}
		digito= 11 - (suma % 11)
		if(digito==11){
			digito=0;
		}
		if(digito==10){
			digito="k";
		}
		if(dv!=digito){
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
		}
		if (rut+dv==0){
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
		}
		switch(rut){
			case "11111111":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "22222222":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "33333333":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "44444444":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "55555555":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "66666666":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "77777777":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "88888888":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
			case "99999999":
			alert("RUT INVALIDO");
			document.formcotizacion.rut_cliente.focus();
			return false;
			break;
		}
	}
	
	if (document.formcotizacion.direccion.value==""){
		alert("Indiquenos su direccion");
		document.formcotizacion.direccion.focus();
		return false;
	}
	if (document.formcotizacion.destino.value==""){
		alert("Indiquenos su destino");
		document.formcotizacion.destino.focus();
		return false;
	}
	if (document.formcotizacion.garantia.value=="0"){
		alert("Indiquenos el documento en garantia");
		document.formcotizacion.garantia.focus();
		return false;
	}
	/*
	for ( i = 0; i < document.formcotizacion.primer.length; i++ ) {
		if (!document.formcotizacion.primer[i].checked) {
			alert("Radio "+i+" no seleccionado")
			document.formcotizacion.primer[0].focus();		
			break;
			return false;
		}
	}
	*/
}

function verifica_cotiza_repuestos(){
	if (document.formcotizacion.marca_repuestos.value=="0"){
		alert("Seleccione una marca");
		document.formcotizacion.marca_repuestos.focus();
		return false;
	}
	
	if (document.formcotizacion.modelo_repuestos.value=="0"){
		alert("Seleccione un modelo");
		document.formcotizacion.modelo_repuestos.focus();
		return false;
	}
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	
	if (document.formcotizacion.region.value=="0"){
		alert("Seleccione una Region");
		document.formcotizacion.region.focus();
		return false;
	}
	
}

function verifica_cotiza_simple(){
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	
	if (document.formcotizacion.region.value=="0"){
		alert("Seleccione una Region");
		document.formcotizacion.region.focus();
		return false;
	}
	
	if (document.formcotizacion.tipo_contacto.value=="0"){
		alert("Seleccione un motivo de contacto");
		document.formcotizacion.tipo_contacto.focus();
		return false;
	}
	
}

function verifica_contacto(){
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.focus();
		return false;
	}
	
	if (document.formcotizacion.apellido.value==""){
		alert("Se requiere su apellido");
		document.formcotizacion.apellido.focus();
		return false;
	}
	
	email=document.formcotizacion.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcotizacion.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcotizacion.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcotizacion.email.focus();
			return false;
		}
	}
	
	if (document.formcotizacion.fono.value==""){
		alert("Se requiere su Fono");
		document.formcotizacion.fono.focus();
		return false;
	}
	
	if (document.formcotizacion.region.value=="0"){
		alert("Seleccione una Region");
		document.formcotizacion.region.focus();
		return false;
	}
	
	if (document.formcotizacion.tipo_contacto.value=="0"){
		alert("Seleccione un motivo de contacto");
		document.formcotizacion.tipo_contacto.focus();
		return false;
	}else{
		var tipo=document.formcotizacion.tipo_contacto.value;
		switch (tipo){
		case "9":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "5":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "6":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "8":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "2":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "3":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "16":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		case "17":
			if (document.formcotizacion.marca_contacto.value=="0"){
				alert("Seleccione una marca");
				document.formcotizacion.marca_contacto.focus();
				return false;
			}
		break;
		}
	}
}

function recir_tipo(idtipo,pagina){
	if(idtipo!=0){
		var page = pagina+'.php?idtipo='+idtipo;
		document.location.href = page;
	}
}

function recir_marca(idtipo,idmarca,pagina){
	if(idmarca!=0){
		var page = pagina+'.php?idtipo='+idtipo+'&idmarca='+idmarca;
		document.location.href = page;
	}
}

function recir_modelo(idtipo,idmarca,idmodelo,pagina){
	if(idmarca!=0 && idmodelo!=0){
		var page = pagina+'.php?idtipo='+idtipo+'&idmarca='+idmarca+'&idmodelo='+idmodelo;
		document.location.href = page;
	}
}



function muestraesconde(ID) {
		
		cual = document.getElementById(ID).style;
		if (cual.display == "block") {
			cual.display = "none";
			cual.visibility = "hidden";
			
		}else {
			cual.display = "block";
			cual.visibility = "visible";
			
		}
	

}

function muestraesconde_suc(ID,imag) {

		cual = document.getElementById(ID).style;
		if (cual.display == "block") {
			cual.display = "none";
			cual.visibility = "hidden";
			MM_swapImage(imag,'','estilos/estilo_busqueda/mas.gif',0)
			
		}else {
			cual.display = "block";
			cual.visibility = "visible";
			MM_swapImage(imag,'','estilos/estilo_busqueda/menos.gif',0)
		}
	

}

function chktipo2(id){
	switch (id){
		case "1":
		fuerzadisplay('1','si');
		fuerzadisplay('2','no');
		break;
		case "2":
		fuerzadisplay('1','no');
		fuerzadisplay('2','si');	
		break;
	}
}

function esconde_anuncio(divId) 
{ if (document.layers) document.layers[divId].visibility = 'hide';
  else if (document.all) document.all[divId].style.visibility = 'hidden';
  else if (document.getElementById) document.getElementById(divId).style.visibility = 'hidden';
}
function mostrar_anuncio(divId) 
{ state=typeof topPos;
  if(state=='undefined') topPos=-600;
  if(topPos < 35)
  { topPos+=5;
	   if (document.layers) document.layers[divId].top = topPos;
    else if (document.all) document.all[divId].style.top = topPos;
    else if (document.getElementById) document.getElementById(divId).style.top = topPos;	
    
    setTimeout("mostrar_anuncio('pop');",10);
	 }
}

function uncheck(ID,radio){

		cual = document.getElementById(ID).style;
		if (cual.display == "none") {
			cual.display = "block";
			cual.visibility = "visible";
			document.formcotizacion[radio].checked = true;
					
		}else {
			cual.display = "none";
			cual.visibility = "hidden";
			document.formcotizacion[radio].checked=false;
		}
	

	
}