ns = (document.layers)? true:false
ie = (document.all)? true:false
ns6 = (navigator.appName == "Netscape" && document.getElementById)? true:false
winIE5 = false;
var browserString = navigator.appVersion;
if (navigator.userAgent.indexOf("Win") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	if (parseInt(browserString.charAt(22)) < 6){
		winIE5 = true;
	}
}
macIE = false;
macNS = false;
var browserString = navigator.appVersion;
if (navigator.userAgent.indexOf("Mac") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	macIE = true;
}else if(navigator.userAgent.indexOf("Mac") > -1 && navigator.appName != "Microsoft Internet Explorer"){
	macNS = true;
}

//alert(navigator.userAgent);
if (navigator.userAgent.indexOf("Firefox")!=-1){
	//alert("Firefox");
	isFirefox = true;
}else{
	isFirefox = false;
}

function doOnLoad(){
	if( !isFirefox ){
		window.focus();	
	}
}

function doResize(){
	if( !isFirefox ){
		location = location;
	}
}

loaded = false;

function hide(id){
	if (ns) document.layers[id].visibility = "hide"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "hidden"
	}
	else if (ie) document.all[id].style.visibility = "hidden"
}
function show(id){
	if (ns) document.layers[id].visibility = "show"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "visible"
	}
	else if (ie) document.all[id].style.visibility = "visible"
}

bOff = new Image; bOff.src = "../images/nav/bOff.gif";
bOn = new Image; bOn.src = "../images/nav/bOn.gif";

function swap(theName,theIMG){
	theIMG = eval(theIMG);
	document[theName].src = theIMG.src;
}

function menuItem(displayText,theLink,theWidth,theTarget){
	this.displayText= displayText;
	this.theLink	= theLink;
	this.theWidth	= theWidth;
	this.theTarget	= theTarget;
}
mainNav = new Array();
	mainNav[0] = new menuItem("Home", "../home", 57, 0);
	mainNav[1] = new menuItem("Services", "../services", 72, 0);	
	mainNav[2] = new menuItem("Experience", "../casestudies", 87, 0);	
	mainNav[3] = new menuItem("About Us", "../about", 74, 0);	
	mainNav[4] = new menuItem("Contact Us", "../contact", 84, 0);
	mainNav[5] = new menuItem("Client Extranet", "../extranet", 94, 0);
subnav0 = new Array();
subnav1 = new Array();
	subnav1[0] = new menuItem("Strategy and Consulting", "../services/consulting.asp", -1, 0);
	subnav1[1] = new menuItem("Creative Marketing and Branding", "../services/marketing.asp", -1, 0);
	subnav1[2] = new menuItem("Technology and Process Digitization", "../services/tech.asp", -1, 0);
	subnav1[3] = new menuItem("Ongoing Strategy and Support", "../services/strategy.asp", -1, 0);
subnav2 = new Array();
	//subnav2[0] = new menuItem("Bob's Discount Furniture", "../casestudies/bobs.asp", -1, 0);
	subnav2[0] = new menuItem("The Wall Street Journal", "../casestudies/wsj.asp", -1, 0);
	subnav2[1] = new menuItem("Rodney Dangerfield", "../casestudies/rodney.asp", -1, 0);
	subnav2[2] = new menuItem("Financial Times", "../casestudies/ft.asp", -1, 0);
	subnav2[3] = new menuItem("Garber Travel", "../casestudies/garber.asp", -1, 0);
	subnav2[4] = new menuItem("Dav El", "../casestudies/davel.asp", -1, 0);
	//subnav2[6] = new menuItem("iParty", "../casestudies/iparty.asp", -1, 0);
	subnav2[5] = new menuItem("Head of the Charles", "../casestudies/hocr.asp", -1, 0);
	subnav2[6] = new menuItem("Complete Client List", "../about/clients.asp", -1, 0);
subnav3 = new Array();
	subnav3[0] = new menuItem("Overview", "../about", -1, 0);
	subnav3[1] = new menuItem("Our Approach", "../about/process.asp", -1, 0);
	subnav3[2] = new menuItem("DB Insighter", "../about/db_insighter.asp", -1, 0);
	subnav3[3] = new menuItem("Management Team", "../about/management.asp", -1, 0);
	subnav3[4] = new menuItem("News & Events", "../about/news.asp", -1, 0);
	subnav3[5] = new menuItem("Careers", "../about/careers.asp", -1, 0);
subnav4 = new Array();
subnav5 = new Array();

function mainNavWidth(){
	mainWidth = 0;
	for(w = 0; w < mainNav.length; w ++){
		mainWidth += mainNav[w].theWidth;
	}
	return mainWidth;
}

