﻿var globalNavRoot;
var g;
function closeIt(){
	for (g=0; g<globalNavRoot.childNodes.length; g++){
		globalNavRoot.childNodes[g].className=this.className.replace(" displayBlock", "");
	}
}
function globalTopNav() {
	 ContentMenuNav();
     if (document.getElementById) {
          globalNavRoot = document.getElementById('nav');
		  if (globalNavRoot !=null ) {
			   var allLi = document.getElementById('nav').getElementsByTagName('LI').length;
	          for (i=0; i<globalNavRoot.childNodes.length; i++) {
	               node = globalNavRoot.childNodes[i];
	               if (node.nodeName=='LI') {
	                    node.onmouseover=function() {
	                         this.className+=' displayBlock';
	                    }
						node.onkeypress=function() {
	                         this.className+=' displayBlock';
	                    }
	                    node.onmouseout=function() {
							 this.className=this.className.replace(" displayBlock", ""); 
	                    }
						// following commented out to fix error in all browsers - need to redo to alow tabbing - PK_21_April
						//node.childNodes[0].onfocus=function(){
						//	 closeIt();
						//	this.parentNode.className+=' displayBlock';
						//}
				   }
	          }
			globalNavRoot.getElementsByTagName('LI')[allLi-1].childNodes[0].onblur=function(){
				closeIt(); 
			}
		}
     }
}

function ContentMenuNav() {
     if (document.getElementById) {
          globalNavRoot = document.getElementById('nav2');
		  if (globalNavRoot !=null ) {
			   var allLi = document.getElementById('nav2').getElementsByTagName('LI').length;
	          for (i=0; i<globalNavRoot.childNodes.length; i++) {
	               node = globalNavRoot.childNodes[i];
	               if (node.nodeName=='LI') {
	                    node.onmouseover=function() {
	                         this.className+=' displayBlock';
	                    }
						node.onkeypress=function() {
	                         this.className+=' displayBlock';
	                    }
	                    node.onmouseout=function() {
							 this.className=this.className.replace(" displayBlock", ""); 
	                    }
						// following commented out to fix error in all browsers - need to redo to alow tabbing - PK_21_April
						//node.childNodes[0].onfocus=function(){
						//	 closeIt();
						//	this.parentNode.className+=' displayBlock';
						//}
				   }
	          }
			globalNavRoot.getElementsByTagName('LI')[allLi-1].childNodes[0].onblur=function(){
				closeIt(); 
			}
		}
     }
}



/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

function pageoverlay(url, element) {
	overlay();
	ajaxpage(url, element);
	
}
function overlay() {
	elb = document.getElementById("outer");
	elb.style.visibility = (elb.style.visibility == "visible") ? "hidden" : "visible";
	el = document.getElementById("overlay");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
	
	
}
function checkchecked(myform, element) {
	elb = document.getElementById(element)
  	if (! elb.checked) {
  		alert("Please read and accept our terms and conditions first...");
  		return false;
  	}
  	return true;
}
function checkuncheckAll(f,name,bool){
	var reg=new RegExp(name,'g')
	var elem=f.elements, i=0, e;
	while(e=elem[i++]){
	e.name.match(reg)?e.checked=bool:null;
	}
} 


window.onload=globalTopNav;
