// JavaScript Document

// SERVICES DROP DOWN

function pageLoad()
{
	var menuId;
	
	if(section && section != "")
	{
		switch(section)
		{
			case "home":
				menuId = document.getElementById("menu-home");	
				menuId.style.background = "url(../images/menu/button-hover.gif)";
				break;
			case "industry":
				menuId = document.getElementById("menu-industry");
				menuId.style.background = "url(../images/menu/button-down-hover.gif)";
				menuId.style.backgroundPosition = "center center";
				break;
			case "capabilities":
				menuId = document.getElementById("menu-capabilities");
				menuId.style.background = "url(../images/menu/button-down-hover.gif)";
				menuId.style.backgroundPosition = "center center";
				break;
			case "news-and-views":
				menuId = document.getElementById("menu-news-and-views");
				menuId.style.background = "url(../images/menu/button-hover.gif)";
				break;
			case "about-us":
				menuId = document.getElementById("menu-about-us");
				menuId.style.background = "url(../images/menu/button-hover.gif)";
				break;
			case "careers":
				menuId = document.getElementById("menu-careers");
				menuId.style.background = "url(../images/menu/button-hover.gif)";
				break;
		}
	} else {
		var section = "";
	}
}

function listMenuChange(list)
{
	var pageLink = list.options[list.selectedIndex].value;
	
	if(pageLink != "nil")
	{
		window.location = "../services/" + pageLink + ".aspx";
	}
}

// CASE STUDY CODE

var id = "casecontent";
var caseStudyOpen = true;
var display = 'inline';

function casecollapse()
{	
	if(caseStudyOpen)
	{		
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'none';
			}
			else { // IE 4
				document.all.id.style.display = 'none';
			}
		}
		caseStudyOpen = false;
	}
	else
	{
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = display;
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = display;
			}
			else { // IE 4
				document.all.id.style.display = display;
			}
		}
		caseStudyOpen = true;
	}
}

// POP-UP CODE

function popUpWindow(popUpLink)
{
	//alert(popUpLink);
	popUpCode(popUpLink);
	//alert("CLICK");
}

function popUpCode(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=900,height=600,left = 270,top = 150');");
}

// MENU CODE

//here you place the ids of every element you want.
//var ids = new Array('Services', 'NewsViews', 'AboutUs', 'Careers');
var ids = new Array('industry', 'capabilities');
var activeid = 'Home';
function switchid(id) {
	hideallids();
	showdiv(id);
}

function hideallids() {

	//loop through the array and hide each element by id
	for (var i = 0; i < ids.length; i++) {
		hidediv(ids[i]);
	}
}
function hideallmenuids() {
	if (activeid != '' && activeid != 'Home') {
		opacity(activeid, 100, 0, 200);
		activeid = 'Home'
	}

}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
	
	if(section && section == "services")
	{	
		// ONLY DO FOR IE6 and LOWER
		ShowHideDropDown('industry', 'show');
		ShowHideDropDown('capabilities', 'show');
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
	if (activeid != id) {
		opacity(id, 0, 100, 200);
		activeid = id;
	}
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
	
	if(section && section == "industry")
	{	
		// ONLY DO FOR IE6 and LOWER
		ShowHideDropDown('industry', 'hide');
		ShowHideDropDown('capabilities', 'hide');
	}	
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if (opacStart > opacEnd) {
		for (i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
			timer++;
		}
		timer++;
		setTimeout("hidediv('" + id + "')", (timer * speed));
	} else if (opacStart < opacEnd) {
		for (i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function ShowHideDropDown(id, mode)
{
	var PropertyToSet = '';
	if (mode != 'show') {
		PropertyToSet = 'none';
	}
	else {
		PropertyToSet = 'inline';
	}
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = PropertyToSet;
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = PropertyToSet;
		}
		else { // IE 4
			document.all.id.style.display = PropertyToSet;
		}
	}
}
