//<![CDATA[

// Declarations
var loaded = false;
var initState = false;	//placeholder to indicate initial state is current
var hideInt = 300;		//sets timeout length for hiding of menus - ADJUST LENGTH OF MENU DISPLAY HERE!
var menuItems = 8;			//number of drop downs + 1
var browserName = navigator.userAgent;
var browserVer = parseInt(navigator.appVersion);

var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var ie5mac = ((window.navigator.userAgent.indexOf('MSIE 5.2') >= 0) && (window.navigator.userAgent.indexOf('Mac') >= 0))
var ns6 = (document.getElementById)? true:false;
var ie6 = (browserName.indexOf('MSIE 6.') > 0)
var ie7 = (browserName.indexOf('MSIE 7.') > 0)

var propertyList = ''; // stores a comma seperated list of propertyIDs for passing to GoogleMaps RSS
var mapCenterLat = ''; // GoogleMaps central Latitude
var mapCenterLong = ''; // GoogleMaps central Longitude
var map_type = ''; // are we loading a buy or a rent RSS feed for the map
var buy_from = ''; // for GoogleMaps link
var buy_to = ''; // for GoogleMaps link
var buy_type = ''; // for GoogleMaps link
var buy_suburb = ''; // for GoogleMaps link
var buy_surrounding = ''; // for GoogleMaps link
var buy_bedrooms = ''; // for GoogleMaps link

var rent_from = ''; // for GoogleMaps link
var rent_to = ''; // for GoogleMaps link
var rent_type = ''; // for GoogleMaps link
var rent_suburb = ''; // for GoogleMaps link
var rent_surrounding = ''; // for GoogleMaps link
var rent_bedrooms = ''; // for GoogleMaps link

var currentImage = '' // for property detail image viewer

var googleMapDiv = 'googleMap' // specify which div to load google maps into
var googleMapZoomLevel = 13 // specify which level to be zoomed into

var geoXml;
var map;
var searchcontrol;

var disableGalleryMouseOver = false;// buy/rent detail pages

var sl_menu_confirm_0, sl_menu_confirm_1, sl_menu_ok_0, sl_menu_ok_1, sl_menu_submit_0, sl_menu_submit_1, sl_menu_register_0, sl_menu_register_1;

function preLoadConfirm() {
	sl_menu_confirm_0 = new Image(56,18); sl_menu_confirm_0.src="images_dev/menu/sl_menu_confirm_0.gif"
	sl_menu_confirm_1 = new Image(56,18); sl_menu_confirm_1.src="images_dev/menu/sl_menu_confirm_1.gif"	
}

function preLoadOk() {
	sl_menu_ok_0 = new Image(56,18); sl_menu_ok_0.src="images_dev/menu/sl_menu_ok_0.gif"
	sl_menu_ok_1 = new Image(56,18); sl_menu_ok_1.src="images_dev/menu/sl_menu_ok_1.gif"	
}

function preLoadSubmit() {
	sl_menu_submit_0 = new Image(56,18); sl_menu_submit_0.src="images_dev/menu/sl_menu_submit_0.gif"
	sl_menu_submit_1 = new Image(56,18); sl_menu_submit_1.src="images_dev/menu/sl_menu_submit_1.gif"	
}

function preLoadRegister() {
	sl_menu_register_0 = new Image(59,18); sl_menu_register_0.src="images_dev/menu/sl_menu_register_0.gif"
	sl_menu_register_1 = new Image(59,18); sl_menu_register_1.src="images_dev/menu/sl_menu_register_1.gif"	
}

// Menu related functions

window.onload=detectSize;
window.onresize=detectSize;

function setLeft(layerID, val) {
	if (ie4) { if(document.all[layerID]) document.all[layerID].style.left = val; }
	else if (ns4) { if(document.layers[layerID]) document.layers[layerID].left = val; }
	else if (ns6) { if(document.getElementById(layerID)) document.getElementById(layerID).style.left = val + 'px' };
}

function getWidth() {
	if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth) return document.body.clientWidth;
}

function detectSize() {
	if(loaded && ie5mac) location.replace(location.href);
	
	var aw = 0;
	aw = getWidth();
	xPos = 0;
	if(aw > 950) xPos = Math.round((aw - 950) / 2);

	setLeft("logo", xPos + 1);
	
	loaded = true;
}

function refreshMenu() {
	for (var i = 1; i < menuItems; i++) {
		setVis("menu" + i, false);
	}
}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	var x = document.getElementById(lyr);
	coors[1] += 28; // adjust for padding, border, margin. Vertical position
	coors[0] -= 47; // adjust for padding, border, margin. Horizontal position
	if (ie6) {coors[0] += 425;}
	if (ie7) {coors[0] -= 502;}
	x.style.top = coors[1] + 'px';
	x.style.left = coors[0] + 'px';
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

	
function showMenu(menuID) {
		
	if (initState) { clearTimeout(TID) } else { initState = true; }
  
  	refreshMenu();
			
	for (var i = 1; i < menuItems; i++) {
		if (menuID == "" + i) { setVis("menu" + i, true);	} else { setVis("menu" + i, false); }
	}
}


