<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://www.willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
var timeoutcounter;
/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "/buttons/";
var ButtonState = new Array();


/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("svcsbtnup.png","partnerbtnup.png","newsbtnup.png","aboutusbtnup.png","careersbtnup.png","trainingbtnup.png");
overSources = new Array("svcsbtnover.png","partnersbtnover.png","newsbtnover.png","aboutusbtnover.png","careersbtnover.png","trainingbtnover.png");


function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX-50) + "px";
d.style.top = (cY) + "px";
}
function HideContent(currWin) {
if(currWin.length < 1) { return; }
document.getElementById(currWin).style.display = "none"


}
function keepalive(){
	clearTimeout(timeoutcounter);
}

function btnTimer(currWin) {
//window.setTimeout("HideContent(currWin)",600);
timeoutcounter = setTimeout(function(){
					if(currWin.length < 1) {return; }
					document.getElementById(currWin).style.display = "none";
					clearTimeout(timeoutcounter);
					}, 25);

}

function winClose(currWin) {
	timeoutcounter = setTimeout(function(){
										 if (currWin.length < 1) {return; }
										 document.getElementById(currWin).style.display = "none";
										 clearTimeout(timeoutcounter);
										 }, 10);
}

function playMovie(movieName) {
	var movie = document.getElementById(movieName);
	window.document[movieName].play();
}

function stopMovie(movieName) {
	var movie = document.getElementById(movieName);
	window.document[movieName].stop();
}

function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document[But].src = buttonFolder + overSources[ID-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {

	document[But].src = buttonFolder + upSources[ID-1];
}

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}
function bodyClick() {
	//close the windows that are open
	if (ButtonState["ServicesButton"] == 1){ToggleMenu('ServicesButton','svcsBtn', 1);}
	if (ButtonState["PartnersButton"] == 1){ToggleMenu('PartnersButton','partnerBtn', 2);}
	if (ButtonState["NewsButton"] == 1){ToggleMenu('NewsButton','newsBtn', 3);}
	if (ButtonState["AboutUsButton"] == 1){ToggleMenu('AboutUsButton','aboutusBtn', 4);}
	if (ButtonState["CareersButton"] == 1){ToggleMenu('CareersButton','careersBtn', 5);}
	if (ButtonState["TrainingButton"] == 1){ToggleMenu('TrainingButton','trainingBtn', 6);}
	if (ButtonState["leaderMenu"] == 1){ToggleSubMenu('Leadership', 'leaderMenu', 'aboutusBtn');}
	if (ButtonState["livingMenu"] ==1){ToggleSubMenu('LivingSub', 'livingMenu', 'svcsBtn');}
	if (ButtonState["thingsdoMenu"] ==1){ToggleSubMenu('ThingsDoSub', 'thingsdoMenu', 'svcsBtn');}
	if (ButtonState["workingMenu"] ==1){ToggleSubMenu('WorkSub', 'workingMenu', 'svcsBtn');}
	if (ButtonState["otherMenu"] ==1){ToggleSubMenu('OtherSub', 'otherMenu', 'svcsBtn');}

}

