var ie = (document.all) ? 1:0
var dom = (document.getElementById && !document.all) ? 1:0
var killNav = 0

// Browser Detect Lite  v2.1.4
// http://www.dithered.com/javascript/browser_detect/index.html
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
  
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // platform
   this.isMac   = (ua.indexOf('mac') != -1);
   
   // specific browser shortcuts
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();

if(browser.isIE == true && browser.isMac == true){
	killNav = 1 //Kills drop down nav for Mac IE
}

// Preload Images
operations=new Image(); operations.src="images/nav_operations.gif"
operationsOv=new Image(); operationsOv.src="images/nav_operations_over.gif"
operationsOn=new Image(); operationsOn.src="images/nav_operations_on.gif"
aboutus=new Image(); aboutus.src="images/nav_aboutus.gif"
aboutusOv=new Image(); aboutusOv.src="images/nav_aboutus_over.gif"
aboutusOn=new Image(); aboutusOn.src="images/nav_aboutus_on.gif"
press=new Image(); press.src="images/nav_press.gif"
pressOv=new Image(); pressOv.src="images/nav_press_over.gif"
pressOn=new Image(); pressOn.src="images/nav_press_on.gif"
investors=new Image(); investors.src="images/nav_investors.gif"
investorsOv=new Image(); investorsOv.src="images/nav_investors_over.gif"
investorsOn=new Image(); investorsOn.src="images/nav_investors_on.gif"
contactus=new Image(); contactus.src="images/nav_contactus.gif"
contactusOv=new Image(); contactusOv.src="images/nav_contactus_over.gif"
contactusOn=new Image(); contactusOn.src="images/nav_contactus_on.gif"

var pageLoaded = 0; var timer; var timer2;
var sections = new Array("operations","aboutus","press","investors","contactus")

function init(){
	pageLoaded = 1
	if(activeNav != ""){document.images[activeNav+"Img"].src = eval(activeNav + "On.src")}
	positionSNav()
}
onload = init;

// Resize on Refresh
window.onresize = function() {
     window.location.reload();
}

// Reposition SubNavs ********************************************
function positionSNav(){
	theLeft = getLeftPos("operationsImg")

	document.getElementById("operationsDiv").style.left = theLeft;
	document.getElementById("aboutusDiv").style.left = theLeft+81;
	document.getElementById("pressDiv").style.left = theLeft+150;
	document.getElementById("investorsDiv").style.left = theLeft+228;
}

// Get position of nav for DIV placement *****************************************************
function getLeftPos(which){
var img = document.images[which];
	if(ie || dom){return( getX(img))}
	if(ns4){return(getXNS(which))}
	}
function getX(obj){
	return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
	}
function getXNS(name){
	return(document.images[name].x)
	}


// RollOver Script
function iC(imageID,which){
	if(which == 1 && activeNav!=imageID){document.images[imageID+"Img"].src = eval(imageID + "Ov.src")}
	if(which == 1 && activeNav==imageID){document.images[imageID+"Img"].src = eval(imageID + "Ov.src")}
	if(which == 0 && activeNav!=imageID){document.images[imageID+"Img"].src = eval(imageID + ".src")}
	if(which == 0 && activeNav==imageID){document.images[imageID+"Img"].src = eval(imageID + "On.src")}
}

	//ShowHide Divs
function showHide(layerName,v){
	if(pageLoaded==0){return}
	thelayerName = layerName	
	if(v==1){
		for(i=0;i<sections.length;i++){ //hide all other layers first
			if(killNav == 0){showHideDiv(sections[i],0)}
			iC(sections[i],0)
			}
		iC(thelayerName,1)
		if(killNav == 0){showHideDiv(thelayerName,1)}
	}
	else {
		if(thelayerName != "contactus"){
			if(killNav == 0){timer = setTimeout("showHideDiv(thelayerName,0)",500)} //hide the layer after a delay
			timer2 = setTimeout("iC(thelayerName,0)",500)
		} else {
			if(killNav == 0){showHideDiv(thelayerName,0)}
			iC(thelayerName,0)
		}
	}
}
function showHideDiv(layerName,v){
layerName = layerName+"Div"
	if (v == 0) {option = 'hidden';}
	else if(v == 1){option = 'visible';}
	if(ie) {document.all(layerName).style.visibility = option;}
	else if (dom) {document.getElementById(layerName).style.visibility = option}
}
function killDelay(){
	window.clearTimeout(timer);
	window.clearTimeout(timer2);
} 