// Load Images
usPic1 = new Image(214,283)
usPic1.src = "us.jpg"
usPic2 = new Image(223,283)
usPic2.src = "us2.jpg"

whichOpenMenu = null		// Placeholder for the last opened menu.  This way, you know which one to close.
sourceSave = null			// Placeholder for the last sourceEvent

// Set mouse pointer for IE
if(whichBrowser=="IE"){ document.styleSheets[0].addRule(".menuHeading", "cursor:hand") }
if(whichBrowser=="IE"){ document.styleSheets[0].addRule(".menuItem", "cursor:hand") }

if(whichBrowser == "Dom1"){
		window.addEventListener("mouseover",mouseOver,false)
		window.addEventListener("mouseout",mouseOut,false)
	}
	else {
		window.document.onmouseover = mouseOver
		window.document.onmouseout = mouseOut
	}

function openMenu(source, whichMenu){
	whichMenu.style.display=""	// Unhide menu
	whichOpenMenu = whichMenu	// Save this menu's name in a variable
} // End function openMenu()

function closeMenu(source, whichMenu){
	source.bgColor = itemStandardColor	// de-highlight the menu heading
	whichOpenMenu = null				// reset variable
	sourceSave = null					// reset variable
	whichMenu.style.display = "none"	// Hide the menu
} // End function closeMenu()
	
function mouseOver(e){
// Get Main Menu ID
sDivMenuBar = document.getElementById("divMenuBar")
sDivMenuBar2 = document.getElementById("divMenuBar2")
// Find source of event
if((whichBrowser == "Dom1") || (whichBrowser == "Netscape") || (whichBrowser == "Mozilla") || (whichBrowser == "Firefox")) { 
	source = e.target; if(source.nodeType==3){ source = source.parentNode }
}
else { source = window.event.srcElement }

	if(source.className == "menuItem"){
		source.bgColor = itemHighlightColor
	}

	// If it's a menu heading
	if(source.className == "menuHeading"){
	
		// Highlight menu heading
		source.bgColor = itemHighlightColor

		// Get the menu
		whichMenu = document.getElementById([source.id.replace("Heading","Menu")])	// Switch "Heading" with "Menu"
		
		// Get coordinates if from menu #1
		if(whichBrowser == "Dom1"){
			headingLeft = source.offsetLeft
			headingTop = source.offsetTop - 3
			headingRight = headingLeft + source.offsetWidth
			headingBottom = headingTop + source.offsetHeight
		}
		else if(whichBrowser == "Netscape"){
			if(browserVer >= 7){
				pnt = source.offsetParent
				pnt2 = source.offsetParent.offsetParent
				pnt3 = source.offsetParent.offsetParent.offsetParent
				headingLeft = pnt.offsetLeft + pnt2.offsetLeft + pnt3.offsetLeft + source.offsetLeft
				headingTop = pnt.offsetTop + pnt2.offsetTop + pnt3.offsetTop + source.offsetTop - 3
				headingRight = headingLeft + source.offsetWidth
				headingBottom = headingTop + source.offsetHeight
			}
			if((browserVer >= 6.2) && (browserVer < 7)) {
				headingLeft = source.offsetLeft
				headingTop = source.offsetTop - 3
				headingRight = headingLeft + source.offsetWidth
				headingBottom = headingTop + source.offsetHeight
			}

//browserAlert = "whichBrowser: " + whichBrowser
//browserAlert += "\nbrowserVer: " + browserVer
//browserAlert += "\n\nnavigator.appName: " + navigator.appName
//browserAlert += "\nnavigator.appVersion: " + navigator.appVersion
//alert(browserAlert)
		}
		else if(whichBrowser == "Mozilla"){
				pnt = source.offsetParent
				pnt2 = source.offsetParent.offsetParent
				pnt3 = source.offsetParent.offsetParent.offsetParent
				headingLeft = pnt.offsetLeft + pnt2.offsetLeft + pnt3.offsetLeft + source.offsetLeft
				headingTop = pnt.offsetTop + pnt2.offsetTop + pnt3.offsetTop + source.offsetTop - 3
				headingRight = headingLeft + source.offsetWidth
				headingBottom = headingTop + source.offsetHeight
		}
		else{
			pnt = source.offsetParent
			pnt2 = source.offsetParent.offsetParent
			pnt3 = source.offsetParent.offsetParent.offsetParent
			headingLeft = pnt.offsetLeft + pnt2.offsetLeft + pnt3.offsetLeft + source.offsetLeft 
			headingTop = pnt.offsetTop + pnt2.offsetTop + pnt3.offsetTop + source.offsetTop -4
			headingRight = headingLeft + source.offsetWidth
			headingBottom = headingTop + source.offsetHeight
		}
		
		whichMenu.style.left = headingRight
		whichMenu.style.top = headingTop
		
		// Close the menu if another menu is selected
		if(whichOpenMenu && whichOpenMenu != whichMenu){	// If a menu is already open, and a new menu is selected
			closeMenu(sourceSave, whichOpenMenu)			// close the menu that is already open.
		}
		
			sourceSave = source		// Save the menu heading object in a variable so we can de-highlight it later
		
		// Open the menu
		if(whichMenu){						// If a menu heading is highlighted,
			openMenu(source, whichMenu)		// open the associated menu
		}
			
	} // End if className == "menuHeading"
	
	
	// Close the menu
	// Create variable, and adjust it's value to see if the
	// source of the event is within the menu itself, or the
	// menu bar.	
	else if(whichOpenMenu){

		adjustSource = source.parentNode
		if(adjustSource.tagName == "TD") { adjustSource = source.parentNode }
		if(adjustSource.tagName == "TR") { adjustSource = adjustSource.parentNode }
		if(adjustSource.tagName == "TBODY") { adjustSource = adjustSource.parentNode }
		if(adjustSource.tagName == "TABLE") { adjustSource = adjustSource.parentNode }
		if(adjustSource.tagName == "BODY") { adjustSource = source }

		if((adjustSource != whichOpenMenu) && (adjustSource != sDivMenuBar) && (adjustSource != sDivMenuBar2)) {
				closeMenu(sourceSave, whichOpenMenu)
		}
	}

} // End function mouseOver(e)

