///
/// Videos Aleatorios
///
var arrVideos = new Array ( 1 );

arrVideos[0] = 1;
var strVideo1 = 'pPzilGBwyX4';

fisher_yates(arrVideos);
function insertar_video(intPos){
	document.write('<object width="300" height="250">');
	document.write('<param name="movie" value="http://www.youtube.com/v/' + eval("strVideo" + arrVideos[0]) + '&hl=es&fs=1&"></param>');
	document.write('<param name="allowFullScreen" value="true"></param>');
	document.write('<param name="allowscriptaccess" value="always"></param>');
	document.write('<embed src="http://www.youtube.com/v/' + eval("strVideo" + arrVideos[0]) + '&hl=es&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="250"></embed>');
	document.write('</object>');
}

//
// LS
//
function e_n(strE,strT,strD) {
	if (strD == "_blank") {
		t1 = "ht";
		t2 = "tp";
		t3 = ":/";
		t4 = "/";   
		t5 = "wi";
		t6 = "nd";
		t7 = "ow";
		t8 = ".";  
		t9 = "op";
		t10 = "en('";
		t11 = "ww";
		t12 = "w."
		t13 = "')";
		eval(t5+t6+t7+t8+t9+t10+t1+t2+t3+t4+t11+t12+strE+"."+strT+t13);
	}
	else {
		t1 = "'ht";
		t2 = "tp";
		t3 = ":/";
		t4 = "/";   
		t5 = "wi";
		t6 = "nd";
		t7 = "ow";
		t8 = ".l";  
		t9 = "oc";
		t10 = "at";
		t11 = "io";
		t12 = "n.";
		t13 = "hr";
		t14 = "ef=";
		t15 = "ww";
		t16 = "w."
		eval(t5+t6+t7+t8+t9+t10+t11+t12+t13+t14+t1+t2+t3+t4+t15+t16+strE+"."+strT+"'");
	}
}
//
// Anuncios Aleatorios
//
function fisher_yates ( myArray ) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}
var arrAnuncios = new Array ( 1, 2, 3 );
var strAnuncio1 = '<a onClick="track(1);" target="_blank" href="/seguro-para-coche.htm"><img src="/publicidad/catalana-occidente-1.jpg" alt="seguros catalana occidente" border="0"></a>';
//var strAnuncio2 = '<a onClick="track(2);" target="_blank" href="http://www.retiradacarnet.com"><img src="/publicidad/retirada-de-carnet-1.gif" alt="seguro retirada de carnet" border="0"></a>';
var strAnuncio2 = '<a onClick="track(4);" target="_blank" href="http://www.elmejorsegurodecoche.es/seguro-coche-mutua-todoriesgo.htm"><img src="/publicidad/mutualamitad-banner.gif" alt="seguro coche mutua todoriesgo" border="0"></a>';
//var strAnuncio3 = '<a onClick="track(3);" target="_blank" href="http://www.grupocarlunas.com"><img src="/publicidad/carlunas-para-coche.gif" alt="Especialistas en reparación y sustitución de lunas y parabrisas" border="0"></a>';
var strAnuncio3 = '<a onClick="track(6);" target="_blank" href="http://www.garantiamecanica.es"><img src="/publicidad/300x250-garantiamecanica.gif" alt="Sin nigún límite en el importe de la reparación" border="0"></a>';
//var strAnuncio4 = '<a onClick="track(5);" target="_blank" href="http://www.segurosmedicosgratis.com"><img src="/publicidad/concurso300x250.gif" alt="seguros medicos gratis" border="0"></a>';
fisher_yates(arrAnuncios);
function insertar_anuncio(intPos){
	document.write(eval("strAnuncio" + arrAnuncios[intPos]));
}
function impresion(idanuncio){
	var idanunciante;
	if (idanuncio == 1){idanunciante = 1;}
	if (idanuncio == 2){idanunciante = 4;}
	if (idanuncio == 3){idanunciante = 6;}
	ImgLlamada = new Image;
	ImgLlamada.src = "/print.asp?pos1=" + idanunciante;
}
impresion(arrAnuncios[0]);
function track(id){
	ImgLlamada = new Image;
	ImgLlamada.src = "/track.asp?id=" + id;
}

