// JavaScript Document

// this takes care of errors associated with the way the jquery ready event 

// declare some variables we'll be using later
arr_first_a_tags = new Array()
el_current_section_a_tag = ""
el_current_open_a_tag = ""
filename = location.pathname.substring(location.pathname.lastIndexOf('\/')+1); 
home_page_changeme_text = "";
office_map_changeme_text = "";
arr_links = new Array();
arr_divs = new Array();
arr_links_b = new Array();
arr_divs_b = new Array();

$(document).ready(function() {		
	// if #submenu exists, and it has a ul in it, run set_up_menu
	if (document.getElementById('submenu')) {	
		if (document.getElementById('submenu').getElementsByTagName("ul")[0]) {
			set_up_menu();
		} 
	}
	// if #home_rollover_content and #home_rollover_changeme exist, run set_up_title_page
	if (document.getElementById('home_rollover_content')) {	
		set_up_title_page()
	}
	if (document.getElementById('office_map_rollover_content')) {	
		set_up_office_map_page()
	}
	if (document.getElementById('orgchart')){
		set_up_orgchart();							
	}
	if (document.getElementById('orgchart_v2')){
		set_up_orgchart_v2();							
	}
	if (document.getElementById('staff_menu')){
		set_up_staff_page();							
	}
	if (document.getElementById('articles_menu')){
		set_up_articles_page();							
	}
	if (document.getElementById('publications_menu')){
		set_up_publications_page();							
	}
	// and re-assemble the email addresses 
	obfusticate_email_addresses()
});

//////////////////////////////////////////

function set_up_publications_page(){	
	arr_links_b = document.getElementById('publications_menu').getElementsByTagName("a");
	for (i=0; i<arr_links_b.length; i++) {
		
		div_to_hide = "publications_detail_" + i;
		//alert(div_to_hide);
		arr_divs_b.push(document.getElementById(div_to_hide));
		arr_links_b[i].onmouseover=function(){
			link_pos = "not found";
			for (i=0; i<arr_links_b.length; i++) {
				if (arr_links_b[i] ==  this) {
					link_pos = i;
				}
			}
			select_publications_page(link_pos);
		}
	}
	reset_publications_page()
	select_publications_page(0);
}

function reset_publications_page (){
	for (i=0; i<arr_divs_b.length; i++) {
		div_to_hide = "publications_detail_" + i;
		//alert(arr_divs_b[i].id)
		arr_divs_b[i].style.display="none"
		arr_links_b[i].className="";
	}
}

function select_publications_page (index) {
	reset_publications_page();
	document.getElementById('publications_detail_'+index).style.display="block"
	arr_links_b[index].className="publications_link_selected";	
}

//////////////////////////////////////////

function set_up_articles_page(){	
	arr_links = document.getElementById('articles_menu').getElementsByTagName("a");
	for (i=0; i<arr_links.length; i++) {
		
		div_to_hide = "articles_detail_" + i;
		//alert(div_to_hide);
		arr_divs.push(document.getElementById(div_to_hide));
		arr_links[i].onmouseover=function(){
			link_pos = "not found";
			for (i=0; i<arr_links.length; i++) {
				if (arr_links[i] ==  this) {
					link_pos = i;
				}
			}
			select_articles_page(link_pos);
		}
	}
	reset_articles_page()
	select_articles_page(0);
}

function reset_articles_page (){
	for (i=0; i<arr_divs.length; i++) {
		div_to_hide = "articles_detail_" + i;
		//alert(arr_divs[i].id)
		arr_divs[i].style.display="none"
		arr_links[i].className="";
	}
}

function select_articles_page (index) {
	reset_articles_page();
	document.getElementById('articles_detail_'+index).style.display="block"
	arr_links[index].className="articles_link_selected";	
}

//////////////////////////////////////////

function set_up_staff_page(){	
	arr_links = document.getElementById('staff_menu').getElementsByTagName("a");
	for (i=0; i<arr_links.length; i++) {
		
		div_to_hide = "staff_detail_" + i;
		//alert(div_to_hide);
		arr_divs.push(document.getElementById(div_to_hide));
		arr_links[i].onmouseover=function(){
			link_pos = "not found";
			for (i=0; i<arr_links.length; i++) {
				if (arr_links[i] ==  this) {
					link_pos = i;
				}
			}
			select_staff_page(link_pos);
		}
	}
	reset_staff_page()
	select_staff_page(0);
}

