//allow multiple onloads
// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
        if  (window.onload)
        {
                if (window.onload != SafeOnload)
                {
                        gSafeOnload[0] = window.onload;
                        window.onload = SafeOnload;
                }
                gSafeOnload[gSafeOnload.length] = f;
        }
        else {
                window.onload = f;
        }
}
function SafeOnload()
{
        for (var i=0;i<gSafeOnload.length;i++)
                gSafeOnload[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_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_findObj(n, d) { //v4.01
  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]; 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);
  if(!x && d.getElementById) x=d.getElementById(n); 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 showmenu(elmnt)
{
document.getElementById(elmnt).style.visibility="visible"
}
function hidemenu(elmnt)
{
document.getElementById(elmnt).style.visibility="hidden"
}

function CheckUsernamePassword() {
   if (document.authenticate.username.value.length < 1) {
      alert('Please specify a username');
      return false;
   }
   if (document.authenticate.password.value.length < 1) {
      alert('Please specify a password');
      return false;
   }

return true;
}


   function cleartxtfield() {
      if (document.qsearch.qstxt.value=="Enter: suburb or postcode") {
         document.qsearch.qstxt.value = "";
      }
   }

   function clearidfield() {
      if (document.idsearch.propertyid.value=="Enter: property ID") {
         document.idsearch.propertyid.value = "";
      }
   }

   function clearregfield() {
      if (document.search.qstxt.value=="Enter: suburb or postcode") {
         document.search.qstxt.value = "";
      }
   }

   function clearpm1field() {
      if (document.pm1search.suburb.value=="Enter: suburb or postcode") {
         document.pm1search.suburb.value = "";
      }
   }

   function clearpm2field() {
      if (document.pm2search.member.value=="Enter: office name") {
         document.pm2search.member.value = "";
      }
   }

   function checkqs() {
      if ((document.qsearch.qstxt.value==null) || (document.qsearch.qstxt.value=="") || (document.qsearch.qstxt.value=="Enter: suburb or postcode")) {
         alert('Find a Rental Property: Please enter a suburb or postcode');
         document.qsearch.qstxt.value = '';
         document.qsearch.qstxt.focus();
         return false;
      }
      return true;
   }

   function checkid() {
      if ((document.idsearch.propertyid.value==null) || (document.idsearch.propertyid.value=="") || (document.idsearch.propertyid.value=="Enter: property ID")) {
         alert('Find a Rental Property: Please enter a property ID');
         document.idsearch.propertyid.value = '';
         document.idsearch.propertyid.focus();
         return false;
      }
      return true;
   }

   function checkpm1() {
      if ((document.pm1search.suburb.value==null) || (document.pm1search.suburb.value=="") || (document.pm1search.suburb.value=="Enter: suburb or postcode")) {
         alert('Find a Property Manager: Please enter a suburb or postcode');
         document.pm1search.suburb.value = '';
         document.pm1search.suburb.focus();
         return false;
      }
      return true;
   }

   function checkpm2() {
      if ((document.pm2search.member.value==null) || (document.pm2search.member.value=="") || (document.pm2search.member.value=="Enter: office name")) {
         alert('Find a Property Manager: Please enter an office name');
         document.pm2search.member.value = '';
         document.pm2search.member.focus();
         return false;
      }
      return true;
   }

   function checkstate1() {
      if (document.addmem.state.value=="") {
         alert('Please select a state');
         return false;
      }
      return true;
   }

   function checkstate2() {
      if (document.addmem.mstate.value=="") {
         alert('Please select a state');
         return false;
      }
      return true;
   }

   function checksuburblist() {
      if (document.myform.suburblist.value=="") {
         alert('Advanced Search: Please enter a suburb');
         document.myform.suburblist.focus();
         return false;
      }
      return true;
   }

   function ShowPhone() {
alert('test');
      phonedj.style.display="block";
   }

    function rollOver(iName,iState)
    {
      if(document.images)
      {
        document.images[iName].src = eval(iName + '_' + iState + '.src');
      }
    }

      function fbs_click() {
         u=location.href;
         t=document.title;
         window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
         return false;
      }

   function submitEmail() {
      if (document.myform.myname.value == "") {
         alert('Please enter your Name');
         document.myform.myname.focus();
         return false;
      }
      if (document.myform.myemail.value == "") {
         alert('Please enter your Email');
         document.myform.myemail.focus();
         return false;
      }
      if (document.myform.myphone.value == "") {
         alert('Please enter your Phone');
         document.myform.myphone.focus();
         return false;
      }
      if (document.myform.mymessage.value == "") {
         alert('Please enter your Message');
         document.myform.mymessage.focus();
         return false;
      }
      document.myform.ch.value = 1;
      document.myform.on.value = 0;
      return true;
   }

          function displayContactDetails(memberid,propertyid) {
            var ajaxRequest;
            try{
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch (e){
                // Internet Explorer Browsers
                try{
                        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                        try{
                                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e){
                                // Something went wrong
                                alert("Your browser broke\!");
                                return false;
                        }
                }
            }
            var queryString = "?memberid=" + memberid + "&propertyid=" + propertyid;
            ajaxRequest.open("GET", "/cgi-bin/ajax/contacthits.cgi" + queryString, true);
            ajaxRequest.send(null);

            elem = document.getElementById("viewcontact");
            elem.style.display = "none";
            elem2 = document.getElementById("phtxt");
            elem2.style.display = "block";
            elem3 = document.getElementById("faxtxt");
            elem3.style.display = "block";
            elem4 = document.getElementById("webtxt");
            elem4.style.display = "block";
            return false;
          }

