
$(document).ready(function(){
	// Selected menu has arrow above it
	$(".ManageTools .selected").each(function() { 
		// Add notch UI
		$(this).append("<div class='selector'></div>");
		$(this).find(".selector").css("left", $(this).width()/2 + 8);
		// Disable link
		var a = $(this).find("a:first");
		a.replaceWith("<span>" + a.html() + "</span>");
	});
	/* Rating */
	var rated = false;
	$('.star').hover(
		function() {
			if (rated) return;
			var id = $(this).attr("id");
			var val = id.charAt(4);
			for (var i=1; i<=val; i++)
				$("#star" + i).find("img").attr("src", "/commonv8/images/ratings/rating-t.gif");
		},
		function() {
			if (rated) return;
			var id = $(this).attr("id");
			var val = id.charAt(4);
			for (var i=1; i<=val; i++)
				$("#star" + i).find("img").attr("src", "/commonv8/images/ratings/rating-f.gif");
		}
	);
	$('.star').click(function() {
		var id = $(this).attr("id");
		var val = id.charAt(4);
		$("input:radio").val([$val]);
		for (var i=1; i<=val; i++)
			$("#star" + i).find("img").attr("src", "/commonv8/images/ratings/rating-t.gif");
		for (; i<=5; i++)
			$("#star" + i).find("img").attr("src", "/commonv8/images/ratings/rating-f.gif");
		rated = true;
		$(this).blur();
		return false;
	});
	// Expand Section
	$(".expandOff").each(function() {
		$(this).find(".block").hide("normal");
	});
	$(".expandOff .header .expandBtn").each(function() {
		$(this).find("img").attr("src", "/commonv8/images/btn_expand_plus.gif");
	});
	$(".expandBtn").click(function() {
		var div = $(this).parent().parent();
		if (div.hasClass("expandOn")) {
			div.find(".block").slideUp("normal");
			div.removeClass("expandOn");
			div.addClass("expandOff");
			$(this).find("img").attr("src", "/commonv8/images/btn_expand_plus.gif");
		} else {
			div.find(".block").slideDown("normal");
			div.removeClass("expandOff");
			div.addClass("expandOn");
			$(this).find("img").attr("src", "/commonv8/images/btn_expand_minus.gif");
		}
	});
	// Expand Info
	$(".infoExpandBtn").click(function() {
		var jthis = $(this);
		while (jthis.get(0).tagName != "DIV" && jthis.parent() != undefined)
			jthis = jthis.parent();
		var infoBox = jthis.next(".infoBox");
		if (infoBox.css("display") == "none") {
			$(this).find("img").attr("src", "/commonv8/images/btn_expand_minus.gif");
			infoBox.slideDown("normal");
		} else {
			$(this).find("img").attr("src", "/commonv8/images/btn_expand_plus.gif");
			infoBox.slideUp("normal");
		}
	});
});