function setVis(layerID, boolval) {
	if (ie4) { if(document.all[layerID]) document.all[layerID].style.visibility = boolval ? 'visible' : 'hidden'; }
	else if (ns4) { if(document.layers[layerID]) document.layers[layerID].visibility = boolval ? 'show' : 'hide'; }
	else if (ns6) { if(document.getElementById(layerID)) document.getElementById(layerID).style.visibility = boolval ? 'visible' : 'hidden'; }
}

		
function closeMe(obj){
	timeoutString = "refreshMenu()"
  	if (ie4) {TID = setTimeout(timeoutString,hideInt);}
  	else if (ns4) {TID = setTimeout(timeoutString,hideInt);}
  	else if (ns6) {TID = window.setTimeout(timeoutString,hideInt);} 
}

	
function get(el) {
  return document.getElementById(el);
}

// Google Map functions


function loadAnyMap() {
	// remember to specify googleMapDiv and googleMapZoomLevel.
	// They have been set to default values at the top of this page
	var geoRSS = "http://www.sarahlorden.com.au/propertiesRSS.asp?buy_from=" + encodeURI(buy_from) + "&buy_to=" + encodeURI(buy_to) + "&buy_type=" + encodeURI(buy_type) + "&buy_suburb=" + encodeURI(buy_suburb) + "&buy_surrounding=" + encodeURI(buy_surrounding) + "&buy_bedrooms=" + encodeURI(buy_bedrooms) + "&rent_from=" + encodeURI(rent_from) + "&rent_to=" + encodeURI(rent_to) + "&rent_type=" + encodeURI(rent_type) + "&rent_suburb=" + encodeURI(rent_suburb) + "&rent_surrounding=" + encodeURI(rent_surrounding) + "&rent_bedrooms=" + encodeURI(rent_bedrooms) + "&type=" + encodeURI(map_type) + "&ids=" + propertyList;
	if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById(googleMapDiv));
		geoXml = new GGeoXml(geoRSS);
    	map.setCenter(new GLatLng(mapCenterLat, mapCenterLong), googleMapZoomLevel);
        //map.addControl(new GSmallZoomControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//map.addControl(new GOverviewMapControl(),
        //new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(1, 1)));
		map.addOverlay(geoXml);
  	}
}

function loadAnyMap2() {
	// remember to specify googleMapDiv and googleMapZoomLevel.
	// They have been set to default values at the top of this page
	var geoRSS = "http://www.sarahlorden.com.au/propertiesRSS2.asp?buy_from=" + encodeURI(buy_from) + "&buy_to=" + encodeURI(buy_to) + "&buy_type=" + encodeURI(buy_type) + "&buy_suburb=" + encodeURI(buy_suburb) + "&buy_surrounding=" + encodeURI(buy_surrounding) + "&buy_bedrooms=" + encodeURI(buy_bedrooms) + "&rent_from=" + encodeURI(rent_from) + "&rent_to=" + encodeURI(rent_to) + "&rent_type=" + encodeURI(rent_type) + "&rent_suburb=" + encodeURI(rent_suburb) + "&rent_surrounding=" + encodeURI(rent_surrounding) + "&rent_bedrooms=" + encodeURI(rent_bedrooms) + "&type=" + encodeURI(map_type) + "&ids=" + propertyList;
	//alert(geoRSS);
	
	if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById(googleMapDiv));
		geoXml = new GGeoXml(geoRSS);
    	map.setCenter(new GLatLng(mapCenterLat, mapCenterLong), googleMapZoomLevel);
        //map.addControl(new GSmallZoomControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//map.addControl(new GOverviewMapControl(),
        //new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(1, 1)));
		map.addOverlay(geoXml);
  	}
}

function loadAnyMap3() {
	// remember to specify googleMapDiv and googleMapZoomLevel.
	// They have been set to default values at the top of this page
	var geoRSS = "http://www.sarahlorden.com.au/propertiesRSS2.asp?buy_from=" + buy_from + "&buy_to=" + buy_to + "&buy_type=" + buy_type + "&buy_suburb=" + buy_suburb + "&buy_surrounding=" + buy_surrounding + "&buy_bedrooms=" + buy_bedrooms + "&rent_from=" + rent_from + "&rent_to=" + rent_to + "&rent_type=" + rent_type + "&rent_suburb=" + rent_suburb + "&rent_surrounding=" + rent_surrounding + "&rent_bedrooms=" + rent_bedrooms + "&type=" + map_type + "&ids=" + propertyList;
	
	if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById(googleMapDiv));
		geoXml = new GGeoXml(geoRSS);
    	map.setCenter(new GLatLng(mapCenterLat, mapCenterLong), googleMapZoomLevel);
        map.addControl(new GSmallZoomControl());
	map.addOverlay(geoXml);
  	}
}


// Google Map functions
function ReCentre(lat, lng) {
    	map.setCenter(new GLatLng(lat, lng ), googleMapZoomLevel);
}

