// Llamamos en el onload a la función "ocultaImgSubmenu"
if( navigator.userAgent.indexOf('MSIE')!=-1 ){
    window.attachEvent('onload', ocultaImgSubmenu );
}		
if( navigator.userAgent.indexOf('Gecko')!=-1 ){
    window.addEventListener( 'load', ocultaImgSubmenu, true );
}

function $(id){
    return document.getElementById(id);
}

// Abir una ventana popup
function abrirPopup( url ,f_amp, f_alt, nom_finestra, scroll ){
	ancho=screen.width;				//ample pantalla
	alto=screen.height;				//alt pantalla
	v_top=(alto-f_alt)/2;	
	v_left=(ancho-f_amp)/2;
	if (typeof(v_fin)!="undefined"){
		v_fin.close();
	}
	v_fin=window.open(url,nom_finestra,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+(scroll?'yes':'no')+",resizable=no,width="+f_amp+",height="+f_alt+",top="+v_top+",left="+v_left);
}
// Crea una cookie
function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure){

	var sCookie = sName + "=" + encodeURIComponent(sValue);
	if(oExpires){
		sCookie += "; expires='" + oExpires+"'";
	}
	if(sPath){
		sCookie += "; path=" + sPath;
	}
	if(sDomain){
		sCookie += "; domain=" + sDomain;
	}
	if(bSecure){
		sCookie += "; secure=";
	}

	document.cookie = sCookie;

}

// Recupera el valor de una cookie al pasarle el nombre
function getCookie(sName){
	
	var sRE = "(?:; )?"+ sName + "=([^;]*);?";
	var oRE = new RegExp(sRE);
	
	if (oRE.test(document.cookie)){
		return decodeURIComponent(RegExp["$1"]);
	}else{
		return null;
	}
}

// Elimina la cookie
function deleteCookie(sName, sPath, sDomain){
	setCookie(sName, "", new Date(0), sPath, sDomain);
}

// Función para ocultar la última imagen del submenú.
function ocultaImgSubmenu(){
    var imgs = document.getElementsByTagName("img");
    var seps = new Array();
    for( var i in imgs ){
        if( imgs[i].className == "separadorSubmenu" ){
            seps.push( imgs[i] );
        }
    }    
    if( seps.length > 0 ){
        seps[ seps.length-1 ].style.display = "none";
    }
}