function reset_staff_page (){
	for (i=0; i<arr_divs.length; i++) {
		div_to_hide = "staff_detail_" + i;
		//alert(arr_divs[i].id)
		arr_divs[i].style.display="none"
		arr_links[i].className="";
	}
}

function select_staff_page (index) {
	reset_staff_page();
	document.getElementById('staff_detail_'+index).style.display="block"
	arr_links[index].className="staff_link_selected";	
}


function org_clear_all() {
	arr_all_divs = new Array();
	arr_all_divs.push(document.getElementById('op1'));
	arr_all_divs.push(document.getElementById('op11'));
	arr_all_divs.push(document.getElementById('op111'));
	arr_all_divs.push(document.getElementById('op1111'));
	arr_all_divs.push(document.getElementById('op1112'));
	arr_all_divs.push(document.getElementById('op1113'));
	arr_all_divs.push(document.getElementById('op1114'));
	arr_all_divs.push(document.getElementById('op112'));
	arr_all_divs.push(document.getElementById('op1121'));
	arr_all_divs.push(document.getElementById('op1122'));
	arr_all_divs.push(document.getElementById('op1123'));
	arr_all_divs.push(document.getElementById('op1124'));
	arr_all_divs.push(document.getElementById('op1125'));
	arr_all_divs.push(document.getElementById('op1126'));
	arr_all_divs.push(document.getElementById('op12'));
	arr_all_divs.push(document.getElementById('op121'));
	arr_all_divs.push(document.getElementById('op13'));
	arr_all_divs.push(document.getElementById('op14'));
	arr_all_divs.push(document.getElementById('op141'));
	arr_all_divs.push(document.getElementById('op142'));
	arr_all_divs.push(document.getElementById('op143'));
	for (i=0; i<arr_all_divs.length; i++) {
		arr_all_divs[i].style.display = 'none';
	}
}

function set_up_orgchart_v2(){
	// first, hide stuff.
	org_clear_all()
	$('#col1_reveal').hide();
	$("#org_1a").mouseover(function () {
		$('#col1_reveal').show();
	});
	
	// add functions to buttons
	$("#btn1").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';						 
	});
	$("#btn11").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
	});
	$("#btn111").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op111').style.display = 'block';
	});
	$("#btn1111").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op111').style.display = 'block';
		document.getElementById('op1111').style.display = 'block';
	});
	$("#btn1112").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op111').style.display = 'block';
		document.getElementById('op1112').style.display = 'block';
	});
	$("#btn1113").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op111').style.display = 'block';
		document.getElementById('op1113').style.display = 'block';
	});
	$("#btn1114").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op111').style.display = 'block';
		document.getElementById('op1114').style.display = 'block';
	});
	$("#btn112").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
	});
	
	$("#btn1121").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1121').style.display = 'block';
	});
	$("#btn1122").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1122').style.display = 'block';
	});
	$("#btn1123").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1123').style.display = 'block';
	});
	$("#btn1124").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1124').style.display = 'block';
	});
	$("#btn1125").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1125').style.display = 'block';
	});
	$("#btn1126").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op11').style.display = 'block';
		document.getElementById('op112').style.display = 'block';
		document.getElementById('op1126').style.display = 'block';
	});
	$("#btn12").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op12').style.display = 'block';
	});
	$("#btn121").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op12').style.display = 'block';
		document.getElementById('op121').style.display = 'block';
	});
	$("#btn122").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op12').style.display = 'block';
	});
	$("#btn13").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op13').style.display = 'block';
	});
	$("#btn14").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op14').style.display = 'block';
	});
	$("#btn141").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op14').style.display = 'block';
		document.getElementById('op141').style.display = 'block';
	});
	$("#btn142").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op14').style.display = 'block';
		document.getElementById('op142').style.display = 'block';
	});
	$("#btn143").mouseover(function () {
		org_clear_all();
		document.getElementById('op1').style.display = 'block';		
		document.getElementById('op14').style.display = 'block';
		document.getElementById('op143').style.display = 'block';
	});
}

