var message = "";
var isMac = navigator.userAgent.indexOf("Mac") != -1;

$(document).ready(function() {
						   
	if (isMac && jQuery.browser.mozilla) {
		$("body").addClass("ffMac");
	}
	if (jQuery.browser.safari) {
		$("body").addClass("safari");
	}
						   
	$(".inlineList li:first").addClass("first");
	$(".inlineList li:last").addClass("last");
	
	$("input:text,input:password").addClass('text');
	
	$(".propertiesSelection .listing:has(img), .balloonInner:has(img)").addClass('hasImage');
	$(".propertiesSelection .listing:nth-child(even)").after('<div class="floatClear"></div>');
	
	$(".purchaseOptions li:not(.purchaseOptions li li):nth-child(even)").addClass("alt");
	
	$(".validator:not(.validator:has(.error))").text('');
	
	buttonHovers();
	searchFormOptions();
	propertyPricesInfo();

	message += "Browser: \n";
	jQuery.each(jQuery.browser, function(i, val) {
		message += i + ": " + val + "\n";
    });
	// alert(message);
});

function buttonHovers() {
	$("input:submit, input:button").addClass('button');
	$("input.button").hover(
		function() {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	);	
}

function searchFormOptions() {
	$moreOptions = $("#moreOptions:not(.searchResultsForm #moreOptions)");
	$moreOptionsLink = $("#moreOptionsLink:not(.searchResultsForm #moreOptionsLink)");
	$moreOptions.hide();
	$moreOptionsLink.show();
	$moreOptionsLink.click(function(){
		$moreOptionsLink.hide();
		$moreOptions.fadeIn();
		return false;
	});
}

function propertyPricesInfo() {
	$(".propertyDetailsSummary .prices li").each(function(){
		var $infoDiv = $(this).children(".info");
		var $h3 = $(this).children("h3");
		var h3Text = $(this).children("h3").text();
		$infoDiv.prepend("<h3>" + $h3.text() + "</h3>");
		$(this).mouseover(function(){
			$infoDiv.show();
		});
		$(this).mouseout(function(){
			$infoDiv.hide();
		});
	});
}

