//Activacion de los submenus en IE

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload = startList;

/* Ajax Tabs Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code*/


var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadstatustext="<div style='color:#b2b8b9; font-size: 11px;'><img src='http://www.marca.com/imgs/home/cargando.gif' /> cargando ...</div>";

////NO NEED TO EDIT BELOW////////////////////////
var loadedobjects="";
var defaultcontentarray=new Object();
var bustcacheparameter="";

function ajaxpage(url, containerid, targetobj){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
var ullist=targetobj.parentNode.parentNode.getElementsByTagName("li")
for (var i=0; i<ullist.length; i++)
ullist[i].className=""  //deselect all tabs
targetobj.parentNode.className="selected"  //highlight currently clicked on tab
if (url.indexOf("#default")!=-1){ //if simply show default content within container (verus fetch it via ajax)
document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
return
}
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText;
}

function loadobjs(revattribute){
if (revattribute!=null && revattribute!=""){ //if "rev" attribute is defined (load external .js or .css files)
var objectlist=revattribute.split(/\s*,\s*/) //split the files and store as array
for (var i=0; i<objectlist.length; i++){
var file=objectlist[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel")){
ajaxpage(thetab.getAttribute("href"), thetab.getAttribute("rel"), thetab)
loadobjs(thetab.getAttribute("rev"))
}
}

function savedefaultcontent(contentid){// save default ajax tab content
if (typeof defaultcontentarray[contentid]=="undefined") //if default content hasn't already been saved
defaultcontentarray[contentid]=document.getElementById(contentid).innerHTML
}

function startajaxtabs(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
ulistlink.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
savedefaultcontent(ulistlink.getAttribute("rel")) //save default ajax tab content
ulistlink.onclick=function(){
ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)
loadobjs(this.getAttribute("rev"))
return false
}
if (ulist[x].className=="selected"){
ajaxpage(ulistlink.getAttribute("href"), ulistlink.getAttribute("rel"), ulistlink) //auto load currenly selected tab content
loadobjs(ulistlink.getAttribute("rev")) //auto load any accompanying .js and .css files
}
}
}
}
}

// =================================================================
// FLACCESS v1.3 LITE (c)2004 Sergi Meseguer (http://zigotica.com/)
// For DOM browsers only and builds always on the fly (on call)
// Released under Creative Commons ShareAlike license:
// http://creativecommons.org/licenses/by-sa/2.0/
// Check out http://meddle.dzygn.com/eng/tools/ or
// http://meddle.dzygn.com/esp/utilidades/ for further info

// Añadidos por Victor marca.com
// Reparado pequeño bug con las comillas en el código generado
// nuevo parametro permitido "allowFullScreen"
// Si el parámetro es flashVars permitir que todo lo demás sean parámetros dentro de los flashvars... esto evita problemas con urls absolutas del tipo http://
// =================================================================

// Set this variable to 1 if you want to alert intermediate steps:
var flaccess_debug;

function checkFlash(min){
	var version = 0;
	if(!min) min = 10;
	if (navigator.plugins)  {
		if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var desc = navigator.plugins["Shockwave Flash"].description;
			version = parseInt(desc.substring(16));
		}
		else if(navigator.appVersion.indexOf("MSIE")>-1){
			// loop by Geoff Stearns (geoff@deconcept.com, http://blog.deconcept.com/)
			result = false;
	   		for(var i = min; i >= 3 && result != true; i--){
	    			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
				version = i;
			}
		}
	}
	return version;
}

function addFlash(minversion,path,width,height,node) {
	if(!document.getElementById) return false;

	// defining arguments (from arguments array) in object and embed elements:
	var minargs = 5;
	var objpars = '<param name="movie" value="'+path+'">';
	var empars = ' src="'+path+'" ';
	var align = '';
	var flashid = '';
	var salign = '';
	var flvars = '';
	var allowedObjParams = ["menu","play","quality","scale","devicefont","bgcolor","wmode","salign","base","allowfullscreen"];
	var allowedEmbParams = ["menu","play","quality","scale","devicefont","bgcolor","wmode","base","swliveconnect","allowfullscreen"];

	for(var op=parseInt(arguments.length);op>minargs;op--) {
		var tmp = arguments[op-1].split(":");
		var tmpname = tmp[0]
		// Añadido
		if(tmpname.toLowerCase() == "flashvars") {

			var tmpvalue = arguments[op-1].slice(10,-1);

			} else {
			var tmpvalue = tmp[1];
		}

		//
		if(allowedObjParams.indexOf(tmpname.toLowerCase()) >-1) {
			objpars += '<param name="'+tmpname+'" value="'+tmpvalue+'">';
		}
		if(allowedEmbParams.indexOf(tmpname.toLowerCase()) >-1) {
			empars += ' '+tmpname+'="'+tmpvalue+'" ';
		}
		if(tmpname.toLowerCase() == "align") {
			align = ' align="'+tmpvalue+'" ';
		}
		if(tmpname.toLowerCase() == "salign") {
			salign = ' salign="'+tmpvalue+'" ';
		}
		if(tmpname.toLowerCase() == "flashvars") {
			if(minversion>=6) flvars = tmpvalue;
			else alert("flashVars support was not available until flash version 6");
		}
	}


	if(checkFlash(minversion) >= minversion){
		if(flaccess_debug==1) alert("minimum flash " + minversion + " is ok, we have version " + checkFlash())

		// splits flash id and node id
		var col = node.split(",");
		var flid = col[0];
		var parentid = col[1];
		if(minversion>=6){
			if(flvars!='') flvars += '&';
			flvars += 'flid='+node;
			objpars += '<param name="flashvars" value="'+flvars+'">';
		}

		// flash object:
		var obj = '<object '+flashid+' id="'+flid+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" '+align+'>';
		obj += objpars;
		obj += '<embed src="'+path+'" name="'+flid+'" id="'+flid+'" width="'+width+'" height="'+height+'"  '+empars+' type="application/x-shockwave-flash" '+align+' '+salign;
		if(minversion>=6) obj += ' flashvars="'+flvars+'" ';
		obj += ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
		obj += '</object>'

		if(flaccess_debug==1) alert(" flid: " + flid + "\n\n" + obj);

		if(document.getElementById(parentid)) {
			document.getElementById(parentid).innerHTML = obj;
			document.getElementById(parentid).style.height = height+"px";
			document.getElementById(parentid).style.width = width+"px";
		}

	}
	else {
		if(flaccess_debug==1) alert("we have version " + checkFlash() + " and we needed flash " + minversion)
	}

}