function ToggleSubMenu(d, span, parent) {
	var subtop, subleft, height, width, bottom;
		
	var menuElement = document.getElementById(d);
	if (ButtonState[d] == 1) {
		menuElement.style.display = "none";
		ButtonState[d] = 0;
	}
	else {
		menuElement.style.display = "block";
		width = document.getElementById(parent).offsetWidth;
		//menuElement.style.left = width + 50 + "px";
		menuElement.style.left = findLeft(parent) + width + "px";
		menuElement.style.top = findTop(parent) + 50 + "px";
		//menuElement.style.width = "155";
		ButtonState[d] = 1;
		if (d != "LivingSub"){winClose('LivingSub'); ButtonState['LivingSub'] = 0;}
		if (d != "WorkSub"){winClose('WorkSub'); ButtonState['WorkSub'] = 0;}
		if (d != "OtherSub"){winClose('OtherSub'); ButtonState['OtherSub'] = 0;}
		if (d != "ThingsDoSub"){winClose('ThingsDoSub'); ButtonState['ThingsDoSub'] = 0;}
		
	}
}
function ToggleMenu(d, btn, id) {
	var top, left, height, width, bottom;
	top = findTop(btn);
	left = findLeft(btn);
	
	//find the bottom
	var btnElement = document.getElementById(btn);
	height = btnElement.offsetHeight;
	width = btnElement.offsetWidth;
	bottom = height + top;

	if(d.length < 1) { return; }
	var menuElement = document.getElementById(d);
	menuElement.style.left = left + "px";
	menuElement.style.top = bottom + "px";
	//menuElement.style.width = (width + 40) + "px";
	
	if (ButtonState[d] == 1){
		//Menu is displayed, hide it
		winClose(d);
		btnElement.src = buttonFolder + upSources[id -1];
		ButtonState[d] = 0;
		
	}
	else {
		//Menu is not displayed, show it
		menuElement.style.display = "block";
		//menuElement.style.width = "150px";
		btnElement.src = buttonFolder + overSources[id -1];
		ButtonState[d] = 1;

		//hide all other buttons
        if (d != "ServicesButton"){winClose('ServicesButton'); ButtonState['ServicesButton'] = 0; document["svcsBtn"].src = buttonFolder + upSources[0];}
	    if (d != "PartnersButton"){winClose('PartnersButton'); ButtonState['PartnersButton'] = 0; document["partnerBtn"].src = buttonFolder + upSources[1];}
    	if (d != "NewsButton"){winClose('NewsButton'); ButtonState['NewsButton'] = 0; document["newsBtn"].src = buttonFolder + upSources[2];}
	    if (d != "AboutUsButton"){winClose('AboutUsButton'); ButtonState['AboutUsButton'] = 0; document["aboutusBtn"].src = buttonFolder + upSources[3];}
    	if (d != "CareersButton"){winClose('CareersButton'); ButtonState['CareersButton'] = 0; document["careersBtn"].src = buttonFolder + upSources[4];}
    	if (d != "TrainingButton"){winClose('TrainingButton'); ButtonState['TrainingButton'] = 0; document["trainingBtn"].src = buttonFolder + upSources[5];}

	}
}
function findTop(obj)
{
	var top = 0;
	var ElementTop = document.getElementById(obj);
	
	while (ElementTop != null){
		top += ElementTop .offsetTop;
		ElementTop = ElementTop.offsetParent;
	}

	return(top);
}

function findLeft(obj)
{
	var left = 0;
	var ElementLeft = document.getElementById(obj);
	
	while (ElementLeft != null){
		left += ElementLeft.offsetLeft;
		ElementLeft = ElementLeft.offsetParent;
	}
	return(left);
}

function fadeLeaders(ref){
	var ids = new Array("esolimon","ekaul","vsmith","jmoen","jparsons","mcody");
	for (var i in ids){
		if (i != ref){
			document.getElementById(ids[i] + "pic").style.opacity = 0.2;
			document.getElementById(ids[i] + "pic").style.filter = "alpha(opacity=20)";
			document.getElementById(ids[i]).style.display = "none";
		}
		else {
			document.getElementById(ids[i] + "pic").style.opacity = 1.0;
			document.getElementById(ids[i] + "pic").style.filter = "alpha(opacity=100)";
			document.getElementById(ids[i]).style.display = "block";
		}
		
		
	}
	
}


function fadeOthers(ref){
	var ids = new Array("aroth","dwright","evelasquez","mwright","ndickens");
	for (var i in ids){
		if (i != ref){
			document.getElementById(ids[i] + "pic").style.opacity = 0.2;
			document.getElementById(ids[i] + "pic").style.filter = "alpha(opacity=20)";
			document.getElementById(ids[i]).style.display = "none";
		}
		else {
			document.getElementById(ids[i] + "pic").style.opacity = 1.0;
			document.getElementById(ids[i] + "pic").style.filter = "alpha(opacity=100)";
			document.getElementById(ids[i]).style.display = "block";
		}
		
		
	}
	
}
	
