// JavaScript Document
$(function(){
	var img_w;
	
	initLayout();
	$(window).resize(function(){
		initLayout();
		})
	
	$(".main_frame li a").attr("href","javascript:void(0)")
	var n=0,c=0;
	function initLayout(){
		h1=document.documentElement.clientHeight;
		w1=document.documentElement.clientWidth;
		$(".main_frame").width(w1)
		$("#fixed_body").width(w1)
		$(".masker").width(w1)
		$(".masker").height(h1)
		$("#fixed_body").height(h1)
		//$(".hide_photo").width(h1*1.3)
		$(".hide_photo").width(h1)
		$(".hide_photo img").height(h1)
		$("#reel").width($(".main_frame").width()*$(".main_frame").length)
		$(".main_frame").height(h1)
		}
	$(".home_btn").click(function(){
		//$("#reel").animate({left:0},function(){window.location.reload()})
		$("#reel").animate({left:0},function(){$("#logo").animate({top:15+"%"}).animate({left:50+"%"})})
		
		})
	$(".lang_chinese").click(function(){
		$("#reel").animate({left:-$(".main_frame").width()+"px"},function(){
			$("#logo").animate({top:5+"%"})
			})
		
		$("#nav_home").show()
		})
	$(".workbook").click(function(){
		$("#reel").animate({left:-$(".main_frame").width()*2+"px"})
		$(".bc_home").css({backgroundPosition:"right -175px"})
		$("#c_page3_1").hide()
		$("#c_page3_2").hide()
		})
		
	$(".about").click(function(){
		$("#c_page3").hide()
		$("#reel").animate({left:-$(".main_frame").width()*2+"px"})
		$(".bc_home").css({backgroundPosition:"right -175px"})
		})
		
	$(".contact").click(function(){
		$("#c_page3").hide()
		$("#c_page3_1").hide()
		$("#reel").animate({left:-$(".main_frame").width()*2+"px"})
		$(".bc_home").css({backgroundPosition:"right -175px"})
		})
	
	$(".beijing_story").click(function(){
		$("#c_page4").css({display:"block"})
		$("#reel").animate({left:-$(".main_frame").width()*3+"px"},function(){
		$(".photo_album img").show()})
		$(".bc_home").css({backgroundPosition:"right -210px"})
		$(".back_level").css({backgroundPosition:"right -175px"})
		$("#logo").animate({left:5+"%"})
		})
	$(".menggu_family").click(function(){
		$("#c_page4").css({display:"none"})
		$("#reel").animate({left:-$(".main_frame").width()*3+"px"},function(){
		$(".photo_album img").show()})
		$(".bc_home").css({backgroundPosition:"right -210px"})
		$(".back_level").css({backgroundPosition:"right -175px"})
		$("#logo").animate({left:5+"%"})
		})	
	$(".back_level").click(function(){
		$(".photo_album img").hide()
		$("#reel").animate({left:-$(".main_frame").width()+"px"},function(){
			$(".main_frame").show()})
			$("#logo").animate({left:50+"%"})
			})
	$(".back_level2").click(function(){
		$(".photo_album img").hide()
		$("#reel").animate({left:-$(".main_frame").width()*2+"px"},function(){
			$("#logo").animate({left:50+"%"})
			})
		})
	$(".hide_photo").hover(function(){$(".zoom_icon").fadeIn("fast")},function(){$(".zoom_icon").fadeOut("fast")})
	$(".close").click(function(){
		$(".hide_photo").hide()
		//$(".hide_photo").css({left:"auto",right:100+"%"})
		$(".hide_photo").animate({left:100+"%"},function(){$(".masker").fadeOut("fast")})
		n=0;
		})
	
	$("#c_page4 .photo_album img").each(function(i){
		$(this).hover(function(){
			$(".hide_photo").animate({left:80+"%"},function(){$(".hide_photo").show()})
			//console.log($(".photo_album img:eq("+i+")").attr("src").split("-"))
			//$(".hide_photo img").attr("src","photos/"+$("#c_page4 .photo_album img:eq("+i+")").attr("src").split("-")[1])
			$(".hide_photo img").attr("src",$("#c_page4 .photo_album img:eq("+i+")").attr("src"))
			$(this).click(function(){
				n=1;
				$(".hide_photo").animate({left:0+"%"},600,function(){$(".masker").css({display:"block"});})
				})
			},function(){
				if(n==0){
					$(".hide_photo").animate({left:100+"%"})
					}
				})
		})
	$("#c_page4_1 .photo_album img").each(function(i){
		$(this).hover(function(){
			$(".hide_photo").animate({left:80+"%"},function(){$(".hide_photo").show()})
			//console.log($("#c_page4_1 .photo_album img:eq("+i+")").attr("src").split("-"))
			//$(".hide_photo img").attr("src","photos/"+$("#c_page4_1 .photo_album img:eq("+i+")").attr("src").split("-")[1])
			$(".hide_photo img").attr("src",$("#c_page4_1 .photo_album img:eq("+i+")").attr("src"))
			$(this).click(function(){
				n=1;
				$(".hide_photo").animate({left:0+"%"},600,function(){$(".masker").css({display:"block"});})
				})
			},function(){
				if(n==0){
					$(".hide_photo").animate({left:100+"%"})
					}
				})
		})
	$(".zoom_icon").hover(function(){
		$(this).attr("href","photos/"+$(".hide_photo img").attr("src").split("-")[1])
		},function(){
			$(this).attr("href"," ")
			})	
	})
	
    
