// ---- BEGIN GLOBAL JS VARS ----

var isIE4 = (document.all) ? true : false;
var isNS4 = (document.layers) ? true : false;
var isDOM = (document.getElementById && !document.all) ? true : false;

// ---- END GLOBAL JS VARS ----

// ---- BEGIN POPUP WINDOW FUNCTIONS ----

function OpenPopup(URL, width, height) {
	window.self.name = "main";
	//var now = new Date();
	//var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=0");
	var remote = window.open(URL, "popup", "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=0");
	remote.resizeTo(parseInt(width)+2,parseInt(height)+35);
	remote.focus();	
}

function OpenBarlessScrollingPopup(URL, width, height) {
	window.self.name = "main";
	//var now = new Date();
	//var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=yes");
	var remote = window.open(URL, "popup", "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=yes");
	remote.resizeTo(parseInt(width)+2,parseInt(height)+35);
	remote.focus();	
}

function OpenBarlessPopup(URL, width, height) {
	window.self.name = "main";
	//var now = new Date();
	//var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=0");
	var remote = window.open(URL, "popup", "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=0");
	remote.resizeTo(parseInt(width)+2,parseInt(height)+35);
	remote.focus();
}

function OpenScrollingPopup(URL, width, height) {
	window.self.name = "main";
	//var now = new Date();
	//var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=1,scrollbars=yes");
	var remote = window.open(URL, "popup", "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=1,scrollbars=yes");
	remote.resizeTo(parseInt(width)+2,parseInt(height)+35);
	remote.focus();	
}

// ---- END POPUP WINDOW FUNCTIONS ----

// ---- BEGIN NAVIGATION ROLLOVER FUNCTIONS ----
if(document.images)
{
	nav1On = new Image(); 
	nav1On.src = "http://www.cbre.com/images/menu/button_property_listings_o.gif"; 
	nav1Off = new Image(); 
	nav1Off.src = "http://www.cbre.com/images/menu/button_property_listings.gif"; 

	nav2On = new Image(); 
	nav2On.src = "http://www.cbre.com/images/menu/button_service_lines_o.gif"; 
	nav2Off = new Image(); 
	nav2Off.src = "http://www.cbre.com/images/menu/button_service_lines.gif"; 

	nav3On = new Image(); 
	nav3On.src = "http://www.cbre.com/images/menu/button_research_centre_o.gif"; 
	nav3Off = new Image(); 
	nav3Off.src = "http://www.cbre.com/images/menu/button_research_centre.gif"; 

	nav4On = new Image(); 
	nav4On.src = "http://www.cbre.com/images/menu/button_our_offices_o.gif"; 
	nav4Off = new Image(); 
	nav4Off.src = "http://www.cbre.com/images/menu/button_our_offices.gif"; 

	nav5On = new Image(); 
	nav5On.src = "http://www.cbre.com/images/menu/button_our_people_o.gif"; 
	nav5Off = new Image(); 
	nav5Off.src = "http://www.cbre.com/images/menu/button_our_people.gif"; 

	nav6On = new Image(); 
	nav6On.src = "http://www.cbre.com/images/menu/button_client_tools_o.gif"; 
	nav6Off = new Image(); 
	nav6Off.src = "http://www.cbre.com/images/menu/button_client_tools.gif"; 

	nav7On = new Image(); 
	nav7On.src = "http://www.cbre.com/images/menu/button_about_us_o.gif"; 
	nav7Off = new Image(); 
	nav7Off.src = "http://www.cbre.com/images/menu/button_about_us.gif";
	
	nav8On = new Image(); 
	nav8On.src = "http://www.cbre.com/images/menu/button_investor_relations_o.gif"; 
	nav8Off = new Image(); 
	nav8Off.src = "http://www.cbre.com/images/menu/button_investor_relations.gif"; 	
}
	
function turnOn(imgName)
{
	if (document.images)
	{
		imgOn = eval(imgName + "On.src");
		document[imgName].src = imgOn;
	}
}

function turnOff(imgName)
{
	if (document.images)
	{
		imgOff = eval(imgName + "Off.src");
		document[imgName].src = imgOff;
	}
}

function hideNavMenu(lay) {
	if (isIE4) {document.all[lay].style.visibility = "hidden";}
	if (isNS4) {document.layers[lay].visibility = "hide";}
	if (isDOM) {document.getElementById([lay]).style.visibility = "hidden";}
}

