// JavaScript Document

function setImage(obj) {
	var img = new Image();
	img.src = obj.src;
	if(img.height > img.width) {
		obj.height = 99;
		var width = (99 * img.width)/img.height;
		width = width > 99 ? 99:width;			
		obj.width= (width > 0 ? width : 99) ;	
	}
	else {
		obj.width = 99;
		var height = obj.width * (img.height/img.width);
		obj.height = height > 99 ? 99:height;
		
		
		obj.width = 99;
		var height =(99 * img.height)/img.width;				
		height = height > 99 ? 99:height;		
		
		obj.height = (height > 0 ? height : 99);
	}
}

function setListingsImage(obj) {
	var img = new Image();
	img.src = obj.src;
	if(img.height > img.width) {
		obj.height = 150;
		var width = (150 * img.width)/img.height;
		width = width > 150 ? 150:width;			
		obj.width= (width > 0 ? width : 150) ;	
	}
	else {
		obj.width = 150;
		var height = obj.width * (img.height/img.width);
		obj.height = height > 150 ? 150:height;
		
		
		obj.width = 150;
		var height =(150 * img.height)/img.width;				
		height = height > 150 ? 150:height;		
		
		obj.height = (height > 0 ? height : 150);
	}
}

function setDetMainImage(obj) {
	var img = new Image();
	img.src = obj.src;
	if(img.height > img.width) {
		obj.height = 140;
		var width = (140 * img.width)/img.height;
		width = width > 140 ? 140:width;			
		obj.width= (width > 0 ? width : 140) ;	
	}
	else {
		obj.width = 140;
		var height = obj.width * (img.height/img.width);
		obj.height = height > 140 ? 140:height;
		
		
		obj.width = 140;
		var height =(140 * img.height)/img.width;				
		height = height > 140 ? 140:height;		
		
		obj.height = (height > 0 ? height : 140);
	}
}

function setDetThumbImage(obj) {
	var img = new Image();
	img.src = obj.src;
	if(img.height > img.width) {
		obj.height = 96;
		var width = (96 * img.width)/img.height;
		width = width > 96 ? 96:width;			
		obj.width= (width > 0 ? width : 96) ;	
	}
	else {
		obj.width = 96;
		var height = obj.width * (img.height/img.width);
		obj.height = height > 96 ? 96:height;
		
		
		obj.width = 96;
		var height =(96 * img.height)/img.width;				
		height = height > 96 ? 96:height;		
		
		obj.height = (height > 0 ? height : 96);
	}
}


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);
}