//////////////////////////////////////////
function org_clear_col4(){
	arr_4_divs = new Array();
	arr_4_divs.push(document.getElementById('col4_option_2a1'));
	arr_4_divs.push(document.getElementById('col4_option_2a2'));
	arr_4_divs.push(document.getElementById('col4_option_2a3'));
	arr_4_divs.push(document.getElementById('col4_option_2a4'));
	arr_4_divs.push(document.getElementById('col4_option_2a5'));
	for (i=0; i<arr_4_divs.length; i++) {
		arr_4_divs[i].style.display = 'none';
	}
}

function org_clear_col3(){
	org_clear_col4()
	arr_3_divs = new Array();
	arr_3_divs.push(document.getElementById('col3_option_1a'));
	arr_3_divs.push(document.getElementById('col3_option_1b'));
	arr_3_divs.push(document.getElementById('col3_option_1c'));
	arr_3_divs.push(document.getElementById('col3_option_1d'));
	arr_3_divs.push(document.getElementById('col3_option_1e'));
	arr_3_divs.push(document.getElementById('col3_option_2a'));
	arr_3_divs.push(document.getElementById('col3_option_2b'));
	arr_3_divs.push(document.getElementById('col3_option_3a'));
	arr_3_divs.push(document.getElementById('col3_option_4a'));
	arr_3_divs.push(document.getElementById('col3_option_4b'));
	arr_3_divs.push(document.getElementById('col3_option_5a'));
	arr_3_divs.push(document.getElementById('col3_option_6a'));
	for (i=0; i<arr_3_divs.length; i++) {
		arr_3_divs[i].style.display = 'none';
	}
}

function org_clear_col2(){
	org_clear_col3()
	arr_2_divs = new Array();
	arr_2_divs.push(document.getElementById('col2_option1'));
	arr_2_divs.push(document.getElementById('col2_option2'));
	arr_2_divs.push(document.getElementById('col2_option3'));
	arr_2_divs.push(document.getElementById('col2_option4'));
	arr_2_divs.push(document.getElementById('col2_option5'));
//	arr_2_divs.push(document.getElementById('col2_option6'));
	for (i=0; i<arr_2_divs.length; i++) {
		arr_2_divs[i].style.display = 'none';
	}
}

function set_up_orgchart(){
	// first, hide stuff.
	org_clear_col2()
	$('#col1_reveal').hide();
	$("#org_1a").mouseover(function () {
		$('#col1_reveal').show();
	});
	
	// add functions to buttons
	$("#ceo").mouseover(function () {
		org_clear_all;
		document.getElementById('op0').style.display = 'block';						 
	});
	

	// add functions to buttons
	// COLUMN 2
	$("#col2_btn_1").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option1').style.display = 'block';						 
	});
	$("#col2_btn_2").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option2').style.display = 'block';						 
	});
	$("#col2_btn_3").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option3').style.display = 'block';		
		document.getElementById('col3_option_3a').style.display = 'block';
	});
	$("#col2_btn_4").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option4').style.display = 'block';						 
	});
	$("#col2_btn_5").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option5').style.display = 'block';						 
	});
	$("#col2_btn_6").mouseover(function () {
		org_clear_col2()
		document.getElementById('col2_option6').style.display = 'block';						 
	});
	// COLUMN 3
	$("#col3_btn_1a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_1a').style.display = 'block';						 
	});
	$("#col3_btn_1b").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_1b').style.display = 'block';						 
	});
	$("#col3_btn_1c").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_1c').style.display = 'block';						 
	});
	$("#col3_btn_1d").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_1d').style.display = 'block';						 
	});
	$("#col3_btn_1e").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_1e').style.display = 'block';						 
	});
	$("#col3_btn_2a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_2a').style.display = 'block';						 
	});
	$("#col3_btn_2b").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_2b').style.display = 'block';						 
	});
	$("#col3_btn_3a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_3a').style.display = 'block';	
	});
	$("#col3_btn_4a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_4a').style.display = 'block';						 
	});
	$("#col3_btn_4b").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_4b').style.display = 'block';						 
	});
	$("#col3_btn_5a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_5a').style.display = 'block';						 
	});
	$("#col3_btn_6a").mouseover(function () {
		org_clear_col3()
		document.getElementById('col3_option_6a').style.display = 'block';						 
	});
	// COLUMN 4
	$("#col4_btn_2a1").mouseover(function () {
		org_clear_col4()
		document.getElementById('col4_option_2a1').style.display = 'block';						 
	});
	$("#col4_btn_2a2").mouseover(function () {
		org_clear_col4()
		document.getElementById('col4_option_2a2').style.display = 'block';						 
	});
	$("#col4_btn_2a3").mouseover(function () {
		org_clear_col4()
		document.getElementById('col4_option_2a3').style.display = 'block';						 
	});
	$("#col4_btn_2a4").mouseover(function () {
		org_clear_col4()
		document.getElementById('col4_option_2a4').style.display = 'block';						 
	});
	$("#col4_btn_2a5").mouseover(function () {
		org_clear_col4()
		document.getElementById('col4_option_2a5').style.display = 'block';						 
	});
}