function showNavMenu(lay) {
	var i;

	if('nav0menu' != lay)
	{
		if((lay.charAt(0) == 'n') && (lay.charAt(lay.length - 1) == 'u')) {
			for(i = 1; i < 9; i++) {
				if(('nav' + i + 'menu') == lay) {
					//alert('nav' + i + 'menu is on');
					if (isIE4) {document.all[lay].style.visibility = "visible";}
					if (isNS4) {document.layers[lay].visibility = "show";}
					if (isDOM) {document.getElementById([lay]).style.visibility = "visible";}
				}
				else {
					//alert('nav' + i + 'menu is off');
					if (isIE4) {document.all['nav' + i + 'menu'].style.visibility = "hidden";}
					if (isNS4) {document.layers['nav' + i + 'menu'].visibility = "hide";}
					if (isDOM) {document.getElementById(['nav' + i + 'menu']).style.visibility = "hidden";}		
				}
			}
		}
		else {
				if (isIE4) {document.all[lay].style.visibility = "visible";}
				if (isNS4) {document.layers[lay].visibility = "show";}
				if (isDOM) {document.getElementById([lay]).style.visibility = "visible";}
		}
	}
	else
	{
		for(i = 1; i < 20; i++) {
			if (isIE4 && document.all['nav' + i + 'menu'] != null) {document.all['nav' + i + 'menu'].style.visibility = "hidden";}
			if (isNS4 && document.layers['nav' + i + 'menu'] != null) {document.layers['nav' + i + 'menu'].visibility = "hide";}
			if (isDOM && document.getElementById(['nav' + i + 'menu']) != null) {document.getElementById(['nav' + i + 'menu']).style.visibility = "hidden";}
		}
	}
}
function showNavLayerMenu(lay,intLayCount) {
	var i;
	var intNavCount;
	intNavCount = parseInt(intLayCount) + 1;

	if((lay.charAt(0) == 'n') && (lay.charAt(lay.length - 1) == 'u')) {
		for(i = 1; i < intNavCount; i++) {
			if(('nav' + i + 'menu') == lay) {
				//alert('nav' + i + 'menu is on');
				if (isIE4) {document.all[lay].style.visibility = "visible";}
				if (isNS4) {document.layers[lay].visibility = "show";}
				if (isDOM) {document.getElementById([lay]).style.visibility = "visible";}
			}
			else {
				//alert('nav' + i + 'menu is off');
				if (isIE4) {document.all['nav' + i + 'menu'].style.visibility = "hidden";}
				if (isNS4) {document.layers['nav' + i + 'menu'].visibility = "hide";}
				if (isDOM) {document.getElementById(['nav' + i + 'menu']).style.visibility = "hidden";}		
			}
		}
	}
	else {
			if (isIE4) {document.all[lay].style.visibility = "visible";}
			if (isNS4) {document.layers[lay].visibility = "show";}
			if (isDOM) {document.getElementById([lay]).style.visibility = "visible";}
	}
}
// ---- END NAVIGATION ROLLOVER FUNCTIONS ----

// ---- BEGIN OFFICE FINDER REDIRECT FUNCTION ----

function RedirectOffice(strAppPath,frmValue)
{
	//alert(frm);

	if(frmValue != "")
	{
		var arrData = frmValue.split("|");
		var strLocale = arrData[2].replace(' ', '+');
		strLocale.replace('&aacute;','%E1');
		strLocale.replace('&oacute;','%F3');
		
		if(arrData[1] == "C")
		{
			//alert(strAppPath + "/about+us/office+finder/officeresults.htm?zone=" + arrData[0] + "&city=" + strLocale);
			window.location.href = strAppPath + "/about+us/office+finder/officeresults.htm?zone=" + arrData[0] + "&city=" + strLocale;
		}
		else if(arrData[1] == "A")
		{
			//alert(strAppPath + "/about+us/office+finder/officeresults.htm?zone=" + arrData[0] + "&area=" + strLocale);
			window.location.href = strAppPath + "/about+us/office+finder/officeresults.htm?zone=" + arrData[0] + "&area=" + strLocale;
		}
	}		
}

// ---- END OFFICE FINDER REDIRECT FUNCTION ----

// ---- BEGIN CLEAR DROP MENU FUNCTION ----

function ClearDropMenu(menu) {
	document.getElementById(menu).selectedIndex = 0;
}

// ---- END CLEAR DROP MENU FUNCTION ----

// ---- BEGIN FORM RELATED FUNCTIONS ----

function SetFocus(frmInput)
{
    document.frmPage[frmInput].focus();
}

// ---- END FORM RELATED FUNCTIONS ----
