var ChangeCss={
	load:function(){
		var ostyle="<style type='text/css'>"
		var cssStrings="#menuSuperior ul li ul li{visibility:hidden}";
		var cstyle="</style>"
		document.write(ostyle+cssStrings+cstyle)
	}
};ChangeCss.load();

var W3CDOM = (document.createElement && document.getElementsByTagName);

document.getElementsByClassName = function(className, container){
   var data = tags = [];
   var obj = document.getElementById("wrapper");
   var node = aux = null;
	var strClassName = className.replace(/\-/g, "\\-");
    var pattern = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	if(container) node = (typeof(container) == "object") ? container : document.getElementById(container);
	else node = (obj) ? obj : document;
	aux = node.getElementsByTagName("*");
	tags = (document.all) ? node.all : aux;
   for(var i=0;i<tags.length;i++) { if(pattern.test(tags[i].className)) data.push(tags[i]);}
   return data;
}


var e = {
	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;
		}
	}
}

var behaviours = {	
	borraCampo:function(id){
		document.getElementById(id).onfocus=function(){
			document.getElementById(id).value=""
		}
	},
	showComments:function(){
		var f = document.getElementById("sendComment");
		var t = document.getElementById("sendComment").style.display
		if(t=="none") f.style.display="";
		else f.style.display="none";
	},
	resetInputs:{
		obj:null,
		init:function(){
			behaviours.resetInputs.obj = document.getElementById("uploadvideo");
			var button = behaviours.resetInputs.obj.getElementsByTagName("button")[0];
			button.onclick = behaviours.resetInputs.action;
		},
		action:function(){
			var selects = behaviours.resetInputs.obj.getElementsByTagName("select");
			var textareas = behaviours.resetInputs.obj.getElementsByTagName("textarea");
			var inputs = behaviours.resetInputs.obj.getElementsByTagName("input");
			for(var i = 0; i < inputs.length; i++){
				if(inputs[i].type == "text") inputs[i].value = ""; 
			}
			for(var i = 0; i < textareas.length; i++) textareas[i].value = "";
			for(var i = 0; i < selects.length; i++) selects[i].selectedIndex = 0;
		}
	},
	add:{
		cont:2,
		cont2:2,
		objInsert:null,
		objInsert2:null,
		init:function(){
			var linkVideo = document.getElementsByClassName("typeVideo", "uploadvideo");
			var linkImagen = document.getElementsByClassName("typeImagen", "uploadvideo");
			var obj = obj2 = null;
			if(linkVideo != 0){
				obj = linkVideo[0].getElementsByTagName("a")[0];			
				behaviours.add.objInsert = document.getElementsByClassName("insertVideo", "uploadvideo")[0];
				obj.href = "javascript:void(null)";
				obj.onclick = function(){
					behaviours.add.action();
					return false;
				}
			}
			if(linkImagen != 0){
				obj2 = linkImagen[0].getElementsByTagName("a")[0];
				behaviours.add.objInsert2 = document.getElementsByClassName("insertImagen", "uploadvideo")[0];
				obj2.href = "javascript:void(null)";
				obj2.onclick = function(){
					behaviours.add.action2();
					return false;
				}
			}
		},
		action:function(){
			var label = behaviours.add.createMedia("video");
			behaviours.add.objInsert.appendChild(label);
			behaviours.add.cont++;
		},
		action2:function(){
			var label = behaviours.add.createMedia("imagen");
			behaviours.add.objInsert2.appendChild(label);
			behaviours.add.cont2++;
		},
		createMedia:function(type){
			var label = document.createElement("label");
			var input = document.createElement("input");
			var span = document.createElement("span");
			var txt = (type == "video") ? literal["video"] + " " + behaviours.add.cont : literal["imagen"] + " " + behaviours.add.cont2;
			span.appendChild(document.createTextNode(txt));
			input.type = "file";
			input.className = "text examinar";
			input.name = (type == "video") ? "video" + behaviours.add.cont : "imagen" + behaviours.add.cont2;
			label.appendChild(span);
			label.appendChild(input);
			return label;			
		}
	}
}