//////////////////////////////////////////

function obfusticate_email_addresses() {
	if (!document.getElementsByTagName && !document.createElement &&
		!document.createTextNode) return;
	var nodes = document.getElementsByTagName("span");
	for(var i=nodes.length-1;i>=0;i--) {
		if (nodes[i].className=="email_link") {
			var at = / at /;
			var dot = / dot /g;
			var node = document.createElement("a");
			var address = nodes[i].firstChild.nodeValue;

			address = address.replace(at, "@");
			address = address.replace(dot, ".");

			address = address.replace(at, "@");
			address = address.replace(dot, ".");
			node.setAttribute("href", "mailto:"+address);
			node.appendChild(document.createTextNode(address));
			
			var prnt = nodes[i].parentNode;
			for(var j=0;j<prnt.childNodes.length;j++)
				if (prnt.childNodes[j] == nodes[i]) {
					if (!prnt.replaceChild) return;
					prnt.replaceChild(node, prnt.childNodes[j]);
					break;
				}
		}
	}
	var nodes = document.getElementsByTagName("p");
	for(var i=nodes.length-1;i>=0;i--) {
		if (nodes[i].className=="email_link") {
			var at = / at /;
			var dot = / dot /g;
			var node = document.createElement("a");
			var address = nodes[i].firstChild.nodeValue;

			address = address.replace(at, "@");
			address = address.replace(dot, ".");

			address = address.replace(at, "@");
			address = address.replace(dot, ".");
			node.setAttribute("href", "mailto:"+address);
			node.appendChild(document.createTextNode(address));
			
			var prnt = nodes[i].parentNode;
			for(var j=0;j<prnt.childNodes.length;j++)
				if (prnt.childNodes[j] == nodes[i]) {
					if (!prnt.replaceChild) return;
					prnt.replaceChild(node, prnt.childNodes[j]);
					break;
				}
		}
	}
}

//////////////////////////////////////////


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//////////////////////////////////////////

function populate_home_rollover_changeme(text) {
	el_changeme = document.getElementById('home_rollover_changeme');
	$("#home_rollover_changeme").hide();
	el_changeme.innerHTML = text;
	//el_changeme.style.display = 'block';
	$("#home_rollover_changeme").fadeIn();
}