// extending Array, by Aaron Boodman (youngpup.net):
Array.prototype.indexOf = function(foo) {
	for (var i = 0; i < this.length; i++)
	if (foo == this[i]) return i;
	return -1;
}


/* Mostrar y ocultar formatos de Radio Marca */
function toggleRadio () {
	var radio = document.getElementById('radiomarca');
	var formato = document.getElementById('formato');
	if (formato.style.display == "none") {
		radio.style.position = "relative";
		formato.style.display = "block";
		formato.style.position = "absolute";
		formato.style.top = "27px";
		formato.style.left = "0";
	} else {
		radio.style.position = "static";
		formato.style.display = "none";
	}
}
// Funciones para OJD
function contadorVideosOJD ( seccion, tag ) {
	var pixel = new Image();
	var contenido="";
	if(tag){
		contenido = seccion+ "/"+ tag ;
		pixel.src = "http://marca.ojdinteractiva.com/cgi-bin/ivw/CP/"+contenido +";";
	} else {
		tag = seccion;
		pixel.src = "http://marca.ojdinteractiva.com/cgi-bin/ivw/CP/videos/"+tag +";";
	}
}
/* Leer y pasar cookie a la consola multimedia */
<!--
function leerCookie( name ) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
	var c = ca[i];
	while (c.charAt(0)==' ') {
		c = c.substring(1,c.length);
	}
 	if (c.indexOf(nameEQ) == 0) {
		return c.substring(nameEQ.length,c.length);
 	}
}
 return null;
};


function consolaMultimedia_DoFSCommand (command, args) {
  if ( command == "leerCookie" ) {
    	var objConsola = parent.InternetExplorer ? window.consolaMultimedia : window.document.consolaMultimedia;
  		var respuesta = leerCookie('GeoIP-country');
		if ( respuesta == "SPAIN" ){
			//	alert('lo pillo '+ command + ' >responde: '+ leerCookie('GeoIP-country')+ ' y va para '+ objConsola );
			objConsola.SetVariable ("SPAIN" ,"true") ;
		//	objConsola.SetVariable ("SPAIN_js" ,"true_js") ;
		} else if (respuesta == "NO_SPAIN" ){
				objConsola.SetVariable ("SPAIN" ,"false") ;
			//	objConsola.SetVariable ("SPAIN_js" ,"false_js") ;
			//	alert('lo pillo y eres de fuera '+ command + ' >responde: '+ leerCookie('GeoIP-country') );

		} else {

			//	alert('no lo pillo '+ command + ' >responde: '+ leerCookie('GeoIP-country') );

		}
		//objConsola

	}
 }
//-->