function originalCentre() {
    	map.setCenter(new GLatLng(mapCenterLat, mapCenterLong ), googleMapZoomLevel);
}

function loadMap(ptype, propertylist, buy_from, buy_to, buy_type, buy_suburb, buy_surrounding, buy_bedrooms) {
	if (mapLoaded == false) {
		elementID = "resultsMap";
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("POST", "/includes/ajax.asp" , true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send('ptype='+ptype+'&action=map&propertylist=' + encodeURI(propertylist) + '&p_from=' + encodeURI(buy_from) + '&p_to=' + encodeURI(buy_to) + '&buy_type=' + encodeURI(buy_type) + '&p_suburb=' + encodeURI(buy_suburb) + '&p_surrounding=' + encodeURI(buy_surrounding) + '&p_bedrooms=' + encodeURI(buy_bedrooms));
		mapLoaded = true;
	}
}

function loadViewer(ptype, strSQL, orderCell, buy_from, buy_to, buy_type, buy_suburb, buy_surrounding, buy_bedrooms) {
	if (viewerLoaded == false) {
		elementID = "buyViewer";
		document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("POST", "/includes/ajax.asp" , true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send('ptype='+ptype+'&action=viewer&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell + '&p_from=' + encodeURI(buy_from) + '&p_to=' + encodeURI(buy_to) + '&p_type=' + encodeURI(buy_type) + '&p_suburb=' + encodeURI(buy_suburb) + '&p_surrounding=' + encodeURI(buy_surrounding) + '&p_bedrooms=' + encodeURI(buy_bedrooms) + '&PriceOrder=' + encodeURI(PriceOrder) + '&SuburbOrder=' + encodeURI(SuburbOrder) + '&BedroomOrder=' + encodeURI(BedroomOrder) + '&DateListedOrder=' + encodeURI(DateListedOrder));
		if (orderCell == "priceCell") {
			if (PriceOrder == "asc" ) {
				PriceOrder = "ASC"; 
			} else {
				if (PriceOrder == "ASC" ) PriceOrder = "DESC"; else PriceOrder= "ASC" ;
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 				
			}
		}
		if (orderCell == "suburbCell"){
			if (SuburbOrder == "asc" ) {
				SuburbOrder = "ASC"; 
			} else {		
				if (SuburbOrder == "ASC" ) SuburbOrder = "DESC"; else SuburbOrder= "ASC" ;
				PriceOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "bedCell") {
			if (BedroomOrder == "asc" ) {
				BedroomOrder = "ASC"; 
			} else {		
				if (BedroomOrder == "ASC" ) BedroomOrder = "DESC"; else BedroomOrder= "ASC" ;
				SuburbOrder = "ASC";
				PriceOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "dateListed") {
			if (DateListedOrder == "desc" ) {
				DateListedOrder = "DESC"; 
			} else {		
				if (DateListedOrder == "ASC" ) DateListedOrder = "DESC"; else DateListedOrder= "ASC" ;	
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				PriceOrder = "ASC"; 								
			}
		}
	}
}

function saveTab(ptype, tab, order) {
		elementID = "savediv";
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("POST", "/includes/ajax.asp" , true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send('action='+ptype+'&tab='+encodeURI(tab)+'&order=' + encodeURI(order));
}


function loadAnyScript(functionName) {
  	var script = document.createElement("script");
  	script.setAttribute("src", "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAlYiX7azVAZx_iE3g3adZiBRrG-qZfhza36hICAStw0XCungZqRSGNJfbZ-oX0dDAA_rPrEzojowazQ&async=2&callback="+functionName);
  	script.setAttribute("type", "text/javascript");
  	document.documentElement.firstChild.appendChild(script);
}

function UnloadMap() {
	if(typeof(GBrowserIsCompatible) != 'undefined') GUnload();
}	


// Functions for use with AJAX

function loadBuyRecentResults(strSQL, orderCell) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyRecentResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell);
}

function loadRentRecentResults(strSQL, orderCell) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=rentRecentResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell);
}



function loadBuyOpenResults(strSQL, orderCell) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyOpenResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell);
}

function loadBuyOpenResultsRegister(strSQL, orderCell) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('register=1&action=buyOpenResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell);
}

function loadRentOpenResults(strSQL, orderCell) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=rentOpenResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell);
}


function loadBuyResultsMarch(strSQL, conditions, orderCell, buy_from, buy_to, buy_type, buy_suburb, buy_surrounding, buy_bedrooms) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyResults&strSQL=' + encodeURI(strSQL) + encodeURI(conditions) + '&orderCell=' + orderCell + '&buy_from=' + encodeURI(buy_from) + '&buy_to=' + encodeURI(buy_to) + '&buy_type=' + encodeURI(buy_type) + '&buy_suburb=' + encodeURI(buy_suburb) + '&buy_surrounding=' + encodeURI(buy_surrounding) + '&buy_bedrooms=' + encodeURI(buy_bedrooms));
}

