function cargando(){}
function onbeforeload(){
	xmpinit();
	navieinit();
	navieforzaroverany('avisolegal');
	navieforzaroverany('selectorbusqueda');
	estuchesoverinit();
	listadoporletra();
}
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 minisitiosclick(e){
	minisitios.desplegar()
}

var minisitios = {
item:[]
,obj:null

,cerrado:false
,binit:false

,desplegar:function(){
	if(!this.binit)this.init();
	if (this.obj.style.display=="none"){
		this.abrir();
	}else{
		this.cerrar();
	}
}

,cerrar:function(Qsinefecto){
	if(!this.binit)this.init();
	var sinefecto = Qsinefecto || false;
	
	
	var opts = {queue: {position:'end', scope: 'menuxscope', limit:1}, duration:1}
	if(Qsinefecto && Qsinefecto.duration){
		opts.duration = Qsinefecto.duration
	}
	//Effect.BlindUp(this.obj, sinefecto)
	new Effect.BlindUp(this.obj, opts)
	/*
	for(var i = 0; i < this.item.length; i++){
		var o = this.item[i];
		o.parentNode.removeChild(o);
	}
	*/
	this.cerrado=true;
}
,abrir:function(){
	if(!this.binit)this.init();
	
	new Effect.BlindDown(this.obj, {queue: {position:'end', scope: 'menuxscope', limit:1}, duration:1})
	/*
	for(var i = 0; i < this.item.length; i++){
		var o = this.item[i];
		this.obj.appendChild(o);
	}
	*/
	
	this.cerrado=false;
}

,init:function(){
	var obj = this.obj = document.getElementById("minisitios");
	if(!obj) return false;
	var oo = obj.getElementsByTagName("div");
	for(var i = 0; i < oo.length; i++){
		var o = oo[i];
		if(/item/.test(o.className)){
			this.item.push(o);
		}
	}
	return (this.binit = true);
}
}

function listadoporletra(){
	var listadoporletra = document.getElementById("listadoporletra");
	if(listadoporletra){
		var oodt = listadoporletra.getElementsByTagName("dt");
		var oodd = listadoporletra.getElementsByTagName("dd");
		for(var i = 1; i < oodt.length; i+=2){
			var dt = oodt[i];
			var dd = oodd[i];
			dt.className+= " color";
			dd.className+= " color";
		}
	}
}
function insertVideo(video){
	var rnd = Math.round(Math.random() * 100000000);
	var id = "v" + rnd;
	document.writeln("<a id=" + id + " href='/Gallery/" + video + "' style='display: block; width: 352px; height: 288px;'></a>");

	flowplayer( id, {src: '/images/flowplayer-3.1.2.swf', wmode: 'transparent'},
    {
        clip: {
        autoPlay: false,  
        autoBuffering: true
        }
    }); 
	
}
function insertAudio(audio){
	var rnd = Math.round(Math.random() * 100000000)
	var id = "a" + rnd
	
	document.writeln("<div id=" + id + "></div>")
	var fo = new SWFObject("images/Mp3Player.swf?clip=/Gallery/" + audio, "mp3162", "188", "58", "7", "#000000", true);
	fo.write(id);
	
}

function insertEducamusica(){
	window.open('/educaMusica/index.html', 'Popup', 'width=790,height=500,toolbars=no,scrollbars=no');
	return false;
}

function insertCollage() {
	altura = screen.height;
	largura = screen.width;
	px = (largura - 790) / 2;
	py = (altura - 500) / 2;
	win=window.open("/collage/jujuba.html", "popup", "width=790,height=500,menubar=no,scrollbars=no,statusbar=no,status=no,toolbar=no,resizable=no");
	win.moveTo(px, py);
	return false
}
function insertSWF(video, width, height){
	var rnd = Math.round(Math.random() * 100000000);
	var id = "v" + rnd;
	document.writeln("<a id=" + id + " href='/Gallery/" + video + "' style='display: block; width: "+ width + "px; height: " + height + "px;'></a>");

	flowplayer( id, {src: '/images/flowplayer-3.1.2.swf', wmode: 'transparent'},
    {
        clip: {
        autoPlay: true,
        autoBuffering: true
        },
        play: {opacity: 0},
        plugins: {
        controls: null
        }
    }); 
}
function jvn_passwordrecovery(){
    window.open('/jvn_passwordrecovery.aspx', 'Popup', 'width=420,height=210,toolbars=no,scrollbars=no');
    return false;
}
function displayWindow(url, width, height)
{
	var Win;
	Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,menubar=no,status=no' );
	Win.resizeTo(width,height);
	Win.focus();
	return (Win == null);
}
function displayRecommend(url, recommendaspx){
	if (!recommendaspx) {recommendaspx = "/recommend.aspx?UrlRecomendado="}
	return displayWindow(recommendaspx + url, 580, 400);
}
function displayVideo(url, width, height){
	displayWindow(url, width + 20, height + 50);
}
function displayTvenvivo(aspx){
	if (!aspx) {aspx = "/tvenvivo.aspx"}
	return displayWindow(aspx, 580, 400, true);
}
function tvenvivo_click(e, url){
	return displayTvenvivo();
}

function ViewOverItems(id, viewOver)
{
    var positionLi = id.replace('li','');
    var liOver = document.getElementById(id);
    if (liOver)
    {
        if (viewOver) //mostrar over
        {
            liOver.className='item selected';
            document.getElementById('overFin'+id).style.display='block';
            if (positionLi==1)
            {
                document.getElementById('over'+id).style.display='block';
                liOver.className='item primero selected';
            }
        }
        else //mostrar estado normal
        {
            liOver.className='item';
            document.getElementById('overFin'+id).style.display='none';
            if (positionLi==1)
            {
                document.getElementById('over'+id).style.display='none';
                liOver.className='item primero';
            }
        }
    }
}