// JavaScript Document

//the following variables relate to the currentOver and currentOut functions
var imagename;
var sideimagename;
var recent;
recent = false;

//creates an array that contains the names of each of the drop-down menus
var Menu = new Array("membership","chapters","support","news","programs","career","online");

//Toggle function opens and closes drop down menus in left column
function Toggle(item, varLabel) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("m_" + item);
   
	if (visible) {
		obj.style.display="none";
		key.innerHTML="<img src='images/arrow_off.gif' width='9' height='9' hspace='0' vspace='0' border='0' alt='Open' title='arrow' class='arrow'>" + varLabel;
	} else {
    	obj.style.display="block";
		key.innerHTML="<img src='images/arrow_up.gif' width='9' height='9' hspace='0' vspace='0' border='0' alt='Collapse Tree' title='Collapse Tree' class='arrow'>" + varLabel;
   }
}


//menuOver function makes the drop-down menu background white on item rollover
function menuOver(object) {
if (object.className == 'menuOff') object.className =
'menuOver';
};

//mainImage function swaps the primary page image using a timer
var iNum = 1;
//variable maxiNum = the total number of images that will rotate
var maxiNum = 6;
function mainImage(){
iNum++;
if (iNum > maxiNum){
iNum = 1;
};
document.images['mainimage'].src = "images/mainimage" + iNum + ".jpg";
};

//menuOff function restores the drop-down menu background on menu item rolloff
function menuOff(object) {
if (object.className == 'menuOver') object.className =
'menuOff';
};


//resets the drop-down menus and calls the toggleOff function to hide the menus
function resetMenu(){
for (var k = 0; k < 7 ; k++){
id = Menu[k];
toggleOff(id,"blank");
};
}; 

//resets the current type and hides the layer
function resetCurrent(){
for (var i = 1; i <= 6 ; i++){
lyr = "current" + i;
toggleOff(lyr,"currentblank");
//the images[number] for MouseOut for current type is adjusted with the '+12' offset value. //The offset value corrects for images occuring before the current type images
var currentName = document.images[i+12].name;
document.images[currentName].src = "current/" + currentName + "/" + currentName + ".gif";
};
};
// variable browsertype and os are used to determine the client's browser and OS
var browsertype;
var os;
// variable agt is an abreviation to simplify later queries
var agt=navigator.userAgent.toLowerCase(); 
//variable topoffset is the amount of offset required to properly position the drop down layers
var topoffset = '6'; 
//variable top is the starting position of the menu drop down layers
var top = '102';
//toggleMenu function shows the drop-down menu
if (navigator.appName.indexOf("Microsoft")!=-1){
browsertype = "ie"
};
if (navigator.appName.indexOf("Netscape")!=-1){
browsertype = "nav"
};
if (agt.indexOf("firefox")!= -1){
browsertype = "fox"
};
if (browsertype != "ie"){
if (navigator.vendor.indexOf("Safari")!= -1){
browsertype = "safari"
};
};
if ((agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1)){
os = "win";
};
if (agt.indexOf("mac")!=-1){
os = "mac";
};

//the following variables apply to the toggleMenu and toggleOff functions
var NNtype='show';
var IEtype='visible';
var WC3type='visible';

function toggleMenu(id,layerId) {

	var NNtype='show';
	var IEtype='visible';
	var WC3type='visible';
	
	if (document.getElementById) {
	        if (browsertype == "fox" || "safari"){
			document.getElementById(id).style.top = top -topoffset;
			};
		if (browsertype == "nav"){
			document.getElementById(id).style.top = top - topoffset;
		};
		if (browsertype == "ie"){
			document.getElementById(id).style.top = top - topoffset;
		}; 
		eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
		eval("document.getElementById(layerId).style.visibility = \"" + WC3type + "\"");
	} else {
        if (document.layers) {
			if (browsertype == "fox" || "nav" || "safari"){
			document.getElementById(id).style.top = top - topoffset;
		};
			document.layers[id].visibility = NNtype;
            document.layers[layerId].visibility = NNtype;
        } else {
            if (document.all) {
				if (browsertype == "fox" || "safari"){
					document.getElementById(id).style.top = top - topoffset;
				};
				eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
				eval("document.all." + layerId + ".style.visibility = \"" + IEtype + "\"");
            }
        }
   	}
    };
	
//toggleOff function hides the drop-down menus when the mouse is moved off the menu	
function toggleOff(id,layerId){
	
	if (NNtype=='show' || IEtype=='visible' || WC3type=='visible') {
	NNtype='hidden';
	IEtype='hidden';
	WC3type='hidden';
	};
	if (document.getElementById && browsertype != "ie") {
		eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
		eval("document.getElementById(layerId).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
			document.layers[id].visibility = NNtype;
            document.layers[layerId].visibility = NNtype;
        } else {
            if (document.all) {
				eval("document.all." + id + ".style.visibility = 'hidden'");
				eval("document.all." + layerId + ".style.visibility = 'hidden'");
            }
        }
	}
 };

//currentOver function changes the left side rollover and shows the layer that relates to the rollover
function currentOver (id,imagename) {
	document.images[imagename].src = "current/" + imagename + "/" + imagename + "_over.gif";
   	var NNtype='show';
	var IEtype='visible';
	var WC3type='visible';
	
	if (document.getElementById) {
		eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
		eval("document.getElementById('currentblank').style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
            document.layers['currentblank'].visibility = NNtype;
        } else {
            if (document.all) {
				eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
				eval("document.all.currentblank.style.visibility = \"" + IEtype + "\"");
            }
        }
   	}
};

//preloadCurrent function preloads the rollovers for Current buttons
function preloadCurrent() {
	//the variable x increases by one each time and preloads the images at numbers (10-18) Don't change the 20.
	if (document.images) {
	for (var i = 13; i <= 20; i++){
	var preload = document.images[i].name;
	preloadImages = new Array();
	preloadImages[i] = preload + "_over.jpg";
}
}
}
