
var primaryNav;
var secondaryNav;
var imagepath;
var activeTimeout = null;
var timeoutLength = 3000;
var sectionList = new Array('Training','Certification','Partners');
function changeImages(object_name, image_src) {
	if (typeof document[object_name] != "undefined")
		document[object_name].src = image_src;
}

function getElement(id) {
	var object = null;
	if (document.getElementById) 
		object = document.getElementById(id);
	else {
		if (document.layers) 
			object = document.layers[id];
		else if (document.all) 
			object = eval("document.all." + id);
	}
	return object;
}

function bar_open(id) {
	getElement('bar_' + id ).style.display='inline';
	getElement('hide_' + id).style.display='inline';
	getElement('show_' + id).style.display='none';
}
function bar_close(id) {
	getElement('bar_' + id).style.display='none';
	getElement('hide_' + id).style.display='none';
	getElement('show_' + id).style.display='inline';
}

function activateNav() {
	changeImages(primaryNav + '_img', imagepath + '/navigation/primary/' + primaryNav + '_on.gif');
	var anchor = getElement(primaryNav + '_' + secondaryNav);
	if (anchor != null)
		anchor.className = 'active';
	activateSection(primaryNav);
}

function resetNav() {
	doActivateSection(primaryNav);
}

function activateSection(sectionToActivate) {
	stopTimer();
	doActivateSection(sectionToActivate);
}

function stopTimer() {
	if (activeTimeout != null)
		clearTimeout(activeTimeout);
}

function resetTimer() {
	stopTimer();
	activeTimeout = setTimeout("resetNav()", timeoutLength);
}

function doActivateSection(sectionToActivate) {
	for (i = 0; i < sectionList.length; i++) {
		var section = sectionList[i];
		if (section == sectionToActivate) {
			toggleVisibility(section, "visible");
			if (section != primaryNav)
				changeImages(section + '_img', imagepath + '/navigation/primary/' + section + '_over.gif');
		} else {
			toggleVisibility(section, "hidden");
			if (section != primaryNav)
				changeImages(section + '_img', imagepath + '/navigation/primary/' + section + '.gif');
		}
	}
}

function setElementDisplay(id, newVisibility) {
	var div = getElement(id);
	if (div != null)
		div.style.display = newVisibility;
}

function toggleVisibility(id, newVisibility) {
	var div = getElement(id);
	if (div != null)
		div.style.visibility = newVisibility;
}

function getNavId () {
	var metaElements = document.all ?
	document.all.tags('META') :
	document.getElementsByTagName ?
	document.getElementsByTagName ('META') : new Array();
	for (var m = 0; m < metaElements.length; m++){
		if (metaElements[m].name == 'PrimaryNav')
			primaryNav = metaElements[m].content;
		if (metaElements[m].name == 'SecondaryNav')
			secondaryNav = metaElements[m].content;
		if (metaElements[m].name == 'imagepath')
			imagepath = metaElements[m].content;
	}
}

/*  Hold for future needs

function getmacflash(){
document.write('<object WIDTH="730" HEIGHT="120">')
document.write('<param name="movie" value="'+imagepath+'/EDHeader.swf">')
document.write('<embed src="'+imagepath+'/EDHeader.swf" width="730" height="120">')
document.write('</embed>')
document.write('</object>')
}

*/

var is_major = parseInt(navigator.appVersion);
var agt = navigator.appVersion.toLowerCase();

function cookieVal(cookieName) {
	thisCookie = document.cookie.split("; ");
 	    for (i=0; i<thisCookie.length; i++) {
 	        if (cookieName == thisCookie[i].split("=")[0]) {
 	        	return thisCookie[i].split("=")[1]
 	        }
  	    }
	return 0;
}

function browserkind(bwtype) {
	if (browsertype ==0){
		if (
			((agt.indexOf("opera")!=-1) && (is_major < 7)) ||                // Opera 6 or lower
			(document.layers)      ||                                    // Netscape 4 or lower
			((navigator.appName.indexOf("Netscape") > -1) && parseInt(navigator.vendorSub) < 7) || // Netscape 6
			((agt.indexOf("msie 5.0")!=-1) && (is_major == 4)) ||        // IE 5.0
			((agt.indexOf("msie 4")  !=-1) && (is_major == 4)) ||        // IE 4
			((agt.indexOf("msie")    !=-1) && (is_major  < 4))           // IE 3
		) {
			window.open('http://merc-training.cce.hp.com/main/incompatible.html','','toolbar=0,width=820,height=560,scrollbars=1,resizable=no');
		} 
	}
 }

	function initKeepAlive() {
		window.setTimeout("keepAlive()",500000);
	}

	function keepAlive() {
		window.document.getElementById("MTKeepAlive").src=window.document.getElementById("MTKeepAlive").src;
		initKeepAlive();
		
	}
