/*
  rOvEr
  Clon de soopa-rollovers.js (www.youngpup.net)
  Modificado por Kern.

  + Novedades +
  Se ha añadido la opción de establecer enlaces y no utilizar
  así la etiqueta <A></A> rodeando la imagen.
  
  + Instrucciones +
  Ejecutar roverSetup() en el evento onLoad de BODY.
  Los rollovers tienen, aparte del atributo src, los atributos
  over y down con las rutas de las imágenes de sustitución.
  Para crear un link normal se puede establecer el atributo
  url:

    <img src="google.gif" url="http://www.google.es" />
	
  Si se quiere que el enlace se abra en una ventana nueva se
  añadirá el atributo external="external":

    <img src="google.gif" url="http://www.google.es" external="external" />
	
*/

function roverSetup() {
	var img, normal, over, down, lnk, out;
	for (var i=0; (img = document.images[i]);i++) {
		if (img.getAttribute) {
			normal = img.getAttribute("src");
			over = img.getAttribute("over");
			down = img.getAttribute("down");
			lnk = img.getAttribute("url");
			out = img.getAttribute("external");
			if (normal != "" && normal != null) {
				img.n = new Image();
				img.n.src = normal;
			}
			if (over != "" && over != null) {
				img.h = new Image();
				img.h.src = over;
				img.onmouseover = swapOn;
				img.onmouseout = swapOff;
			}
			if (down != "" && down != null) {
				img.d = new Image();
				img.d.src = down;
				img.onmousedown = swapDown;
			}
			if (lnk != "" && lnk != null && lnk != 'undefined' && lnk != 'unknown') {
				img.l = lnk;
				if (out != null) {
					img.out = true;
				} else {
					img.out = false;
				}
				img.onclick = goTo;
			}
		}
	}
}

function swapOn() {
	this.src = this.h.src;
}

function swapOff() {
	this.src = this.n.src;
}

function swapDown() {
	this.src = this.d.src;
	this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unkonwn'?document.onmouseup:"";
	swapUp.img = this;
	document.onmouseup = swapUp;
}

function swapUp() {
	var ths = swapUp.img;
	ths.src = ths.n.src;
	if (ths.temp) {
		document.onmouseup = ths.temp;
	}
}

function goTo() {
	if (this.l != 'undefined' && this.l != 'unknown' && this.l != "") {
		if (this.out == true)
			window.open(this.l,'');
		else
			document.location = this.l;
	}
}