DOM = (document.getElementById) ? true : false;
NS4 = (document.layers) ? true : false;
IE = (document.all) ? true : false;
IE4 = IE && !DOM;
NS = (navigator.appName=="Netscape") ? true : false;
NS6 = NS && DOM;
MAC = (navigator.appVersion.indexOf("Mac") != -1);
 
function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj + 'On = new Image()')
		eval(imgObj + 'On.src = imgSrc + "_on.gif"')
		eval(imgObj + 'Off = new Image()')
		eval(imgObj + 'Off.src = imgSrc + "_off.gif"')
	}
}

function img_act(imgName) {
	if (document.images) {
		document[imgName].src = eval(imgName + "On.src");
	}
}

function img_inact(imgName) {
	if (document.images) {
		document[imgName].src = eval(imgName + "Off.src");
	}
}

function butt_act(imgName, obj) {
	obj.src = eval(imgName + "On.src");
}

function butt_inact(imgName, obj) {
	obj.src = eval(imgName + "Off.src");
}

function changeImages() {
	if (document.images) {
    	for (var i=0; i<changeImages.arguments.length; i+=2) {
      		document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
    		}
		}
}

function openWindow(windowURL,windowName,windowWidth,windowHeight,scroll,center) {
	newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars='+scroll+',resizable=0');
	newWindow.focus(); 
   if (center) {
      newWindow.moveTo((screen.width-windowWidth)/2,(screen.height-windowHeight)/2)
   }
}

function changeStyle(id,styleSelector,value){
	eval("document.getElementById(id).style."+styleSelector+"='"+value+"';");
}

function showElement(id) {
	document.getElementById(id).style.display = "block";
}

function hideElement(id) {
   document.getElementById(id).style.display = "none";
}


hideMenu = null;
isActive = "";
isActiveLink = "";
stay = "";
currSection = '';

if (NS4) {
	visible = 'show';
	hidden = 'hide';
} else {
	visible = 'visible';
	hidden = 'hidden';
}

function setCurrentSection( sectionName ) {
    
    if( document.getElementById( 'submenu' + sectionName ) ) {
        currSection = sectionName;
        var button,buttonName = '';
        //*
        if( button = document.getElementById( 'menu' + sectionName ) ) {
            buttonName = 'menu' + sectionName;
            button.style.backgroundColor = '#abda4d';
        }
        //*/
        menuOn( 'submenu' + sectionName, buttonName );
    }
}

function menuOn(item,itemlink){
	clearTimeout(hideMenu);	
   //hide other menu
	if (isActive != "" && isActive != item) {
		hideItem(isActive);
	}
    //* unhide old menu button
	if (isActiveLink != "" && isActiveLink != itemlink ) {
       	if (DOM) {
       	  daItem = document.getElementById(isActiveLink);
       	} else if (NS4) {
       	  daItem = document.layers[isActiveLink];
       	} else {
       	  daItem = document.all(isActiveLink);
       	}
       	daItem.className = "menuoff";
	}
	//*/
	if( item ) {
    	if (DOM) {
    	  daItem = document.getElementById(item).style;
    	} else if (NS4) {
    	  daItem = document.layers[item];
    	} else {
    	  daItem = document.all(item).style;
    	}
    }
	isActive = item;
	isActiveLink = itemlink;
   //show this one
	daItem.visibility = visible;
	
    //* change currSection if necessary
    var currSectionButton;
    if( currSectionButton = document.getElementById( 'menu' + currSection ) ) {
        //alert( item + ' != ' + 'submenu' + currSection );
        currSectionButton.style.backgroundColor = (item == 'submenu'+currSection) ? '#abda4d' : 'transparent';
    }
    //*/
}

function menuOff(item) {
   //start timer to hide current menu
   menuitem = item;
   hideMenu = setTimeout('hideItem(isActive,menuitem,true)',100);
}

function subOn(item) {
   //stop current menu hide
   clearTimeout(hideMenu);
   //keep main item hilited
	if (DOM) {
	  daItem = document.getElementById(item);
	} else if (NS4) {
	  daItem = document.layers[item];
	} else {
	  daItem = document.all(item);
	}
	daItem.className = "menuon";
}

function hideItem( item, mainitem, showSection ) {
	if (DOM) {
	  daItem = document.getElementById(item).style;
	} else if (NS4) {
	  daItem = document.layers[item];
	} else {
	  daItem = document.all(item).style;
	}
	isActive = "";
   //hide menu
	daItem.visibility = hidden;
   //keep main item unhilited
   if (mainitem != null) {
   	if (DOM) {
   	  daItem = document.getElementById(mainitem);
   	} else if (NS4) {
   	  daItem = document.layers[mainitem];
   	} else {
   	  daItem = document.all(mainitem);
   	}
   	daItem.className = "menuoff";
   }
   
   //alert( 'item:'+item+' \nmainitem:'+mainitem+'\ncurrSection:' + currSection );
   if( showSection && currSection ) setCurrentSection( currSection );

}

function checkActive() {
	if (isActive != "") {
      //start timer to hide current menu
		hideMenu = setTimeout('hideItem(isActive,null,true)',100);
	} else if( currSection ) {
	    setCurrentSection( currSection );
	}
}

function changeCss(id,theClass) {
	document.getElementById(id).className = theClass;
}

//select nav bar
function navChange(obj) {
   if (obj.value != "") {
      location.href = obj.value;
   }
}

//checks form field for value
function checkField(val, obj) {
   if (obj.value == val) {
      obj.value = "";
   }
}