function loadBuyResults(strSQL, conditions, orderCell, buy_from, buy_to, buy_type, buy_suburb, buy_surrounding, buy_bedrooms) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyResults&strSQL=' + encodeURI(strSQL) + encodeURI(conditions) + '&orderCell=' + orderCell + '&buy_from=' + encodeURI(buy_from) + '&buy_to=' + encodeURI(buy_to) + '&buy_type=' + encodeURI(buy_type) + '&buy_suburb=' + encodeURI(buy_suburb) + '&buy_surrounding=' + encodeURI(buy_surrounding) + '&buy_bedrooms=' + encodeURI(buy_bedrooms) + '&PriceOrder=' + encodeURI(PriceOrder) + '&SuburbOrder=' + encodeURI(SuburbOrder) + '&BedroomOrder=' + encodeURI(BedroomOrder) + '&DateListedOrder=' + encodeURI(DateListedOrder));
		if (orderCell == "priceCell") {
			if (PriceOrder == "asc" ) {
				PriceOrder = "ASC"; 
			} else {
				if (PriceOrder == "ASC" ) PriceOrder = "DESC"; else PriceOrder= "ASC" ;
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 				
			}
		}
		if (orderCell == "suburbCell"){
			if (SuburbOrder == "asc" ) {
				SuburbOrder = "ASC"; 
			} else {		
				if (SuburbOrder == "ASC" ) SuburbOrder = "DESC"; else SuburbOrder= "ASC" ;
				PriceOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "bedCell") {
			if (BedroomOrder == "asc" ) {
				BedroomOrder = "ASC"; 
			} else {		
				if (BedroomOrder == "ASC" ) BedroomOrder = "DESC"; else BedroomOrder= "ASC" ;
				SuburbOrder = "ASC";
				PriceOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "dateListed") {
			if (DateListedOrder == "desc" ) {
				DateListedOrder = "DESC"; 
			} else {		
				if (DateListedOrder == "ASC" ) DateListedOrder = "DESC"; else DateListedOrder= "ASC" ;	
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				PriceOrder = "ASC"; 								
			}
		}
	
}

function loadRentResultsMarch(strSQL, conditions, orderCell, rent_from, rent_to, rent_type, rent_suburb, rent_surrounding, rent_bedrooms) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=rentResults&strSQL=' + encodeURI(strSQL) + encodeURI(conditions) + '&orderCell=' + orderCell + '&rent_from=' + encodeURI(rent_from) + '&rent_to=' + encodeURI(rent_to) + '&rent_type=' + encodeURI(rent_type) + '&rent_suburb=' + encodeURI(rent_suburb) + '&rent_surrounding=' + encodeURI(rent_surrounding) + '&rent_bedrooms=' + encodeURI(rent_bedrooms));
}

function loadRentResults(strSQL, conditions, orderCell, rent_from, rent_to, rent_type, rent_suburb, rent_surrounding, rent_bedrooms) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=rentResults&strSQL=' + encodeURI(strSQL) + encodeURI(conditions) + '&orderCell=' + orderCell + '&rent_from=' + encodeURI(rent_from) + '&rent_to=' + encodeURI(rent_to) + '&rent_type=' + encodeURI(rent_type) + '&rent_suburb=' + encodeURI(rent_suburb) + '&rent_surrounding=' + encodeURI(rent_surrounding) + '&rent_bedrooms=' + encodeURI(rent_bedrooms) + '&PriceOrder=' + encodeURI(PriceOrder) + '&SuburbOrder=' + encodeURI(SuburbOrder) + '&BedroomOrder=' + encodeURI(BedroomOrder) + '&DateListedOrder=' + encodeURI(DateListedOrder));

		if (orderCell == "priceCell") {
			if (PriceOrder == "asc" ) {
				PriceOrder = "ASC"; 
			} else {
				if (PriceOrder == "ASC" ) PriceOrder = "DESC"; else PriceOrder= "ASC" ;
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 				
			}
		}
		if (orderCell == "suburbCell"){
			if (SuburbOrder == "asc" ) {
				SuburbOrder = "ASC"; 
			} else {		
				if (SuburbOrder == "ASC" ) SuburbOrder = "DESC"; else SuburbOrder= "ASC" ;
				PriceOrder = "ASC";
				BedroomOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "bedCell") {
			if (BedroomOrder == "asc" ) {
				BedroomOrder = "ASC"; 
			} else {		
				if (BedroomOrder == "ASC" ) BedroomOrder = "DESC"; else BedroomOrder= "ASC" ;
				SuburbOrder = "ASC";
				PriceOrder = "ASC";
				DateListedOrder = "DESC"; 								
			}
		}
		if (orderCell == "dateListed") {
			if (DateListedOrder == "desc" ) {
				DateListedOrder = "DESC"; 
			} else {		
				if (DateListedOrder == "ASC" ) DateListedOrder = "DESC"; else DateListedOrder= "ASC" ;	
				SuburbOrder = "ASC";
				BedroomOrder = "ASC";
				PriceOrder = "ASC"; 								
			}
		}
}

function loadTeamRecentResults(strSQL, orderCell, memberID) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "";
	document.getElementById(elementID).className = "loading";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=TeamRecentResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell + '&memberID=' + memberID);
}

