/************************************************************************************
** File: rolloverpack.js
** 
** Description: 
**
** This script browses through the document for all images whose parent tag
** is an anchor (<a>) and sets that image 3-handler rollover effect. 
**
** Usage:
**
** The script assumes that the name of the rolling images are under the
** following directory: "../image" (A folder labeled "image" a step back from 
** the current document location) and that the name of the images follow this
** convention:
**
** 		onMouseOut Image File Name = (IMG.SRC) 
**		onMouseOver Image File Name = (IMG.ID) + "_over.jpg" (I.e "myImg_over.jpg")
**		onClick Image File Name = (IMG.ID_ + "_click.jpg" (I.e "myImg_click.jpg")
**
** As you can see, the scripts also assumes that the images are JPEGs.
**
** Therefore, to use the script make sure that the image that's going to be set to
** rollover is within an anchor tag and assigned the value of its id attribute to the
** name of the file without the "_over.jpg" and "_click.jpg" extensions
**
** 		(I.e. <a href="www.mysite.com"><img src="myImage.jpg" id="myImage" /></a> )
**
**************************************************************************************/



function rolloverInit() {
     for (var i=0; i<document.images.length; i++) {
        if (document.images[i].parentNode. tagName == "A" && document.images[i].className != "no-rollover") {
           setupRollover(document.images[i]);
        }
     }
}

function setupRollover(thisImage) {	
	thisImage.outImage = new Image();
    thisImage.outImage.src = thisImage.src;
    thisImage.onmouseout = rollOut;

	thisImage.clickImage = new Image();
	thisImage.clickImage.src = "image/" + thisImage.id + "_click.jpg";
	thisImage.onclick = rollClick;
	
	thisImage.overImage = new Image();
	thisImage.overImage.src = "image/" + thisImage.id + "_over.jpg";
	thisImage.onmouseover = rollOver;
}

function rollOver() {
     this.src = this.overImage.src;
}

function rollOut() {
     this.src = this.outImage.src;
}

function rollClick() {
     this.src = this.clickImage.src;
}

