/***** ROLLOVER SENCILLO QE TE CAGAS *****/
//en la imagen --> onmouseover="this.src=Imagenes[0].src;" onmouseout="this.src=Imagenes[1].src;"
//en onLoad de <body> -->onLoad="Precargar('rutarelativa/imagen-ON', 'rutarelativa/imagen-OFF')"
Imagenes = new Array();
function Precargar() {
	
  for (var i=0; i<Precargar.arguments.length; i++) {    
    Imagenes[i]=new Image; 
    Imagenes[i].src=Precargar.arguments[i];
  }
}



/***** Captura de la posición del ratón *****/
function Browser() {
this.isIE = false; // Internet Explorer
this.isNS = false; // Netscape
this.isOpera = false; // Opera
if (navigator.userAgent.indexOf("Netscape6/") >= 0) {
this.isNS = true;
return;
}
if (navigator.userAgent.indexOf("Gecko") >= 0) {
this.isNS = true;
return;
}
if (navigator.userAgent.indexOf("MSIE") >=0 && navigator.userAgent.indexOf("Opera") <0) {
this.isIE = true;
return;
}
if (navigator.userAgent.indexOf("Opera") >=0) {
this.isOpera = true;
return;
}
}

var browser = new Browser();

function initMovimiento(event){
cancelar();
if (browser.isIE || browser.isOpera) {
document.attachEvent("onmousemove", getposicion);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (browser.isNS) {
document.addEventListener("mousemove", getposicion, true);
event.preventDefault();
}
}
function initPulsar(event){
cancelar();
if (browser.isIE || browser.isOpera) {
document.attachEvent("onclick", getposicion);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (browser.isNS) {
document.addEventListener("click", getposicion, true);
event.preventDefault();
}
}
function getposicion(event){
if (browser.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}
if (browser.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}
if (browser.isOpera) {
x = window.event.clientX + document.documentElement.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop;
}
document.getElementById("posicion").style.visibility = "visible";
document.getElementById("posicion").style.left= (x - 55) +"px";
document.getElementById("posicion").style.top = y + 20 +"px";
document.getElementById("posicion").innerHTML = "Coordenada x: " + x + "<br>Coordenada y: " + y;
}

function cancelar() {
if (browser.isIE || browser.isOpera) {
document.detachEvent("onmousemove", getposicion);
document.detachEvent("onclick", getposicion);
}
if (browser.isNS ) {
document.removeEventListener("mousemove", getposicion, true);
document.removeEventListener("click", getposicion, true);
}
document.getElementById("posicion").style.visibility= "hidden";
}

//-----------------------------------------

// popups de imágenes de la galería
function popup(ruta_base, ancho, id_imagen)
{
	
	var features = "width=" + ancho + ", height=600";
	
	nueva = window.open(ruta_base + "admin/galeria/ver_imagen.php?id=" + id_imagen, "imagen", features);
	nueva.focus();
}

// funciones para mostrar/ocultar capas

function ajustar_menu()
{
	var contenidos = document.getElementById('contenido');
	var menu = document.getElementById('menu_izq');
	menu.style.height = contenidos.offsetHeight + "px";
	if (document.all) {
		menu.style.height = contenidos.offsetHeight;
	}
}
// funciones para mostrar/ocultar capas
function mostrar_capa(capa)
{
	capa.style.display = 'block';

}
function ocultar_capa(capa)
{
	capa.style.display = 'none';

}

// despliegue de menús
function desplegar_menu(numero_bloque)
{
	num_op = document.getElementById("total_opciones").value;

	/***** Algoritmo para apertura y cierre automáticos *****/
	/*for(var i = 0; i < num_op; i++ )
	{
		if( (i != numero_bloque) && document.getElementById("bloque_" + i) )
			ocultar_capa(document.getElementById('bloque_' + i));
		else if( i == numero_bloque )
			mostrar_capa(document.getElementById('bloque_' + i));
	}*/

	/***** Algoritmo para apertura y cierre manual *****/
	menu = document.getElementById("bloque_" + numero_bloque);

	if( menu.style.display == 'none' )
		mostrar_capa(menu);
	else
		ocultar_capa(menu);
}