/* validaciones de formularios */
var formsValidations = {	
	setMsgError:function(txt, form){
		var parentForm = form.parentNode;		
		var msgError = document.getElementsByClassName("msgError", parentForm);
		var divElement = (msgError.length != 0) ? msgError[0] : document.createElement("div");		
		var ulElement = document.createElement("ul");
		var liElement = null;		
		var errors = txt.split("|");				
		divElement.className = "msgError"
		if(divElement.getElementsByTagName("ul").length != 0) divElement.removeChild(divElement.getElementsByTagName("ul")[0])
		for(var i = 0; i < errors.length - 1; i++){
			liElement = document.createElement("li");
			liElement.appendChild(document.createTextNode(errors[i]));
			ulElement.appendChild(liElement);
		}
		divElement.appendChild(ulElement);		
		divElement.tabIndex = -1;
		if(msgError.length == 0) parentForm.insertBefore(divElement,form);
		divElement.focus();
	},

	logged:function(){
		var f = document.getElementById("login");
		var errorTxt = "";
		if(f.Login.value == "") errorTxt += literal["mail"];		
		else{			
			if(!regularExpressions.isValidEmail(f.Login.value))  errorTxt += literal["mail_formato"];			
		}
		if(f.Password.value == "") errorTxt += literal["pass"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("login"));
			return false;
		}

	},
	loginPressed:function(){
		var f = document.getElementById("loginPress");
		var errorTxt = "";
		if(f.mailloginPress.value == "") errorTxt += literal["mail"];		
		else{
			if(!regularExpressions.isValidEmail(f.mailloginPress.value))  errorTxt += literal["mail_formato"];				
		}
		if(f.passloginPress.value == "") errorTxt += literal["pass"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("loginPress"));
			return false;
		}	
	},
	registerednNewslettered:function(){
		var f = document.getElementById("registeredNewsletter");
		var errorTxt = "";

		if(f.nameReg.value == "") errorTxt += literal["nombre"];		
		if(f.apellidosReg.value == "") errorTxt += literal["apellidos"];		
		if(f.emailReg.value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(f.emailReg.value))  errorTxt += literal["mail_formato"]
		}
		//if(!f.conditions.checked || !f.conditions2.checked) errorTxt += literal["condiciones"];
		if(!f.conditions.checked) errorTxt += literal["condiciones"];		
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("registeredNewsletter"));
			return false;
		}	
	},		
	registeredPrensa:function(){
		var f = document.getElementById("registerPrensa");
		var errorTxt = "";
		if(f.nameReg.value == "") errorTxt += literal["nombre"];		

		if(f.apellidosReg.value == "") errorTxt += literal["apellidos"];		

		if(f.medioReg.value == "") errorTxt += literal["medio"];		
		if(f.seccionReg.value == "") errorTxt += literal["seccion"];		
		//if(f.cargoReg.value == "") errorTxt += literal["cargo"];		
		
		if(f.emailReg.value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(f.emailReg.value))  errorTxt += literal["mail_formato"]
		}
		
		
		if ((f.telefReg.value != "") && (!regularExpressions.esNumero(f.telefReg.value))) errorTxt += literal["telefono_formato"];

		
		/*
		if(f.telefReg.value == "") errorTxt += literal["telefono"];
		else{
			if(!regularExpressions.esNumero(f.telefReg.value))  errorTxt += literal["telefono_formato"];
		}	
		*/
		// if(f.direcReg.value == "") errorTxt += literal["direccion"];
		
		
		if(f.localidad.value == "") errorTxt += literal["localidad"];

		//if(!f.conditions.checked || !f.conditions2.checked) errorTxt += literal["condiciones"];
		if(!f.conditions.checked) errorTxt += literal["condiciones"];		
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("registerPrensa"));
			return false;
		}	
	},	
	registered:function(){
		/*var f = document.getElementById("register");*/
		var errorTxt = "";
		if(document.getElementById("nameReg").value == "") errorTxt += literal["name"];
		if(document.getElementById("lastNameReg").value =="") errorTxt += literal["apellidos"];
		if(document.getElementById("emailReg").value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(document.getElementById("emailReg").value))  errorTxt += literal["mail_formato"]
		}
		if(document.getElementById("passReg").value == "")errorTxt += literal["password"];
		if(document.getElementById("re_passReg").value == "") errorTxt += literal["re_password"];
		if(document.getElementById("nacionalidad").selectedIndex == 0) errorTxt += literal["nacionalidad"];
		//if(document.getElementById("localidad").value == "") errorTxt += literal["localidad"];
		if(document.getElementById("cp").value == "") errorTxt += literal["cp"];
		if(document.getElementById("fijo").value == "") errorTxt += literal["fijo"];		
		if(document.getElementById("year").selectedIndex == 0) errorTxt += literal["yearNac"];
		if(document.getElementById("month").selectedIndex == 0) errorTxt += literal["monthNac"];
		if(document.getElementById("day").selectedIndex == 0) errorTxt += literal["dayNac"];
		if(document.getElementById("male").checked =="" && document.getElementById("female").checked =="") errorTxt += literal["sex"];
		
		if(!document.getElementById("conditions").checked) errorTxt += literal["condiciones"];		
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("register"));
			return false;
		}	
	},
	register:function(){
		var errorTxt = "";

	    hoy = new Date();

	    // Comprobamos años
		if(document.getElementById("year").value != "" && document.getElementById("month").value != "" && document.getElementById("day").value){
		    edad = hoy.getFullYear() - document.getElementById("year").value;
	
		    // Comprobamos si los ha cumplido ya o no
		    if (document.getElementById("month").value > (hoy.getMonth() + 1)) edad--;
			else if(document.getElementById("month").value == (hoy.getMonth() + 1) 
					&& document.getElementById("day").value > hoy.getDate()) edad--;
		} else {
			edad = 0;
		}

		if(edad < 18) errorTxt += literal["edad_menor"];

		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("register"));
			return false;
		}	
	},
	areaPrivaded:function(){
		var f = document.getElementById("login_private");		
		var errorTxt = "";
		if(f.user_private.value == "") errorTxt += literal["usuario"];
		if(f.pwd_private.value == "") errorTxt += literal["pass"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("login_private"));
			return false;
		}			
	},
	getLogined:function(){
		var f = document.getElementById("getLogin");		
		var errorTxt = "";
		if(f.usuario.value == "") errorTxt += literal["usuario"];
		if(f.contrasena.value == "") errorTxt += literal["pass"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("getLogin"));
			return false;
		}			
	},	
	sendbannered:function(){
		var f = document.getElementById("sendbanner");		
		var errorTxt = "";
		
		if(f.name.value == "") errorTxt += literal["nombre"];
		if(f.mail.value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(f.mail.value))  errorTxt += literal["mail_formato"];
		}
		
		if (f.web.value !="")
		{
			if (f.web.value.indexOf("http:\/\/")== -1 ) errorTxt += literal["http_formato"];
			
		}
				
		//if(!f.conditions.checked || !f.conditions2.checked) errorTxt += literal["condiciones"];
		if(!f.conditions.checked) errorTxt += literal["condiciones"];		
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("sendbanner"));
			return false;
		}			
	},	
	sendCommented:function(){
		var f = document.getElementById("sendComment");		
		var errorTxt = "";
		

		if(f.msg.value == "") errorTxt += literal["mensaje"];
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("sendComment"));
			return false;
		}			
	},	
	contacted:function(){
		var f = document.getElementById("contact");		
		var errorTxt = "";
		if(f.nameall.value == "") errorTxt += literal["nombre"];
		if(f.email.value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(f.email.value))  errorTxt += literal["mail_formato"];
		}
		if(document.getElementById("asunto").selectedIndex == 0) errorTxt += literal["asunto"];

		if(!f.conditions.checked || !f.conditions2.checked) errorTxt += literal["condiciones"];

		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("contact"));
			return false;
		}					
	},
	uploadvideoed:function(){
		var f = document.getElementById("uploadvideo");
		var errorTxt = "";
		
		if(f.nameBeach.value == "") errorTxt += literal["nombre_playa"];
		
		if(f.powercontent_video_youtube_ContentObjectAttribute_ezstring_data_text_pcattributeid.value != "" && f.powercontent_video_flv_ContentObjectAttribute_data_videoflvfilename_pcattributeid.value != "" && f.powercontent_imagen_ContentObjectAttribute_data_imagename_pcattributeid.value != "" ) errorTxt += literal["video3"];
		else{
		
			if(f.powercontent_video_youtube_ContentObjectAttribute_ezstring_data_text_pcattributeid.value != "" && f.powercontent_video_flv_ContentObjectAttribute_data_videoflvfilename_pcattributeid.value != "") errorTxt += literal["video"];
		
			if(f.powercontent_video_youtube_ContentObjectAttribute_ezstring_data_text_pcattributeid.value != "" && f.powercontent_imagen_ContentObjectAttribute_data_imagename_pcattributeid.value != "") errorTxt += literal["video4"];
		
			if(f.powercontent_video_flv_ContentObjectAttribute_data_videoflvfilename_pcattributeid.value != "" && f.powercontent_imagen_ContentObjectAttribute_data_imagename_pcattributeid.value != "" ) errorTxt += literal["video5"];
		}
		
		if(f.powercontent_video_youtube_ContentObjectAttribute_ezstring_data_text_pcattributeid.value == "" && f.powercontent_video_flv_ContentObjectAttribute_data_videoflvfilename_pcattributeid.value == "" && f.powercontent_imagen_ContentObjectAttribute_data_imagename_pcattributeid.value == "" ) errorTxt += literal["video2"];
		
			
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("uploadvideo"));
			return false;
		}							
	},
	postAction:function(){
		var f = document.getElementById("uploadvideo");
		var errorTxt = "";		
		if(f.titulo.value == "") errorTxt += literal["newact.titNoticia"];
		if(f.fecha1.selectedIndex == 0 && f.fecha2.selectedIndex == 0) errorTxt += literal["newact.fechas"];
		else if(f.fecha1.selectedIndex == 0 && f.fecha2.selectedIndex != 0) errorTxt += literal["newact.fecha1"];
		else  if(f.fecha1.selectedIndex != 0 && f.fecha2.selectedIndex == 0) errorTxt += literal["newact.fecha2"]
		if(f.noticia.value == "") errorTxt += literal["newact.noticia"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("uploadvideo"));
			return false;
		}							
	},
	postNews:function(){
		var f = document.getElementById("uploadvideo");
		var errorTxt = "";		
		if(f.titulo.value == "") errorTxt += literal["newpost.titNoticia"];
		if(f.noticia.value == "") errorTxt += literal["newpost.noticia"];
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("uploadvideo"));
			return false;
		}							
	},
	uploadvideoed2:function(){
		errorTxt = "";
		
		if (document.getElementById("nameBeach").value == "") errorTxt += literal["nombre_playa"];
		if(load.existeId("linkVideo") && document.getElementById("linkVideo").value == "") errorTxt += literal["link_youtube"];
			
		if (errorTxt != "") {
			formsValidations.setMsgError(errorTxt, document.getElementById("uploadvideo2"));
			return false;
		}
	},
	uploadnoticiaed:function(){
		var f = document.getElementById("uploadnoticia");		
		var errorTxt = "";
		
		if(f.nameNew.value == "") errorTxt += literal["tit_noticia"];
		if(f.entraNew.value == "") errorTxt += literal["entradilla"];			
		if(f.comment.value == "") errorTxt += literal["descripcion"];
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("uploadnoticia"));
			return false;
		}		
	},
	registerPred:function(){
		var f = document.getElementById("registerPre");		
		var errorTxt = "";
		
		if(f.name.value == "") errorTxt += literal["nombre_pre"];
		if(f.surname.value == "") errorTxt += literal["apellidos_pre"];
		if(f.mail.value == "") errorTxt += literal["mail_pre"];
		else{
			if(!regularExpressions.isValidEmail(f.mail.value))  errorTxt += literal["mail_formato_pre"];
		}				
		
		if(!f.conditions.checked) errorTxt += literal["condiciones_pre"];
		
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("registerPre"));
			return false;
		}		
	},
	generatepassed:function(){

		var f = document.getElementById("generatepass");		
		var errorTxt = "";
	
		if(f.mail.value == "") errorTxt += literal["mail"];
		else{
			if(!regularExpressions.isValidEmail(f.mail.value))  errorTxt += literal["mail_formato"];
		}				
		if(errorTxt != ""){			
			formsValidations.setMsgError(errorTxt, document.getElementById("generatepass"));
			return false;
		}		
	}							
}

