	function printReceipt()
	{
		var url = "./receipt-print.php";		
		var w=window.open(url, "receiptWin", "width=650, height=500, resizable=yes, menubar=yes, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function printPropertyImages(lid)
	{
		var url = "/print/propertyImages.php?lid=" + lid;
		var printWin = "printImagesWin" + lid;		
		var w=window.open(url, printWin, "width=575, height=600, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function printPropertyImage(fid)
	{
		var url = "/print/propertyImage.php?fid=" + fid;
		var printWin = "printImagesWin" + fid;		
		var w=window.open(url, printWin, "width=575, height=600, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function printProperty(lid)
	{
		var url = "/print/property.php?lid=" + lid;
		var printWin = "printListingWin" + lid;		
		var w=window.open(url, printWin, "width=700, height=600, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function printPropertyLocation(lid)
	{
		var url = "/print/propertyLocation.php?lid=" + lid;
		var printWin = "printMapWin" + lid;		
		var w=window.open(url, printWin, "width=575, height=600, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function printMapTool()
	{
		var url = "/print/map-tool.php";			
		var printWin = "printMapToolWin";		
		var w=window.open(url, printWin, "width=700, height=600, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}

	function emailListing(lid)
	{
		var url = "/email/listing.php?lid=" + lid;		
		var w=window.open(url, "emailListingWin", "width=500, height=435, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function emailSeller(cid)
	{
		var url = "/email/seller.php?cid=" + cid;		
		var w=window.open(url, "emailSellerWin", "width=500, height=425, resizable=yes, menubar=no, toolbar=no, location=no, scrollbars=yes");
		w.focus();
	}
	
	function bannerAdReferral(bid)
	{
		var currentDate = new Date();
		var ms = currentDate.getTime();
		
		if(bid > 0)
		{
			new Image().src = '/art/bannerReferral.php?bid=' + bid + "&ms=" + ms;
		}
	}
	
	function listingWebsiteReferral(lid)
	{
		var currentDate = new Date();
		var ms = currentDate.getTime();
		
		if(lid > 0)
		{
			new Image().src = '/art/websiteReferral.php?lid=' + lid + "&ms=" + ms;
		}
	}
	
	function sellerWebsiteReferral(cid)
	{
		var currentDate = new Date();
		var ms =  currentDate.getTime();
		
		if(cid > 0)
		{
			new Image().src = '/art/websiteReferral.php?cid=' + cid + "&ms=" + ms;
		}
	}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	function sendMail()
	{
		if(validateForm() == true)
		{
			document.form1.Button.disabled=true;
			document.form1.submit();
		}
	}

	function validateForm()
	{
		var fromName = trim(document.form1.fromName.value);
		var fromAddress = trim(document.form1.fromAddress.value);
		var fromPhone = trim(document.form1.fromPhone.value);
		var fromCell = trim(document.form1.fromCell.value);
		var message = trim(document.form1.message.value);

		if(!fromName)
		{
			 alert("Your name is missing...");
			 return false;
		}
		
		if(!fromAddress && !fromPhone && !fromCell)
		{
			 alert("Please provide your email address or phone number.");
			 return false;
		}
		
		if(!message)
		{
			 alert("Please type a message first...");
			 return false;
		}
	return true;
	}


// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	function isUndefined(o) 
	{
		return 'undefined' == typeof o;
	}
	
	function isObject(o) 
	{
		return 'object' == typeof o;
	}

	function trim(subject)
	{
		var subject = rTrim(subject);
		subject = lTrim(subject);
		
	return subject;
	}
	
	function rTrim(subject)
	{
		return subject.replace(/[\s]+$/g, "");
	}
	
	function lTrim(subject)
	{
		return subject.replace(/^[\s]+/g, "");
	}

/*************************************************************
 * Window Onload Manager (WOM) v1.0
 * Author: Justin Barlow - www.netlobo.com
 *
 * Description:
 * The WOM library of functions allows you to easily call
 * multiple javascript functions when your page loads.
 *
 * Usage:
 * Add functions to WOM using the womAdd() function. Pass the
 * name of your functions (with or without parameters) into
 * womAdd(). Then call womOn() like this:
 *     womAdd('hideDiv()');
 *     womAdd('changeBg("menuopts","#CCCCCC")');
 *     womOn();
 * WOM will now run when your page loads and run all of the
 * functions you have added using womAdd()
 *************************************************************/

/*************************************************************
 * The womOn() function will set the window.onload function to
 * be womGo() which will run all of your window.onload
 * functions.
 *************************************************************/
function womOn(){
	window.onload = womGo;
}

/*************************************************************
 * The womGo() function loops through the woms array and
 * runs each function in the array.
 *************************************************************/
function womGo(){
	for(var i = 0;i < woms.length;i++)
		eval(woms[i]);
}

/*************************************************************
 * The womAdd() function will add another function to the woms
 * array to be run when the page loads.
 *************************************************************/
function womAdd(func){
	woms[woms.length] = func;
}

/*************************************************************
 * The woms array holds all of the functions you wish to run
 * when the page loads.
 *************************************************************/
var woms = new Array();


// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Quick Search

var sortOrder = "";
var d = new dynamicSelect();
d.addSelect('qsCountry'); 

d.selects['qsCountry'].addOption('argentina');
d.selects['qsCountry'].options['argentina'].createOption('All', 'All');

d.selects['qsCountry'].addOption('bahamas');
d.selects['qsCountry'].options['bahamas'].createOption('All', 'All');

d.selects['qsCountry'].addOption('belize');
d.selects['qsCountry'].options['belize'].createOption('All', 'All');

d.selects['qsCountry'].addOption('italy');
d.selects['qsCountry'].options['italy'].createOption('All', 'All');

d.selects['qsCountry'].addOption('canada'); 
d.selects['qsCountry'].options['canada'].createOption('All', 'All');
d.selects['qsCountry'].options['canada'].createOption('Alberta', 'alberta'); 
d.selects['qsCountry'].options['canada'].createOption('British Columbia', 'british-columbia'); 
d.selects['qsCountry'].options['canada'].createOption('Manitoba', 'manitoba'); 
d.selects['qsCountry'].options['canada'].createOption('New Brunswick', 'new-brunswick');
d.selects['qsCountry'].options['canada'].createOption('Newfoundland', 'newfoundland');
d.selects['qsCountry'].options['canada'].createOption('Northwest Territories', 'northwest-territories');
d.selects['qsCountry'].options['canada'].createOption('Nova Scotia', 'nova-scotia'); 
d.selects['qsCountry'].options['canada'].createOption('Ontario', 'ontario'); 
d.selects['qsCountry'].options['canada'].createOption('Prince Edward Island', 'prince-edward-island'); 
d.selects['qsCountry'].options['canada'].createOption('Quebec', 'quebec');
d.selects['qsCountry'].options['canada'].createOption('Saskatchewan', 'saskatchewan');
d.selects['qsCountry'].options['canada'].createOption('Yukon', 'yukon');

d.selects['qsCountry'].addOption('costa-rica');
d.selects['qsCountry'].options['costa-rica'].createOption('All', 'All');

d.selects['qsCountry'].addOption('usa');
d.selects['qsCountry'].options['usa'].createOption('All', 'All');
d.selects['qsCountry'].options['usa'].createOption('Alabama', 'alabama'); 
d.selects['qsCountry'].options['usa'].createOption('Alaska', 'alaska');
d.selects['qsCountry'].options['usa'].createOption('Arizona', 'arizona'); 
d.selects['qsCountry'].options['usa'].createOption('Arkansas', 'arkansas'); 
d.selects['qsCountry'].options['usa'].createOption('California', 'california'); 
d.selects['qsCountry'].options['usa'].createOption('Colorado', 'colorado'); 
d.selects['qsCountry'].options['usa'].createOption('Connecticut', 'connecticut'); 
d.selects['qsCountry'].options['usa'].createOption('Delaware', 'delaware'); 
d.selects['qsCountry'].options['usa'].createOption('Florida', 'florida'); 
d.selects['qsCountry'].options['usa'].createOption('Georgia', 'georgia'); 
d.selects['qsCountry'].options['usa'].createOption('Hawaii', 'hawaii');
d.selects['qsCountry'].options['usa'].createOption('Idaho', 'idaho'); 
d.selects['qsCountry'].options['usa'].createOption('Illinois', 'illinois'); 
d.selects['qsCountry'].options['usa'].createOption('Indiana', 'indiana'); 
d.selects['qsCountry'].options['usa'].createOption('Iowa', 'iowa'); 
d.selects['qsCountry'].options['usa'].createOption('Kansas', 'kansas'); 
d.selects['qsCountry'].options['usa'].createOption('Kentucky', 'kentucky'); 
d.selects['qsCountry'].options['usa'].createOption('Louisiana', 'louisiana'); 
d.selects['qsCountry'].options['usa'].createOption('Maine', 'maine'); 
d.selects['qsCountry'].options['usa'].createOption('Maryland', 'maryland'); 
d.selects['qsCountry'].options['usa'].createOption('Massachusetts', 'massachusetts'); 
d.selects['qsCountry'].options['usa'].createOption('Michigan', 'michigan'); 
d.selects['qsCountry'].options['usa'].createOption('Minnesota', 'minnesota'); 
d.selects['qsCountry'].options['usa'].createOption('Mississippi', 'mississippi'); 
d.selects['qsCountry'].options['usa'].createOption('Missouri', 'missouri'); 
d.selects['qsCountry'].options['usa'].createOption('Montana', 'montana'); 
d.selects['qsCountry'].options['usa'].createOption('Nebraska', 'nebraska'); 
d.selects['qsCountry'].options['usa'].createOption('Nevada', 'nevada'); 
d.selects['qsCountry'].options['usa'].createOption('New Hampshire', 'new-hampshire'); 
d.selects['qsCountry'].options['usa'].createOption('New Jersey', 'new-jersey'); 
d.selects['qsCountry'].options['usa'].createOption('New Mexico', 'new-mexico'); 
d.selects['qsCountry'].options['usa'].createOption('New York', 'new-york'); 
d.selects['qsCountry'].options['usa'].createOption('North Carolina', 'north-carolina'); 
d.selects['qsCountry'].options['usa'].createOption('North Dakota', 'north-dakota'); 
d.selects['qsCountry'].options['usa'].createOption('Ohio', 'ohio'); 
d.selects['qsCountry'].options['usa'].createOption('Oklahoma', 'oklahoma'); 
d.selects['qsCountry'].options['usa'].createOption('Oregon', 'oregon'); 
d.selects['qsCountry'].options['usa'].createOption('Pennsylvania', 'pennsylvania'); 
d.selects['qsCountry'].options['usa'].createOption('Rhode Island', 'rhode-island'); 
d.selects['qsCountry'].options['usa'].createOption('South Carolina', 'south-carolina'); 
d.selects['qsCountry'].options['usa'].createOption('South Dakota', 'south-dakota'); 
d.selects['qsCountry'].options['usa'].createOption('Tennessee', 'tennessee'); 
d.selects['qsCountry'].options['usa'].createOption('Texas', 'texas'); 
d.selects['qsCountry'].options['usa'].createOption('Utah', 'utah'); 
d.selects['qsCountry'].options['usa'].createOption('Vermont', 'vermont'); 
d.selects['qsCountry'].options['usa'].createOption('Virgin Islands', 'virgin-islands');
d.selects['qsCountry'].options['usa'].createOption('Virginia', 'virginia'); 
d.selects['qsCountry'].options['usa'].createOption('Washington', 'washington'); 
d.selects['qsCountry'].options['usa'].createOption('West Virginia', 'west-virginia'); 
d.selects['qsCountry'].options['usa'].createOption('Wisconsin', 'wisconsin'); 
d.selects['qsCountry'].options['usa'].createOption('Wyoming', 'wyoming'); 

function dynamicSelect()
{
	this.selects = new Array();
	
	this.addSelect = function(name)
	{
		this.selects[name] = new selectObj();
	}

	this.updateOptions = function(source, target)
	{
		var form = source.form;
		var target = form.elements[target];
		var value = source.options[source.selectedIndex].value;
		
		while(target.options.length) target.remove(0);
		
		if(!this.selects[source.name].options[value])
		{
			//alert('Invalid selection.'); 
			return;
		}
		
		var data = this.selects[source.name].options[value].options;
		
		for(var x=0; x<data.length; x++)
		{
			try
			{
				target.add(data[x]);
			}
			catch(e)
			{
				target.add(data[x], null);
			}
		}
		
		target.selectedIndex = 0;
	}

}

function selectObj()
{
	this.options = new Array();
	
	this.addOption = function(value)
	{
		this.options[value] = new optionObj();
	}
}

function optionObj()
{
	this.options = new Array();
	
	this.createOption = function(name, value)
	{
		this.options[this.options.length] = new Option(name, value);
	}
}

function setQsCountry(c)
{
	var c = c;
	
	oCountry = document.qsForm.qsCountry;

	//new Option( text, value, defaultSelected, selected );
	//oCountry.options[oCountry.options.length] = new Option('All', 'All', true, true);
	oCountry.options[oCountry.options.length] = new Option('Bahamas', 'bahamas', false, false);
	oCountry.options[oCountry.options.length] = new Option('Belize', 'belize', false, false);
	oCountry.options[oCountry.options.length] = new Option('Canada', 'canada', false, false);
	oCountry.options[oCountry.options.length] = new Option('Costa Rica', 'costa-rica', false, false);
	oCountry.options[oCountry.options.length] = new Option('Italy', 'italy', false, false);
	oCountry.options[oCountry.options.length] = new Option('United States', 'usa', false, false);
	
	// Set the selected country
	if(c.length > 0)
	{
		// Set the selected country
		for(var i=0; i < oCountry.options.length; i++)
		{
			if(c == oCountry.options[i].text)
			{
				oCountry.options[i].selected = true;
				break;
			}
		}
	}
}

function setQsState(s)
{
	var s = s;
	
	oCountry = document.qsForm.qsCountry;
	oState = document.qsForm.qsState;
	
	// Load state / province list
	d.updateOptions(oCountry, 'qsState');
	
	// Set the selected state
	oState.options[0].selected = false; // default all
	
	if(s.length > 0)
	{
		// Set the selected state
		for(var i=0; i < oState.options.length; i++)
		{
			if(s == oState.options[i].text)
			{
				oState.options[i].selected = true;
				break;
			}
		}
	}
}

function setQsPrice(p)
{
	var p = p;
	
	oPrice = document.qsForm.qsPrice;
	
	//new Option( text, value, defaultSelected, selected );
	oPrice.options[oPrice.options.length] = new Option('All', 1, true, true);
	oPrice.options[oPrice.options.length] = new Option('Less Than $100k', 2, false, false);
	oPrice.options[oPrice.options.length] = new Option('$100k - $300k', 3, false, false);
	oPrice.options[oPrice.options.length] = new Option('$300k - $500k', 4, false, false);
	oPrice.options[oPrice.options.length] = new Option('$500k - $1m', 5, false, false);
	oPrice.options[oPrice.options.length] = new Option('More Than $1m', 6, false, false);
	
	// Set the selected country
	if(p > 0)
	{
		// Set the selected price
		for(var i=0; i < oPrice.options.length; i++)
		{
			if(p == oPrice.options[i].value)
			{
				oPrice.options[i].selected = true;
				break;
			}
		}
	}
}

function setQsAcres(a)
{
	var a = a;
	
	oAcres = document.qsForm.qsAcres;
	
	//new Option( text, value, defaultSelected, selected );
	oAcres.options[oAcres.options.length] = new Option('All', 1, true, true);
	oAcres.options[oAcres.options.length] = new Option('Up To 5 Acres', 2, false, false);
	oAcres.options[oAcres.options.length] = new Option('6 - 25 Acres', 3, false, false);
	oAcres.options[oAcres.options.length] = new Option('26 - 100 Acres', 4, false, false);
	oAcres.options[oAcres.options.length] = new Option('101 - 300 Acres', 5, false, false);
	oAcres.options[oAcres.options.length] = new Option('301 - 600 Acres', 6, false, false);
	oAcres.options[oAcres.options.length] = new Option('601+ Acres', 7, false, false);
	
	// Set the selected country
	if(a > 0)
	{
		// Set the selected price
		for(var i=0; i < oAcres.options.length; i++)
		{
			if(a == oAcres.options[i].value)
			{
				oAcres.options[i].selected = true;
				break;
			}
		}
	}
}

function setQsSortOrder(val)
{
	sortOrder = val;
	showMe();
}

function getSelectedCountry() 
{   
	for(var i = 0; i < document.qsForm.qsCountry.length; i++) 
	{      
		if(document.qsForm.qsCountry.options[i].selected == true) 
		{         
			return document.qsForm.qsCountry.options[i].value;     
		}   
	}   
	
	return null;
}

function getSelectedRegion() 
{   
	for(var i = 0; i < document.qsForm.qsState.length; i++) 
	{      
		if(document.qsForm.qsState.options[i].selected == true) 
		{         
			return document.qsForm.qsState.options[i].value;     
		}   
	}   
	
	return null;
}

function getSelectedPrice() 
{   
	for(var i = 0; i < document.qsForm.qsPrice.length; i++) 
	{      
		if(document.qsForm.qsPrice.options[i].selected == true) 
		{         
			return document.qsForm.qsPrice.options[i].value;     
		}   
	}   
	
	return 1;
}

function getSelectedAcres() 
{   
	for(var i = 0; i < document.qsForm.qsAcres.length; i++) 
	{      
		if(document.qsForm.qsAcres.options[i].selected == true) 
		{         
			return document.qsForm.qsAcres.options[i].value;     
		}   
	}   
	
	return 1;
}

function showMe()
{
	var url = '';
	var sCountry = getSelectedCountry();
	var sRegion = getSelectedRegion();
	var sPrice = getSelectedPrice();
	var sAcres = getSelectedAcres();	

	// Country
	url = '/' + sCountry + '/';
		
	// Region
	if(sRegion != null && sRegion != 'All')
	{
		url += sRegion + '/';
	}
	
	// Price & Acres...
	if(sPrice > 1 || sAcres > 1 || sortOrder != "")
	{
		url += 'land/';
		
		// Price
		if(sPrice > 1)
		{
			url += 'price' + sPrice + '/';
		}
		
		// Acreage
		if(sAcres > 1)
		{
			url += 'acres' + sAcres + '/';
		}
		
		// Sort
		if(sortOrder != "")
		{
			url += sortOrder + '/';
		}
	}

	//alert(url);
	window.location.href = url;
}
