$(function()
{
	$("#city_menu ul li").mouseover(function() {
		$(this).addClass("over");
		$("span", this).addClass("over");
		$("span a", this).addClass("over");
	});
	$("#city_menu ul li").mouseout(function() {
		$(this).removeClass("over");
		$("span", this).removeClass("over");
		$("span a", this).removeClass("over");
	});

	$(".button").mouseover(function(){
		$(this).addClass("over");
	});
	$(".button").mouseout(function(){
		$(this).removeClass("over");
	});
	
	$(".link").mouseover(function(){
		$("p a", this).attr("style", "color:#000000");
	});
	$(".link").mouseout(function(){
		$("p a", this).attr("style", "");
	});
	
	$(".link").click(function(){
		location.href = $("a", this).attr("href");
		return false;
	});
	
	$(".closest_advanced").change(function(){
		sel = $(this).attr("selectedIndex");
		$(".closest_advanced").attr("selectedIndex", 0);
		$("#closest_postcode").val("Postcode");
		$("#closest_street").val("Street name");
		$(this).attr("selectedIndex", sel);
	});
	
	$("#closest_postcode").click(function(){
		if ($(this).val() == "Postcode")
			$(this).val("");
	});
	$("#closest_postcode").blur(function(){
		if ($(this).val() == "")
			$(this).val("Postcode");
		else
		{
			$(".closest_advanced").attr("selectedIndex", 0);
			$("#closest_street").val("Street name");
		}
	});
	
	$("#closest_street").click(function(){
		if ($(this).val() == "Street name")
			$(this).val("");
	});
	$("#closest_street").blur(function(){
		if ($(this).val() == "")
			$(this).val("Street name");
		else
		{
			$(".closest_advanced").attr("selectedIndex", 0);
			$("#closest_postcode").val("Postcode");
		}
	});
	
	$("a.select").click(function(){
		if ($(this).prev().val() != "")
			location.href = $(this).prev().val();
		return false;
	}).mouseover(function(){
		$("img", this).attr("src", "img/search_arrow_on.gif");
	}).mouseout(function(){
		$("img", this).attr("src", "img/search_arrow.gif");
	});
	
	$("a.postcode").click(function(){
		if (($("#closest_postcode").val() != "") && ($("#closest_postcode").val() != "Postcode"))
			location.href = $("#closest_postcode_url").val() + $("#closest_postcode").val();
		return false;
	}).mouseover(function(){
		$("img", this).attr("src", "img/search_arrow_on.gif");
	}).mouseout(function(){
		$("img", this).attr("src", "img/search_arrow.gif");
	});
	
	$("a.street").click(function(){
		if (($("#closest_street").val() != "") && ($("#closest_street").val() != "Street name"))
			location.href = $("#closest_street_url").val() + $("#closest_street").val();
		return false;
	}).mouseover(function(){
		$("img", this).attr("src", "img/search_arrow_on.gif");
	}).mouseout(function(){
		$("img", this).attr("src", "img/search_arrow.gif");
	});
	
	$("#home_form").submit(function(){
		return checkHomeSearch();
	});
	
	$("#city_map area").mouseover(function(){
		$("#city_map_img").attr("src", "img/" + $(this).attr("name").toLowerCase() + "_city_map_" + $(this).attr("id") + ".gif");
	}).mouseout(function(){
		$("#city_map_img").attr("src", "img/city_map_" + $(this).attr("name").toLowerCase() + ".gif");
	});
	
	$(".sort_up").mouseover(function() {
		$("img", this).attr("src", "img/sort_up_over.gif");
	}).mouseout(function() {
		$("img", this).attr("src", "img/sort_up.gif");
	});
	$(".sort_down").mouseover(function() {
		$("img", this).attr("src", "img/sort_down_over.gif");
	}).mouseout(function() {
		$("img", this).attr("src", "img/sort_down.gif");
	});
});
