(function() {
 	selectInstructionType('instruction_type', 'minpricew', 'maxpricew');
 	if (typeof ShowMap == "function") {
		if (document.body.hasClassName("property-details-page")) {
			ShowMap({zoom: 15, id: 'map', context_amenities_icon_anchor: 'center center'});
		} else {
			ShowMap({zoom:15});
		}
	}
 	if (typeof restore_search == "function") restore_search();
}).onLoad();

if (typeof jQuery == 'function') {
	jQuery(document).ready(function($) {
		if ($.browser.msie && parseInt($.browser.version) == 7) {
			$("#infoToggle").hide();
		} else {
			var left = $("#infoToggle").css("left");
			$("#infoToggle a").click(function() {
				$("#infoDraw").toggle(0, function() {
					var $toggle = $("#infoToggle");
					if ($(this).is(":visible")) {
						$toggle.css("left", left);
						$("img", $toggle).attr("src", "/images/infoToggle.png")
						$("#map").css("width", "527px");
						PropertyMap.triggerResize();
					} else {
						$toggle.css("left", "0");
						$("img", $toggle).attr("src", "/images/infoToggleClose.png")
						$("#map").css("width", "698px");
						PropertyMap.triggerResize();
					}
				});
				return false;
			});
		}

		$("#schoolmenu input.amenity").click(function() {
			ContextAmenities.loadAmenities();
		});
	});

	(function($) {
		if (typeof Plugin == 'object') {
			Plugin.register("context_amenities_load_amenities", function(args) {
				if (args.amenities.length) {
					$("#infoDrawWrapper").show();
					if ($("#infoDraw").is(":visible")) {
						$("#map").css("width", "527px");
						PropertyMap.triggerResize();
					} else {
						$("#map").css("width", "698px");
					}
				} else {
					$("#infoDrawWrapper").hide();
					$("#map").css("width", "698px");
					PropertyMap.triggerResize();
				}
			});
		}
	})(jQuery);
}

