CABECERAPLUS = {
	inicio : function() {
		var recordatorioClave = document.getElementById('recordatorioClave');
		if (recordatorioClave)
			recordatorioClave.onclick = CABECERAPLUS.abreRecordatorio;
			//enlace.addEventListener("click",MENUCNN.alerta,false);
		var opcioneslogado = document.getElementById('selectopcioneslogado');
		if (opcioneslogado) {
			opcioneslogado.onchange = CABECERAPLUS.mandame;
		}
		// Esto es sólo de la portada
		var selectYAdemas = document.getElementById('selectYAdemas');
		if (selectYAdemas) {
			selectYAdemas.onchange = CABECERAPLUS.mandame;
		}
		// Huevos de pascua de los inicios
		var progragrameitors = document.getElementById('progragrameitors');
		if (progragrameitors)
			progragrameitors.onclick = function() { window.open('/codigo/television/pr.asp','Pr','width=250,height=289,toolbar=no,location=no,status=no,titlebar=no,directories=no,menubar=no,scrollbars=no,resizable=no,top=50,left=300') };
		var disenieitors = document.getElementById('disenieitors');
		if (disenieitors)
			disenieitors.onclick = function() { window.open('/codigo/television/ds.asp','Ds','width=250,height=289,toolbar=no,location=no,status=no,titlebar=no,directories=no,menubar=no,scrollbars=no,resizable=no,top=50,left=300') };

		// Evitar que se pueda seleccionar un elemento vacío
		var destacados1 = document.getElementById('destacados1');
		var destacados2 = document.getElementById('destacados2');
		if (destacados1)
			destacados1.onsubmit = CABECERAPLUS.sinVacios;
		if (destacados2)
			destacados2.onsubmit = CABECERAPLUS.sinVacios;
	},

	abreRecordatorio : function() {
		window.open(this.href,'recordatorio','width=300,height=300,scrollbars=0,resizable=no');
		return false;
	},
	mandame : function (e) {
		/* Conseguimos el nodo que recibe el evento */
		if (window.event && window.event.srcElement) {
			/* El Explorer como siempre a su bola incompatible con todo */
			oSelect = window.event.srcElement
		}
		else if (e && e.target) {
			/* Mozilla y Opera */
			oSelect = e.target;
		}
		
		//alert("Recuperar el elemento que recibe el foco "+oSelect.nodeName);
		// si el elemento seleccionado no está vacio se envia el formulario
		if (oSelect.options[oSelect.selectedIndex].value != '')
		{
			oSelect.form.submit();
		}
		
		//alert("logado"+opcioneslogado.form.action);
	},
	sinVacios: function() {
		//if (this.url.value == '')
		if (this.url.selectedIndex == 0) {
			alert ('No has seleccionado ningún elemento');
			return false;
		}
		else {
			//alert (this.url.value + ' '+this.url.selectedIndex);
			return true;
		}
	}
//a href="/codigo/television/pr.asp" onclick="window.open('/codigo/television/pr.asp','Pr','width=250,height=289,toolbar=no,location=no,status=no,titlebar=no,directories=no,menubar=no,scrollbars=no,resizable=no,top=50,left=300'); return false; " 
}

// ----------------------
/* Para añadir eventos */
 EXTRAS = {

	// Event listener by Scott Andrew (www.scottandrew.com):
	addEvent : function(obj, evType, fn, useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		}
		else {
			return false;
		}
	},

	// Method adapted from Dan Pupius (pupius.co.uk):
	getElementsByClass : function(className,node) {
		if(!node) node=document;
		var refTags = document.all ? node.all : node.getElementsByTagName("*");
		var retVal = new Array();
		for(var z=0;z<refTags.length;z++) {
			if(refTags[z].className == className)
			retVal.push(refTags[z]);
		}
		return retVal;
	}
}


// adds 1 or more elements to an array (IE only)
if(!Array.prototype.push)
{
	Array.prototype.push =  function()
	{
		var i;
		for(i=0; j=arguments[i]; i++) this[this.length] = j;
		return this.length;
	}
}

// ==============================================================
// Crossbrowser Get computed styles
// (c)2004 Sergi Meseguer http://zigotica.com/ under CC license:
// http://creativecommons.org/licenses/by-sa/2.0/
// ==============================================================
var  CSS = {
	setStyle : function(node,rule,value){
		if(typeof(node)=="string")  node = document.getElementById(node);
		node.style[rule] = value;
	},

	getStyle : function(node,rule){
		if(typeof(node)=="string")  node = document.getElementById(node);
		if(rule=="width") return CSS.getW(node);
		else if(rule=="height") return CSS.getH(node);
		else {
			if (window.getComputedStyle) return window.getComputedStyle(node, null)[rule];
			else return node.currentStyle[rule];
		}
	},

	getH : function(node){
		if(typeof(node)=="string")  node = document.getElementById(node);
		return node.offsetHeight;
	},

	getW : function(node){
		if(typeof(node)=="string")  node = document.getElementById(node);
		return node.offsetWidth;
	}
}



/* Reemplazo de los target="_blank" */

EXTERNALLINKS = {
	start : function() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") &&
				anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		}
	}
}

if (document.getElementsByTagName) EXTRAS.addEvent(window, 'load', EXTERNALLINKS.start, false);
EXTRAS.addEvent(window, 'load', CABECERAPLUS.inicio, false);
