﻿
/*
begin case studies list rollover
*/
function caseStudiesRollovers(){
var cont_caseStudiesContent = document.getElementById('caseStudiesListWrapper');
var myCaseStudiesWrappers = getElementsByClassName('caseStudyWrapperWrapper', 'div', cont_caseStudiesContent);
if(cont_caseStudiesContent!=null){	
	for (var i=0, j=myCaseStudiesWrappers.length; i<j; i++){
		myCaseStudiesWrappers[i].onmouseover=function(){
		this.style.cursor="pointer";
		this.style.backgroundColor = "#f1f8ff";
		}
		//
		myCaseStudiesWrappers[i].onmouseout=function(){
		//this.style.cursor="normal";
		this.style.backgroundColor = "#fff";
		}
		var link=myCaseStudiesWrappers[i].getElementsByTagName('a');
		if(link!=null){		
		for(var k=0, l=link.length; k<l; k++){
			if(typeof whichLinkFunction=="function"){
			whichLinkFunction(link[k], myCaseStudiesWrappers[i]);						
			}
		}
		}
				
	}	
}
}
function removeCategories(){
	var categoriesSidebar = document.getElementById('caseStudiesSidebar');
	var listItems = categoriesSidebar.getElementsByTagName('li');
	for (var i=0, j=20; i<j; i++){		
		if(listItems[i]){			
			if(getText(listItems[i])=="Corporate Solutions" || getText(listItems[i])=="Owner Representation" || getText(listItems[i]).indexOf("Location Advisory")!=-1 || getText(listItems[i])=="Tenant Representation"){
				listItems[i].parentNode.removeChild(listItems[i]);
			}
		}
	}
}
function highlightCurrentPage(){
	function highlightPage(headerText){
		var cont_secondaryNav = document.getElementById('secondaryNav');
		var links = cont_secondaryNav.getElementsByTagName('a');
		for (var i=0, j=links.length; i<j; i++){
			if(getText(links[i])==headerText){
				
				links[i].parentNode.className='currentPage';
			}
		}
	}
	var cont_caseStudiesContent = document.getElementById('caseStudiesContent');
	var contentHeaders = getElementsByClassName('content-header', 'h2', cont_caseStudiesContent);
	var entries = getElementsByClassName('entry', 'div', cont_caseStudiesContent);
	if(cont_caseStudiesContent!=null){	
		for (var i=0, j=contentHeaders.length; i<j; i++){
			var headerText = getText(contentHeaders[i]);
			highlightPage(headerText);
		}
	}
	if(cont_caseStudiesContent!=null && entries.length==1){	
		var cont_entry = entries[0];
		var footers = getElementsByClassName('post-footers', 'span', cont_caseStudiesContent);
		if(footers[0]){
			if(getText(footers[0]).indexOf("Corporate Solutions")!=-1){
				var headerText = "Corporate Solutions";
				highlightPage(headerText)
				
			} ;
			if(getText(footers[0]).indexOf("Tenant Representation")!=-1){
				var headerText = "Tenant Representation";
				if((typeof highlightPage=='function') && (headerText == "Tenant Representation")){
					highlightPage(headerText);
				};
			} ;
			if(getText(footers[0]).indexOf("Owner Representation")!=-1){
			var headerText = "Owner Representation";
				if((typeof highlightPage=='function') && (headerText == "Owner Representation")){
					highlightPage(headerText);
				};
			} ;
			if(getText(footers[0]).indexOf("Location")!=-1){	
			var headerText = "Location Advisory & Incentive Services";
				if((typeof highlightPage=='function') && (headerText == "Location Advisory & Incentive Services")){
					highlightPage(headerText);
				};
			} ;
		}
	}
}
//
//
function openingsRollovers(){
var cont_openingsContent = document.getElementById('openingsWrapper');
var myOpenings = getElementsByClassName('opening', 'div', cont_openingsContent);
if(cont_openingsContent!=null){	
	for (var i=0, j=myOpenings.length; i<j; i++){
		myOpenings[i].onmouseover=function(){
		this.style.cursor="pointer";
		this.style.backgroundColor = "#f1f8ff";
		}
		//
		myOpenings[i].onmouseout=function(){
		//this.style.cursor="normal";
		this.style.backgroundColor = "#fff";
		}
		var link=myOpenings[i].getElementsByTagName('a');
		if(link!=null){		
		for(var k=0, l=link.length; k<l; k++){
			if(typeof whichLinkFunction=="function"){
			whichLinkFunction(link[k], myOpenings[i]);						
			}
		}
		}
				
	}	
}
}
function whichLinkFunction(whichLink, whichWrapper){
			whichWrapper.onclick=function(){
			window.location=whichLink.href;
			return false;
			}
}
//
//
addLoadEvent(highlightCurrentPage);
//if(!document.all){
//addLoadEvent(removeCategories);
//}
//if(!document.all){
addLoadEvent(caseStudiesRollovers);
//}
addLoadEvent(openingsRollovers);
