$(document).ready(function(){
	$(".rollOver").hover (
		function() {
			$(this).attr("src", $(this).attr("src").replace(".","_over."));
		},
		function() {
			$(this).attr("src", $(this).attr("src").replace("_over.","."));
		}
	);

	$(".rollOverImg").hover (
		function() {
			$(this).find('img').each(function() {
				$(this).attr("src", $(this).attr("src").replace(".","_over."));
			}) 
		},
		function() {
			$(this).find('img').each(function() {
				$(this).attr("src", $(this).attr("src").replace("_over.","."));
			});
		}
	);

	var imgSwap = [];
	$(".rollOver").each(function() {
		imgUrl = $(this).attr("src").replace(".","_over.");
		imgSwap.push(imgUrl);
	});
	$(imgSwap).preload();

	$(".submitLink").click(function(){
		$(this).closest("form").submit();
		return false;
 	});

	$(".dialogLink").live("click", function () {
		$dialogLink = $(this);
		$("#dialogConfirm").attr("title", $(this).attr("title"));
		$("#dialogText").html($(this).attr("rel"));

		$("#dialogConfirm").dialog({
			resizable: false,
			minHeight: 170,
			width: 330,
			modal: true,
			show: "drop",
			hide: "drop",
			buttons: {
				"Confirm": function() {
					if($($dialogLink).attr("href") == "#") {
						$($dialogLink).closest("form").submit();
					}
					else {
						window.location.href = $($dialogLink).attr("href");
					}

					$(this).dialog("close");
				},
				"Cancel": function() {
					$(this).dialog("close");
				}
			}
		});

		return false;
	});

	$("a.nonLink").click(function() { 
		return false; 
	});

	$("form").submit(function() {
		$("input[type=submit]", this).attr("disabled", "true");
	});

	$("input").keypress(function(e){ 
		if(e.which == 13){ 
			$(this).closest("form").submit();
			return false;
		} 
	});
});

$.fn.preload = function() {
	this.each(function() {
		$('<img/>')[0].src = this;
	});
}

function showHide(objID, newDisplay) {  
	if(!newDisplay)
		$("#" + objID).toggle("slow");
	else {
		if(newDisplay == "hide")
			$("#" + objID).show("slow");
		else if(newDisplay == "show")
			$("#" + objID).hide("slow");
		else
			$("#" + objID).toggle("slow");
	}
}