/* expresiones regulares para validar formularios */
var regularExpressions = {	
	isValidEmail:function (str){
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		return (filter.test(str));
	},
	esCadena:function(c) { return /^[0-9A-Za-z-\/Ññ?É?ÓÚáéíóúÜüÄäËë?ïÖö´,'/\\t\n\r\s]+$/.test(c); },
	esAlfabetico:function(c){return /^([a-zA-Z])+$/.test(c);},
	esNumero:function(c){return /^[0-9]+$/.test(c);},
	esCifra:function(c){return /^[0-9\.\,]+$/.test(c);},
	esTelefono:function(c){return /^[0-9\s\+\-)(]+$/.test(c)},
	comparaFechas:function(c1,c2){
		var f1=c1.split("/");
		var f2=c2.split("/");
		var fecha1=new Date();
		var fecha2=new Date();
		fecha1.setFullYear(f1[2],f1[1]-1,f1[0]);
		fecha2.setFullYear(f2[2],f2[1]-1,f2[0]);
		return (fecha2-fecha1)/1000/60/60/24;
	}

}

var Gallery={
	compareHeights:function(obj){		
		var fHeight = 0;
		var aux = 0;
		for(var i = 0; i < obj.getElementsByTagName("li").length; i++){ 
			li = obj.getElementsByTagName("li")[i];
			li.style.height= "auto";
			aux = li.clientHeight;
			if(obj.className.match("editVideo")) aux += li.getElementsByTagName("form")[0].clientHeight;
			if ( aux > fHeight) fHeight = aux;
		}
		for(var i = 0; i < obj.getElementsByTagName("li").length; i++)	obj.getElementsByTagName("li")[i].style.height = fHeight+"px";		
	},
	compareHeights2:function(obj){
		
		var fHeight = 0;
		for(var i = 0; i < obj.getElementsByTagName("li").length; i++){ 
			obj.getElementsByClassName("shopitem")[i].style.height= "auto";
			if (obj.getElementsByClassName("shopitem")[i].clientHeight > fHeight){
				fHeight = obj.getElementsByClassName("shopitem")[i].clientHeight;
			}
		}
		for(var i = 0; i < obj.getElementsByClassName("shopitem").length; i++)	obj.getElementsByClassName("shopitem")[i].style.height = fHeight+"px";		
	}
}

	
var load={
	existeId:function(cid){	
		if(document.getElementById(cid)) return true;		
		return false;
	},
	setEvents:function(){



//		if(load.existeId("mainMenu"))behaviours.menuOK();

		if(load.existeId("user"))behaviours.borraCampo("user");
		if(load.existeId("pwd"))behaviours.borraCampo("pwd");		
		if(load.existeId("user_private"))behaviours.borraCampo("user_private");		
		if(load.existeId("pwd_private"))behaviours.borraCampo("pwd_private");						
		if(load.existeId("usuario"))behaviours.borraCampo("usuario");		
		if(load.existeId("contrasena"))behaviours.borraCampo("contrasena");			
		
		if(load.existeId("login"))document.getElementById("login").onsubmit = formsValidations.logged;
		if(load.existeId("loginPress"))document.getElementById("loginPress").onsubmit = formsValidations.loginPressed;		
		if(load.existeId("register"))document.getElementById("register").onsubmit = formsValidations.registered;				
		if(load.existeId("registerPrensa"))document.getElementById("registerPrensa").onsubmit = formsValidations.registeredPrensa;						

		if(load.existeId("login_private"))document.getElementById("login_private").onsubmit = formsValidations.areaPrivaded;						
		if(load.existeId("contact"))document.getElementById("contact").onsubmit = formsValidations.contacted;
		if(load.existeId("sendbanner"))document.getElementById("sendbanner").onsubmit = formsValidations.sendbannered;
		if(load.existeId("sendComment"))document.getElementById("sendComment").onsubmit = formsValidations.sendCommented;		
		if(load.existeId("uploadvideo")){
			if(document.getElementsByClassName("add", "uploadvideo").length != 0) behaviours.add.init();	
			if(document.getElementById("uploadvideo").className == "postAction") document.getElementById("uploadvideo").onsubmit = formsValidations.postAction;			
			else if(document.getElementById("uploadvideo").className == "postNews") document.getElementById("uploadvideo").onsubmit = formsValidations.postNews;			
			else document.getElementById("uploadvideo").onsubmit = formsValidations.uploadvideoed;	
			behaviours.resetInputs.init();						
		}
		if(load.existeId("register"))document.getElementById("register").onsubmit = formsValidations.register;							
		if(load.existeId("uploadnoticia"))document.getElementById("uploadnoticia").onsubmit = formsValidations.uploadnoticiaed;							
		if(load.existeId("registerPre")) document.getElementById("registerPre").onsubmit = formsValidations.registerPred;
		if(load.existeId("registeredNewsletter")) document.getElementById("registeredNewsletter").onsubmit = formsValidations.registerednNewslettered;
		if(load.existeId("getLogin")) document.getElementById("getLogin").onsubmit = formsValidations.getLogined;
		if(load.existeId("uploadvideo2")) document.getElementById("uploadvideo2").onsubmit = formsValidations.uploadvideoed2;
		if(load.existeId("generatepass")) document.getElementById("generatepass").onsubmit = formsValidations.generatepassed;		
		if(load.existeId("rankingSel")) document.getElementById("rankingSel").onchange = function(){
				if(document.getElementById("rankingSel").value!="0"){document.getElementById("selectRanking").submit();}
		}
		
		if(load.existeId("add"))document.getElementById("sendComment").style.display="none";
		if(load.existeId("add")){
			document.getElementById("add").href="javascript:;"
			document.getElementById("add").onclick=function(){behaviours.showComments();}
		}
		if(load.existeId("calendario")) calendario.init();
		if(load.existeId("mainImages"))Gallery.compareHeights(document.getElementById("mainImages"));
		
		if(document.getElementsByClassName("mainVideos", document.getElementById("wrapper13")).length > 0)Gallery.compareHeights(document.getElementsByClassName("mainVideos", document.getElementById("wrapper13"))[0]);
		
		if(document.getElementsByClassName("shop", document.getElementById("wrapper13")).length > 0)Gallery.compareHeights2(document.getElementsByClassName("shop", document.getElementById("wrapper13"))[0]);
		
		
	}
}

//mouseenter and mouseleave
var ultima = "";
$(document).ready(function(){
	$("#menuSuperior ul li ul li").css({"visibility":"visible"});
	if ($("ul.subMain li.active").length > 0){
		ultima = $("ul.subMain li.active");
	}else{
		ultima = "";
	}

	if ($("#menuSuperior").length > 0){
		$("#flags").css({"left":($("#menuSuperior ul").width()+40)+"px"});
		$("#flags").css({"display":"block"});
		var FF=/a/[-1]=='a'
		$("#menuSuperior li").each(function(e){
				if ($(this).find("ul").length > 0) {
					var auxH = 0;
					
					if (FF) {
						var adicional = 60;
					}else{
						var adicional = 47;
					}

					$(this).find("ul li").each(function(e){auxH += $(this).width() + adicional});
					$(this).find("ul").css ({"width" : (auxH+160) +"px"});	

					var pos = $(this).position();

					var posX = pos.left - $(this).find("ul").width()/2;
					posX =($(this).find("ul").width()/2 * -1) + 150;

					$(this).find("ul").css ({"left" : posX +"px"});			
				}
		});
			
		$("#menuSuperior ul.main > li").each(function(e){
			$(this).bind("click", function(){
				//return false;
			});
			$(this).bind("mouseenter", function(){
				$("#menuSuperior ul > li").removeClass("active");
				
				if ($(this).find("li").length > 0) {
					$("#menuSuperior ul ul").removeClass("showM");
					$("#menuSuperior ul ul").addClass("hideM");
					$("#menuSuperior a").removeClass("negrita");
				}
				
				$(this).find("ul").removeClass("hideM");
				$(this).find("ul").addClass("showM");
			});
			$(this).bind("mouseleave", function(){
			
				if ($(this).find(" > a").attr("class").indexOf("negrita")==-1){
					$(this).find("ul").removeClass("showM");
					$(this).find("ul").addClass("hideM");
				}else{
						$(this).addClass("active");
				}

				if ($(this).find(" > a").attr("class").indexOf("negrita")==-1){
					if ($(this).find("li").length > 0) {
						if (ultima != "") {
							ultima.parent().parent().find("ul").removeClass("hideM");
							ultima.parent().parent().find("ul").addClass("showM");
							ultima.parent().parent().addClass("active");
							ultima.find("a").addClass("negrita");
							ultima.parent().parent().find(" > a").addClass("negrita");
						}
					}
				
				}

			});
			
			$(this).find("li").bind("click", function(){

				$("#menuSuperior a").removeClass("negrita");
				$(this).find("a").addClass("negrita");
				$(this).parent().parent().find(" > a").addClass("negrita");
				$("#menuSuperior > li").removeClass("active");
				$(this).parent().parent().addClass("active");
				
				ultima = $(this);
				
			});
		});
		
		
	}
});

if(W3CDOM) e.addEvent(window, "load", load.setEvents, false);