function loadTeamResults(strSQL, orderCell, memberID) {
	elementID = "ajaxDiv";
	document.getElementById(elementID).innerHTML = "<br /><br /><br /><br /><img src='/images_dev/ajax-loader.gif' width='32' height='32' border='0' alt='loading...' /><br /><br /><br /><br />";
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=TeamResults&strSQL=' + encodeURI(strSQL) + '&orderCell=' + orderCell + '&memberID=' + memberID);

}

function clearThumbnails() {
	// update thumbnails
	if (currentImage != '') {
		currentImage = get(currentImage);
		currentImage.className = '';
	}
	currentImage = '';	
} 


function toggleVRTour(propertyID, vrURL) {
	clearThumbnails();

	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=vrTour&propertyID=' + encodeURI(propertyID) + '&vrURL=' + encodeURI(vrURL));
}


function toggleMap(propertyID) {
	clearThumbnails();

	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	googleMapDiv = 'mainBlock';
	googleMapZoomLevel = 16;
	loadAnyScript('loadAnyMap');
	document.getElementById(elementID).className = '';
	
}

function toggleOpenAlert(propertyID,sms_name,sms_number) {
	clearThumbnails();

	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyOpenTimeAlert&propertyID=' + encodeURI(propertyID)+'&sms_name=' + encodeURI(sms_name)+'&sms_number=' + encodeURI(sms_number));
}


function checkOpenTimeAlert(thisForm) {
	var alert_str = '', ticked = false, pids, pidsArray;
	
	if(eval(thisForm + ".sms_name.value") == '') {alert_str = alert_str + '\n- Your Name';}
	if(eval(thisForm + ".sms_mobile.value") == '') {alert_str = alert_str + '\n- Your Mobile Number';}
	pids = eval(thisForm + ".smsIds.value")
	pidsArray = pids.split(",");
	for (var i = 0; i <pidsArray.length; i++){
		if (eval(thisForm + ".cb_smsSaturday"+pidsArray[i]) != undefined )	
			if (eval(thisForm + ".cb_smsSaturday"+pidsArray[i]+".checked") )	
				ticked = true;
		if (eval(thisForm + ".cb_smsSunday"+pidsArray[i]) != undefined )	
			if (eval(thisForm + ".cb_smsSunday"+pidsArray[i]+".checked") )	
				ticked = true;		
		if (eval(thisForm + ".cb_smsWeekend1"+pidsArray[i]) != undefined )	
			if (eval(thisForm + ".cb_smsWeekend1"+pidsArray[i]+".checked")  )	
				ticked = true;	
		if (eval(thisForm + ".cb_smsWeekend2"+pidsArray[i]) != undefined )
			if (eval(thisForm + ".cb_smsWeekend2"+pidsArray[i]+".checked") )
				ticked = true;		
		if (eval(thisForm + ".cb_smsAuction"+pidsArray[i]) != undefined )	
			if (eval(thisForm + ".cb_smsAuction"+pidsArray[i]+".checked"))	
				ticked = true;	
	}

	if (!ticked)
		alert_str = alert_str + '\n- Select an opening time.';		

	if(alert_str != '') alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str);
	if(alert_str == '') eval(thisForm + ".submit()") ;
}


function registerOpenTimeAlert(thisForm) {
	var propertyID, sms_name, sms_mobile, saturday_sms_cb = false, sunday_sms_cb = false, weekend1_sms_cb = false, weekend2_sms_cb = false, auction_sms_cb = false
	var alert_str = '';

	propertyID = eval(thisForm + ".propertyID.value");
	sms_name = eval(thisForm + ".sms_name.value");
	sms_mobile = eval(thisForm + ".sms_mobile.value");	
	
	if(sms_name == '') {alert_str = alert_str + '\n- Your Name';}
	if(sms_mobile == '') {alert_str = alert_str + '\n- Your Mobile Number';}
		

	if (eval(thisForm + ".saturday_sms_cb") != undefined )
		saturday_sms_cb = eval(thisForm + ".saturday_sms_cb.checked");
	if (eval(thisForm + ".sunday_sms_cb") != undefined )	
		sunday_sms_cb = eval(thisForm + ".sunday_sms_cb.checked");
	if (eval(thisForm + ".weekend1_sms_cb") != undefined )	
		weekend1_sms_cb = eval(thisForm + ".weekend1_sms_cb.checked");
	if (eval(thisForm + ".weekend2_sms_cb") != undefined )
		weekend2_sms_cb = eval(thisForm + ".weekend2_sms_cb.checked");
	if (eval(thisForm + ".auction_sms_cb") != undefined )	
		auction_sms_cb = eval(thisForm + ".auction_sms_cb.checked");	

	if (!saturday_sms_cb & !sunday_sms_cb & !weekend1_sms_cb & !weekend2_sms_cb & !auction_sms_cb)
		alert_str = alert_str + '\n- Select an opening time.';		
		
	if(alert_str != '') { alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str); return; }
	
	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=registerOpenTimeAlert&propertyID=' + encodeURI(propertyID) + '&your_name=' + encodeURI(sms_name) + '&your_number=' + encodeURI(sms_mobile) + '&saturday_sms_cb=' + encodeURI(saturday_sms_cb) + '&sunday_sms_cb=' + encodeURI(sunday_sms_cb) + '&weekend1_sms_cb=' + encodeURI(weekend1_sms_cb) + '&weekend2_sms_cb=' + encodeURI(weekend2_sms_cb) + '&auction_sms_cb=' + encodeURI(auction_sms_cb));
}

