// BrowserCheck
var bT = navigator.appName
var uA = navigator.userAgent
var b;
if (bT=="Netscape") b = "ns"
else if (bT=="Microsoft Internet Explorer") b = "ie"
else b=bT
var version = navigator.appVersion
var v = parseInt(this.version)
var ns = b=="ns" && v>=4
var ns4 = b=="ns" && v==4
var ns5 = b=="ns" && v==5
var ie = b=="ie" && v>=4
var ie4 = version.indexOf('MSIE 4')>0
var ie5 = version.indexOf('MSIE 5')>0
var ie55 = version.indexOf('MSIE 5.5')>0
var min = ns||ie
var isMac = (uA.indexOf("Mac")!=-1)

// browser redirection code
if (parseFloat(navigator.appVersion) < 4 || (ns4 && parseFloat(navigator.appVersion)<4.06) ) location.href="/browser.html"
if(!document.layers && !navigator.cookieEnabled) location.href="/browser.html";

//----------------------------------------------------------------------------------------------
//for opening up pdf's in a new window
	var blnRegistering
	

	function getPdf(FormType){
		
				FilePath = document.pdfform.pdf.value;
//			var PDF_Form = OpenRegFormWindow("/reg/index.asp?related_service_link=" + FilePath,480,580);
//modify by Amy on 2005-05-30
			var PDF_Form = OpenRegFormWindow(FilePath,480,580);
				}

	function OpenRegFormWindow(on_page, X, Y) {

			OpenRegFormWindow_nme = window.open(on_page,"OpenRegFormWindow_nme","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + X + ",height=" + Y );
	        
			if (OpenRegFormWindow_nme.opener == null){
					OpenRegFormWindow_nme.opener = self;
					this.OpenRegFormWindow_nme = OpenRegFormWindow_nme;
			}
			return this;
	}
	
	
	function registering(){
		blnRegistering = true
	}
	
	
	function closeWinIfLoadedPDF(oWin){
		var sPageName = oWin.document
		if(!blnRegistering){
			oWin.document.location.href = "/closewin.asp"
		}else{
			focusWin(oWin)
		}
	}
	
//----------------------------------------------------------------------------------------------
//for the 'go' button on keyword search
function keyWdSearch(){
	if (document.keywordSearch){
		document.keywordSearch.submit()
	}
}
//----------------------------------------------------------------------------------------------
//for the 'printer friendly' and 'contact savills' button on news
function doForm(sFormName){
	var newWin
/*
	if (document[sFormName]){
		if(document[sFormName].target=="newPrintWin"){
			newWin = window.open("", "newPrintWin", "width=600,height=500,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes")
			newWin.focus()
		}
		document[sFormName].submit()
	}
*/

//modify by Amy on 2005-05-31	
	if (document[sFormName]){
		if(document[sFormName].target=="newPrintWin"){
			newWin = window.open(document[sFormName].filePath.value, "newPrintWin", "width=600,height=500,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes")
			newWin.focus()
		}
//		document[sFormName].submit()
	}	
}
//----------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------


function goContact(sEmail, sName, width, height,propertyId, sExtraMessage){
	var sPageName
	var newWin
	var thisWidth = "500"
	var thisHeight="400"
	if (propertyId==null) propertyId=""
	
	if(width) thisWidth=width
	if(height) thisHeight=height
	
	if(!sExtraMessage) sExtraMessage = ""
	
	sPageName = document.location.href
	//get the page filename
	if(sPageName.lastIndexOf("/") != -1){
		sPageName = sPageName.substr(sPageName.lastIndexOf("/")+1)
		if (sPageName.indexOf("?") != -1){
			sPageName = sPageName.substr(0,sPageName.indexOf("?"))
		}
		if (sPageName.indexOf("#") != -1){
			sPageName = sPageName.substr(0,sPageName.indexOf("#"))
		}
	}
	//add to this list any page which supports 
	/*if(sPageName=="content.asp" || sPageName=="hub.asp" || sPageName=="research.asp" || sPageName=="service_directory.asp" || sPageName=="news.asp" || sPageName=="recruitment.asp")
		goLink(sEmail, sName)
	else{*/
		newWin = openWin("/reg/contact_form.asp?toName="+escape(sName)+"&toEmail="+escape(sEmail),"newWin",thisWidth,thisHeight)
		if (newWin){
			newWin.focus()	
		}
	//}
		
}

function doLinks()
{
	if(!linksState)
	{
		if(window.otherLinks) otherLinks.hide();
		//infoLinks.hide();
	}
	return;
}

//----------------------------------------------------------------------------------------------

function goLink(sLink, sContactName,sSpecial){
	var slinkPage
	var sFromPage = document.location.href

//	if(sLink.indexOf('Savills.com')!=-1);
	 if(sLink.substr(0,7)=="http://"){
		window.open(sLink)
	}
	else
	{
		slinkPage = "/link.asp?from="+escape(sFromPage)+"&content="+sLink
		if (sContactName){
			slinkPage += "&contactName="+sContactName
		}
		if (sSpecial){
			slinkPage += "&sp="+sSpecial
		}
		document.location.href = slinkPage
	}
}

//----------------------------------------------------------------------------------------------

function goReg(){
	if(document.preReg){
		newWin = openWin("/reg/reg_form.asp?loading=true&regSite=com","regWin")
		document.preReg.submit()
		setTimeout("focusWin(newWin)",20)
	}
}
//----------------------------------------------------------------------------------------------
//focus new windows after they are created. use on timeout, otherwsie get intermittent errors

	function focusWin(oWin){
		if (oWin){
			oWin.focus()
		}else{
			if (newWin) newWin.focus()
		}
	}
	var newWin

//----------------------------------------------------------------------------------------------

	function goLet(sLet){
		var	sCurrentURL = document.location.href
		var sToURL
		var sExtraQuerystring
		
		sLet = sLet.toUpperCase()

		if (g_sServDirSection != sLet){
		//hack to clear the content
			sToURL = appendToQuerystring(sCurrentURL, "content", "")
			sToURL = appendToQuerystring(sToURL, "section", sLet)
			document.location.href = sToURL
		}
	}

	function appendToQuerystring(sCurrentURL, sKey, sVal){
		var sToURL, sExtraQuerystringItem, iPos
		sExtraQuerystringItem = sKey+"="

			if(sCurrentURL.indexOf("?") != -1){
				if (sCurrentURL.indexOf(sExtraQuerystringItem) != -1){
					iPos = sCurrentURL.indexOf(sExtraQuerystringItem)
					sToURL = sCurrentURL.substring(0, iPos)
					sToURL += sExtraQuerystringItem+sVal
					
					if (sCurrentURL.indexOf("&",iPos) != -1){
						sToURL += sCurrentURL.substr(sCurrentURL.indexOf("&",iPos))
					}
				}else{
					sToURL = sCurrentURL + "&"+sExtraQuerystringItem+sVal
				}
			}else{
				sToURL = sCurrentURL + "?"+sExtraQuerystringItem+sVal
			}
	
		return sToURL
	
	}
//---------------------------------------------------------------------------------------------
function openWin(filename, winname, width, height) {
	if(!winname) winname = ""
	if(!width) width = 500
	if(!height) height = 600
	return window.open(filename, winname, "width="+width+",height="+height+",scrollbars=yes,resizable=yes")
}
	
	//----------------------------------------------------------------------------------------
	
function euroOn(imgName)
{
	var docu1 = document.layers ? document.worldmapDiv.document.europeDiv.document.europemaskDiv.document : document;
	var docu2 = document.layers ? document.worldmapDiv.document.europeDiv.document : document;
	if (docu1.images[imgName])
	{
		docu2.images["europe_image"].src = europe_imageon.src;
		docu1.images[imgName].src = eval(imgName + "on.src");
	}	
}

function euroOff(imgName)
{
	var docu1 = document.layers ? document.worldmapDiv.document.europeDiv.document.europemaskDiv.document : document;
	var docu2 = document.layers ? document.worldmapDiv.document.europeDiv.document : document;
	if (docu1.images[imgName])
	{
		docu2.images["europe_image"].src = europe_imageoff.src;
		docu1.images[imgName].src = eval(imgName + "off.src");
	}	
}

function imgOn(imgName,nest)
{
 	var docu = nest&&document.layers ? eval(nest) : document;
	if (docu.images[imgName])
		docu.images[imgName].src = eval(imgName + "on.src");
}

function imgOff(imgName,nest)
{
 	var docu = nest&&document.layers ? eval(nest) : document;
 	if (docu.images[imgName])
		docu.images[imgName].src = eval(imgName + "off.src");
}

function z(){}

/* fixes recurrsive netscape onload bug */
if(document.layers)
{	
	var currHeight = window.innerHeight;
	var currWidth = window.innerWidth;
	window.onresize = function()
	{
		if((window.innerHeight!=currHeight)||(window.innerWidth!=currWidth)) location.reload(); 	
	}
}

/* corrects netscapes document.height [needs divs in page] */
function fixDocumentHeight()
{
	var allheight;
	if(document.layers&&document.layers['leftcontent']&&document.layers['rightcontent'])
	{
		allheight = Math.max(document.layers['leftcontent'].pageY,document.layers['rightcontent'].pageY);
		//alert(allheight + ", " + document.height + ", " + window.innerHeight)
		if((document.height>window.innerHeight)&&(allheight<window.innerHeight))
			document.height = window.innerHeight+1;
		else if((window.innerHeight<document.height))
			document.height = allheight;
	}
	else if(ns5&&document.getElementById("leftcontent")&&document.getElementById("rightcontent"))
	{
		allheight = Math.max(document.getElementById("leftcontent").offsetTop,document.getElementById("rightcontent").offsetTop);
	}
}