function cargando(){}
function onbeforeload(){
	xmpinit();
	navieinit();
	navieforzaroverany('avisolegal');
	estuchesoverinit();
}
function estuchesoverinit(){
	//busca el listado de estuches a mostrar
	//precarga los htmls y los ubica dentro del documento escondidos
	//agrega el script para posibilitar el over
	
	var o = navieforzarover('estuches', true, estuchesover, estuchesout)
	
	var ids = [];
	if(o){
		for( var i = 0; i < o.childNodes.length; i++){
			var li = o.childNodes[i]
			if(li.nodeName.toLowerCase() == 'li'){
				ids.push(li.getAttribute("idestuche"));
			}
		}
		
		for(var i = 0; i < ids.length; i++){
			var id = ids[i];
			var iframe = document.createElement("iframe")
			iframe.src = "estuches/" + id + ".html";
			iframe.id="estuche" + id
			iframe.name="estuche" + id
			iframe.className="estucheiframe"
			document.body.appendChild(iframe)
		}
	}
};

var overultimo = null;
function estuchesover(){
	var iframe = window.frames['estuche' + this.getAttribute("idestuche")];
	if(iframe){
		var doc = iframe.document
		if(doc.getElementsByTagName("div").length == 4){
			var body = doc.body.innerHTML;
			
			var over  = document.createElement("div")
			over.className="estucheover posicion"+this.getAttribute("posicion")
			document.body.appendChild(over);
			over.innerHTML = body
			
			overultimo = over ;
		}
	}
}
function estuchesout(){
	if(overultimo){
		overultimo.parentNode.removeChild(overultimo);
		overultimo = null
	}
}

function navieinit(){
	var o = document.getElementById('menuHeader');
	var oo = document.getElementsByTagName('ul')
	for(var i = 0; i < oo.length; i++){
		if (oo[i].className.indexOf('desplegable') >= 0){
			navieforzarover(oo[i]);
		}else if (oo[i].parentNode.parentNode.className.indexOf('desplegable') >= 0){
			navieforzarover(oo[i]);
		}
	}
}

function navieforzarover(id, Qseguro, funcionover, funcionout){
	var seguro = Qseguro || false
	if (seguro || BrowserDetect.browser=="Explorer"&&BrowserDetect.version==6) {
		if(typeof id == 'string'){
			var navRoot = document.getElementById(id);
		}else{
			var navRoot = id
		}
		if(navRoot){
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
						this.funcionover()
					}
					node.funcionover = function(){};
					if (typeof funcionover == 'function'){
						node.funcionover = funcionover
					}
					
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
						this.funcionout()
					}
					node.funcionout = function(){};
					if (typeof funcionout == 'function'){
						node.funcionout = funcionout
					}
				}
			}
			return navRoot
		}
	}
	return false
}
function navieforzaroverany(id, Qseguro, funcionover, funcionout){
	var seguro = Qseguro || false
	if (seguro || BrowserDetect.browser=="Explorer"&&BrowserDetect.version==6) {
		if(typeof id == 'string'){
			var navRoot = document.getElementById(id);
		}else{
			var navRoot = id
		}
		if(navRoot){
			node = navRoot
			node.onmouseover=function() {
				this.className+=" over";
				this.funcionover()
			}
			node.funcionover = function(){};
			if (typeof funcionover == 'function'){
				node.funcionover = funcionover
			}
			
			node.onmouseout=function() {
				this.className=this.className.replace(" over", "");
				this.funcionout()
			}
			node.funcionout = function(){};
			if (typeof funcionout == 'function'){
				node.funcionout = funcionout
			}
		}
	}
}

function xmpinit(){
	var oo= document.getElementsByTagName('xmp');
	for (var i=0; i<oo.length; i++) {
		node = oo[i];
		node.ondblclick=xmpclick
	}
}
function xmpclick(e, obj){
	if(!obj) obj = this;
	
	obj.className = obj.className || ''
	
	if(obj.className.indexOf('hover')>=0){
		obj.className = obj.className.replace(/(?:^| )hover/i, '')
	}else{
		obj.className+= ' hover'
	}
	
	if(obj.className.indexOf('docked')>=0){
		obj.className = obj.className.replace(/(?:^| )docked/i, '')
	}else{
		obj.className+= ' docked'
	}
}
var ultimoobj = null;
function abrirproducto(obj){
	var oda;
	if(oda = cerrarproducto() && oda.parentNode == obj){return false}
	
	var Qimg = obj.getAttribute('oimagen');
	var Qtexto = obj.getAttribute('otitulo');
	
	var Hcontenedor = document.createElement('div');
	Hcontenedor.className="popup"
	
	var Htitulo = document.createElement('div');Hcontenedor.appendChild(Htitulo);
	Htitulo.innerHTML = Qtexto;
	Htitulo.className = "textopopup"
	
	var Himg = document.createElement('img');Hcontenedor.appendChild(Himg);
	Himg.src = Qimg;
	Himg.width = 290;
	
	Hcontenedor.onclick = cerrarproducto;
	
	obj.insertBefore(Hcontenedor,obj.childNodes[0]);
	ultimoobj = Hcontenedor
}
function cerrarproducto(){
	var uo = null
	if (ultimoobj){
		ultimoobj.parentNode.removeChild(ultimoobj);
		uo = ultimoobj
		ultimoobj = null;
	}
	return ultimoobj;
}

function cerrarse(){ 
window.close() 
}

function atras(){ 
history.go(-1) 
}

function buscar(formulario){ 

if(formulario == 'conoloratinta'){
window.open('/Form.SearchOloratinta.aspx','','width=750,height=350,resizable=yes,scrollbars=yes') 
//window.open('PasswordRecovery.aspx','','toolbar=no,width=406,height=190,menubar=no,status=no,scrollbars=no,resizable=no,location=no,left=400,top=70')
}
if(formulario == 'videosdepepe'){
window.open() 
}
if(formulario == 'apuromicrofono'){
window.open() 
}
if(formulario == 'encuentroscaraacara'){
window.open() 
}

}  



function PopupContent(Id){
window.open('/Content.aspx?Id='+Id,'','width=750,height=350,resizable=yes,scrollbars=yes') 
} 