var appver = navigator.appVersion.substring(0,navigator.appVersion.indexOf('.'));
var bIsOk = (navigator.appName == 'Netscape') && (appver >= '5') || (navigator.appName == 'Microsoft Internet Explorer') && (appver >= '4');
var esMac=navigator.appVersion.indexOf("Mac");
function selecciona(cual) {		
	//Hoja de estilos para Mac
	plat_mac = "/estilosM/explorer/"+cual+"e4.css";
	//Hoja de estilos para Pc según navegador
	Pc_n4 = "/estilosM/netscape/"+cual+"n4.css";
	Pc_e4 = "/estilosM/explorer/"+cual+"e4.css";		
	if (esMac != -1){
	        document.write("<link rel='stylesheet' href='" + plat_mac + "' type='text/css'>");
	}
	else{
		if (bIsOk){
		   document.write("<link rel='stylesheet' href='" + Pc_e4 + "' type='text/css'>");
		}else{
		   document.write("<link rel='stylesheet' href='" + Pc_n4 + "' type='text/css'>");
		}
	}
}
//Escribo plantilla (no puedo usar selecciona porque es distinta ruta)
plat_mac = "/estilos/plantillae4.css";
Pc_n4 = "/estilos/plantillan4.css";
Pc_e4 = "/estilos/plantillae4.css";	
if (esMac != -1){
  	document.write("<link rel='stylesheet' href='" + plat_mac + "' type='text/css'>");
}
else{
	if (bIsOk){	   
	   document.write("<link rel='stylesheet' href='" + Pc_e4 + "' type='text/css'>");
	}else{
	   document.write("<link rel='stylesheet' href='" + Pc_n4 + "' type='text/css'>");
	}
}
function overTD(td,color){td.style.cursor='hand';td.bgColor=color;}
function outTD(td,color){td.style.cursor='default';td.bgColor=color;}
function clickTD(td){td.children.tags('A')[0].click();}
function MM_openBrWindow(theURL,winName,features) {
window.name='principal';
window.open(theURL,winName,features);
}
function cambiar(objeto) { //v4.0
	valor = objeto.options[objeto.selectedIndex].value;
	if(valor.indexOf("viapolis.com") > 0) {
		window.document.location = "/vizcaya/ocio/redirect.html";
	} else {
		if(valor) {
			window.document.location = valor;
		}
	}
}
function cambioWebCam(ciudadwebcam) { window.document.location = "/vizcaya/ocio/redirect.html"; }
function Imprimir() {
      var direccion = '/interactivo/imprimir/imprimir.php?url=' + document.URL;
      newWindow = window.open(direccion, 'Imprimir', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=420');
}
function abrir(){
      var direccion = '/interactivo/enviar_amigo/enviar_amigo.php?dir=' + document.URL;
      newWindow = window.open(direccion, 'Enviar', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=490,height=540');
}
function Enviar(){
      var direccion = '/interactivo/enviar_amigo/enviar_amigo.php?dir=' + document.URL;
      newWindow = window.open(direccion, 'Enviar', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=490,height=540');
}


/*
	DE AQUI PARA ABAJO COOKIES
*/
// Variables para Cookies
var quiere_info;
var dias_semana = Array('domingo', 'lunes', 'martes', 'miercoles', 'jueves', 'viernes', 'sabado');
var meses = Array('enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre');

// Funciones para Cookies
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}
function grabar_info(nombre, dato) {
    tope = new Date();
    fixDate(tope);
    tope.setTime(tope.getTime() + 1000 * 60 * 60 * 24);
    setCookie(nombre, dato, tope);
}
function recuperar_info(nombre) {
    quiere_info = getCookie(nombre);
	if(!quiere_info) {
		quiere_info = "";
	}
}
function recuperar_info_auto(nombre) {
    quiere_info = getCookie(nombre);
	if(!quiere_info) {
		quiere_info = "";
	}
}

function confirmar(frase, numero){
	var fecha = new Date();
	dia = fecha.getDay();
	mes = fecha.getMonth();
	nombre_dia = dias_semana[dia];
	nombre_mes = meses[mes];
	if(numero == 2) {
		nombre_variable = "quiere_ekoplaneta";
		url_abrir = "/ekoplaneta/datos/galerias_popup/" + nombre_mes + "/" + nombre_mes + ".htm";
		ancho = 250;
		alto = 420;
		n_scrollbars=0;
	} else if(numero == 3) {
		nombre_variable = "quiere_ciclista";
		url_abrir = "/canalciclista/datos/ciclistaweb/especiales/ebizikleta/alminuto_popup/alminuto0.htm";
		ancho = 439;
		alto = 450;
		n_scrollbars=1;
	} else if(numero == 4) {
		nombre_variable = "quiere_planetfutbol";
		var url_perl = window.location.href;
		if(url_perl.indexOf("lasprovincias") > 1) {
		 	url_abrir = "http://planetfutbol.lasprovincias.es/planetfutbol/datos/popup_planet/web/index.htm";
		} else {
			url_abrir = "/planetfutbol/datos/popup_planet/web/index.htm";
		}
		ancho = 487;
		alto = 375;
		n_scrollbars="no";
	} else if(numero == "ciclismo") {
		nombre_variable = "quiere_ciclista";
		url_abrir = "http://canalciclista.elcorreodigital.com/etapa_online/visor.htm";
		ancho = 490;
		alto = 450;
		n_scrollbars=1;
	}

	recuperar_info(nombre_variable);
	if(quiere_info != "yes" && quiere_info != "no") {
		if(confirm(frase)) {
			grabar_info(nombre_variable, "yes");
			open(url_abrir,'popup_info','toolbar=no,width='+ancho+',height='+alto+',left=500,top=200,screenX=500,screenY=200,status=no,scrollbars='+n_scrollbars+',resizable=yes');
		} else {
			grabar_info(nombre_variable, "no");
		}
	} else {
		if(quiere_info == "yes") {
			open(url_abrir,'popup_info','toolbar=no,width='+ancho+',height='+alto+',left=500,top=200,screenX=500,screenY=200,status=no,scrollbars='+n_scrollbars+',resizable=yes');
		}
	}
}

function confirma(frase, numero){ confirmar(frase, numero); }
function confirma_sinnada(frase, numero) { confirmar(frase, numero); }

function personaliza(frase, numero) {
	var fecha = new Date();
	dia = fecha.getDay();
	mes = fecha.getMonth();
	nombre_dia = dias_semana[dia];
	nombre_mes = meses[mes];
	nombre_variable="personaliza";

    quiere_info = getCookie(nombre_variable);
	if(!quiere_info) {
		quiere_info = "no";
	}
	var url_abrir = "/interactivo/personalizar/contenido.htm";
	ancho = 500;
	alto = 450;
	n_scrollbars="no";

	if(quiere_info == "no") {
		open(url_abrir,'popup_info','toolbar=no,width='+ancho+',height='+alto+',left=500,top=200,screenX=500,screenY=200,status=no,scrollbars='+n_scrollbars+',resizable=yes');
		grabar_info(nombre_variable, "yes");
	}
}
// funciones fotonoticia: rotacion
var intTimeoutValue;
intTimeoutValue = 19000;
var intTimeoutID;
function Rota(){
        var fecha = new Date();
        var aleatorio = fecha.getSeconds() % nElementos;
        return ( arrayHTML[aleatorio] );
}
function Cambia(){
}

  function cargarPubliMethode(posicion) {
    if(navigator.userAgent.indexOf("Netscape/7.0") > -1) {
        bIsNS70 = true;
    }
    else {
        bIsNS70 = false;
    }
    var ie4 = document.all;
    var ns6 = document.getElementById;
    if (ie4 || ns6) {
        eval('var objOrigen = document.getElementById ? document.getElementById("publi2_' + posicion + '") : document.all.publi2_' + posicion + ';');
        eval('var objDestino = document.getElementById ? document.getElementById("publi1_' + posicion + '") : document.all.publi1_' + posicion + ';');
        if((objDestino != null) && (!bIsNS70))
                objDestino.appendChild(objOrigen);
        else
                objOrigen.style.display = "none";
    }
  }

  // FUNCIONES PARA PERSONLAIZACION DE HOYINVERSION

function personalizar() {
	var cook = getCookie_p("HOYINVERSION");
	if(cook != "" && cook != "undefined" && cook != null) {
		if(document.location.host != cook) {
			var protocol = document.location.protocol;
			var host = cook;
			var pathname = document.location.pathname;
			var hash = document.location.hash;
			var url = protocol + '//' + host + pathname + hash;
			//document.location.href = url;
		 }
	} else {
		var curCookie = "HOYINVERSION=elcorreodigital.hoyinversion.com; expires=Fri, 31-Dec-2010 00:00:00 GMT;path=/;domain=.hoyinversion.com";
		document.cookie = curCookie;
	}
}

function personalizar2() {
	var curCookie = "HOYINVERSION=elcorreodigital.hoyinversion.com; expires=Fri, 31-Dec-2010 00:00:00 GMT;path=/;domain=.hoyinversion.com";
	document.cookie = curCookie;
	personalizar();
}


function setCookie_p(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	document.cookie = curCookie;
	personalizar();
}
    	
function getCookie_p(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

personalizar2();

//Zooming
  var id_medio_zooming = "elcorreodigital";
  
  function ftvlaunch(video,quality,pid) {
	  var LeftPosition = (screen.width) ? (screen.width-665)/2 : 0;
	  var TopPosition = (screen.height) ? (screen.height-430)/2 : 0;
	  var popwin = window.open('http://videonoticias.vocento.com/videoplayer/index.cfm?id='+video+'&mode=normal&quality='+ quality +'&pid='+ pid,'MTV6_window','toolbar=no,width=665,height=430,top='+TopPosition+',left='+LeftPosition+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
      popwin.focus();
}

//Tour de France 2005 video player launch:

function tourlaunchNL(video,quality,pid,langid) {
	  var LeftPosition = (screen.width) ? (screen.width-648)/2 : 0;
	  var TopPosition = (screen.height) ? (screen.height-460)/2 : 0;
	  var popwin = window.open('http://videonoticias.vocento.com/tourdefrance2005/videoplayer/index.cfm?id='+video+'&mode=normal&quality='+ quality +'&pid='+ pid + '&lang='+ langid,'MTV6_window','toolbar=no,width=648,height=460,top='+TopPosition+',left='+LeftPosition+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
      popwin.focus();
}

function tourlaunch(video,quality,pid,langid) {
	switch(langid)
	{
		case "1":
			tourlaunchNL(video,quality,pid,"NL");
			break;
		case "2":
			tourlaunchBE(video,quality,pid,"BE");
			break;
	}
}

function tourlaunchBE(video,quality,pid,langid) {
	  var LeftPosition = (screen.width) ? (screen.width-665)/2 : 0;
	  var TopPosition = (screen.height) ? (screen.height-457)/2 : 0;
	  var popwin = window.open('http://videonoticias.vocento.com/tourdefrance2005/videoplayer/index.cfm?fuseaction=homebe&id='+video+'&mode=normal&quality='+ quality +'&pid='+ pid + '&lang='+ langid,'MTV7_window','toolbar=no,width=665,height=457,top='+TopPosition+',left='+LeftPosition+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
      popwin.focus();
}

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();

http.open('get', '/acceso.php?pag=' + window.document.location.href + '&resolucion=' + screen.width + 'x' + screen.height + '&r=' + Math.random());
http.send(null);

// http.open('get', '/resolucion.php?resolucion=' + screen.width + 'x' + screen.height + '&r=' + Math.random());
// http.send(null);