function set_up_title_page() {
	$("#home_rollover_changeme").hide();
	//el_changeme = document.getElementById('home_rollover_changeme');
	//el_changeme.style.display = 'none';
	arr_links = document.getElementById('home_rollover_content').getElementsByTagName("a")
	for (i=0; i<arr_links.length; i++) {
		 switch (trim(arr_links[i].innerHTML)) {
			case "capabilities":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Capabilities</h1><p>Originating as a small construction company in 1911, Bentall is today the largest Canadian-based real estate advisory and services organization, with $17.6 billion in assets under management. Our business has been built on a solid foundation of real estate knowledge and exacting fiduciary standards.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;
			case "offices":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Offices</h1><p>Bentall's North American services platform is soundly supported by experienced investment advisory and real estate services teams at offices in seven major Canadian markets and in Seattle, WA. Operations of Bentall Balloch China are based at our office in Beijing.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;
			case "senior management":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Senior Management</h1><p>Each member of our senior management team has invested in and is a partner in Bentall, and has a personal stake in the long-term success of our clients</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;
			case "governance":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Governance</h1><p>Our dedication to meeting the highest fiduciary and performance standards is supported by leading edge corporate governance. These standards are followed by all Bentall employees and govern the way we work.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;
			case "sustainability and social responsibility":
			case "sustainability":
			case "social responsibility":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Sustainability<br /> and Social Responsibility</h1><p>Bentall is widely recognized as a leader in advancing sound and sustainable environmental practices in our industry.</p><p>We also believe strongly in giving back to the communities in which we live and work through our support of a range of charitable organizations.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;		
				
			// and for the French...
			
			case "services":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Services</h1><p>Bentall débute en 1911 en tant que petite société de construction et aujourd’hui, avec la gestion d’éléments d’actif s’élevant à 17.6 milliards de $, elle est l’organisation de services et de conseils dans le secteur immobilier la plus importante au Canada. Nos activités reposent sur de solides connaissances de l’immobilier et des normes rigoureuses en termes de fiducie. </p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;	
			
			case "bureaux":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Bureaux</h1><p>La plate-forme de services qu’offre Bentall en Amérique du Nord repose sur de solides équipes expérimentées dans les secteurs de services-conseils dans l’immobilier et les placements et ce, à partir de bureaux situés au cœur de sept (7) marchés canadiens importants et à Seattle, dans l’État de Washington. Les activités de Bentall Balloch China sont menées à partir de notre bureau de Beijing.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;	
			
			case "haute direction":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Haute direction</h1><p>Chacun et chacune des membres de l’équipe de la haute direction a investi financièrement dans Bentall, est un(e) associé(e) de cette dernière et, dans cette mesure, se sent personnellement concerné(e) par le succès à long terme de nos clients.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;	
			
			case "gouvernance":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Gouvernance</h1><p>Nous nous engageons à respecter les normes fiduciaires et les normes de rendement les plus élevées qui soient et pour ce faire, nous bénéficions d’une gouvernance d’entreprise de pointe. Les normes en question sont respectées par tout(e)s les employé(e)s de Bentall, de même qu’elles déterminent la façon dont nous travaillons. </p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;	
			
			case "durabilité":
			case "responsabilité sociale de l’entreprise":
				arr_links[i].onmouseover = function () {
					home_page_changeme_text = "<h1>Durabilité et responsabilté sociale de l’entreprise</h1>Dans notre industrie, Bentall est réputée pour être un leader dans la promotion de pratiques saines et respectueuses d’un développement environnemental durable. <br/> <br/>Nous croyons aussi fermement qu’il est important de s’impliquer dans la vie des communautés dans lesquelles nous vivons et travaillons en accordant notre aide et notre soutien à tout un ensemble d’œuvres de bienfaisance.</p>";
					populate_home_rollover_changeme(home_page_changeme_text);
				}
				break;	
			
		 }
	}
}

//////////////////////////////////////////

function populate_office_map_rollover_changeme(text, offset) {
	el_changeme = document.getElementById('office_map_rollover_changeme');
	$("#office_map_rollover_changeme").hide();
	pre = "<div style=\"padding-left:" + offset + "px;\">";
	post = "</div>";
	el_changeme.innerHTML = pre + text + post;
	//el_changeme.style.display = 'block';
	$("#office_map_rollover_changeme").fadeIn();
}

