$(function(){

	/* global variable */
	var contents = "#contents";
	
	/* rollover */
	/*
	$("a" , contents).each(function(){
		$(this).mouseover(function(){
			$("img" , this).animate({ opacity: 0.6 },50, function(){$(this).animate({ opacity: 1 },100);});
		});
	});
	*/
	

	/* top Flash */
	var photoList = "#photoList";
	$("#thumbnail > li a").hover(function(){
		$("img:visible",this).stop().fadeTo(200,0);
	},function(){
		$("img:visible",this).fadeTo(200,1);
	});
	
	$("h2" , photoList).not($("h2:first-child" , photoList)).hide();
	var thumbnail = "#thumbnail";
	var block = "block";
	$("."+block+" img").css({ opacity: 0 });
	$("li" , thumbnail).each(function(){
		$("a" , this).mouseover(function(){
			var ID = $(this).attr("title");
			$("a."+block , thumbnail).removeClass(block);
			$("h2" , photoList).hide();
			$(this).addClass(block);
			$(ID).fadeIn("slow");
			return false;
		});
	});

	/* category tab setting */
	var tabNav = "#tabNav";
	$("li" , tabNav).each(function(){
		var url = document.URL;
		var stepSkincare ="#stepSkincare";
		var categoryBnr ="#categoryBnr";

		if(url.match("=step")){
			$($("a" , this).attr("href")).not($(stepSkincare)).hide();
			$("li:last-child a" , tabNav).addClass("active");
			$("li:last-child a img" , tabNav).hide();
		} else {
			$($("a" , this).attr("href")).not($($("li:first-child a" , tabNav).attr("href"))).hide();
			$("li:first-child a" , tabNav).addClass("active");
			$("li:first-child a img" , tabNav).hide();
		}
		$("a" , this).hover(function(){
			if($(this).attr("class").match("active")){
			} else {
				$("img" , this).fadeOut(50);				
			}
		}, function(){
			if($(this).attr("class").match("active")){
			} else {
				$("img" , this).fadeIn(50);
			}
		});
		$("a" , this).click(function(){
			var id = $(this).attr("href");
			if(id.match(categoryBnr)){
				$(stepSkincare).fadeOut(50);			
			} else {
				$(categoryBnr).fadeOut(50);
			}
			$(id).fadeIn("normal");

			if($(this).attr("class").match("active")){
			} else {
				$("li a" , tabNav).not($(this)).removeClass("active");
				$(this).addClass("active");
				$("li a img" , tabNav).not($("img" , this)).show();
				$("img" , this).hide();
			}
			return false;
		});
	});
	
});