//
// Funciones del panel de control
//
function overTR(tr,color){tr.style.cursor='hand';tr.bgColor=color;tr.style.color='#3a5db7';}
function outTR(tr,color){tr.style.cursor='default';tr.bgColor=color;tr.style.color='#57453a';}
function overTR1(tr,color){tr.bgColor=color;}
function outTR1(tr,color){tr.bgColor=color;}

//
// Pop-up centrada en pantalla
//
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

//
// Limite de longitud en text areas
//
function maximaLongitud(texto,maxlong) { 
  var tecla, in_value, out_value; 

  if (texto.value.length > maxlong) { 
    in_value = texto.value; 
    out_value = in_value.substring(0,maxlong); 
    texto.value = out_value; 
    return false; 
  } 
  return true; 
} 

//
// Funciones para Zoom
//
	var _img_grande;

	function mostrarZ() {
		var ops = "top=" + ((screen.height - _img_grande.height) / 2);
		ops += ",left=" + ((screen.width - _img_grande.width) / 2);
		ops += ",width=" + _img_grande.width + ",height=" + _img_grande.height;
		ops += ",location=NO";

		ops += ",status=NO";
		ops += ",titlebar=NO";
		ops += ",toolbar=NO";
		ops += ",menubar=NO";
		ops += ",directories=NO";
		var contenido = "<html><body style='background-image: url(" + _img_grande.src + ")'></body></html>";
		var ventana = window.open("", "", ops);
		ventana.document.write(contenido);
		ventana.document.close();
	}

	function cargando() {
		if (_img_grande.complete) mostrarZ();
		else setTimeout("cargando()", 100);
	}

	function Zoom(imagen)	{
		_img_grande = new Image();
		_img_grande.src = imagen;
		cargando();
	}

///
/// Funciones captura/pérdida de foco para formularios
///
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

///
/// Validaciones formularios comunes a varias páginas
///
function validar_frmBuscador () {	
	var correcto = true;
	if ((document.frmBuscador.q.value == "*Escribir búsqueda")||(document.frmBuscador.q.value == "")) {
	    correcto = false;
		alert("El campo Búsqueda es obligatorio.");
	   	document.frmBuscador.q.focus();
		return correcto;
	}
	if (correcto) {
		//document.getElementById("enviar_frmBusqueda").innerHTML = "Espere...";
		document.frmBuscador.submit();
		}
}
function validar_frmBuscador2 () {	
	var correcto = true;
	if ((document.frmBuscador2.q.value == "*Escribir búsqueda")||(document.frmBuscador2.q.value == "")) {
	    correcto = false;
		alert("El campo Búsqueda es obligatorio.");
	   	document.frmBuscador2.q.focus();
		return correcto;
	}
	if (correcto) {
		//document.getElementById("enviar_frmBusqueda").innerHTML = "Espere...";
		document.frmBuscador2.submit();
		}
}
function validar_frmSubs () {	
	var correcto = true;
	if ((document.frmSubs.txtCorreo.value == "*Escribe tu correo")||(document.frmSubs.txtCorreo.value == "")) {
	    correcto = false;
		alert("El campo Correo electrónico es obligatorio.");
	   	document.frmSubs.txtCorreo.focus();
		return correcto;
	}
	correcto = esCorreo(document.frmSubs.txtCorreo.value,"Correo electrónico")
	if (!correcto) {document.frmSubs.txtCorreo.focus();return correcto;}
	if (!document.frmSubs.chkAcepto.checked){
		correcto = false;
		alert ("Para poder enviar sus datos es preciso que lea y acepte la cláusula de confidencialidad.")
	} 
	if (correcto) {
		document.getElementById("enviar_frmSubs").innerHTML = "  Espere...";
		document.frmSubs.submit();
		}
}

