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 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=-500;
  if(topPos < 5)
  { 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');",15);
	 }
}

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 MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function validaEnviadatos(){
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.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=="" && document.formcotizacion.celular.value==""){
		alert("Se requiere algun telefono Fijo o Celular");
		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.provincia.value=="0"){
		alert("Seleccione una Provincia");
		document.formcotizacion.provincia.focus();
		return false;
	}
	
	if (document.formcotizacion.comuna.value=="0"){
		alert("Seleccione una Comuna");
		document.formcotizacion.comuna.focus();
		return false;
	}
	
}

function validaCotizacion(){
	if (document.formcotizacion.modelo.value=="0"){
		alert("Seleccione un Modelo");
		document.formcotizacion.modelo.focus();
		return false;
	}
	
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.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=="" && document.formcotizacion.celular.value==""){
		alert("Se requiere algun telefono Fijo o Celular");
		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.provincia.value=="0"){
		alert("Seleccione una Provincia");
		document.formcotizacion.provincia.focus();
		return false;
	}
	
	if (document.formcotizacion.comuna.value=="0"){
		alert("Seleccione una Comuna");
		document.formcotizacion.comuna.focus();
		return false;
	}
	
}

function validaSimulador(){
		
	if (document.formcotizacion.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcotizacion.nombre.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=="" && document.formcotizacion.celular.value==""){
		alert("Se requiere algun telefono Fijo o Celular");
		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.provincia.value=="0"){
		alert("Seleccione una Provincia");
		document.formcotizacion.provincia.focus();
		return false;
	}
	
	if (document.formcotizacion.comuna.value=="0"){
		alert("Seleccione una Comuna");
		document.formcotizacion.comuna.focus();
		return false;
	}
	
	if(document.formcotizacion.rut.value==""){
		alert("Debe escribir su RUT");
		document.formcotizacion.rut.focus();
		return false;
	}else{
		
		var rut=document.formcotizacion.rut.value;
		var dv=document.formcotizacion.dv.value;
		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");
			return false;
		}
		if (rut+dv==0){
			alert("RUT INVALIDO");
			return false;
		}
		switch(rut){
			case "11111111":
			alert("RUT INVALIDO");
			return false;
			break;
			case "22222222":
			alert("RUT INVALIDO");
			return false;
			break;
			case "33333333":
			alert("RUT INVALIDO");
			return false;
			break;
			case "44444444":
			alert("RUT INVALIDO");
			return false;
			break;
			case "55555555":
			alert("RUT INVALIDO");
			return false;
			break;
			case "66666666":
			alert("RUT INVALIDO");
			return false;
			break;
			case "77777777":
			alert("RUT INVALIDO");
			return false;
			break;
			case "88888888":
			alert("RUT INVALIDO");
			return false;
			break;
			case "99999999":
			alert("RUT INVALIDO");
			return false;
			break;
		}
	}
	
	if (!document.formcotizacion.desea_cotizacion.checked && !document.formcotizacion.desea_financiamiento.checked){
		alert("Seleccione al menos una opcion sobre que tipo de informacion desea recibir");
		return false;
	}
	
	if (document.formcotizacion.plazo_compra.value=="0"){
		alert("Seleccione un plazo estimado de compra");
		document.formcotizacion.plazo_compra.focus();
		return false;
	}
	
}

function validaContacto(){
	
	if (document.formcontacto.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcontacto.nombre.focus();
		return false;
	}
	
	email=document.formcontacto.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcontacto.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.formcontacto.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcontacto.email.focus();
			return false;
		}
	}
	
	if (document.formcontacto.fono.value=="" && document.formcontacto.celular.value==""){
		alert("Se requiere algun telefono Fijo o Celular");
		document.formcontacto.fono.focus();
		return false;
	}
	
		
	if (document.formcontacto.region.value=="0"){
		alert("Seleccione una Region");
		document.formcontacto.region.focus();
		return false;
	}
	
	if (document.formcontacto.provincia.value=="0"){
		alert("Seleccione una Provincia");
		document.formcontacto.provincia.focus();
		return false;
	}
	
	if (document.formcontacto.comuna.value=="0"){
		alert("Seleccione una Comuna");
		document.formcontacto.comuna.focus();
		return false;
	}
	if (document.formcontacto.tipo_contacto.value=="0"){
		alert("Seleccione un Motivo");
		document.formcontacto.tipo_contacto.focus();
		return false;
	}
	
	
}

function validaTrabajo(){
	
	if (document.formcontacto.nombre.value==""){
		alert("Se requiere su nombre");
		document.formcontacto.nombre.focus();
		return false;
	}
	
	email=document.formcontacto.email.value;
	if(email==""){
		alert("Debe escribir su email para recibir sus datos.");
		document.formcontacto.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.formcontacto.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcontacto.email.focus();
			return false;
		}
	}
	
	if (document.formcontacto.fono.value==""){
		alert("Se requiere su Fono");
		document.formcontacto.fono.focus();
		return false;
	}
	
	if (document.formcontacto.Attachment.value==""){
		alert("Debes adjuntar tu curriculum en formato .DOC o .TXT");
		document.formcontacto.Attachment.focus();
		return false;
	}
	
}
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 fuerzadisplay(ID) {
		if(navigator.appVersion.indexOf("Win") != -1){
		cual = document.getElementById(ID).style;
		if (cual.display == "none" || cual.display == "") {
			cual.display = "block";
		}else {
			cual.display = "none";
		}
		return false;		
	}
}


function cargaXML(url,valor,opcion) {
	//  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+"&opcion="+opcion, 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+"&opcion="+opcion, true);
            req.send();
        }
    }
}


function processReqChange(){
// Referencia a nuestro DIV con ID unica:
var detalles = document.getElementById("fotos_grandes");
// 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 cargaDATA(url,valor,opcion) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange2;
        req.open("GET", url+"?valor="+ valor+"&opcion="+opcion, 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 = processReqChange2;
            req.open("GET", url+"?valor="+ valor+"&opcion="+opcion, true);
            req.send();
        }
    }
}

function cargaVERSIONES(url,valor) {
	//  Primero vamos a ver si la URL es una URL :)
    if(url==''){
        return;
    }
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqversion = new XMLHttpRequest();
        reqversion.onreadystatechange = processReqChange3;
        reqversion.open("GET", url+"?valor="+ valor, true);
        reqversion.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqversion = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqversion) {
            reqversion.onreadystatechange = processReqChange3;
            reqversion.open("GET", url+"?valor="+ valor, true);
            reqversion.send();
        }
    }
}


function processReqChange2(){
// Referencia a nuestro DIV con ID unica:
var detalles = document.getElementById("detalles");
// 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 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 processReqChange3(){
// Referencia a nuestro DIV con ID unica:
var versiones = document.getElementById("versiones");
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqversion.readyState == 4){
versiones.innerHTML = reqversion.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
versiones.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function chek_ajax(URL,campo,idmarca){
	if (campo!=0){
		cargaDATA(URL,campo,idmarca)
	}
}

function chek_ajax_versiones(URL,campo){
	if (campo!=0){
		cargaVERSIONES(URL,campo)
	}
}