/***** ROLLOVER SENCILLO  *****/

//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=1000";
	

	nueva = window.open(ruta_base + "admin/galeria/ver_imagen.php?id=" + id_imagen, "imagen", features);

	nueva.focus();

}



// funciones para mostrar/ocultar capas

function mostrar_capa(event, capa)

{

	var flagstyle = document.getElementById('flagstyle');

	if (flagstyle.style.display == 'none') {

		document.getElementById(capa).style.display = "block";

		document.getElementById(capa).style.position = "absolute";



		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(capa).style.left= (x - (document.getElementById(capa).offsetWidth/2)) +"px";

		document.getElementById(capa).style.top = (y + 20) +"px";

	}

}

function ocultar_capa(capa)

{

	var flagstyle = document.getElementById('flagstyle');

	if (flagstyle.style.display == 'none') {

		document.getElementById(capa).style.display = "none";

		document.getElementById(capa).style.position = "absolute";



		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);

		}

	}

}


