//Stores each of the Rollover objects
//so they can be turned on by the onload
//of the layout*.jsp
var rollList = new Array();
var topNav = new Rollover('','');
var secondNav = new Rollover('','');                                    
var setup = "false";
var lastImg = "";

function addRollover(rollover) {
    rollList[rollList.length] = rollover;
}

function navSetup(primary,secondary) {
    if(primary!=null) {
	topNav = new Rollover("nav_",primary);
	addRollover(topNav);
    }
    if(secondary!=null) {
	secondNav = new Rollover("nav2_",secondary);
	addRollover(secondNav);
    }
    for(i=0;i<rollList.length;i++) {
	rollList[i].set();
    }
    setup = "true";
}

function Rollover(type,section) {
    //properties
    this.type = type;
    this.section = section;
    this.prefix = "images/"+type;
    //methods
    this.Over = navImageOver;
    this.On = navImageOn;
    this.Off = navImageOff;
    this.toggle = navImageToggle;
    this.set = navImageSetOn;
}

function navImageToggle(section,name,extension) {
    if(name != "" && name != section) {
	if(document.layers && document.layers["mainnav"] && document.layers["mainnav"].document.images[name]) {
	    document.layers["mainnav"].document.images[name].src = this.prefix+name+extension;
	} else if((is_nav6 || is_moz7)&& document.getElementById(name)) {
	    document.getElementById(name).src = this.prefix+name+extension;
	} else if(document.images[name]) {
	    document.images[name].src = this.prefix+name+extension;
		
	}
    }
}

function navImageSetOn() {
    this.toggle("",this.section,"_on.gif");
}

function navImageOver(name) {
    if(setup == "true") {
	//Don't need if we aren't using drop down menus
    	this.toggle(this.section,name,"_over.gif");
    	//this.toggle(this.section,name,"_on.gif");
	lastImg = name;
    }
}

function navImageOff(name) {
    if(setup == "true") {
	if(this.section != name)
	    this.toggle(this.section,name,"_off.gif");
	else
	    this.toggle(this.section,name,"_on.gif");
	lastImg = "";
    }
}

function navImageOn(name) {
    if(setup == "true") {
	this.toggle(this.section,name,"_on.gif");
    }
}

function preCache(image){
    if (document.images){
	pic = new Image();
	pic.src = image;
    }
}
