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) {	
	var mi_url = document.location.href;
	
	//Hoja de estilos para Mac
	plat_mac = "http://www.ideal.es/estilosM/explorer/"+cual+"e4.css";
	//Hoja de estilos para Pc según navegador
	Pc_n4 = "http://www.ideal.es/estilosM/netscape/"+cual+"n4.css";
	Pc_e4 = "http://www.ideal.es/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 = "http://www.ideal.es/estilos/plantillae4.css";
Pc_n4 = "http://www.ideal.es/estilos/plantillan4.css";
Pc_e4 = "http://www.ideal.es/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 || valor.indexOf("212.0.125.86") > 0) {
                window.document.location = "http://www.ideal.es/granada/ocio/redirect.html";
        } else {
                if(valor) {
                        window.document.location = valor;
                }
        }
}

function Imprimir() {
      var direccion = 'http://www.ideal.es/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 = 'http://www.ideal.es/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 = 'http://www.ideal.es/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');
}
// Abre ventana nueva a partir de un SELECT
function ir(objeto) {
	var peich = objeto.options[objeto.options.selectedIndex].value;
	nueva = window.open(peich);
}

// 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 = "";
	}
}
// 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";
    }
  }

//Zooming
  var id_medio_zooming = "ideal";
  
  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);

//FUNCIONES EUROSPORT
function getRightMediaCenterSwf(appName,layoutDomain,urlFlux,curdomain,colorparam,fs,partner,refpartner)
{
fontsystem = (fs!=null?fs:'0');
document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"100%\" height=\"100%\" id=\"videocenter\" align=\"middle\">');
document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
document.write('<param name=\"movie\" value=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner +"&init="+urlFlux+"&dom=" + curdomain + '&fs=' + fontsystem + '\" />');
document.write('<param name=\"quality\" value=\"high\" />');
document.write('<param name=\"wmode\" value=\"transparent\" />');
document.write('<param name=\"bgcolor\" value=\"#dcddde\" />');
document.write('<param name=\"swliveconnect\" value=\"true\" />');  
document.write('<param name=\"menu\" value=\"false\" />'); 
document.write('<embed src=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner +"&init="+urlFlux+"&dom="+curdomain + '&fs=' + fontsystem + '\" quality=\"high\" bgcolor=\"#dcddde\" width=\"100%\" height=\"100%\" name=\"videocenter\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\"/>');
document.write('</object>');
}

function getLiveBoxSwf(appName,layoutDomain,urlFlux,colorparam,fontSystem,bf,partner,refpartner)
{
bigfont = (bf!=null?bf:'0');
document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"100%\" height=\"100%\" id=\"livescore" + partner + "\" align=\"top\">');
document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
document.write('<param name=\"movie\" value=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner + "&nav=1&init="+urlFlux+colorparam+fontSystem+'&cn='+bf+'\" />');
document.write('<param name=\"quality\" value=\"high\" />');
document.write('<param name=\"wmode\" value=\"transparent\" />');
document.write('<param name=\"scale\" value=\"noscale\" />');
document.write('<param name=\"bgcolor\" value=\"#ffffff\" />');
document.write('<param name=\"swliveconnect\" value=\"true\" />');
document.write('<param name=\"menu\" value=\"false\" />');
document.write('<embed src=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner + "&nav=1&init="+urlFlux+colorparam+fontSystem+'&cn='+bf+'\" quality=\"high\" scale=\"noscale\" bgcolor=\"#ffffff\" width=\"100%\" height=\"100%\" name=\"livescore\" align=\"top\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\"  swliveconnect=\"true\" menu=\"false\"/>');
document.write('</object>');
}

function getNewsSwf(appName,layoutDomain,urlFlux,curdomain,colorparam,fs,partner,refpartner)
{
fontsystem = (fs!=null?fs:'0');
document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"100%\" height=\"100%\" id=\"videocenter\" align=\"middle\">');
document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
document.write('<param name=\"movie\" value=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner +"&init="+urlFlux+"&dom=" + curdomain + '&fs=' + fontsystem + '\" />');
document.write('<param name=\"quality\" value=\"high\" />');
document.write('<param name=\"wmode\" value=\"transparent\" />');
document.write('<param name=\"bgcolor\" value=\"#dcddde\" />');
document.write('<param name=\"swliveconnect\" value=\"true\" />');  
document.write('<param name=\"menu\" value=\"false\" />'); 
document.write('<embed src=\"'+layoutDomain+"/"+appName+"?refpartner=" + refpartner + "&partner=" + partner +"&init="+urlFlux+"&dom="+curdomain + '&fs=' + fontsystem + '\" quality=\"high\" bgcolor=\"#dcddde\" width=\"100%\" height=\"100%\" name=\"videocenter\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\"/>');
document.write('</object>');
}
//FIN FUNCIONES EUROSPORT