/* Este Script genera una ventana nueva con el flashVideo ampliado piezaTV*/
function fullFlashWindow( video, nombre ) { //v1.0
	var width= screen.width;
	var height=screen.height;
	var theURL = "http://www.marca.com/videos/piezaTV2.swf"+video;
	var features = 'scrollbars=0,width='+width+',height='+height+';';
	var ventanaFlash = window.open('',"zoom",features);

  ventanaFlash.document.write('<html><head><title>Zoom VÃ­deo</title>');
  ventanaFlash.document.write('<style>* {margin: 0;padding: 0;}</style>');
  ventanaFlash.document.write('</head><body>');

  if (window.ActiveXObject)
{

// browser supports ActiveX
// Create object element with
// download URL for IE OCX

	ventanaFlash.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	ventanaFlash.document.write(' codebase="http://download.macromedia.com');
	ventanaFlash.document.write('/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	ventanaFlash.document.write(' width="100%" height="100%" id="fullScreenSWF">');
	ventanaFlash.document.write(' <param name="movie" value="' + theURL + '" />');
	ventanaFlash.document.write(' <param name="quality" value="high" />');
	ventanaFlash.document.write('<param name="menu" value="false" />');
	ventanaFlash.document.write(' <param name="swliveconnect" value="true" />');
	ventanaFlash.document.write('<\/object>');

} else {

// browser supports Netscape Plugin API

	ventanaFlash.document.write('<object id="fullScreenSWF" data="'+theURL+'"');
	ventanaFlash.document.write(' type="application/x-shockwave-flash"');
	ventanaFlash.document.write(' width="100%" height="100%">');
	ventanaFlash.document.write('<param name="movie" value="'+ theURL +'" />');
	ventanaFlash.document.write('<param name="quality" value="high" />');
	ventanaFlash.document.write('<param name="menu" value="false" />');
	ventanaFlash.document.write('<param name="swliveconnect" value="true" />');
	ventanaFlash.document.write('<p>Necesita Flash para ver este contenido.');
	ventanaFlash.document.write(' Obtenga flash desde esta direcciÃ³n');
	ventanaFlash.document.write(' <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">click aquÃ­<\/a>.');
	ventanaFlash.document.write('<\/p>');
	ventanaFlash.document.write('<\/object>');
}
  ventanaFlash.document.write('</body></html>');
}


// TAG DE PUBLICIDAD
<!--
//configuration



var ANAJS_Date = new Date();
var ANAJS_ms = ANAJS_Date.getTime();

document.write('<SC' + 'RIPT LANGUAGE=JavaScript1.1 SRC="' + 'http://anajs.marca.com/' + 'anajsmultiple/' + 'marca' + '/1' + ANAJS_ms.toString() + '@portada_int,portada728,portada300,portada200x90,portada200x90b,portada220x135,portada220x200,portada220x45a,portada220x45b,portada380x70,portada750x90,portada91x14b,portada91x14?' + '"></SCRIPT>');
document.write('<SC' + 'RIPT LANGUAGE=JavaScript1.1 SRC="' + 'http://estaticos.marca.com/js/comunes.js' + '"></SCRIPT>');

function ANAJS_Publicidad(pos) {
  if ('undefined' != typeof(ANAJS_Served)) {
    var PositionTmp = 'portada' + pos;
    if ('pr640' == pos) {
        PositionTmp = pos;
    }
    var Creativity = ANAJS_Served(PositionTmp);
    if ('undefined' == typeof(Creativity)) {
      Creativity = "<!-- Position: " + pos + " doesn't exists on this page -->";
    }
    document.write(Creativity);
  }
}



//-->

// Listener para el multitema
function listenerMultitema () {
	var sUserAgent = navigator.userAgent;
	var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1;

	var oDiv = document.getElementById("navMultitema");
	var enlaces = oDiv.getElementsByTagName('a');

	if (isIE) {
		for (i=0; i<enlaces.length; i++) {
			enlaces[i].attachEvent("onclick", ojdMultitema);
		}
	} else {
		for (i=0; i<enlaces.length; i++) {
			enlaces[i].addEventListener("click", ojdMultitema, false);
		}
	}
}
function ojdMultitema () {
	var tag = new Image();
	tag.src = "http://marca.ojdinteractiva.com/cgi-bin/ivw/CP/multitema;";
}

// Javascript para el buscador


		function cambiarColor (id) {
			var elemento = document.getElementById(id);		
			elemento.style.background = "#f9f9f9";
			elemento.style.border = "1px solid #000";
			elemento.style.color = "#000";
		}
		function restauraColor (id) {
			var elemento = document.getElementById(id);
			elemento.style.background = "#FFFFFF";
			elemento.style.border = "1px solid #999";
			elemento.style.color = "#333";
			document.getElementById("txtW").value = escape(document.getElementById("q").value);
		}
	
function ss(w){window.status=w;return true;}
function cs(){window.status='';}






function formAction(valor) {

var myForm = document.formulariobusqueda1;
if (valor == "marca") {
myForm.action = "http://www.marca.com/rec-templating/templates/marca/cmp/buscador.jsp";
document.getElementById("txtW").value = escape(document.getElementById("q").value);
} else {
myForm.action = "http://cgi.marca.com/buscador/buscador_marca.html?q=" + document.getElementById("q").value + "&num=10&sa=Buscar&searchselector=0"
}

myForm.action = "http://www.marca.com/rec-templating/templates/marca/cmp/buscador.jsp";
document.getElementById("txtW").value = escape(document.getElementById("q").value);
 
}







function estableceFoco(){
document.formulariobusqueda1.q.focus();
}

function hiddenSubmit() {
var miFormulario = document.createElement("form");
miFormulario.name = "fmMarca";
miFormulario.method = "POST";
miFormulario.action = "http://www.marca.com/rec-templating/templates/marca/cmp/buscador.jsp";
var miHidden = document.createElement("input");
miHidden.name = "txtW";
miHidden.type = "hidden";
miHidden.value = "";
miFormulario.appendChild(miHidden);
document.body.appendChild(miFormulario);
miFormulario.submit();
}



//-->

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


