/* Cloack e-mail addresses */

function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
		  if (alltags[i].className == "emailCloak") {
		  	var oldText = alltags[i].firstChild;
		  	var emailAddress = alltags[i].firstChild.nodeValue;
		  	var user = emailAddress.substring(0, emailAddress.indexOf("("));
		  	var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
		  	var newText = user+"@"+website;
		  	var a = document.createElement("a");
		  	a.href = "mailto:"+newText;
			var address = document.createTextNode(newText);
			a.appendChild(address);
			alltags[i].replaceChild(a,oldText);
		  }
		}
	}
}

/* Show/Hide */

function show (id) { 

whichdiv = document.getElementById(id);

var thearray= new Array("opt_photos","opt_calculator","opt_emailfriend","opt_floorplans","opt_enquiry","opt_viewing"); 
for(i=0; i<thearray.length; i++){ 
      if(thearray[i] == id){ 
            whichdiv.className="show"; 
      }else{ 
            document.getElementById(thearray[i]).className="hide"; 
      } 
   } 
}


/* Scroll Photos */

function update(url, index, isSuper) 
{
	currentIndex = index;
	currentIsSuper = isSuper;
	document.getElementById('mainphoto').src = url;
	return;
}

/* Show buying or renting drop down prices */
 function fShowDiv(boxid) {
   document.getElementById(boxid).style.display="block";
}

function fHideDiv(boxid) {
   document.getElementById(boxid).style.display="none";
}

function fPopulateMinMaxPrice(strType)
{
	if (strType == "buy")
	{
		fHideDiv("divRent");
		fShowDiv("divBuy");
	}
	else
	{
		fHideDiv("divBuy");
		fShowDiv("divRent");
	}
}

function checkPriceBuying(iType)
{
	var intPriceMin = document.searchForm.fSearchPriceMin.value;
	var intPriceMax = document.searchForm.fSearchPriceMax.value;

//	alert(intPriceMin);
//	alert(intPriceMax);

	intPriceMin = Math.round(intPriceMin)
	intPriceMax = Math.round(intPriceMax)

	if (intPriceMin >= intPriceMax)
	{
		if (iType==1)
		{
			i = document.searchForm.fSearchPriceMax.selectedIndex
			document.searchForm.fSearchPriceMin.options[i].selected = true
		}
		else
		{
			i = document.searchForm.fSearchPriceMin.selectedIndex
			document.searchForm.fSearchPriceMax.options[i].selected = true
		}
	}
}

function checkPriceRenting(iType)
{
	var intRentMin = document.searchForm.fSearchRentMin.value;
	var intRentMax = document.searchForm.fSearchRentMax.value;

	//alert(intRentMin);
	//alert(intRentMax);

	intRentMin = Math.round(intRentMin)
	intRentMax = Math.round(intRentMax)

	if (intRentMin >= intRentMax)
	{
		if (iType==1)
		{
			i = document.searchForm.fSearchRentMax.selectedIndex
			document.searchForm.fSearchRentMin.options[i].selected = true
		}
		else
		{
			i = document.searchForm.fSearchRentMin.selectedIndex
			document.searchForm.fSearchRentMax.options[i].selected = true
		}
	}
}

// Popup
// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
function popup(){// v1.3
	var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18;if (v4>1){v10=screen.width;for (v6=0;v6<v2.length;v6++){v18=v2[v6].split("=");if (v18[0]=="width"){v8=parseInt(v18[1]);}if (v18[0]=="left"){v9=parseInt(v18[1]);v11=v6;}}if (v4==2){v7=(v10-v8)/2;v11=v2.length;}else if (v4==3){v7=v10-v8-v9;}v2[v11]="left="+v7;}if (v5>1){v14=screen.height;for (v6=0;v6<v2.length;v6++){v18=v2[v6].split("=");if (v18[0]=="height"){v12=parseInt(v18[1]);}if (v18[0]=="top"){v13=parseInt(v18[1]);v15=v6;}}if (v5==2){v7=(v14-v12)/2;v15=v2.length;}else if (v5==3){v7=v14-v12-v13;}v2[v15]="top="+v7;}v16=v2.join(",");v17=window.open(v1[0],v1[1],v16);if (v3){v17.focus();}document.MM_returnValue=false;
}