
$().ready(function(){

	$("#left>ul>li:eq(0) a").click(function(){
		$(this).parent().find("ul").slideToggle("slow");
	});
	$("#left>ul>li:eq(3) a").click(function(){
		$(this).parent().find("ul").slideToggle("slow");
	});

	if (location.href.match(/president|history|outline|system|map|client/i)) {
		$("#left>ul>li:eq(0) ul").show();	
	}
	if (location.href.match(/message|grow|mvp|evaluate|training|review/i)) {
		$("#left>ul>li:eq(3) ul").show();	
	}
	
	$("#left>ul>li:eq(3) ul>li:eq(1)").hide();
	$("#left>ul>li:eq(3) ul>li:eq(2)").hide();
	
	
	$("#left ul li a").each(function(){
		_src = $(this).find("img").attr("src").split("/");
		jQuery('<img />').attr('src', _src[0] + "/on/" + _src[1]);
	});
	$("#left ul li a").hover(
		function(){ 
			_src = $(this).find("img").attr("src").split("/");
			$(this).find("img").hide();
			$(this).append($("<img />").attr('src', _src[0] + "/on/" + _src[1]));
		},
		function(){
			$(this).find("img").show();
			$(this).find("img:last").remove();
		}
  	);
	
	$("#left>ul>li>ul>li>ul>li>a").unbind('mouseover').unbind('mouseout');
	
	
	if (location.href.match(/system/i)) {
		for(var i=1; i<=10; i++){
			$(document.body).append($("<img />").addClass("pop").attr({src: "img/sys-pop" + i +".gif", id: 'pop'+i}));
		}
		$("#Map area").click(function(e){
			$(".pop").fadeOut();
			_id="#pop"+$(this).attr("href").split("#a")[1];
			//_offset = $(_id).attr("width")/2;
			_offset = 169;
			$(_id).css("left",e.pageX - _offset);
			$(_id).css("top",e.pageY);
			$(_id).fadeIn();
			$(_id).click(function(){
				$(this).fadeOut();					
			});
		});
	}
	if (location.href.match(/review/i)) {
		
		
		if (location.href.match(/review02/i)) {
			
			$(document.body).append($("<img />").attr({src: "img/review02-pop1.gif", id: 'pop1'}));
			$(document.body).append($("<img />").attr({src: "img/review02-pop2.gif", id: 'pop2'}));
			$(document.body).append($("<img />").attr({src: "img/review02-pop3.gif", id: 'pop3'}));
		
			$("#review_vision").bind("click", {id: "#pop1", offset: 104}, openPop);
			$("#review_sky").bind("click", {id: "#pop2", offset: 350}, openPop);
			$("#review_semi").bind("click", {id: "#pop3", offset: 230}, openPop);
						
		}else{
			
			$(document.body).append($("<img />").attr({src: "img/review-pop1.gif", id: 'pop1'}));
			$(document.body).append($("<img />").attr({src: "img/review-pop2.gif", id: 'pop2'}));
			$(document.body).append($("<img />").attr({src: "img/review-pop3.gif", id: 'pop3'}));
		
			$("#review_sky").bind("click", {id: "#pop1", offset: 350}, openPop);
			$("#review_course").bind("click", {id: "#pop2", offset: 120}, openPop);
			$("#review_vision").bind("click", {id: "#pop3", offset: 104}, openPop);
			
		}
	}
});

function openPop(e) {
	 $(".pop").fadeOut();
	_id=e.data.id;
	_offset = e.data.offset;
	$(_id).addClass("pop");
	$(_id).css("left",e.pageX - _offset);
	$(_id).css("top",e.pageY);
	$(_id).fadeIn();
	$(_id).click(function(){
		$(this).fadeOut();					
	})
}