function registerEmailPropertyAlert(thisForm) {
	var reg_name, reg_address, reg_password, reg_cpassword;
	var sendmeSales_cb, sendmeRentals_cb;
	var alert_str = '';
	
	reg_name = eval(thisForm + ".reg_name.value");
	reg_address = eval(thisForm + ".reg_address.value");
	reg_password = eval(thisForm + ".reg_password.value");	
	reg_cpassword = eval(thisForm + ".reg_cpassword.value");		
	
	sendmeSales_cb = eval(thisForm + ".sendmeSales_cb.checked");			
	sendmeRentals_cb = eval(thisForm + ".sendmeRentals_cb.checked");				
	
	if(reg_name == '') {alert_str = alert_str + '\n- Your Name';}
	if(reg_address == '') {
		alert_str = alert_str + '\n- Your Email Address';
	} else {
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(reg_address)) 
			alert_str = alert_str + '\n- Incorrect email address format';
	}
	if(reg_password == '') {
		alert_str = alert_str + '\n- Your Password';
	} else {
		if(reg_password.length <= 0) {alert_str = alert_str + '\n- Your Password needs at least 1 Character';}
	}
	if(reg_password != reg_cpassword) {alert_str = alert_str + '\n- Your Confirm Password needs to match';}
	if(!sendmeSales_cb & !sendmeRentals_cb) {alert_str = alert_str + '\n- Activate your criteria in the Buy or/and Rent section';}
				
	if(alert_str != '') { alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str); return; }
	eval(thisForm + ".submit()") ;
	
}



function togglePropertyAlert(propertyID) {
	clearThumbnails();

	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=buyPropertyAlert&propertyID=' + encodeURI(propertyID));
}


function checkPropertyAlert(thisForm) {
	var alert_str = '';

	if(eval(thisForm + ".your_name.value") == '') {alert_str = alert_str + '\n- Your Name';}
	if(eval(thisForm + ".your_email.value") == '') {alert_str = alert_str + '\n- Your Email';}

	if(alert_str != '') alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str);
	if(alert_str == '') registerPropertyAlert(thisForm);
}


function registerPropertyAlert(thisForm) {
	var propertyID, your_name, your_email
	
	propertyID = eval(thisForm + ".propertyID.value");
	your_name = eval(thisForm + ".your_name.value");
	your_email = eval(thisForm + ".your_email.value");
	
	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=registerPropertyAlert&propertyID=' + encodeURI(propertyID) + '&your_name=' + encodeURI(your_name) + '&your_email=' + encodeURI(your_email));
}

function registerPropertyAlertConfirm(thisForm) {
	var propertyID, sms_name, sms_mobile, saturday_sms_cb, sunday_sms_cb, weekend1_sms_cb, weekend2_sms_cb, auction_sms_cb, after;
	var alert_str = '';
	var ticked = false, pids, pidsArray, querystring = '';
		
	propertyID = eval(thisForm + ".propertyIDs.value");
	sms_name = eval(thisForm + ".your_name.value");
	sms_mobile = eval(thisForm + ".your_number.value");	
	after = eval(thisForm + ".after.value");
	
	pids = propertyID;
	pidsArray = pids.split(",");
	
	for (var i = 0; i <pidsArray.length; i++){
		saturday_sms_cb = false;
		sunday_sms_cb = false;
		weekend1_sms_cb = false;
		weekend2_sms_cb = false;
		auction_sms_cb = false;

		propertyID = pidsArray[i];
		if (eval(thisForm + ".saturday_sms_cb"+propertyID) != undefined )
			saturday_sms_cb = eval(thisForm + ".saturday_sms_cb"+propertyID+".value");
		if (eval(thisForm + ".sunday_sms_cb"+propertyID) != undefined )	
			sunday_sms_cb = eval(thisForm + ".sunday_sms_cb"+propertyID+".value");
		if (eval(thisForm + ".weekend1_sms_cb"+propertyID) != undefined )	
			weekend1_sms_cb = eval(thisForm + ".weekend1_sms_cb"+propertyID+".value");
		if (eval(thisForm + ".weekend2_sms_cb"+propertyID) != undefined )
			weekend2_sms_cb = eval(thisForm + ".weekend2_sms_cb"+propertyID+".value");
		if (eval(thisForm + ".auction_sms_cb"+propertyID) != undefined )	
			auction_sms_cb = eval(thisForm + ".auction_sms_cb"+propertyID+".value");	
			
		if (saturday_sms_cb == "1" | sunday_sms_cb == "1" | weekend1_sms_cb == "1" | weekend2_sms_cb == "1" | auction_sms_cb == "1")
			ticked = true;

		querystring = querystring + '&saturday_sms_cb'+propertyID+'='+ encodeURI(saturday_sms_cb) + '&sunday_sms_cb'+propertyID+'='+ encodeURI(sunday_sms_cb) + '&weekend1_sms_cb'+propertyID+'='+ encodeURI(weekend1_sms_cb) + '&weekend2_sms_cb'+propertyID+'='+ encodeURI(weekend2_sms_cb) + '&auction_sms_cb'+propertyID+'='+ encodeURI(auction_sms_cb)
	}
		
	if (!ticked) {	alert_str = '\n- Select an opening time.';		}
	if(alert_str != '') { alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str); return; }
	
	
	if(thisForm == "document.opentime_alertConfirm") {
		eval(thisForm + ".submit()");
	}
	else {
		elementID = "mainBlock";
		document.getElementById(elementID).innerHTML = '';
		document.getElementById(elementID).className = 'loading';
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("POST", "smsAlert.asp" , true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send('propertyIDs=' + encodeURI(propertyID) + '&your_name=' + encodeURI(sms_name) + '&your_number=' + encodeURI(sms_mobile) + querystring + '&after='+encodeURI(after));	
		setTimeout(after,500);
	}
	   
}