outHTML = "";
function writeNav(){
	outHTML += "<table cellpadding=0 cellspacing=0 border=0 width='" + mainNavWidth() + "'><tr>";
	for( i = 0; i < mainNav.length; i ++ ){
		if( mainNav[i].theTarget > 0 ){
			theTarget = " target=\"" + mainNav[i].displayText.replace(" ", "") + "\"";
		}else{
			theTarget = "";
		}
		if( mainNavHighlight == i ){
			theClass = "navON";
			theSQ = "bOn";
		}else{
			theClass = "nav";
			theSQ = "bOff";
		}
		if( home ){
			theMouseOver = "doSubs(" + i + ");";
			theMouseOut = ""; //"doSubs(-1);";
		}else{
			theMouseOver = "dropMenu.showMenu('" + mainNav[i].displayText.replace(" ","") + "');";
			theMouseOut = "dropMenu.hideMenu('" + mainNav[i].displayText.replace(" ","") + "');";
		}
		outHTML += "<td width=" + mainNav[i].theWidth + " class=\"" + theClass + "\" id=\"theBase" + i + "\"><ilayer name=\"theBaseNS\"><layer>";
		outHTML += "<a href=\"" + mainNav[i].theLink + "\" " + theTarget + " onMouseOver=\"swap('i" + i + "','bOn');" + theMouseOver + "\" onMouseOut=\"swap('i" + i + "','" + theSQ + "');" + theMouseOut + "\"><img src=\"../images/nav/" + theSQ + ".gif\" width=13 height=11 align=\"absmiddle\" name=\"i" + i + "\" border=0>" + mainNav[i].displayText + "</a>"
		outHTML += "</layer></ilayer></td>"; 
	}
	outHTML += "</tr></table>";
	document.write(outHTML);
}
function subNavTitle(){
	document.write(mainNav[mainNavHighlight].displayText);
}

function doSubs(focus){
	show("bigHide");
	for( n = 0; n < mainNav.length; n ++ ){
		if( n == focus ){
			show("subNav" + n);
		}else{
			hide("subNav" + n);
		}
	}
	if( focus == -1 ){
		hide("bigHide");
	}
}

function writeSubNav(){
	curELE = eval("subnav" + mainNavHighlight);
	outSubHTML = "<table cellpadding=0 cellspacing=0 border=0 width=174>";
	for( j = 0; j < curELE.length; j ++ ){
		if( curELE[j].theTarget > 0 ){
			theTarget = " target=\"" + curELE[j].displayText.replace(" ", "") + "\"";
		}else{
			theTarget = "";
		}
		if( subNavHighlight == j ){
			theClass = "navON";
			theSQ = "bOn";
		}else{
			theClass = "nav";
			theSQ = "bOff";
		}
		outSubHTML += "<tr><td class=\"" + theClass + "\">";
		outSubHTML += "<a href=\"" + curELE[j].theLink + "\" " + theTarget + " onMouseOver=\"swap('s" + j + "','bOn');\" onMouseOut=\"swap('s" + j + "','" + theSQ + "');\"><img src=\"../images/nav/" + theSQ + ".gif\" width=13 height=11 align=\"absmiddle\" name=\"s" + j + "\" border=0>" + curELE[j].displayText + "</a>";
		outSubHTML += "</td></tr>";
		outSubHTML += "<tr><td><img src=\"../images/spacer.gif\" width=1 height=4></td></tr>";
	}
	outSubHTML += "</table>";
	//alert(outSubHTML);
	document.write(outSubHTML);
}

function writeSubNav2(){
	curELE = eval("subnav" + mainNavHighlight);
	outSubHTML = "<table cellpadding=0 cellspacing=0 border=0 width=220>";
	for( j = 0; j < curELE.length; j ++ ){
		if( curELE[j].theTarget > 0 ){
			theTarget = " target=\"" + curELE[j].displayText.replace(" ", "") + "\"";
		}else{
			theTarget = "";
		}
		if( subNavHighlight == j ){
			theClass = "navON";
			theSQ = "bOn";
		}else{
			theClass = "nav";
			theSQ = "bOff";
		}
		outSubHTML += "<tr><td class=\"" + theClass + "\">";
		outSubHTML += "<a href=\"" + curELE[j].theLink + "\" " + theTarget + " onMouseOver=\"swap('s" + j + "','bOn');\" onMouseOut=\"swap('s" + j + "','" + theSQ + "');\"><img src=\"../images/nav/" + theSQ + ".gif\" width=13 height=11 align=\"absmiddle\" name=\"s" + j + "\" border=0>" + curELE[j].displayText + "</a>";
		outSubHTML += "</td></tr>";
		outSubHTML += "<tr><td><img src=\"../images/spacer.gif\" width=1 height=8></td></tr>";
	}
	outSubHTML += "</table>";
	//alert(outSubHTML);
	document.write(outSubHTML);
}