function mouseOut(e){
	if(source.className == "menuItem"){
		source.bgColor = itemStandardColor
	}
} // End function mouseDown(e)

function newURL(URL){
currentLocation=""
numOfSlashes = 0
numOfSlashes2 = 0

	for (var i=0; i < location.href.length; i++){
		if((location.href.charAt(i) == "/") || (location.href.charAt(i) == "\\")){ numOfSlashes ++ }
	}
	
	for (var i=0; i < location.href.length; i++){
		if((location.href.charAt(i) == "/") || (location.href.charAt(i) == "\\")){ numOfSlashes2 ++ }

		if(numOfSlashes2 != numOfSlashes){ currentLocation += location.href.charAt(i) }
	}
	
	currentLocation += "/"
	location.href = currentLocation + URL
} // End function newURL

function pictureTrans(){
sUsPic = document.getElementById("usPic")
	
	if(sUsPic.src == usPic1.src){
		if(whichBrowser=="Netscape"){
			sUsPic.src = usPic2.src
		}
		else{
			sUsPic.style.filter="blendTrans(duration=2)"
			sUsPic.filters.blendTrans.Apply()
			sUsPic.src = usPic2.src
			sUsPic.filters.blendTrans.Play()
		}
	}
	else if(sUsPic.src == usPic2.src){
		if(whichBrowser=="Netscape"){
			sUsPic.src = usPic1.src
		}
		else{
			sUsPic.style.filter="blendTrans(duration=2)"
			sUsPic.filters.blendTrans.Apply()
			sUsPic.src = usPic1.src
			sUsPic.filters.blendTrans.Play()
		}	
	}
} // End function pictureTrans()

function fitToScreen(){
	sOutsideTable = document.getElementById("outsideTable")
	
	// Find page dimentions
	if(whichBrowser == "IE") {
		docWidth = document.body.clientWidth
		docHeight = document.body.clientHeight
	}
	else{
		docWidth = window.innerWidth
		docHeight = window.innerHeight
	}
	
	sOutsideTable.style.position="absolute"
	sOutsideTable.style.top=0
	sOutsideTable.style.left=0
	sOutsideTable.style.width = parseInt(docWidth)
	sOutsideTable.style.height = parseInt(docHeight)
} // End function fitToScreen()