function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
}
function setCookie (name, value) {  
	var argv = setCookie.arguments;  
	var argc = setCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +	
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}
function deleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = getCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function goBack(){
	window.history.go(-1);
}

function askUser(str){
	if (window.confirm(str))
		return true;
	else
		return false;
}
function hasLoggedIn() {
	if(getCookie(cookie_memberid)==null) return false;
	else return true;
}
function gotoPage(sURL){
	window.location=sURL;
}

function viewUnderCurrentCat(){
	document.CurrentForm.submit();
}

function clearForm() {
        document.form.reset();
}
function submitOnEnter(fm) {	
	chrCode = event.keyCode;
	if (chrCode==13) fm.submit();			
}
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];}}
}

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_findObj(n, d) { //v3.0
  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];
  	//alert (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);
  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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  	if ((obj=MM_findObj(args[i]))!=null) { 
  		v=args[i+2];
    	if (obj.style) { 
    		obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; 
    	}
    	obj.visibility=v; 
    }
}

function MM_openBrWindow(url,winName,features) {
if (url != "")
  window.open(url,winName,features);
}

function isIE() {
	var b = navigator.appName
	if (b=="Netscape") return false;
	else if (b=="Microsoft Internet Explorer") return true;	
}
/**************************************
 * The following selectLang / selectCity
 * functions include cookie change
 * within common.jsp, thus switchLang / switchCity
 * not required.
 **************************************/
function selectLang(langID){	
	window.location = self.location.pathname + changeQueryString("langid",langID,true);
}	
function selectCity(cityID){			
	window.location = self.location.pathname + changeQueryString("cityid",cityID,true);	
}	
function switchLang(newLang){
	/* 
	// Expires in one year (default)
	var today = new Date();	
	var expires = new Date();
	expires.setTime(today.getTime()+1000*60*60*24*365);	
	*/
	
	//Cookie expires on browser exit
	if(document.cookie && newLang!=null) {
		setCookie('cookielangid',newLang,null,'/');				
	}
}
function switchCity(newCity){	
	/* 
	// Expires in one year (default)
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime()+1000*60*60*24*365);	
	*/
	
	//Cookie expires on browser exit		
	if(document.cookie && newCity!=null) {	
		setCookie('cookiecityid',newCity,null,'/');		
	}
}
function changeQueryString(sWhichQueryString, sNewValue, bAddIfMissing) {		
	// Returned querystring is in form "?a=1&b=2"
	var q = self.location.search.substr(1);	
	var conc = "";		
	var bVarExists = false;
	if (q.length > 0) {										
		var a = q.replace(/\+/g, " ").split("&");				
		for (i=0;i < a.length;i++) {									
			var b = a[i].split("=");			
			if (b[0] == sWhichQueryString) {
				bVarExists = true;
				b[1] = sNewValue;
			}		
			// Concat result
			if (conc.length == 0) conc = "?";
			else conc += "&";			
			conc += b[0] + "=" + b[1];	
		}						
	} 	
	if (bAddIfMissing && !(bVarExists)) {
		if (conc.length == 0) conc = "?" + sWhichQueryString + "=" + sNewValue;
		else conc += "&" + sWhichQueryString + "=" + sNewValue;
	}
	return conc; 
}
function addToComparison(){
	document.BuildingComparisonForm.comparisonlist.value='1';
	document.BuildingComparisonForm.submit();
}

function addToShortlist(){
	document.UnitShortListForm.shortlist.value='1';
	document.UnitShortListForm.submit();
}

function removeFromComparison(){
	document.BuildingComparisonForm.RemoveSelectedBuilding.value='1';
	document.BuildingComparisonForm.submit();
}

function removeFromShortlist(){
	document.UnitShortListForm.removeunit.value='1';
	document.UnitShortListForm.submit();
}
function moveSubMenu(obj) {	
	if(!isIE()) {		
		obj.pageX = document.anchors["submenu_xcoord"].x;		
	}
}
function nsOnLoad() {// Called only in Netscape
	if(!isIE()) {
		moveSubMenu(document.layers.submenu);
		moveSubMenu(document.layers.submenu2);
		moveSubMenu(document.layers.submenu3);
	}
}

// Pop-up functions here
function openPopupWindow(sDest,sCond) {
	if (openPopupWindow.arguments.length < 2) {
		sCondition = 'alwaysRaised=yes,menubar=no,toolbar=yes,resizable=yes,scrollbars=yes,status=yes,top=0,left=0,status=yes,height=600,width=814';	
	} else {
		sCondition = sCond;
	}
	MM_openBrWindow(sDest,'',sCondition);	
}

