checkBrowser();
setTimeout("moveMenu()",1000);
reSelectForm();
window.onscroll = "moveMenu()" ;

function checkBrowser() {
	// when entering the site, check if proper browser is used
	var referringpage = unescape(document.referrer) ;
	var thispage = unescape(document.location.href) ;
	entering_the_site = true ;
	if (referringpage == thispage) {
		entering_the_site = false ;
	}
	var lastSlash = thispage.lastIndexOf("/") ;
	if (referringpage.substr(0,7) == "http://") {
		if (referringpage.substr(0,lastSlash) == thispage.substr(0,lastSlash)) {
			entering_the_site = false ;
		}
	}
	
	if (entering_the_site == true) {
		//check browser used
		type = getBrowserType() ;
		platform = getPlatform() ;
		version = (navigator.appVersion).substr(0,1) ;
		if (type =="Netscape" && version < 7) {
			document.location.href = "browser_warning.php" ;
		} else if (type =="Mozilla" && version < 1) {
			document.location.href = "browser_warning.php" ;
		} else if (type =="Internet Explorer" && platform == "Macintosh") {
			document.location.href = "browser_warning.php" ;
		} else if (type != "Internet Explorer" && type !="Netscape" && type !="Mozilla" && type !="Safari") {
			document.location.href = "browser_warning.php" ;
		} else if (thispage.indexOf("index.html") != -1 || 
		  thispage.indexOf("index.php") != -1 || 
		  lastSlash == (thispage.length)-1) {
			document.location.href = "search.php" ;
		}
	}
}

function selectSearchForm() {
	if (document.search_form) {
		if (document.search_form.search_string) {
			document.search_form.search_string.focus();
			document.search_form.search_string.select();
		}
	}
}

function checkSearchForm() {
	search_string = document.search_form.search_string.value ;
	if (search_string == "") {
		alert ("Please enter the name that you want to find.") ;
		document.search_form.search_string.focus();
		document.search_form.search_string.select();
		return false ;
	}
	if (document.select_hub) {
		if (document.select_hub.IntegratedHub.checked == true) {
			document.search_form.hub.value = "IntegratedHub" ;
		} else if (document.select_hub.EuroHub.checked == true) {
			document.search_form.hub.value = "EuroHub" ;
		} else if (document.select_hub.GlobalHub.checked == true) {
			document.search_form.hub.value = "GlobalHub" ;
		} else {
			document.search_form.hub.value = "" ;
		}
	}
}

function switchRadioButtons(currentRadioButton) {
	if (currentRadioButton == "IntegratedHub" && document.select_hub) {
		if (document.select_hub.IntegratedHub.checked = true)  {
			document.select_hub.EuroHub.checked = false ;
			document.select_hub.GlobalHub.checked = false ;	
		}
		
	} else if (currentRadioButton == "EuroHub" && document.select_hub) {
		if (document.select_hub.EuroHub.checked = true)  {
			document.select_hub.IntegratedHub.checked = false ;
			document.select_hub.GlobalHub.checked = false ;	
		}
		
	} else if (currentRadioButton == "GlobalHub" && document.select_hub) {
		if (document.select_hub.GlobalHub.checked = true)  {
			document.select_hub.IntegratedHub.checked = false ;
			document.select_hub.EuroHub.checked = false ;	
		}
		
	}
}

function deSelectForm(){
	browser = getBrowserType() ;
	if (browser == "Internet Explorer" && document.search_form && document.storage) {
		if (document.search_form.search_string && document.storage.text_selection) {
			if (document.all) {
				var theRange = document.search_form.search_string.createTextRange() ;
				var theSelection = theRange.getBookmark() ;
				document.storage.text_selection.value = theSelection ;
			} else {
				selectionStart = document.search_form.search_string.selectionStart ;
				selectionEnd = document.search_form.search_string.selectionEnd ;
				theSelection = selectionStart + "," + selectionEnd ;
				document.storage.text_selection.value = theSelection ;
			}
			document.search_form.search_string.blur() ;
		}
	}
}

function reSelectForm() {
	browser = getBrowserType() ;
	if (browser == "Internet Explorer" && document.search_form && document.storage) {
		if (document.search_form.search_string && document.storage.text_selection) {
			if (layerIsVisible("menu_browse") == false && layerIsVisible("menu_search") == false && layerIsVisible("menu_info") == false ) {
				var oldSelection = document.storage.text_selection.value ;
				document.storage.text_selection.value = "" ;
				if (oldSelection != "") {
					if (document.all) {
						var theRange = document.search_form.search_string.createTextRange() ;
						var theSelection = theRange.moveToBookmark(oldSelection) ;
					} else {
						oldSelection = oldSelection.split(",") ;
						eval ("document.search_form.search_string.selectionStart = " + oldSelection[0]) ;
						eval ("document.search_form.search_string.selectionEnd = " + oldSelection[1]) ;
					}
					document.search_form.search_string.focus() ;
				}
			}
		}
	}
	setTimeout("reSelectForm()",2000);
}

function selectMenuRow(theRow) {
   if (document.getElementById) {
      var tr = eval("document.getElementById(\"" + theRow + "\")");
	   if (tr.style) {
		   tr.style.backgroundColor = "#EAF2F7";
		   tr.style.Color = "#000066";
	   }
   }
}

function deSelectMenuRow(theRow) {
   if (document.getElementById) {
		var tr = eval("document.getElementById(\"" + theRow + "\")");
		if (tr.style) {
			tr.style.backgroundColor = "";
		}
   }
}

function moveMenu() {
	menuLayer = document.getElementById('menu_layer') ;
	theScroll = 0;
	if (window.pageYOffset) {
		theScroll = window.pageYOffset;
	} else if (window.document.documentElement && window.document.documentElement.scrollTop) {
		theScroll = window.document.body.scrollTop;
	} else if (window.document.body) {
		theScroll = window.document.body.scrollTop;
	}
	var newY = theScroll + "px";
	if (menuLayer) {
		menuLayer.style.top = newY;
		setTimeout("moveMenu()",500);
	}
}

function ShowLayer(id, action){
	if (document.all)  {
		eval("document.all." + id + ".style.visibility='" + action + "'");
	} else if (document.getElementById) {
		eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
	} else {
		eval("document." + id + ".visibility='" + action + "'");
	}
}

function layerIsVisible(id){
	if (document.all)  {
		if (eval("document.all." + id)) {
			return eval("document.all." + id + ".style.visibility");
		} else {
			return false ;
		}
	} else if (document.getElementById) {
		if (eval("document.getElementById('" + id + "')")) {
			return eval("document.getElementById('" + id + "').style.visibility");
		} else {
			return false ;
		}
	} else {
		if (eval("document." + id)) {
			return eval("document." + id + ".visibility");
		} else {
			return false ;
		}
	}
}

function getBrowserType() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="Opera";	
	else if (navigator.userAgent.indexOf("Safari")!=-1) type="Safari";	
	else if (navigator.userAgent.indexOf("iCab")!=-1) type="iCab";	
	else if (document.all) type="Internet Explorer";
	else if (document.layers) type="Netscape";	//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="Mozilla"; //Mozila e.g. Netscape 6 upwards
	else type = "??";		//I assume it will not get here
	return type ;
}

function getPlatform() {
	browserInfo = navigator.userAgent.toLowerCase() ;
	if (browserInfo.indexOf("win")!=-1) {
		platform = "Windows" ;
	} else if (browserInfo.indexOf("mac")!=-1) {
		platform = "Macintosh" ;
	} else {
		platform = "??" ;
	}
	return platform ;
}

function showStatus(message) {
    window.status = unescape(message) ;
    return true ;
}