/* Ajax stuff */
var xmlHttp;
var rootpath;
 
rootpath = "http://www.rwnoosa.com.au/";   // be sure to change this to your URL
 
function getSearchResultTotal(frm)
{
	var strQuery 
	strQuery = "?strAction=Search&search_suburb=" + frm.search_suburb.options[frm.search_suburb.selectedIndex].value;
	strQuery = strQuery + "&search_price=" + frm.search_price.options[frm.search_price.selectedIndex].value;
	strQuery = strQuery + "&search_propertytype=" + frm.search_propertytype.options[frm.search_propertytype.selectedIndex].value;
    /* if (frm.search_reference.value != '') {
		strQuery = strQuery + "&search_reference=" + frm.search_reference.value;
	} */
    if (frm.search_streetname.value != '') {
		strQuery = strQuery + "&search_streetname=" + frm.search_streetname.value;
	}
	var url=rootpath + "ajax_noosa_real_estate_property_results.asp" + strQuery
    
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
 
function stateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("search_ajaxresults").innerHTML=xmlHttp.responseText
    }
}
 
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 
/* Used to hide form elements when dropdown menu appears */

if (!window.hiddenDivs) window.hiddenDivs = new Array();

function showDiv() {
   	for (var i=0; i < window.hiddenDivs.length; i++) {
		if (document.layers) document.layers[hiddenDivs[i]].visibility="show";
   		else {
			   if (document.getElementById(hiddenDivs[i])) {
				   document.getElementById(hiddenDivs[i]).style.visibility="visible";
			   }
		   }
	}
}
function hideDiv() {
   	for (var i=0; i < window.hiddenDivs.length; i++) {
		   if (document.layers) document.layers[hiddenDivs[i]].visibility="hide";
		   else {
			   if (document.getElementById(hiddenDivs[i])) {
				   document.getElementById(hiddenDivs[i]).style.visibility="hidden";
			   }
		   }
	}
}
function hideIt(divname) {
	document.getElementById(divname).className=divname+"_hide";
}
function rollItOver(divname) {
	document.getElementById(divname).className=divname+"_over";
}
function rollItOut(divname) {
	document.getElementById(divname).className=divname;
}
function hidePopDiv(divname)
{
	var checkIt;
	checkIt = setTimeout('hideIt("'+divname+'")',9000);
}

/* open window centred */
var win= null;
function NewWindow(mypage,myname,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars='+scroll+',';
settings +='resizable=yes';
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
} 
function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}
	
/* Obfuscate email addresses */
function obfuscator(name, domain, display) {
displayed=(typeof(display)=="undefined") ? name+"@"+domain : display
document.write('<a href=mailto:' + name + '@' + domain + '>' + displayed + '</a>');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*  Pops windowMaker */	
function windowMaker(url, name) {
			window.open( url, name, 'toolbar=no,resizable=no,scrollbars=no,menubar=no,location=no,width=600,height=400,top=10,left=10' );
		}
		
/*  Pops Photo Gallery windows */		
function photoGallery(url, name) {
			window.open( url, name, 'toolbar=no,resizable=no,scrollbars=no,menubar=no,location=no,width=678,height=460,top=10,left=10' );
		}
		
/* functions for selecting checkboxes */
function checkAll(cbAll,cbList,bSelect)
{
  if (cbAll.checked == true) {
  for (var i=0; i<cbList.length; i++) 
    cbList[i].selected = cbList[i].checked = bSelect
	}
}
function checkAllToggle(cbAll,cbList)
{
  var blnCheckAll;
  blnCheckAll=true;
  for (var i=0; i<cbList.length; i++) {
		if (cbList[i].checked == false) {
			blnCheckAll = false;
		} 
	}
	if (blnCheckAll) {
		cbAll.checked=true;
		  for (var i=0; i<cbList.length; i++) {
			cbList[i].checked = false;
    		} 
	} else {
		cbAll.checked=false;
	}	
}


/* Extra stuff to enable nav hovers in lame IE */
sfHover = function() {
	var sfEls = document.getElementById("subnav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