function set_up_office_map_page() {
	
	$("#office_map_rollover_changeme").hide();
	//el_changeme = document.getElementById('office_map_rollover_changeme');
	//el_changeme.style.display = 'none';
	arr_links = document.getElementById('office_map_rollover_content').getElementsByTagName("a")
	for (i=0; i<arr_links.length; i++) {
		 switch (trim(arr_links[i].innerHTML)) {
			case "Vancouver":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Vancouver </strong><br /> Suite 1800  <br /> Four Bentall Centre  <br /> 1055 Dunsmuir Street  <br /> Vancouver, BC  V7X 1B1  <br /> Tel: 604 661 5000  <br /> Fax: 604 661 5055 ";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Edmonton":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Edmonton </strong><br /> Suite 330  <br /> 10123 99th Street  <br /> Edmonton, AB  T5J 3H1  <br /> Tel: 780 990 7000  <br /> Fax: 780 429 0827";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Calgary":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Calgary </strong><br /> Suite 301  <br /> 240 – 4th Avenue SW  <br /> Calgary, AB  T2P 4H4  <br /> Tel: 403 303 2400  <br /> Fax: 403 303 2450";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Winnipeg":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Winnipeg </strong><br /> Unit 4 <br /> 1679 Burrows Avenue <br /> Winnipeg, MB  R2X 3B5  <br /> Tel: 204 589 8202  <br /> Fax: 204 582 3115";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Ottawa":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Ottawa </strong><br /> Suite 300  <br /> 45 O’Connor  <br /> Ottawa, ON  K1P 1A4  <br /> Tel: 613 230 3002   <br /> Fax: 613 563 3217";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Toronto":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Toronto </strong><br /> Suite 300  <br /> 55 University Avenue  <br /> Toronto, ON  M5J 2H7  <br /> Tel: 416 681 3400  <br /> Fax: 416 681 3405";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Montreal":
			case "Montréal":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Montréal </strong><br /> 1155, rue Metcalfe  <br /> Bureau 55  <br /> Montréal, QC H3B 2V6 <br /> Tél. : 514 393 8820  <br /> Téléc. : 514 393 9820";
					populate_office_map_rollover_changeme(office_map_changeme_text, 0);
				}
				break;
			case "Seattle":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Seattle </strong><br />Kennedy Associates LP<br/> Suite 400  <br /> 1420 5th Avenue  <br /> Seattle, WA 98101 <br /> Tel: 206 315 3818  <br /> Fax: 206 315 3819";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "San Francisco":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>San Francisco </strong><br/>Kennedy Associates LP<br/>San Francisco<br/>655 Montgomery, <br/>Suite 1490<br/>San Francisco, CA 94111<br/>Phone: (415) 395-4142<br/>Fax: (415) 395-4143";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "Los Angeles":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Los Angeles </strong><br/><div style='float: left; display: inline; margin-right: 20px;'>Kennedy Associates LP<br/>Los Angeles<br/>6320 Canoga Avenue, <br/>Suite 1420<br/>Woodland Hills, CA 91367<br/>Phone: (818) 577-2424<br/>Fax: (818) 577-2425<br /></div><div style='float: left; display: inline; margin-right: 20px;'>Landon Butler & Company, LP<br />8413 Fallbrook Avenue<br />Suite 300 West Hills, <br />CA 91304<br />Phone: 818-932-9955<br />Fax: 818-610-8405</div>";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "Chicago":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Chicago </strong><br/>Kennedy Associates LP<br/>Chicago<br/>Two North Riverside Plaza, <br/>Suite 2150<br/>Chicago, Illinois 60606<br/>Phone: (312) 596-9140<br/>Fax: (312) 596-9139<br/>";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "Washington, DC":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Washington, DC </strong><br/><div style='float: left; display: inline; margin-right: 20px;'>Kennedy Associates LP<br/>Washington, D.C.<br/>7315 Wisconsin Avenue, <br/>Suite 350 West <br/>Bethesda, MD 20814 <br/>Phone: (301) 656-9119 <br/>Fax: (301) 656-9339</div><div style='float: left; display: inline; margin-right: 20px;'>Landon Butler & Company, LP<br />700 Thirteenth Street, NW<br />Suite 925<br />Washington, D.C. 20005<br />Phone: 202-737-7300<br />Fax: 202-737-7604</div>";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "Dallas":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Dallas </strong><br/>Kennedy Associates LP<br/>Dallas<br/>Three Lincoln Centre<br/>5430 LBJ Freeway<br/>Suite 1570<br/>Dallas, Texas 75240<br/>Phone: (972) 733-6450<br/>Fax: (972) 733-6454";
					populate_office_map_rollover_changeme(office_map_changeme_text, 270);
				}
				break;
			case "Beijing":
				arr_links[i].onmouseover = function () {
					office_map_changeme_text = "<strong>Beijing </strong><br/>Bentall Balloch China<br/> Suite 511 Lufthansa Centre<br/> 50 Liangmaqiao Rd<br/> Beijing 100016<br/> China<br/> Phone +86 (10) 8451-9616 ext. 366";
					populate_office_map_rollover_changeme(office_map_changeme_text, 500);
				}
				break;
			
		 }
	}
}

//////////////////////////////////////////

