function prevEmail(ID, emailserver, emailname, emailinner) {
	var span = document.getElementById(ID);
	if (span != null) {
		var str = "<a href='mailto:" + emailname + "@" + emailserver + "'>";
		if (emailinner == '') str += emailname + "@" + emailserver; else str += emailinner;
		str += "</a>";
		span.innerHTML = str;
	}
}

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_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 QuickSearchSelect() {
	if (document.getElementById("ddlLooking").selectedIndex == 0) {
		document.getElementById("ddlMinPriceSale").style.display = "block";
		document.getElementById("ddlMinPriceRent").style.display = "none";
		document.getElementById("ddlMaxPriceSale").style.display = "block";
		document.getElementById("ddlMaxPriceRent").style.display = "none";
	}
	else {
		document.getElementById("ddlMinPriceSale").style.display = "none";
		document.getElementById("ddlMinPriceRent").style.display = "block";
		document.getElementById("ddlMaxPriceSale").style.display = "none";
		document.getElementById("ddlMaxPriceRent").style.display = "block";
	}
}

function QuickSearchSubmit() {
	var search_URL = "quick_search.aspx";
	var ddlLooking = document.getElementById("ddlLooking");
	search_URL += "?to=" + ddlLooking.options[ddlLooking.selectedIndex].value;
	var ddlLocation = document.getElementById("ddlLocation");
	search_URL += "&loca=" + ddlLocation.options[ddlLocation.selectedIndex].value;
	var ddlBedrooms = document.getElementById("ddlBedrooms");
	search_URL += "&bed=" + ddlBedrooms.options[ddlBedrooms.selectedIndex].value;

	var ddlMinPrice;
	var varMaxPrice;

	if (ddlLooking.selectedIndex == 0) {
		ddlMinPrice = document.getElementById("ddlMinPriceSale");
		search_URL += "&min=" + ddlMinPrice.options[ddlMinPrice.selectedIndex].value;
		ddlMaxPrice = document.getElementById("ddlMaxPriceSale");
		search_URL += "&max=" + ddlMaxPrice.options[ddlMaxPrice.selectedIndex].value;
	} else {
		ddlMinPrice = document.getElementById("ddlMinPriceRent");
		search_URL += "&min=" + ddlMinPrice.options[ddlMinPrice.selectedIndex].value;
		ddlMaxPrice = document.getElementById("ddlMaxPriceRent");
		search_URL += "&max=" + ddlMaxPrice.options[ddlMaxPrice.selectedIndex].value;
	}
	window.location.href = search_URL;
	return false;
}

function InsertFlashHeader(ID, filePath, width, height) {
	var span = document.getElementById(ID);
	if (span != null) {
		var str = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0' id='index' width='" + width + "' height='" + height + "'>";
		str += "<param name='movie' value='" + filePath + "' />";
		str += "<param name='bgcolor' value='#FFFFFF' />";
		str += "<param name='quality' value='high' />";
		str += "<param name='allowscriptaccess' value='samedomain' />";
		str += "<embed type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' name='index' width='" + width + "' height='" + height + "' src='" + filePath + "' bgcolor='#FFFFFF' quality='high' swliveconnect='true' allowscriptaccess='samedomain'><noembed></noembed></embed>";
		str += "</object>";
		span.innerHTML = str;
	}
}

//called on page load (first 'full, non ajax' load);
$(document).ready(function() {
	main();
});
function main() {
	//track click-throughs to 3rd party pages via Google Analytics...
	//$("a[rel*='nofollow']").click(function() {
	$("a[target*='_blank']").click(function() {
		if (typeof (pageTracker) != "undefined")
			pageTracker._trackPageview('/outgoing/' + $(this).attr('href'));
	});
}
