$(document).ready(function() {
	$(".category_list ul li").hover(function() {
		parent_offset = $(this).offset();
		num = parseInt($(this).attr("id").substring(4));
		$(this).children("a").addClass("active");
		$(this).children("ul.collapse").each(function(i) {
			$(this).removeClass("collapse");
			level = parseInt($(this).attr("class").substring(6));
			$(this).addClass("expanded");
			
			if (level < 3)
			{
				temp_left = parent_offset.left + 223 + "px";
				temp_top = parent_offset.top + i * 31 + "px";
			}
			else
			{
				temp_left = 223 + "px";
				temp_top = i * 31 + "px";
//				temp_left = "223px";
//				temp_top = 0;
			}
			$(this).css({"position" : "absolute", "left" : temp_left, "top" : temp_top, "z-index" : "99"});
		});
	}, function() {
		$(this).children("a").removeClass("active");
		$(this).children("ul.expanded").each(function(i) {
			$(this).addClass("collapse").removeClass("expanded");
		})
	});
	
	$("ul.menu li.expanded").hover(function() {
		$(this).children("a").addClass("active");
		$(this).children("ul.collapse").removeClass("collapse").addClass("expanded");
	}, function() {
		$(this).children("a").removeClass("active");
		$(this).children("ul.expanded").removeClass("expanded").addClass("collapse");
	});
	
	$("#featured .tab_title").click(function() {
		$("#featured .tab_title").removeClass("tab_title_active");
		num = parseInt($(this).attr("class").substring(10));
		$(this).addClass("tab_title_active");
		$("#featured .tab_content").removeClass("tab_content_active");
		$("#featured .tab_content_" + num).addClass("tab_content_active");
	});
	$(".description .tab_title").click(function() {
		$(".description .tab_title").removeClass("tab_title_active");
		num = parseInt($(this).attr("class").substring(10));
		$(this).addClass("tab_title_active");
		$(".description .tab_content").removeClass("tab_content_active");
		$(".description .tab_content_" + num).addClass("tab_content_active");
	});
	
	$("#review_tab .tab_title").click(function() {
		$("#review_tab .tab_title").removeClass("tab_title_active");
		num = parseInt($(this).attr("class").substring(10));
		$(this).addClass("tab_title_active");
		$("#review_tab .tab_content").removeClass("tab_content_active");
		$("#review_tab .tab_content_" + num).addClass("tab_content_active");
	});
	
	$("#top_keyword").focusin(function() {
		if ($("#top_keyword").attr("value") == "Enter keywords here"){
			$("#top_keyword").attr("value", "")
		}
	});
	
	$("#top_keyword").focusout(function() {
		if ($("#top_keyword").attr("value") == ""){
			$("#top_keyword").attr("value", "Enter keywords here")
		}
	});
	
	$("#top_search_form").submit(function () {
		if ($("#top_keyword").attr("value") == "" || $("#top_keyword").attr("value") == "Enter keywords here")
		{
			alert("Please input a keyword.");
			
			return false;
		}
		else
		{
			return true;
		}
	});
});