// used to set up right hand nav for sub-pages. Works based on filename.
function my_location() {
	my_loc = String(document.location);
	my_exceptions = new Array()
	my_exceptions.push("canada_real_estate_current_projects");
	my_exceptions.push("fr_canada_real_estate_current_projects");
	my_exceptions.push("canada_retail_current_projects");
	my_exceptions.push("fr_canada_retail_current_projects");
	my_exceptions.push("usa_real_estate_current_projects");
	my_exceptions.push("fr_usa_real_estate_current_projects");
	for (i=0; i< my_exceptions.length; i++) {
		my_string = my_exceptions[i];
		if ((my_loc.indexOf(my_string))!= -1) {
			my_loc_1 = String(document.location).slice(0, my_loc.indexOf(my_string));
			my_loc = my_loc_1 + my_string + ".html"
		}
	}
	return(my_loc)
}

function set_up_menu() {
	// make some exceptions to the rules:
	my_location = my_location();
	
	
	// make an array of only first li tags - arr_first_a_tags
	first_list = document.getElementById('submenu').getElementsByTagName("ul")[0]
	arr_first_list_li_tags = document.getElementById('submenu').getElementsByTagName("ul")[0].getElementsByTagName("li");
	for (i=0; i<arr_first_list_li_tags.length; i++){
		
		if (first_list == arr_first_list_li_tags[i].parentNode){
			arr_first_a_tags.push(arr_first_list_li_tags[i].getElementsByTagName("a")[0]);
		}
	}
	
	// determine if we are in a section that belongs to one of those a tags.
	//   if so, remember that tag - el_current_section_a_tag
	//   and also, open that menu.
	for (i=0; i<arr_first_a_tags.length; i++){
		arr_links_to_check = arr_first_a_tags[i].parentNode.getElementsByTagName("a");
		for (a=0; a<arr_links_to_check.length; a++){
			if (my_location == arr_links_to_check[a].href) {
				el_current_section_a_tag = arr_first_a_tags[i];
				//alert(arr_first_a_tags[i].parentNode.getElementsByTagName("ul").length);
				if (arr_first_a_tags[i].parentNode.getElementsByTagName("ul").length > 0) {
					arr_first_a_tags[i].parentNode.getElementsByTagName("ul")[0].style.display = 'block';
				}
			}
		}
	}
	
	// add the close function to all first a tags, except for the one whose section we are in
	for (i=0; i<arr_first_a_tags.length; i++){
		// add the open function to the tags that need it in the first a tags array
		if (arr_first_a_tags[i].parentNode.getElementsByTagName("a").length > 1) {
			arr_first_a_tags[i].onmouseover = function () {
				// if we aren't currently open here:
				if (this != el_current_open_a_tag) {
					close_all_submenus();
					//this.parentNode.getElementsByTagName("ul")[0].style.display = 'block';
					$(this.parentNode.getElementsByTagName("ul")[0]).slideDown('fast');
					el_current_open_a_tag = this;
				}
			}
		} else if (arr_first_a_tags[i] != el_current_section_a_tag) {
			arr_first_a_tags[i].onmouseover = function () {
				if (this != el_current_open_a_tag) {
					close_all_submenus();
					el_current_open_a_tag = this;
				}
			}
		}
	}
	
	// hilite the link if it is current
	arr_all_a_tags = first_list.getElementsByTagName("a")
	for (i=0; i<arr_all_a_tags.length; i++){
		
		if (arr_all_a_tags[i].href == my_location) {
			// alert(arr_all_a_tags[i].href + "==" + my_location)
			// arr_all_a_tags[i].style.color = '#990000';
			arr_all_a_tags[i].setAttribute("class", "current_page");
			arr_all_a_tags[i].className = "current_page";
		}
	}
}

function close_all_submenus() {
	for (i=0; i<arr_first_a_tags.length; i++){
		// add the open function to the tags that need it in the first a tags array
		if ((arr_first_a_tags[i].parentNode.getElementsByTagName("a").length > 1) & 
																 (arr_first_a_tags[i] != el_current_section_a_tag)) {
			// arr_first_a_tags[i].parentNode.getElementsByTagName("ul")[0].style.display = 'none';
			$(arr_first_a_tags[i].parentNode.getElementsByTagName("ul")[0]).slideUp('fast');
		}
	}
}

//////////////////////////////////////////

function expand_layer()
{
	document.getElementById('menu_layer').style.height = '530px';
}

function retract_layer()
{
	document.getElementById('menu_layer').style.height = '80px';
}
