// addthis set up

var addthis_pub="rundmb";

var addthis_config = {
	services_compact: 'email, linkedin, twitter, more',
	services_exclude: 'print',
	ui_click: true
}

// show hide search

function switchSearch(target){
	
	if (document.getElementById){
	var toBuy = document.getElementById( "buy" );
	var toRent = document.getElementById( "rent" );
	var tabBuy = document.getElementById( "tabBuy" );
	var tabRent = document.getElementById( "tabRent" );

		if (target == "buy"){
			toBuy.style.display = "";
			tabBuy.className = "active";
			toRent.style.display = "none";
			tabRent.className = "inactive";
		} else if (target == "rent") {
			toBuy.style.display = "none";
			tabBuy.className = "inactive";
			toRent.style.display = "";
			tabRent.className = "active";
		}
	}
}

// tick all map boxes

function allMap () {
	
	form=document.forms['searchForm'];

	if (form.allLoc.checked) {
		for (loop=0;loop<form.mapVar.length;loop++) {
			form.mapVar[loop].checked = true;
		}
	} else {
		for (loop=0;loop<form.mapVar.length;loop++) {
			form.mapVar[loop].checked = false;
		}
	}
}

function addCommas(nStr)	{
	 nStr += '';
	 x = nStr.split('.');
	 x1 = x[0];
	 x2 = x.length > 1 ? '.' + x[1] : '';
	 var rgx = /(\d+)(\d{3})/;
	 while (rgx.test(x1)) {
					 x1 = x1.replace(rgx, '$1' + ',' + '$2');
	 }
	 return x1 + x2;
}

function engNum(numVal)	{
	var numStr = "";
	if(numVal >= 1000000) {
		numStr = addCommas(numVal / 1000000) + "m";
	} else if(numVal >= 1000) {
		numStr = addCommas(numVal / 1000) + "k";
	} else {
		numStr = addCommas(numVal);
	}
	return numStr;
}

