// JavaScript Document
var timer;
$(window).load(function(){
	$("#shadow").height(($("#site").height())+"px");
	var $imgsBox=$(".photoList, .galleryList");
	var $popupBox=$(".popupBox")
	$("img", $imgsBox).click(function(){
		$this=$(this);
		$(".popupBox").fadeIn("normal");
		$("#shadow").fadeIn("normal");
		params=$this.attr("name");
		location.hash='#'+params[0];
		$("img.active", $imgsBox).removeClass("active");
		$this.addClass("active");
		var hr=$("img.active", $imgsBox).attr("src");
		$("#img").attr("src", hr);
		var text=$(this).parent().next().html();
		$("p", ".popupBox").html(text);
		$(".pointL3", $popupBox).fadeTo("fast", ($this.parent().parent().prev().length?1:0.2));
		$(".pointR3", $popupBox).fadeTo("fast", ($this.parent().parent().next().length?1:0.2));
		return false;										
	});
	$(".pointL2", $popupBox).click(function(){
		obj=$("img.active",$imgsBox).parent().parent().prev();
		
		if(obj.length)
			$("img:first", obj).click();
		return false;										  
	});
	$(".pointR2", $popupBox).click(function(){
		obj=$("img.active",$imgsBox).parent().parent().next();
		if(obj.length)
			$("img:first", obj).click();
		return false;										  
	});
	$("#img", $popupBox).click(function(){
		obj=$("img.active",$imgsBox).parent().parent().next();
		if(obj.length)
			$("img:first", obj).click();
		return false;										  
	});

	$("#shadow, .close").click(function(){
		$(".popupBox").fadeOut("normal");
		$("#shadow").fadeOut("normal");
		return false;
	});
});
$(document).ready(function(){
	$("a",".alphabetList, .listBox").click( function() {
		if($(this).next().is(":hidden")){
			$(this).next().slideDown("slow");
			$(this).parent().addClass("active");
		}else{
			$(this).next().slideUp("slow")
			$(this).parent().removeClass("active");	
		}
		return false;
	});
	$("a",".historyList").click( function() {
		$(this).next().slideToggle("slow");
		return false;									  
	});
	$("#list2").attr("lw",$("#list2").width());
	$(".pointR4").click(function(){
		var list=$("#list2");
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);	
			var lp=Math.round(list.position().left-105);
			var lw=eval(list.attr("lw"))+lp;
			if(lw>0){
				list.animate({"left": "-=105px"},"slow", function(){														
					$(".pointR4").attr("cl","");														 									 
				});
			}else{
				$("td:last",list).after($("td:eq(0)",list));
				lp=Math.round(list.position().left+105);
				list.css("left",lp+"px");	
				list.animate({"left": "-=105px"},"slow", function(){														
					$(".pointR4").attr("cl","");														 									 
				});
			}
		}
		return false;
	});
	$(".pointL4").click(function(){
		var list=$("#list2");
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);
			var lp=list.position().left;
			var lw=list.attr("lw");
			if(lp<0){
				$("#list2").animate({"left": "+=105px"},"slow", function(){
					$(".pointL4").attr("cl","");														 													 
				});
			}else{
				list.css("left", "-105px");
				$("td:eq(0)",list).before($("td:last",list));
				$("#list2").animate({"left": "+=105px"},"slow", function(){													 
					$(".pointL4").attr("cl","");														 
				});
			}
		}
		return false;
	});
	//$(".menuBox").children("li").each(function(){
		$("li", ".menuBox").click(function(){
			//clearTimeout($(this).attr("timer"));
			//$(".subMenu",".menuBox li:not("+$(this).attr("class")+")").hide();
			$(".subMenu",this).show();	
			//return false;								
		});
		$(".menuBox").children("li").hover(function(){
		//alert("1")
			//obj=this;
			$(".subMenu",".menuBox").hide();
			
		
		});								   
//	});
	$("li", ".newsList").hover(
		function () {
        		$("li.active",".newsList").removeClass("active");
			$("li.active",".imgList").removeClass("active");
			$(this).addClass("active");
			var i=$("li.active", ".newsList").index();
			$("li:eq("+i+")",".imgList").addClass("active");
			$("li:eq("+i+")",".imgList").show();
			
     	 	},
      		function () {
        		$(this).removeClass("active");
			var i=$("li.active", ".newsList").index();
			$("li",".imgList").hide();
			$("li",".imgList").removeClass("active");
			$("li",".imgList").eq(0).show();
			$("li",".imgList").eq(0).addClass("active");
			$("li", ".newsList").eq(0).addClass("active");
			//$("li:eq(0)",".imgList").show();
			//$("li:eq("+i+")",".imgList").show();
			//$("li:eq(0)",".imgList").addClass("active");	
     		}
    	);
	$(".pointR").click(function(){
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);
			var $this=$("li.active", ".news1");
			var n=$("li", ".news1").length-1;
			var i=$("li.active", ".news1").index();
			$this.fadeOut("slow", function() { 
				$this.next().addClass("active");
				$this.removeClass("active");
				$(".pointR").attr("cl","");	
			});
			$this.next().fadeIn("slow");
			if(i==n){
				$("li:eq(0)", ".news1").addClass("active");
				$("li:eq(0)", ".news1").fadeIn("slow");
			}
		}
		return false;
	});
	$(".pointL").click(function(){
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);
			var $this=$("li.active", ".news1");
			var n=$("li", ".news1").length-1;
			var i=$("li.active", ".news1").index();
			$this.fadeOut("slow", function() { 
				$this.prev().addClass("active");
				$this.removeClass("active");
				$(".pointL").attr("cl","");	
			});
			$this.prev().fadeIn("slow");
			if(i==0){
				var i=$("li.active", ".news1").index();
				$this.fadeOut("slow", function() { 
					$this.removeClass("active");
					$("li:eq("+n+")", ".news1").addClass("active");
					$(".pointL").attr("cl","");	
				});
				$("li:eq("+n+")", ".news").fadeIn("slow");
			}
		}
		return false;
	});
	$(".pointR1").click(function(){
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);
			var $this=$("li.active", ".cabinetBox");
			var n=$("li", ".cabinetBox").length-1;
			var i=$("li.active", ".cabinetBox").index();
			$this.fadeOut("slow", function() { 
				$this.next().addClass("active");
				$this.removeClass("active");
				$(".pointR1").attr("cl","");	
			});
			$this.next().fadeIn("slow");
			if(i==n){
				$("li:eq(0)", ".cabinetBox").addClass("active");
				$("li:eq(0)", ".cabinetBox").fadeIn("slow");
			}
		}
		return false;
	});
	$(".pointL1").click(function(){
		if(!$(this).attr("cl")){
			$(this).attr("cl", 1);
			var $this=$("li.active", ".cabinetBox");
			var n=$("li", ".cabinetBox").length-1;
			var i=$("li.active", ".cabinetBox").index();
			$this.fadeOut("slow", function() { 
				$this.prev().addClass("active");
				$this.removeClass("active");
				$(".pointL1").attr("cl","");	
			});
			$this.prev().fadeIn("slow");
			if(i==0){
				$this.fadeOut("slow", function() { 
					$this.removeClass("active");
					$("li:eq("+n+")", ".cabinetBox").addClass("active");
					$(".pointL1").attr("cl","");	
				});
				$("li:eq("+n+")", ".cabinetBox").fadeIn("slow");
			}
		}
		return false;
	});
});