function toggleEmail(propertyURL, propertyID, ptype) {
	clearThumbnails();
		
	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=emailFriend&propertyURL=' + encodeURI(propertyURL)+ '&propertyID=' + propertyID+ '&ptype=' + ptype);
}

function checkEmail(thisForm) {
	var alert_str = '';

	if(eval(thisForm + ".your_name.value") == '') {alert_str = alert_str + '\n- Your Name';}
	if(eval(thisForm + ".your_email.value") == '') {alert_str = alert_str + '\n- Your Email';}
	if(eval(thisForm + ".friend_email.value") == '') {alert_str = alert_str + '\n- Friends Email';}

	if(alert_str != '') alert('Sorry, you have not completed the form.\nPlease check the following:' + alert_str);
	if(alert_str == '') sendEmail(thisForm);
}


function sendEmail(thisForm) {
	var propertyURL, your_name, your_email, friend_email, message, ptype, propertyID;
	
	propertyURL = eval(thisForm + ".propertyURL.value");
	your_name = eval(thisForm + ".your_name.value");
	your_email = eval(thisForm + ".your_email.value");
	friend_email = eval(thisForm + ".friend_email.value");
	message = eval(thisForm + ".message.value");
	message = message.replace(/&/g, "and"); // replace & with and otherwise will cause an error in the ajax page when parsing query string.
	ptype = eval(thisForm + ".ptype.value");
	propertyID = eval(thisForm + ".propertyID.value");
	
	elementID = "mainBlock";
	document.getElementById(elementID).innerHTML = '';
	document.getElementById(elementID).className = 'loading';
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("POST", "/includes/ajax.asp" , true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('action=emailFriendSend&propertyURL=' + encodeURI(propertyURL) + '&your_name=' + encodeURI(your_name) + '&your_email=' + encodeURI(your_email) + '&friend_email=' + encodeURI(friend_email) + '&message=' + encodeURI(message)+ '&ptype=' + ptype+ '&propertyID=' + propertyID);
}


function toggleImage(imageID, imageURL) {
	if (!disableGalleryMouseOver) {
		// update background, just in case
		document.getElementById('mainBlock').className = 'loading';
		// update thumbnails
		var thumbnail = get(imageID);
		thumbnail.className = 'current';
		if ((currentImage != '') && (currentImage != imageID)) {
			currentImage = get(currentImage);
			currentImage.className = '';
		}
		currentImage = imageID;
		
		// update large image
		document.getElementById('mainBlock').innerHTML='<center><img src="' + imageURL + '" border="0" height="339" alt="Large Property Image" /></center>';
		document.getElementById('mainBlock').className = 'imgBg';
		if (thumbnail.blur) thumbnail.blur(); 	
		
	}
	return false;
}

// -------------------------------- SLRE mortgage calc

//removes any commas
function input_money(value){
	while ((i=value.indexOf(",")) >= 0) {
		value = value.substring(0,i) + value.substring(i+1,value.length);
	}
	i=parseInt(value);//returns integer only
	return i;
}//end of function input_money 


//formats money values
function format_money(value) {

	var result = "";
	value += ""; // converts value into string

	if (value.length > 6)//if it is a more than 6 digit number
		result = (value.substring(0, (value.length - 6))) + "," + 
				(value.substring((value.length - 6), (value.length - 3))) + "," + 
				(value.substring((value.length - 3), value.length));
	else{

		if (value.length > 3)//if it is a more than 3 digit number
			result = (value.substring(0, (value.length - 3))) + "," + 
					(value.substring((value.length - 3), value.length));

		else 
			result = value;
	}

	result = result + "." + "00"; //adds ".00" to resulting value
	return result;

}//end of function format_money 


function calcRepay(mortgage) {

// get input values from form 
var amt = mortgage.fAmount.value;
amt = input_money(amt); // removes any commas
var int_rate = parseFloat(mortgage.fRate.value);
var term = parseInt(mortgage.fTerm.options[mortgage.fTerm.selectedIndex].value);
var type = mortgage.fType.options[mortgage.fType.selectedIndex].value;

// makes sure user inputs a loan amount higher than zero
if (amt <= 0){
	alert("You entered an invalid Loan Amount. Please enter a number higher than 0.");
	return;
	} // end if-statement

// makes sure user inputs a valid interest rate 
if ((int_rate <= 0) || (int_rate >= 100)){
	alert("You entered an invalid Interest Rate. Please enter a number between 0 and 100.");
	return;
	} // end if-statement

//calculates output-values
var monthly_rate = (int_rate/100.0)/12; // calculations in terms of months!!

if (type == "int_and_princ") { //calculates repayment for principal&interest loans

	var monthly_term = term * 12;
	var rate_plusone = 1.0+monthly_rate;
	var ann = Math.pow(rate_plusone, monthly_term);
	var ann_minus_one = ann - 1;
	var repay = amt * monthly_rate * ann / ann_minus_one;
	} 

else { // calculates repayment for interest-only loans

	var repay = (monthly_rate * amt);
	} 

repay = Math.round(repay);
repay = format_money(repay);
mortgage.repay_monthly.value = repay;
mortgage.loan_amount.value = format_money(amt);
finance_request.repay_monthly.value = repay;
finance_request.loan_amount.value = format_money(amt);

alert(repay);

} // end of function calcRepay


// -------------------------------- SLRE mortgage calc


// AJAX core functions. Do not change

var xmlHttp;
var elementID;
var cookieElementID;

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById(elementID).className = 'notloading'; document.getElementById(elementID).innerHTML=xmlHttp.responseText; } 
} 

