function openDiv(divID, hDivObj)
{
  if(document.getElementById(divID).style.display=='block'){
    document.getElementById(divID).style.display='none';
    hDivObj.style.background = "url('http://image.aussielistings.com.au/expand-div.gif') no-repeat";
  }
  else{
    document.getElementById(divID).style.display='block';
    hDivObj.style.background = "url('http://image.aussielistings.com.au/close-div.gif') no-repeat";
  }
}
function CreateBookmarkLink(title,url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}
function SelectAll(id){
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
function ImageWindow(imgURL) {
  var width = 640;
  var height = 480;
  if (screen.width > 800) {
      width = 800;
      height = 600;
  }
  //bypass norton internet security popup blocker
  if (typeof SymRealWinOpen != 'undefined') {
      if(navigator.appVersion.indexOf("MSIE")!=-1) { /* ie */
          window.open = SymRealWinOpen;
      } else {
          alert('Norton Internet Security may block this popup.\nPlease disable your popup blocker if you experience any problems.');
      }
  }
  // pop appropriately sized window
  if (screen.width > 800)
      w=window.open(imgURL,'ImageWindow','menubar=no,toolbar=no,status=no,width='+(width+60)+',height='+(height+150)+',resizable=yes,scrollbars=yes');
  else
      w=window.open(imgURL,'ImageWindow','menubar=no,toolbar=no,status=no,width='+(width+40)+',height='+(height+120)+',resizable=yes,scrollbars=yes');
  w.focus();
} 
function PopWindow(imgURL, width, height) {
  //bypass norton internet security popup blocker
  if (typeof SymRealWinOpen != 'undefined') {
      if(navigator.appVersion.indexOf("MSIE")!=-1) { /* ie */
          window.open = SymRealWinOpen;
      } else {
          alert('Norton Internet Security may block this popup.\nPlease disable your popup blocker if you experience any problems.');
      }
  }
  // pop appropriately sized window
  if (screen.width > 800)
      w=window.open(imgURL,'ImageWindow','menubar=no,toolbar=no,status=no,width='+(width+60)+',height='+(height+150)+',resizable=yes,scrollbars=yes');
  else
      w=window.open(imgURL,'ImageWindow','menubar=no,toolbar=no,status=no,width='+(width+40)+',height='+(height+120)+',resizable=yes,scrollbars=yes');
  w.focus();
} 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
function addUnloadEvent(func) {
  var oldunload = window.onunload;
  if (typeof window.onunload != 'function') {
    window.onunload = func;
  } else {
    window.onunload = function() {
      if (oldonunload) {
        oldonunload();
      }
      func();
    }
  }
}

var map = null;
var geocoder = null;
var address_default = 'australia';

function setRegionMap(region_name){
  regionMapConObj = document.getElementById('region-map-container');
  regionMapObj = document.getElementById('region-map');
  if(regionMapConObj.style.display=='block'){
    regionMapConObj.style.display='none';
  }
  else{        
    if (GBrowserIsCompatible()) {
      regionMapConObj.style.display='block';
      map = new GMap2(regionMapObj);
      geocoder = new GClientGeocoder();
      //point = new GLatLng(-33.54092966585866, 151.30654335021973);
      showAddress(region_name+', nsw, australia');  
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());           
    }
        
  }
}

function showSuburb(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (point) {
        map.setCenter(point, 13);
      }
    }
  );
}
function showStreet(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (point) {
        map.setCenter(point, 15);
				marker = new GMarker(point);
        map.addOverlay(marker);
      }
			else{
			  showSuburb(address_default);
			}
    }
  );
}
function showpay() {
 if ((document.getElementById('calc-amount').value == null || document.getElementById('calc-amount').value.length == 0) ||
     (document.getElementById('calc-length').value == null || document.getElementById('calc-length').value.length == 0) ||
     (document.getElementById('calc-rate').value == null || document.getElementById('calc-rate').value.length == 0))
 { 
   document.calc.pay.value = "Missing Fields";
 }
 else
 {
   var calcAmount = document.getElementById('calc-amount').value;
   var calcLength  = (document.getElementById('calc-length').value*12);
   var calcRate  = document.getElementById('calc-rate').value / 1200;
	 var calcPayments = calcAmount * calcRate / (1 - (Math.pow(1/(1 + calcRate), calcLength)));
   document.getElementById('calc-payments').innerHTML = 'Monthly Repayments = <b>$'+(Math.round(calcPayments*100)/100)+'</b>';
 }
 /* payment = principle x monthly_interest_rate/(1 - (1/(1+monthly_interest_rate)*length)) */
}