/* Function that swaps images. */
function ci(id, newImg) {
    var theImage = FindImage(document, id, 0);
    if (theImage) {
      theImage.src = newImg.src;
    }
}

/* Functions that track and set toggle group button states. */
function FindImage(doc, name, j) {
    var theImage = false;
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);
}

//
// Function to implement rolover
// ro(HREF,base name of image,width,height,alt text,target)
// images named  <base name>_0.gif, _1.gif, and _2.gif
// for norm, over, and down respectively
//

function setactive(index)
{
	ci("I"+active,roNorm[active]); // set old active image to normal
	active=index;
	ci("I"+active,roDown[active]); // set new active image to down
}

var nxtImg=0 // unique image index
var active=1 // current active index - set to active page
roNorm=new Array // array for images
roOver=new Array // array for hover images
roDown=new Array // adday for down images
function ro(roHREF,roName,w,h,alt,targ)
{
	nxtImg++     //next image index
	roN="I"+nxtImg // ref name
	// load images
	roNorm[nxtImg]=new Image(w,h);roNorm[nxtImg].src=roName+"_0.gif"
	roOver[nxtImg]=new Image(w,h);roOver[nxtImg].src=roName+"_1.gif"
	roDown[nxtImg]=new Image(w,h);roDown[nxtImg].src=roName+"_2.gif"
    document.write("<a href='"+roHREF+"'"
	  +" onMouseOut=(active=="+nxtImg+")?ci('"+roN+"',roDown["+nxtImg+"]):ci('"+roN+"',roNorm["+nxtImg+"])"
	  +" onMouseOver=ci('"+roN+"',roOver["+nxtImg+"])"
	  +" onMouseDown=ci('"+roN+"',roDown["+nxtImg+"])"
	  +" onClick=setactive("+nxtImg+");this.blur()"
	  +" target='"+targ+"'><img"
	  +" name='"+roN+"'"
	  +" src='"+roName+((active==nxtImg)?"_2.gif'":"_0.gif'")
	  +" width="+w
	  +" height="+h
	  +" border=0"
	  +" alt='"+alt+"'></a>"
	)
}