function GetXmlHttpObject(handler) { 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0) {
		alert("This example doesn't work in Opera") 
		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
	}
}

function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
     key.innerHTML="Show more &gt;";
   } else {
      obj.style.display="";
      key.innerHTML="Hide";
   }
}

function isDate (dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat);
	var status = 0;
	
	if (matchArray == null) {
		status = 0;
	} else if ( matchArray[1] == null || matchArray[3] == null || matchArray[5] == null ) {
        status = 0;
	} else if ( matchArray[1] > 31 || matchArray[1] < 1 ) {
        status = -1;
	} else if ( matchArray[3] > 12 || matchArray[3] < 1 ) {
        status = -2;
	} else {
		status = 1;
	}
	
	return status;
}

function checkBuyDate (from, to) {
	var dateMsg = "";
	var status_from = isDate (from);
	var status_to = isDate (to);
	if ( status_from == 0 || status_to == 0 ) {
		dateMsg = "- Please enter date as dd/mm/yyyy\n";
	} else if ( status_from == -1 || status_to == -1 ) {
		dateMsg = "- Range of day is 1-31, please enter date as dd/mm/yyyy\n"; 
	} else if ( status_from == -2 || status_to == -2 ) {
		dateMsg = "- Range of month is 1-12 please enter date as dd/mm/yyyy\n";
	}
	if ( status_from < 1 || status_to < 1 ) {
		alert (dateMsg);
		return false;  	
	}
	return true;
}

//--------------------------------
// popup code

var popupwin = null;
var ary = new Array();
var first = true;
var previous_url;

var screenHeight = Math.round(screen.availHeight * 0.90)	
function windowOpen(url,openHeight) {		
	if (openHeight > screenHeight) {
		openHeight = screenHeight;
	}
	var winString = "height=" + openHeight + ",width=600,scrollbars=0,status=0,top=20,left=100";
	if (first) {
		popupwin = window.open( url, "breville", winString);
		popupwin.focus();
		first = false;
	} else {
		if ( popupwin != null && !popupwin.closed && previous_url == url ) { popupwin.focus(); }
		else {
			if (popupwin.closed) {
				popupwin = window.open( url, "breville", winString);
				popupwin.focus();
			} else {
				popupwin.location = url;
				popupwin.focus();
			}
		}	
	}
	previous_url = url ;
	return false;
}

//--------------------------------
// popup code for featured video

var popupwin = null;
var ary = new Array();
var first = true;
var previous_url;

var screenHeight = Math.round(screen.availHeight * 0.90)	
function windowOpenFeature(url,openHeight) {		
	if (openHeight > screenHeight) {
		openHeight = screenHeight;
	}
	var winString = "height=" + openHeight + ",width=900,scrollbars=0,status=0,top=20,left=100";
	if (first) {
		popupwin = window.open( url, "breville", winString);
		popupwin.focus();
		first = false;
	} else {
		if ( popupwin != null && !popupwin.closed && previous_url == url ) { popupwin.focus(); }
		else {
			if (popupwin.closed) {
				popupwin = window.open( url, "breville", winString);
				popupwin.focus();
			} else {
				popupwin.location = url;
				popupwin.focus();
			}
		}	
	}
	previous_url = url ;
	return false;
}

//]]>
