var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
var currentPage = ""; //stores which page we are on, specifically, the id of the a tag

function hidelayers() {
	if(ie4 || ns6){
		var arrLayer = Array('nav-hide-button','nav-about-us-sub','nav-solutions-sub','nav-services-sub','nav-training-sub','nav-partners-sub','nav-news-sub','nav-customers-sub');
		var arrButton = Array('nav-about-us-button','nav-solutions-button','nav-services-button','nav-training-button','nav-partners-button','nav-news-button','nav-customers-button');
		
		for(var whichLayer = 0; whichLayer < arrLayer.length; whichLayer++){
			if (ie4) {
				if(document.all[arrLayer[whichLayer]]){
					document.all[arrLayer[whichLayer]].style.visibility = "hidden";
				}
			}
			if (ns6) {
				if(document.getElementById([arrLayer[whichLayer]])){
					document.getElementById([arrLayer[whichLayer]]).style.visibility = "hidden";
				}
			}
		}
		
		for(var whichButton = 0; whichButton < arrButton.length; whichButton++){
			setNav(arrButton[whichButton], "", false);
			//if (ie4) {document.all[arrButton[whichButton]].className = "";}
			//if (ns6) {document.getElementById([arrButton[whichButton]]).className = "";}
		}
	}
}

function showlayer(whichLayer, parentLayer, parentClass) {
	if (ie4) {document.all[whichLayer].style.visibility = "visible";}
	if (ns6) {document.getElementById([whichLayer]).style.visibility = "visible";}
	
	if (ie4) {document.all['nav-hide-button'].style.visibility = "visible";}
	if (ns6) {document.getElementById(['nav-hide-button']).style.visibility = "visible";}	
	
	setNav(parentLayer, parentClass, false);
}

function showHideBio(whichLayer){
	if (ie4) {
		if(document.all[whichLayer].style.display=="block"){
			document.all[whichLayer].style.display = "none";
		}else{
			document.all[whichLayer].style.display = "block"
		}
	}
	if (ns6) {
		if(document.getElementById([whichLayer]).style.display=="block"){
			document.getElementById([whichLayer]).style.display = "none";
		}else{
			document.getElementById([whichLayer]).style.display = "block"
		}
	}
}

function setNav(theobject, theclass, pageLoad){
	if((currentPage!=theobject && !pageLoad) || pageLoad){
		if (ie4) {document.all[theobject].className = theclass;}
		if (ns6) {document.getElementById([theobject]).className = theclass;}	
	}
}


/*******************************************************
FLASH DETECT 2.5
All code by Ryan Parman and mjac, unless otherwise noted.
(c) 1997-2004 Ryan Parman and mjac
http://www.skyzyx.com
*******************************************************/

// This script will test up to the following version.
flash_versions = 20;

// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';

// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}

// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject) {
	for (x = 2; x <= flash_versions; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = x + '.0';
			}
		}
		catch(e) {}
	}
}

// Create sniffing variables in the following style: flash.ver[x]
// Modified by mjac
flash.ver = Array();
for(i = 4; i <= flash_versions; i++) {
	eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
}


//Set the down states of the nav
function checkNav(){
	var whichPage = window.location.pathname;
	if(whichPage.indexOf("/about/")!=-1){
		currentPage = "nav-about-us-button";
		setNav("nav-about-us-button","nav-about-us-button-hover", true);
	}else if(whichPage.indexOf("/solutions/")!=-1){
		currentPage = "nav-solutions-button";
		setNav("nav-solutions-button","nav-solutions-button-hover", true);
	}else if(whichPage.indexOf("/services/")!=-1){
		currentPage = "nav-solutions-button";
		setNav("nav-services-button","nav-services-button-hover", true);
	}else if(whichPage.indexOf("/training/")!=-1){
		currentPage = "nav-training-button";
		setNav("nav-training-button","nav-training-button-hover", true);
	}else if(whichPage.indexOf("/partners/")!=-1){
		currentPage = "nav-partners-button";
		setNav("nav-partners-button","nav-partners-button-hover", true);
	}else if(whichPage.indexOf("/news/")!=-1){
		currentPage = "nav-news-button";
		setNav("nav-news-button","nav-news-button-hover", true);
	}else if(whichPage.indexOf("/clients/")!=-1){
		currentPage = "nav-customers-button";
		setNav("nav-customers-button","nav-customers-button-hover", true);
	}
}

function preload(){
	var the_images = new Array('/images/nav/about_dn.jpg',
														 '/images/nav/solutions_dn.jpg',
														 '/images/nav/services_dn.jpg',
														 '/images/nav/training_dn.jpg',
														 '/images/nav/partners_dn.jpg',
														 '/images/nav/news_dn.jpg',
														 '/images/nav/customers_dn.jpg');
	preloadImages(the_images);
}

function preloadImages(the_images_array) {
	for(var loop = 0; loop < the_images_array.length; loop++){
		var an_image = new Image();
		an_image.src = the_images_array[loop];
	}
}


