if(window.attachEvent){
	window.attachEvent("onload" , function(){starter();});
}else if(window.addEventListener){
	window.addEventListener("load" , function(){starter();} , false);
}


function starter(){
	//Funci?n en que se llaman a todas aquellas funciones necesarias al iniciar la p?gina (eventos etc.)
	makeBackLinks();
	makePopUps();
	checkSwf();
	//takeElements();
	noticiasEFE();
	setFocus();
}


function setFocus(){
	if($("loginForm")){
		$("loginInput").focus();
	}

}

function makeBackLinks(){
	if(oContainer = $("backLink")){
		oText = oContainer.getElementsByTagName("span")[0].childNodes;
		oLink = document.createElement("a");
		oLink.href="#backLink";
		oLink.title="Volver";
		if(window.attachEvent){
			oLink.attachEvent("onclick", function(){history.back();return false;});
		}else if(window.addEventListener){
			oLink.addEventListener("click" , function(e){history.back();e.preventDefault();} , false);
		}
		oLink.appendChild(oText[0]);
		removeAllChilds(oContainer);
		oContainer.appendChild(oLink);
	}
}


function makePopUps(){
	oLinks = $$("a");
	rexp = new RegExp(/\bpopup+\b/);
	for(i=0;i<oLinks.length;i++){
		// if(oLinks[i].className == "popUp"){
		if(oLinks[i].className.match(rexp)){
			if(window.attachEvent){
				oLinks[i].attachEvent("onclick", function(e){windowPop(e); return false;});
			}else if(window.addEventListener){
				oLinks[i].addEventListener("click" , function(e){windowPop(e); e.preventDefault(); } , false);
			}
		}
	}
}


function windowPop(){
	if(arguments[0]){
		oElement = arguments[0].target ? arguments[0].target : arguments[0].srcElement;
		//oElement = arguments[0].srcElement;
	}
	while(oElement.nodeName != "a" && oElement.nodeName != "A"){
		oElement = oElement.parentNode;
	}
	window.open(oElement.href, oElement.target);
	//return false;
}

/*function takeElements(){
	objs = $$("li.sup");//$("navContainer").$$("li.sup");
	for(var i=0;i<objs.length;i++){
//		if(objs[i].className.match(new RegExp("sup"))){
			objs[i].onmouseover = function(){this.getElementsByTagName("ul")[0].className="";}
			objs[i].onmouseout = function(){this.getElementsByTagName("ul")[0].className="noDsp";}//className=this.className.replace(new RegExp(" sfhover\\b"), "");};
			
			objs[i].onfocus = function(){this.getElementsByTagName("ul")[0].className="";}
			objs[i].onblur = function(){this.getElementsByTagName("ul")[0].className="noDsp";}

	//	}
	}
}*/

function noticiasEFE(){
	if ($("newsEFE")) {
		var myEfe=$("newsEFE");
		var myAppletEfe='<applet codebase="http://efe.es/ticker/" code="ticker4_v2.class" width="100%" height="40">';
		myAppletEfe+='<p><a href="http://www.efe.com" title="'+myTitleNewsEfe+'">'+myLinkNewsEfe+'</a></p>';
		myAppletEfe+='<param name="ZONA" value="X-ENERGIA"><param name="PARADA" value="60"><param name="FONDO" value="255 255 255"><param name="TEXTO" value="0 0 0"><param name="TEMA_TEXT_COLOR" value="200 200 255"><param name="TEMA_FONT" value="arial"><param name="TEMA_FONTSIZE" value="10"><param name="TEMA_FONTSTYLE" value="1">';
		myAppletEfe+='</applet>';
		myEfe.innerHTML=myAppletEfe;
	}//end if
}//end function


function checkSwf(){
	if($("energlobal")){
		var so = new SWFObject("/img/Image/bannerEnerglobal.swf", "sotester", "190", "90", "5", "#fff");
		so.addParam("wmode","opaque")
		so.write("energlobal");
	}
}

/* ------------- Funciones Dom ---------------- */

function removeAllChilds(container){
	for(i=0;i<container.childNodes;i++){
		container.removeChild(container.childNodes[i]);
	}
}

/* ----------- Fin Funciones Dom -------------- */