// A javascript, in a normal html document, opens on an http connection: document.location.protocol equals "http" in Konqueror.
// However in Netscape and Explorer it equals "http:". This can breaks things, therefore we do a case insensitive search for the letter 's'
// to determine whether we are in secure mode or not.
storefinderRootURL = (document.location.protocol.search(/s/i) == -1) ?
												"http://www.storefinder.com.au/" :
												"https://anchor.net.au/secure/storefinder.com.au/";

/*
if (typeof(storefinderRootURL)=="undefined") {
//	storefinderRootURL = "http://www.vidoni.com.au/";
	storefinderRootURL = "http://www.storefinder.com.au/";
//	storefinderRootURL = "https://anchor.net.au/secure/storefinder.com.au/";
//	storefinderRootURL = "";
}
*/

function postcodePopupURL(url)
{
	urlWindow = window.open (url, 'PopupPostcode','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,height=700,width=800');
	urlWindow.focus();
}


function isDefined(variable)
{
	return ( typeof(variable) == "undefined" ) ? false : true;
} 


function postcodePopupUsingForm(frmName)
{
	objForm = document.forms[frmName];

	retaID  = (isDefined(objForm.RetailerID)) ? objForm.RetailerID.value : "";

	if      (isDefined(objForm.Postcode) && objForm.Postcode!="") locality = objForm.Postcode.value;
	else if (isDefined(objForm.Locality) && objForm.Locality!="") locality = objForm.Locality.value;
	else 																													locality = "";
	
	market  = (isDefined(objForm.Marketing))  ? objForm.Marketing.value  : "";
	query   = (isDefined(objForm.Query))      ? objForm.Query.value      : "";
	radius  = (isDefined(objForm.Radius))     ? objForm.Radius.value     : -1;

	results        = (isDefined(objForm.Results))        ? objForm.Results.value        :  3;
	resultsShuffle = (isDefined(objForm.ResultsShuffle)) ? objForm.ResultsShuffle.value :  0;

	if (retaID=="") {
		alert("- ID invaid. \n");
		return;
	}

	if (locality=="" && query=="") {
		alert("Please enter a 3 or 4 digit postcode, locality name or a valid query.");
		return;
	}

	var url = storefinderRootURL + "postcode/core/popup.php" +
																	"?RetailerID=" + retaID +
																	"&Postcode=" + locality +
																	"&Marketing=" + market +
																	"&Radius=" + radius +
																	"&Results=" + results +
																	"&ResultsShuffle=" + resultsShuffle +
																	"&Query=" + query;

	postcodePopupURL(url);
}


function postcodePopupUsingID(RetailerID)
{
	var url = storefinderRootURL + "postcode/core/popup.php?RetailerID=" + RetailerID;
	postcodePopupURL(url);
}


function postcodePopupUsingIDandLocality(RetailerID, Locality)
{
	var url = storefinderRootURL + "postcode/core/popup.php?RetailerID=" + RetailerID + "&Postcode=" + Locality;
	postcodePopupURL(url);
}


function _printIt()
{  
	if (window.print) {
		window.print();
	}
	else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);		//Use a 1 vs. a 2 for a prompting dialog box
		WebBrowser1.outerHTML = "";  
	}
}

function printIt()
{
	if (parseInt(navigator.appVersion) > 3)
		document.write('<form><input type=button value="Print and Go !" name="Print" onClick="_printIt()"></form>');
}