function startdrag(t, e) {   
    if (e.preventDefault) e.preventDefault(); //line for IE compatibility   
    e.cancelBubble = true;   
    window.document.onmousemoveOld = window.document.onmousemove;   
    window.document.onmouseupOld = window.document.onmouseup;   
    window.document.onmousemove=dodrag;   
    window.document.onmouseup=stopdrag;   
    window.document.draged = t;   
    t.dragX = e.clientX;   
    t.dragY = e.clientY;   
    return false;   
}   
//move the DIV   
function dodrag(e) {   
       
    if (!e) e = event; //line for IE compatibility   
    t = window.document.draged;   
    t.style.left = (t.offsetLeft + e.clientX - t.dragX)+"px";   
    t.style.top = (t.offsetTop + e.clientY - t.dragY)+"px";   
    t.dragX = e.clientX;   
    t.dragY = e.clientY;   
    return false;   
}   
//restore event-handlers   
function stopdrag() {   
   window.document.onmousemove=window.document.onmousemoveOld;   
   window.document.onmouseup=window.document.onmouseupOld;   
}   

function displayRelease(id, divWidth) {
	//display in the center of the screen
	displayDeadCenter(457, id);

	grayOut(true);
	document.getElementById(id).style.display = "block";
	document.getElementById(id).style.top = 50 + "px";
	document.getElementById(id).style.width = divWidth + "px";
}

function hideRelease(id) {
	//hide the desired release
	grayOut(false);
	document.getElementById(id).style.display = "none";
}

function grayOut(vis, options) {
// Pass true to gray out screen, false to ungray
// options are optional. This is a JSON object with the following (optional) properties
// opacity:0-100 // Lower number = less grayout higher = more of a blackout 
// zindex: # // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx) // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order. Pass only the properties you need to set.
var options = options || {}; 
var zindex = options.zindex || 500;
var opacity = options.opacity || 85;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#000000';
var dark=document.getElementById('darkenScreenObject');
if (!dark) {
// The dark layer doesn't exist, it's never been created. So we'll
// create it here and apply some basic styles.
// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
var tbody = document.getElementsByTagName("body")[0];
var tnode = document.createElement('div'); // Create the layer.
tnode.style.position='absolute'; // Position absolutely
tnode.style.top='0px'; // In the top
tnode.style.left='0px'; // Left corner of the page
tnode.style.overflow='hidden'; // Try to avoid making scroll bars 
tnode.style.display='none'; // Start out Hidden
tnode.id='darkenScreenObject'; // Name it so we can find it later
tbody.appendChild(tnode); // Add it to the web page
dark=document.getElementById('darkenScreenObject'); // Get the object.
}
if (vis) {
// Calculate the page width and height 
if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
var pageWidth = document.body.scrollWidth + 20 +'px';
var pageHeight = document.body.scrollHeight + 200 + 'px';
} else if( document.body.offsetWidth ) {
var pageWidth = document.body.offsetWidth + 20 +'px';
var pageHeight = document.body.offsetHeight+ 200 +'px';
} else {
var pageWidth='100%';
var pageHeight='100%';
} 
//set the shader to cover the entire page and make it visible.
dark.style.opacity=opaque; 
dark.style.MozOpacity=opaque; 
dark.style.filter='alpha(opacity='+opacity+')'; 
dark.style.zIndex=zindex; 
dark.style.backgroundColor=bgcolor; 
dark.style.width= pageWidth;
dark.style.height= pageHeight;
dark.style.display='block'; 
} else {
dark.style.display='none';
}
}

function displayDeadCenter(XWidth, divid) {
	
	var centerX;
	
	if (self.innerHeight) {
		centerX = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		centerX = document.documentElement.clientWidth;
	}
	else if (document.body){
		centerX = document.body.clientWidth;
	}
	
	
	var leftoffset = (centerX - XWidth) / 2;
	document.getElementById(divid).style.left = leftoffset + "px";
}
