function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function thousands(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 check(input){
	input.value = input.value.replace(/[^0-9]*/g, '');
	if(input.value == '' || input.value == 0) {
		input.value = '';
		return;
	}
	input.value = thousands(input.value);
}

function trim(value) {
	return value.replace(/((\\s*\\S+)*)\\s*/, "$1");
}

function trimAll() {
	document.getElementById("priceLow").value = trim(document
			.getElementById("priceLow").value);
	document.getElementById("priceHigh").value = trim(document
			.getElementById("priceHigh").value);
}

function changeLocationType(selectObj) {
	var i;
	for(i = 0; i < selectObj.length; ++i) {
		if(selectObj.options[i].selected) {
			$(selectObj.options[i].value).className = "tabcontent show";
		}
		else {
			$(selectObj.options[i].value).className = "tabcontent hide";
		}
	}
	if(selectObj.value != "tabid-coordinates") {
		$('mapCheckbox').checked = false;
		mapCheckboxChanged();
	}
	if(selectObj.value != "tabid-address") {
		$('StreetNumber').value = '';
		$('StreetDirection').value = '';
		$('StreetName').value = '';
	}
	
}

