/* --------------------------------------------------------------------
	 Copyright 2002 Pixies' Planet - Script by Daniel Herskovits
	 Easy Rollovrers V1.0 - 15-01-2002.

	 Add this script to the head section of your page.
	 Name the images wich will support the rollover effect.
	 Call addRollOver("document_image_name", "alternate_image_url")
	 for each image you want to preload and reference as an alternante
	 image.
	 For "document_image_name" use the same name you give to the 
	 related image in your page to tell the sctipt wich image will be
	 replaced with the alternate image.
	 Add a link tag around your rollovered images and call 
	 "imgOn('image_1_name'[, 'image_2_name'][, ...])" to the onMouseOver
	 event of the link. Simply call "imgOff()" to the onMouseOut event
	 of the link. The script will do all the needed stuff.
 ---------------------------------------------------------------------- */

function addRollOver() {
	if (document.images) {
		if (!document.rolloverArray) document.rolloverArray=new Array();
		if (!document.rolloverNamesArray) document.rolloverNamesArray=new Array();
		var i, j=document.rolloverArray.length, args=addRollOver.arguments;
	for (i=0; i<args.length; i+=2) {
		document.rolloverArray[j]=new Image;
		document.rolloverArray[j].src=args[i+1];
		document.rolloverNamesArray[j]=args[i]+"On";
		j++;
	}
	}
}

function findObj(n, d) {
	var p,i,x;
	if (!d) {
		d=document;
	}
	if ((p=n.indexOf("?"))>0&&parent.frames.length){
	d=parent.frames[n.substring(p+1)].document;
	n=n.substring(0,p);
	}
	if (!(x=d[n])&&d.all) {
	x=d.all[n];
	}
	for (i=0;!x&&i<d.forms.length;i++) {
		x=d.forms[i][n];
	}
	for (i=0;!x&&d.layers&&i<d.layers.length;i++) {
		x=findObj(n,d.layers[i].document);
	}
	if (!x && document.getElementById) {
		x=document.getElementById(n);
	}
	return x;
}

function findImg() {
	var imgToFind=findImg.arguments[0]+"On", imgIdx;
	for (var i=0; i<document.rolloverArray.length; i++) {
	if (document.rolloverNamesArray[i]==imgToFind) imgIdx=i;
	}
	return imgIdx;
}

function imgOn(a) {
	var i,j=0,x,args=imgOn.arguments;
	document.swapArray=new Array;
	document.swapArrayNames=new Array();
	for(i=0;i<(args.length);i++) {
		if ((x=findObj(args[i]))!=null) {
			document.swapArray[j]=x;
			document.swapArrayNames[j]=x.name;
			j++;
			if(!x.oSrc) {
	x.oSrc=x.src;
			}
			imgNum=Number(findImg(x.name));
			if (document.rolloverArray[imgNum].complete) {
				x.src=document.rolloverArray[imgNum].src;
			}
		}
	}
}

function imgOff() {
	var i,x,a=document.swapArray;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) {
		x.src=x.oSrc;
	}
}