function findPosX(obj){
	var curleft = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
		//alert(curleft);
		return curleft;
	}
}
function findPosY(obj){
	var curtop = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
		return curtop;
	}else{
		curtop += obj.y;
		return curtop;
	}
}
theWidth = 215;
theTop = 45;
outLayersHTML = "";
function writeMenus(){
	for( k = 0; k < mainNav.length; k ++ ){
		nameID = mainNav[k].displayText.replace(" ","");
		if(ie){
			theLeft = findPosX(document.all("theBase" + k));
		}else if(ns6){
			theLeft = findPosX(document.getElementById("theBase" + k));
		}else if(ns){
			theLeft = document.layers["theBaseNS"].pageX;
		}
		theLeft -= 6;
		outLayersHTML += "<script language=\"javascript\">new dropMenu('" + nameID + "', 'down', " + theLeft + ", " + theTop + ", " + theWidth + ", 180)</script>";
		outLayersHTML += "<div id='" + nameID + "Container'>";
			outLayersHTML += "<div id='" + nameID + "Content' class='menu'>";
				outLayersHTML += "<div class='options'>";
		curELE = eval("subnav" + k);
		for( n = 0; n < curELE.length; n ++ ){
			if( curELE[n].theTarget > 0 ){
				theTarget = " target=\"" + curELE[n].displayText.replace(" ", "") + "\"";
			}else{
				theTarget = "";
			}
			if( mainNavHighlight == k && subNavHighlight == n ){
				theSQ = "bOn";
			}else{
				theSQ = "bOff";
			}
					outLayersHTML += "<a href=\"" + curELE[n].theLink + "\"" + theTarget + " onMouseOver=\"swap('s" + k + n + "','bOn');\" onMouseOut=\"swap('s" + k + n + "','" + theSQ + "');\"><img src=\"../images/nav/" + theSQ + ".gif\" width=13 height=11 align=\"absmiddle\" name=\"s" + k + n + "\" border=0>" + curELE[n].displayText + "</a>";
		}
			if( curELE.length > 0 ){
					outLayersHTML += "<table cellpadding=0 cellspacing=0 border=0 width=" + theWidth + "><tr><td width=\"" + theWidth + "><img src=\"../images/spacer.gif\" width=1 height=5></td></tr></table>";
			}
				outLayersHTML += "</div>";
				/*if( curELE.length > 0 ){
					outLayersHTML += "<table cellpadding=0 cellspacing=0 border=0 width=" + theWidth + "><tr><td width=9><img src=\"../images/nav/corner.gif\" width=9 height=10></td><td width=\"" + (theWidth - 9) + "\" background=\"../images/nav/botRowBG.gif\"><img src=\"../images/spacer.gif\" width=1 height=10></td></tr></table>";
				}*/
			outLayersHTML += "</div>";
		outLayersHTML += "</div>";
	}
	document.write(outLayersHTML);
}

function writeMenusHome(){
	for( k = 0; k < mainNav.length; k ++ ){
		nameID = mainNav[k].displayText.replace(" ","");
		if(ie){
			theLeft = findPosX(document.all("theBase" + k));
		}else if(ns6){
			theLeft = findPosX(document.getElementById("theBase" + k));
		}else if(ns){
			theLeft = document.layers["theBaseNS"].pageX;
		}
		theLeft -= 6;
		if( home ){
			theID = "subNav" + k;
			if( k == 0 ){
				bigHideLeft = theLeft;
			}
		}else{
			theID = nameID + "Container";
		}
		outLayersHTML += "<div id=\"" + theID + "\" style=\"position:absolute;left:" + theLeft + "px;top:" + theTop + "px;visibility:hidden;z-index:10;\">";
		curELE = eval("subnav" + k);
		if( curELE.length > 0 ){
			outLayersHTML += "<table width=\"" + theWidth + "\" cellpadding=0 cellspacing=0 border=0><tr><td class='homeMenu'>"
			for( n = 0; n < curELE.length; n ++ ){
				if( curELE[n].theTarget > 0 ){
					theTarget = " target=\"" + curELE[n].displayText.replace(" ", "") + "\"";
				}else{
					theTarget = "";
				}
				if( mainNavHighlight == k && subNavHighlight == n ){
					theSQ = "bOn";
				}else{
					theSQ = "bOff";
				}
				outLayersHTML += "<a href=\"" + curELE[n].theLink + "\"" + theTarget + " onMouseOver=\"swap('s" + k + n + "','bOn');\" onMouseOut=\"swap('s" + k + n + "','" + theSQ + "');\"><img src=\"../images/nav/" + theSQ + ".gif\" width=13 height=11 align=\"absmiddle\" name=\"s" + k + n + "\" border=0>" + curELE[n].displayText + "</a>";
			}
			outLayersHTML += "</td></tr></table>"
		}
		outLayersHTML += "</div>";
	}
	if( home ){
		outLayersHTML += "<div id=\"bigHide\" style=\"position:absolute;top:" + theTop + "px;left:" + bigHideLeft + "px;visibility:show;z-index:5;\"><a href=\"#\" onMouseOver=\"doSubs(-1)\"><img src=\"../images/spacer.gif\" width=500 height=150 border=0></a></div>";
	}
	//alert(outLayersHTML);
	document.write(outLayersHTML);
}

function checkLogin(f){
	if( isStringWhitespace(f.username.value) ){
		alert("Please enter your Username.");
		f.username.focus();
		return false;
	}
	if( isStringWhitespace(f.password.value) ){
		alert("Please enter your Password.");
		f.password.focus();
		return false;
	}
	return true;
}