// pngfix
if($.browser.msie && $.browser.version < 7) DD_belatedPNG.fix('#messageArea img, #message, #curriculum div.ph dt');

$(function() {
	$("#curriculum .art dd:odd, #curriculum .basic dl:odd").addClass("odd");

	$("a[rel=works]").fancybox({
		'overlayOpacity': 0.5,
		'titlePosition': 'inside'
	});

	// get path
	var path = location.pathname;
	var dir = path.split("/");
	if(dir[2] == "art") {
		setTab(1);
		campusChange(1, true);
	}else {
		setTab(0);
		campusChange(0, true);
	}
	function setTab(num) {
		$("#message .tab li").each(function(i){
			$(this).unbind();
			if(i == num){
//				if($("div.teacher" , "#teacherArera > div:eq("+i+")").length == 0){
//					setTab(num + 1);
//					return false;
//				}
				$(this).removeClass("btn").css("cursor","default");
				$("img:eq(0)", this).attr("src", $("img:eq(0)", this).attr("src").replace("_off.gif", "_on.gif")).unbind();
			}else {
				if($("div.teacher" , "#teacherArera > div:eq("+i+")").length > 0){
					$(this).click(function(){
						setTab(i);
						campusChange(i, false);
					}).css("cursor","pointer").addClass("btn");
					$("img:eq(0)", this).attr("src", $("img:eq(0)", this).attr("src").replace("_on.gif", "_off.gif")).hover(
						function () {
							$(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
						},
						function () {
							$(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
						}
					);
				}else {
					$("img:eq(0)", this).attr("src", $("img:eq(0)", this).attr("src").replace("_off.gif", "_no.gif"));
					$(this).addClass("btn");
				}
			}
		});
	};

	function campusChange(num, flg) {
		var div = "#teacherArera > div";
		teacherChange(0, div + ":eq("+num+")", true);
		$(div).hide();
		if(flg){
			$(div + ":eq("+num+")").show();
		}else {
			$(div + ":eq("+num+")").fadeIn("fast");
		};
	};

	function teacherChange(num, e, flg) {
		$(e +" > div").hide();
		if(flg){
			$(e +" > div:eq("+num+")").show();
		}else {
			$(e +" > div:eq("+num+")").fadeIn("fast");
		};

		$("li", e).each(function(i){
			$(this).unbind();
			if(i == num){
				$(this).html("<strong>"+$(this).text()+"</strong>");
			}else {
				$(this).html("<a href=\"#\">"+$(this).text()+"</a>").click(function(f){
					f.preventDefault();
					teacherChange(i, e, false);
				});
			}
		});
	};


	// movie
	var mov_path = $("#movieArea").attr('class');
	$("#movieArea a").fancybox({
		'overlayOpacity': 0.5,
		'titleShow': false,
		'scrolling': false,
		'content' : '<div id="moviePop"><div id="movieFlash"></div></div><script type="text/javascript">var flashvars = {path:"/fla/movie/' + mov_path + '.flv"};var params = {allowFullScreen:"true",menu:"false"};var attributes = {};swfobject.embedSWF("../common/player/movie_player.swf", "movieFlash", "394", "337", "8.0.0","", flashvars, params, attributes);</script>'
	});
	

});







