$(document).ready(function() {
	$(".watermark").watermark();
	$("#sidebar_updates, div[class^=admin_section]").corner("br bevel");
	//$("textarea").autoExpand();
	$("form").validate();
	
	$("#tool_header_toggle").click(function() {
		if ($("#tool_header").is(":visible"))
			$(this).removeClass("selected");
		else
			$(this).addClass("selected");
		$("#tool_header").slideToggle();
	});
	
	function formatItem(row) {
		return row[0] + " <i>" + row[1] + "</i>";
	}
	
	function selectItem(li) {
		$("input[name=zip]").val(li.extra[0]);
	}
	$("input[autocomplete=inst]").autocomplete("/mod/musefy/_includes/instrument.php", { autoFill: true, maxItemsToShow: 10 });
	$("input[autocomplete=make]").autocomplete("/mod/musefy/_includes/make.php", { autoFill: true, maxItemsToShow: 10 });
	$("input[autocomplete=model]").autocomplete("/mod/musefy/_includes/model.php", { autoFill: true, maxItemsToShow: 10 });
	$("input[autocomplete=genre]").autocomplete("/mod/musefy/_includes/genre.php", { autoFill: true, maxItemsToShow: 10 });
	$("input[autocomplete=influence]").autocomplete("/mod/musefy/_includes/influences.php", { autoFill: true, maxItemsToShow: 10 });
	$("input[name=zip]").autocomplete("/mod/musefy/_includes/zip_codes.php", { autoFill: true, formatItem: formatItem, maxItemsToShow: 10, onItemSelect: selectItem  });
});

$.fn.center = function() {
	return this.each(function() {
	    $(this).css({ position: "absolute" });
	    $(this).css("left", ($(window).width() / 2 - $(this).outerWidth() / 2) + "px");
		$(this).css("top", ($(window).height() / 2 - $(this).outerHeight() / 2) + "px");
	});
}

