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;
	if(mi_url.indexOf("otro_contenido") > -1) {
		cual = 'articulos_rioja';
	}

	//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';
if(theURL == 'http://www.larioja.com/centrocomercial/'){
window.open(theURL,winName,features + ', scrollbars=yes');
}else{
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 = "/ocio/redirect.html";
        } else {
                if(valor) {
                        window.document.location = valor;
                }
        }
}

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');
}
// Abre ventana nueva a partir de un SELECT
function ir(objeto) {
	var peich = objeto.options[objeto.options.selectedIndex].value;
	nueva = window.open(peich);
}
function cambioWebCam(ciudadwebcam) {
	var url='http://'+ ciudadwebcam +'.viapolis.com/webcams.htm?webcam=' + ciudadwebcam;
	ventana=window.open(url,'WEBCAM','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=770,height=570,screenX=50,screenY=50');
}

// 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(){
        var newdata;
        var str;
        if (document.all)
                {
                        document.all.item('aleat').innerHTML = Rota();
                        window.clearTimeout(intTimeoutID);
                        intTimeoutID = window.setTimeout('Cambia();', intTimeoutValue);
                        str = "try{newdata = new ActiveXObject('msxml');newdata.URL = aSeccion[Seccion()];}catch(e){}";
                        eval(str);
                }
}

  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";
    }
  }
