// JavaScript Document

function setImage(obj) {
	try{
		var img = new Image();
		img.src = obj.src;
		if(img.height > img.width) {
			obj.height = 99;
			var width = obj.height * (img.width/img.height);
			obj.width = width > 99 ? 99:width;
		}
		else {
			obj.width = 99;
			var height = obj.width * (img.height/img.width);
			obj.height = height > 99 ? 99:height;
		}
	}
	catch(e) { obj.src = "images/image.jpg"; }
}

function setListingsImage(obj) {
	var img = new Image();
	img.src = obj.src;
	if(img.height > img.width) {
		obj.height = 150;
		var width = obj.height * (img.width/img.height);
		obj.width = width > 150 ? 150:width;
	}
	else {
		obj.width = 150;
		var height = obj.width * (img.height/img.width);
		obj.height = height > 150 ? 150:height;
	}
}

function setDetMainImage(obj) {
	try{
		var img = new Image();
		img.src = obj.src;
		if(!img.width) { obj.width = 140; obj.height = 140; }
		else if(img.height > img.width) {
			obj.height = 140;
			var width = obj.height * (img.width/img.height);
			obj.width = width > 140 ? 140:width;
		}
		else {
			obj.width = 140;
			var height = obj.width * (img.height/img.width);
			obj.height = height > 140 ? 140:height;
		}
	}
	catch(e) { obj.width = 140; obj.height = 140;}
}

function setDetThumbImage(obj) {
	try{
		var img = new Image();
		img.src = obj.src;
		if(img.height > img.width) {
			obj.height = 96;
			var width = obj.height * (img.width/img.height);
			obj.width = width > 96 ? 96:width;
		}
		else {
			obj.width = 96;
			var height = obj.width * (img.height/img.width);
			obj.height = height > 96 ? 96:height;
		}
	}
	catch(e) {}
}

function changeToBuy() {
	document.getElementById('buytabinsearch').className = "menu_red";
	document.getElementById('renttabinsearch').className = "menu_blue";
	var drp = document.getElementById('drpType');
	drp.value = "buy";
	getLocations(drp);
}

function changeToRent() {
	document.getElementById('buytabinsearch').className = "menu_blue";
	document.getElementById('renttabinsearch').className = "menu_red";
	var drp = document.getElementById('drpType');
	drp.value = "rent";
	getLocations(drp);
}




