// JavaScript Document
//RollOver functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages('/images/strategy_header_1.gif','/images/strategy_header_3.gif','/images/nav/work_over.png','/images/nav/approach_over.png','/images/nav/viewpoint_over.png','/images/nav/company_over.png','/images/nav/dd_case_studies_over.gif','/images/nav/dd_client_list_over.gif','/images/nav/dd_design_intel_over.gif','/images/nav/dd_design_matters_over.gif','/images/nav/dd_exec_over.gif','/images/nav/dd_philosophy_over.gif','/images/nav/dd_portfolio_over.gif','/images/nav/dd_process_over.gif','/images/nav/dd_thoughts_over.gif','/images/nav/dd_about_over.gif','/images/nav/dd_careers_over.gif','/images/buttons/next_over.png','/images/buttons/previous_over.png','/images/backgrounds/bg_1.jpg','/images/backgrounds/bg_2.jpg','/images/backgrounds/bg_3.jpg','/images/backgrounds/bg_4.jpg','/images/backgrounds/bg_5.jpg','/images/backgrounds/bg_6.jpg','/images/backgrounds/bg_7.jpg');


/* End RollOver functions */



//drop downs
var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;


function MM_menuStartTimeout(hideTimeout,resetNav) {
	//var r = resetNav;
	//alert (r);
	//if (r=="true") {
		mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);
	//}
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "inherit";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			if(m){
			m.style.visibility = "hidden";
			//added 6/23, release top level rollover
			//window.alert(section);
			MM_swapImage('work','','/images/nav/work_'+section+'.gif',1);
			MM_swapImage('approach','','/images/nav/approach_'+section+'.gif',1);
			MM_swapImage('viewpoint','','/images/nav/viewpoint_'+section+'.gif',1);
			MM_swapImage('company','','/images/nav/company_'+section+'.gif',1);
			}
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	MM_menuResetTimeout();
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	MM_menuHideMenus();
	MM_menuResetTimeout();
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
	MM_menuShowSubMenu(menuName);
}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}
//END DROPDOWNS!!





function popCenter(URL,name,w,h,sc,rs) {
	if (sc=="") { //scrollbars?
		var sc=0;
	}
	if (rs=="") { //resizable?
		var rs=1;
	}

	l = (screen.width - w) / 2;

	t = (screen.height - h) / 2;

	window.open(URL,name,"width="+w+",height="+h+",left="+l+",top="+t+",scrollbars="+sc+",toolbars=1,location=0,statusbars=0,menubars=1,resizable="+rs+""); 
}


function getScreen() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
  
}

function setPortfolioImg() {
 	/*var a = getScreen();
	var myWidth = a[0], myHeight = a[1];
  	
 	bg_width = (myWidth * 1.00)-480;
	
	var NewWidth = bg_width;
 	var imgWidth = document.getElementById("img_bak").width;
	var imgHeight = document.getElementById("img_bak").height;
	var NewHeight = Math.round(NewWidth * imgHeight/imgWidth);
	
	if (myHeight<700) {
		document.getElementById("img_bak").width = NewWidth;
		document.getElementById("img_bak").height = NewHeight;
	} else {
		//set to original size
		document.getElementById("img_bak").width = 880;
		document.getElementById("img_bak").height = 540;
	}
	
	//set size based on screen resolution
	/*
	var scrnWidth = screen.width;
	if (document.getElementById("img_bak")) {
		if (scrnWidth <= 1024) {
			document.getElementById("img_bak").width = 550;
			document.getElementById("img_bak").height = 338;
		}
	}*/
	
}





function setBackground() {
 	var a = getScreen();
	var myWidth = a[0], myHeight = a[1];
  	//window.alert( 'Width = ' + myWidth );
 	//window.alert( 'Height = ' + myHeight );
 
 	bg_width = (myWidth * 1.00);
	bg_height = (myHeight * 1.00);
	
	var NewWidth = bg_width;
 	var NewHeight = Math.round(NewWidth * .667);
  	
	if (document.getElementById("img_bak")) {
		setPortfolioImg();
	}
	
	
	if (document.getElementById) {
	
		if (myWidth>1280 && document.getElementById("bg_image")) {
			document.getElementById("bg_image").width = NewWidth;
			document.getElementById("bg_image").height = NewHeight;
			
		}
	
		//reset the main text area as well
	
		if(document.getElementById("bg_image")) {
			//commented out since the bg image descriptions have been removed
			//var mainHeight =  myHeight - 140;
			//var mainContentHeight =  myHeight - 210;
			
			var mainHeight =  myHeight - 126;
			var mainContentHeight =  myHeight - 196;
			
		} else {
			var mainHeight =  myHeight - 126;
			var mainContentHeight =  myHeight - 196;
		}
		
		document.getElementById("main").style.height =mainHeight + "px";
		document.getElementById("main_content").style.height =mainContentHeight + "px";
		
	}
	
	changeOpac(100, 'bg_image');
}



/*
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    for(i = opacStart; i <= opacEnd; i++) {
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
        timer++;
	}
}*/

//change the opacity for different browsers
function changeOpac(opacity, id) {
    if (document.getElementById(id)) {
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
} 







//Toggles Job Description in Careers Page
//also used to toggle button states fro client views pages
function toggleJobDesc(id){
	if($(id).style.display == 'none'){
		$(id).style.display = 'block';
	} else {
		$(id).style.display = 'none';
	} 
}


function showHideLayer(id) {
	var d = document.getElementById(eval(id));
	if (d) {
		if (d.style.display=='none') {
			d.style.display='block';
		} else {
			d.style.display='none';
		}
	}
}



//positioning the contact us popup layer in the center of the screen.
function positionContact() {
 	var a = getScreen();
	var myWidth = a[0], myHeight = a[1];
	
	var cWindowHeight = 600;
	var cWindowWidth = 800;
	var cWindowX = myWidth/2 - cWindowWidth/2;
	var cWindowY = myHeight/2 - cWindowHeight/2;
	document.getElementById("contact_content").style.left =cWindowX + "px";
	document.getElementById("contact_content").style.top = cWindowY + "px";
	
}


//function to switch out the header image on the strategy landing page.
function switchHeader(img, altTxt) {
	var imgNum = img;
	var altTxt = altTxt;
	document.getElementById("strategy_header").src="/images/strategy_header_"+ imgNum +".gif"
	document.getElementById("strategy_header").alt=altTxt;
}