var tmpDiv;
var px='unused_';
function displayPanel(panelName,location)
{if(document.getElementById(panelName)==null)return false;
var parentNode=document.getElementById(panelName).parentNode;
var objToAppend=tmpDiv;
if(objToAppend==null)return true
removePanel(panelName);
if(objToAppend.style&&navigator.product=='Gecko'){removePrefix(objToAppend,px);
objToAppend.style.display='';
}else{var endEl=document.getElementById("attributeSearchBottom");
parentNode.insertBefore(objToAppend,endEl);
}
setDdlState('134','135');
switch(panelName){case"housesForSaleSearchForm":case"rentalsSearchForm":setDdlState('135','136');
setControlState('136','133');
break;
}
var saleLink=document.getElementById("saleLink");
var rentalLink=document.getElementById("rentalLink");
switch(panelName){case"housesForSaleSearchForm":case"commercialForSaleSearchForm":saleLink.className="";
rentalLink.className="selected";
break;
case"rentalsSearchForm":case"commercialForLeaseSearchForm":saleLink.className="selected";
rentalLink.className="";
break;
}
var saleImage=document.getElementById("asCom");
var leaseImage=document.getElementById("asLea");
if(saleImage&&leaseImage){if(saleImage.src.indexOf("/Images/3/Property/comm_sale_blue.gif")>0)
saleImage.src="/Images/3/Property/comm_sale_white.gif";
else
saleImage.src="/Images/3/Property/comm_sale_blue.gif";
if(leaseImage.src.indexOf("/Images/3/Property/comm_lease_blue.gif")>0)
leaseImage.src="/Images/3/Property/comm_lease_white.gif";
else
leaseImage.src="/Images/3/Property/comm_lease_blue.gif";
}
return false;
}
function removePanel(panelName)
{tmpDiv=document.getElementById(panelName);
var parent=tmpDiv.parentNode;
if(tmpDiv.style&&navigator.product=='Gecko'){appendPrefix(tmpDiv,px);
tmpDiv.style.display='none';
}else{parent.removeChild(tmpDiv);
}}
function appendPrefix(pc,prefix){if(pc.childNodes.length>0){for(var i=0;
i<pc.childNodes.length;
i++){appendPrefix(pc.childNodes[i],prefix)}}
if(pc.id){pc.id=prefix+pc.id;
}
return;
}
function removePrefix(pc,prefix){if(pc.childNodes.length>0){for(var i=0;
i<pc.childNodes.length;
i++){removePrefix(pc.childNodes[i],prefix)}}
if(pc.id){if(pc.id.length>prefix.length&&pc.id.substr(0,prefix.length)==prefix){pc.id=pc.id.substr(prefix.length,pc.id.length-prefix.length);
}}
return;
}
function setDdlState(parentDdlId,childDdlId)
{var parentDdl=document.getElementById(parentDdlId);
var childDdl=document.getElementById(childDdlId);
if(parentDdl.disabled||parentDdl.value==''){childDdl.value='';
childDdl.disabled=true;
}
else{childDdl.disabled=false;
}}
function setControlState(ddlId,checkboxId)
{var cbo=document.getElementById(checkboxId);
var ddl=document.getElementById(ddlId);
if(ddl.disabled||ddl.value==''){document.getElementById('span_'+checkboxId).style.color="#999";
cbo.checked=false;
cbo.disabled=true;
}
else{document.getElementById('span_'+checkboxId).style.color="#333";
cbo.disabled=false;
}}
function setOptionState()
{if(document.sidebar){var ctrlHidden=document.getElementById('enableBedroomOptions');
if(ctrlHidden.value=="1"){toggleControl(document.sidebar,'27',false);
}
else{toggleControl(document.sidebar,'27',true);
}}
else if(document.rentals_main){var ctrlHidden=document.getElementById('enableBedroomOptions');
if(ctrlHidden.value=="1"){toggleControl(document.rentals_main,'27',false);
}
else{toggleControl(document.rentals_main,'27',true);
}}}
function toggleControl(strTheForm,strNameOfControl,blnDisabled)
{for(var i=0;
i<strTheForm.elements.length;
i++){if(strNameOfControl==strTheForm.elements[i].name){var ctrl=strTheForm.elements[i];
if(ctrl.disabled!=blnDisabled){if(ctrl.type=='select-one'){ctrl.selectedIndex=0;
}
ctrl.disabled=blnDisabled;
}}}}
function toggleControl2(theForm,strNameOfControl,blnDisabled)
{for(var i=0;
i<theForm.elements.length;
i++){if(strNameOfControl==theForm.elements[i].name){var control=theForm.elements[i];
if(control.disabled!=blnDisabled){if(control.type=='select-one'){control.selectedIndex=0;
}
control.disabled=blnDisabled;
}}}}
function cascadeLocationsByAttributeId(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode)
{var ctlLocation=document.getElementById('71');
var ctlSuburb=document.getElementById('72');
var ctlSelectedSuburb=document.getElementById('selected72');
var strActionText=strMode=="search"?"Any "+strChildNoun:"Choose..."
if(ctlLocation.value==''||ctlLocation.text==''){if(ctlSuburb.disabled){ctlSuburb.disabled=false;
}
ctlSuburb.options.length=0
ctlSuburb.options[0]=new Option(strActionText,'',false,false);
}
else if(ctlLocation.options[ctlLocation.selectedIndex].value.indexOf(', ')==-1){if(ctlSuburb.disabled){ctlSuburb.disabled=false;
}
ctlSuburb.options.length=0
ctlSuburb.options[0]=new Option(strActionText,'',false,false);
}
else{var iCurrSource;
iCurrSourceString=ctlLocation.options[ctlLocation.selectedIndex].value
for(i=0;
i<arrParentOptions.length;
i++){if(arrParentOptions[i]==iCurrSourceString){iCurrSource=i;
break;
}}
if(arrParentChildLink[iCurrSource]==null){var strNoChildrenMsg='No '+strChildNoun+'s';
if(ctlSuburb.options[0].text!=strNoChildrenMsg){ctlSuburb.options.length=0
ctlSuburb.options[0]=new Option(strNoChildrenMsg,'',false,false);
if(!ctlSuburb.disabled){ctlSuburb.disabled=true;
}}}
else{if(ctlSuburb.disabled){ctlSuburb.disabled=false;
}
var aOptions;
aOptions=new Array();
for(var destArrLoop=0;
destArrLoop<arrParentChildLink.length;
destArrLoop++){aOptions[destArrLoop]=destArrLoop;
}
sortedOptions=new Array();
sortIndex=0;
for(var iLoop=0;
iLoop<aOptions.length;
iLoop++){if(aOptions[iLoop]!=null){sortedOptions[sortIndex]=aOptions[iLoop];
sortIndex=sortIndex+1;
}}
var arrChildOptionsOutput=new Array(sortIndex);
for(i=0;
i<sortIndex;
i++){arrChildOptionsOutput[i]=new Array(1);
arrChildOptionsOutput[i][0]=arrChildOptions[sortedOptions[i]][0];
arrChildOptionsOutput[i][1]=arrChildOptions[sortedOptions[i]][1];
}
ctlSuburb.options.length=0
ctlSuburb.options[0]=new Option(strActionText,'',false,false);
ctlSuburb.options[1]=new Option('','',false,false);
var intItemToSelect=0;
for(i=0;
i<arrChildOptionsOutput.length;
i++){if(ctlSelectedSuburb.value!=''&&arrChildOptionsOutput[i][1]==ctlSelectedSuburb.value){intItemToSelect=i+2}
ctlSuburb.options[i+2]=new Option(arrChildOptionsOutput[i][0],arrChildOptionsOutput[i][1],false,false);
}
ctlSuburb.options[intItemToSelect].selected=true;
}}}
function cascadeExtra(area,prefix,isAdjacentSearchCheckedProperty,isAdjacentSearchCheckedRentals,arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName){if(prefix=='cnt_f'||prefix=='cnt_r'){cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('rentalsSearchForm',area);
if(isAdjacentSearchCheckedProperty=='True'){setAdjacentAsChecked();
}
cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('housesForSaleSearchForm',area);
if(isAdjacentSearchCheckedRentals=='True'){setAdjacentAsChecked();
}}else if(prefix=='cnt_l'){cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('commercialForLeaseSearchForm',area);
cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('commercialForSaleSearchForm',area);
}else if(prefix=='cnt_c'){cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('commercialForSaleSearchForm',area);
cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('commercialForLeaseSearchForm',area);
}else{cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('housesForSaleSearchForm',area);
if(isAdjacentSearchCheckedRentals=='True'){setAdjacentAsChecked();
}
cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName)
displayPanel('rentalsSearchForm',area);
if(isAdjacentSearchCheckedProperty=='True'){setAdjacentAsChecked();
}}}
function setAdjacentAsChecked(){var cbo=document.getElementById(133);
var ddl=document.getElementById(136);
if(!ddl.disabled||!ddl.value==''){cbo.disabled=false;
cbo.checked=true;
}}
TradeMe.namespace('TradeMe.Flat')
TradeMe.Flat.getElementByIdViaTag=function(id,tagType){var tags=document.getElementsByTagName(tagType);
for(var i=0;
i<tags.length;
i++){if(tags[i].id==id){return tags[i];
}}
return null;
}
function cascadeLocationsByAttributeId2(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId,countsArrayName){var ctlParent=$(parentControlId);
var ctlChild=$(childControlId);
var ctlSelectedChild=$('selected'+childControlId);
var strActionText='';
if(strMode=='search'){if(strChildNoun=='sub category'){strActionText='Any sub category';
}
else{strActionText='(select '+strChildNoun+')';
}}
else{strActionText='Choose a '+strParentNoun+' first';
}
if(!ctlParent){ctlParent=TradeMe.Flat.getElementByIdViaTag(parentControlId,"select");
}
if(!ctlChild){ctlChild=TradeMe.Flat.getElementByIdViaTag(childControlId,"select");
}
if(!ctlSelectedChild){ctlSelectedChild=TradeMe.Flat.getElementByIdViaTag('selected'+childControlId,"input");
}
if(ctlParent.value==''||ctlParent.text==''){if(!ctlChild.disabled){ctlChild.disabled=true;
}
ctlChild.options.length=0
ctlChild.options[0]=new Option(strActionText,'',false,false);
}
else{iCurrSource=ctlParent.options[ctlParent.selectedIndex].value
if(arrParentChildLink[iCurrSource]==null||arrParentChildLink[iCurrSource].length==0){var strNoChildrenMsg='';
if(strChildNoun=='sub category'){strNoChildrenMsg='No sub categories';
}
else{strNoChildrenMsg='No '+strChildNoun+'s';
}
if(ctlChild.options[0].text!=strNoChildrenMsg){ctlChild.options.length=0
ctlChild.options[0]=new Option(strNoChildrenMsg,'',false,false);
if(!ctlChild.disabled){ctlChild.disabled=true;
}}}
else{if(ctlChild.disabled){ctlChild.disabled=false;
}
var aOptions=new Array();
for(i=0;
i<arrParentChildLink[iCurrSource].length;
i++){if(arrParentChildLink[iCurrSource][i]==1){aOptions[i]=i;
}}
sortedOptions=new Array();
sortIndex=0;
for(i=0;
i<aOptions.length;
i++){if(aOptions[i]!=null){sortedOptions[sortIndex]=aOptions[i];
sortIndex++;
}}
var arrChildOptionsOutput=new Array(sortIndex);
for(i=0;
i<sortIndex;
i++){arrChildOptionsOutput[i]=new Array(1);
arrChildOptionsOutput[i]=[sortedOptions[i],arrChildOptions[sortedOptions[i]]];
}
arrChildOptionsOutput.sort(function(a,b){if(a[1]=='Other'){return 1;
}
else if(b[1]=='Other'){return-1;
}
else if(a[1]==b[1]){return 0;
}
else{return a[1]>b[1]?1:-1;
}});
ctlChild.options.length=0
var topOptionText='';
if(strMode=='search'){if(strChildNoun=='sub category'){topOptionText='Any sub category';
}
else{topOptionText='(select '+strChildNoun+')';
}}
else{topOptionText='Choose...';
}
ctlChild.options[0]=new Option(topOptionText,'',false,false);
ctlChild.options[1]=new Option('','',false,false);
var intItemToSelect=0;
var optionKey='';
var optionValue='';
var hasCounts=false;
if(arguments[8]!=null){hasCounts=true;
}
for(i=0;
i<arrChildOptionsOutput.length;
i++){if(ctlSelectedChild&&ctlSelectedChild.value!=''&&arrChildOptionsOutput[i][0]==ctlSelectedChild.value){intItemToSelect=i+2}
optionKey=arrChildOptionsOutput[i][0];
optionValue=arrChildOptionsOutput[i][1];
//if(hasCounts){optionValue=optionValue+' ('+eval(countsArrayName)[optionKey]+')'}
ctlChild.options[i+2]=new Option(optionValue,optionKey,false,false);
}
ctlChild.options[intItemToSelect].selected=true;
}}
if(ctlChild.onchange)ctlChild.onchange();
}
function validateMulti(multi,cbo)
{var anySelected;
var allSelected;
if(multi.options.length==0){anySelected=false;
allSelected=false;
}
else{anySelected=false;
allSelected=true;
for(iLoop=0;
iLoop<multi.options.length;
iLoop++){if(multi.options[iLoop].selected){anySelected=true;
}
else{allSelected=false;
}}}
if(allSelected&&!cbo.checked){cbo.checked=true;
}
else if(!allSelected&&cbo.checked){cbo.checked=false;
}}
function getBitArray(arrIn)
{return g(arrIn);
}
function g(arrIn)
{var arrOut=new Array();
for(iLoop=0;
iLoop<arrIn.length;
iLoop++){arrOut[arrIn[iLoop]]=1;
}
return(arrOut);
}
function numberorder(a,b)
{return a-b;
}