function popUpEnlargeImage(imageID){
	alert("Call Enlarge Image");	        
    window.open();
}

function popUp(urlLink){    
    var oNewWindow;
    oNewWindow = window.open(urlLink, '', 'alwaysRaised=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no,top=0,left=0,height=680,width=816');
}

function popUpWindow(sURL){
    var oNewWindow;
    oNewWindow = window.open(sURL,'','alwaysRaised=yes,menubar=no,toolbar=no,resizable=no,scrollbars=no,status=no,top=0,left=0,height=100,width=200');
}

function popUpImageGallery(src) {
	var oVTWin;
	oVTWin = window.open(src, 'imageGallery', 'height=360,width=680,menubar=no,toolbar=no,resizable=yes,scrollbars=no,status=no');
} 

function popUpVirtualTour(src) {
	var oVTWin;
	oVTWin = window.open(src, 'vtWin', 'height=300,width=360,menubar=no,toolbar=no,resizable=no,scrollbars=no,status=no');
} 
function evalImage(imgName) {
	return eval("document.images['" + imgName + "']");
}
// selectionValue: Returns value of selection box
function selectionValue(selectObj) {
	for(i=0;i<selectObj.length;i++) {
		if(selectObj.selectedIndex==i) {
			return selectObj.options[i].value;
		}
	}
	return "";
}

function openPopup(sLocation, sWinName, iWidth, iHeight, oOpener, bScrollBars)
{	
	var sScrollBars="no";
	if (bScrollBars != null && bScrollBars)		
		sScrollBars="yes";
	// Set the attribute property for the open javascript function
	var attrib = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=' + sScrollBars + ',resizeable=no';
	//var attrib = 'directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no,scrollbars=yes,resizeable=no';
	var attrib = attrib + ',width=' + iWidth + 'px,height=' + iHeight + 'px';
	var attrib = attrib + ',top=' + ((screen.availHeight - iHeight) / 2) + ',left=' + ((screen.availWidth - iWidth) / 2);
	var newWin;
	// Open window
	if (oOpener != null)	
		newWin = oOpener.open(sLocation, sWinName, attrib);
	else
		newWin = window.open(sLocation, sWinName, attrib);
		
  	newWin.focus();
  	return newWin;

}

function openPopup2(sLocation, sWinName, iWidth, iHeight, oOpener, sAttrib)
{	
	
	var attrib = "";
	
	if(sAttrib==null) {
		attrib = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizeable=no';
	} else {
		attrib = sAttrib;
	}
	//var attrib = 'directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no,scrollbars=yes,resizeable=no';	
	
	var attrib = attrib + ',width=' + iWidth + 'px,height=' + iHeight + 'px';
	var attrib = attrib + ',top=' + ((screen.availHeight - iHeight) / 2) + ',left=' + ((screen.availWidth - iWidth) / 2);
	var newWin;
	// Open window
	if (oOpener != null)	
		newWin = oOpener.open(sLocation, sWinName, attrib);
	else
		newWin = window.open(sLocation, sWinName, attrib);
		
  	newWin.focus();
  	return newWin;

}

function loadAdvert(sLocation, sWinName) {
	
	newWin = window.open(sLocation, sWinName,'');	
	return newWin;
	
}

/** Following Code Not Used - Using Java instead
<!-- Original:  Randy Bennett (rbennett@thezone.net) -->
<!-- Web Site:  http://home.thezone.net/~rbennett/utility/javahead.htm -->
<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function setupStrobe() {
	text = " <%=getLabel(2,iLangID,"citymap")%>123";
	var x=navigator.appVersion;
	y=x.substring(0,4);
	if(y>=4)strobeEffect();
}

var isNav=(navigator.appName.indexOf("Netscape")!=-1);
var colors=new Array(
"FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF",
"FFFFFF","F9F9F9","F1F1F1","E9E9E9","E1E1E1","D9D9D9",
"D1D1D1","C9C9C9","C1C1C1","B9B9B9","B1B1B1","A9A9A9",
"A1A1A1","999999","919191","898989","818181","797979",
"717171","696969","616161","595959","515151","494949",
"414141","393939","313131","292929","212121","191919",
"111111","090909","000000")
	
a=0,b=1;

function strobeEffect() {
	color=colors[a];
	aa="<font color="+color+">" + text + "</font>"
	if(isNav) {
	document.object1.document.write(aa);
	document.object1.document.close();
	}
	else object1.innerHTML=aa;
	a+=b;
	if (a==38) b-=2;
	if (a==0) b+=2;
	xx=setTimeout("strobeEffect()",10);
}

**/