
$(document).ready(function() {
	//text shadow
	//if ($.browser.msie) {
	//	$('#menu > ul > li > a').textShadow('1px 1px 5px #9d7202');
	//	
	//};
	//menu
	$('#menu > ul').superfish({
      delay:       600,
      animation:   {opacity:'show', height:'show'},
      speed:       400,
      autoArrows:  false,
      dropShadows: false
    });
	//menu img hover
	$('.ul_3 a').hover(function(){
			$(this).find('img').stop().animate({opacity:'0.8', width:'110%', height:'110%', marginTop:'-5%', marginLeft:'-5%'},400)					  
		}, function(){
			$(this).find('img').stop().animate({opacity:'1', width:'100%', height:'100%', marginTop:'0%', marginLeft:'0%'},400)			
		}
	)
	// tool tip
	$('.normaltip').aToolTip({
    	toolTipClass: 'aToolTip'});
	// footer slideToogle
	$('footer').css({bottom:'-74px'});
	var fl=false;
	$('footer .marker').click(function(){
		if (fl) {
			$(this).html('<img src="images/marker_up.gif" alt=""/>');
			$('footer').stop().animate({bottom:'-74'},400,'easeOutBack')
			fl=false
		} else{
			$(this).html('<img src="images/marker_down.gif" alt=""/>');
			$('footer').stop().animate({bottom:'-20'},400,'easeOutBack');
			fl=true
		}
	})
	//content
		
	var content=$('#content'),
		nav=$('#menu')
	
	nav.navs({
			hover:true
	})
	nav.navs(function(n){
			content.cont_sw(n)
	})
	
	content.cont_sw({
		showFu:function(){
			var _=this
			$.when(_.itms.find('.box')).then(function(){
				_.next.css({visibility:'visible'});
				if (_.next.attr('id')!='page_0') {
					_.next.find('.box').stop().animate({width:'300', height:'300', marginTop:'124', marginLeft:'175',  rotate:'+=720deg'},400).animate({width:'100%', height:'100%', marginTop:'0', marginLeft:'0'},400,'easeOutBack',function(){
						$(this).parent().find('.text').css({visibility:'visible', zIndex:'2'}).stop().animate({opacity:'1'}, function(){$(this).css({opacity:'none'})})																																																			
					});
				} else {
					_.next.find('.text').css({visibility:'visible', zIndex:'2'}).stop().animate({opacity:'1'}, function(){$(this).css({opacity:'none'})})
				}
			});
		},
		hideFu:function(){
			var _=this
				_.itms.not(':hidden').find('.text').stop().animate({opacity:'0'},400, function(){
					$(this).css({visibility:'hidden', zIndex:'1'})																	   
				})
				_.itms.find('.box').animate({width:'300', height:'300', marginTop:'171', marginLeft:'175'},400,'easeInBack').animate({width:'0', height:'0', marginTop:'342px', marginLeft:'350px',  rotate:'+=720deg'},400, function(){
					_.itms.css({visibility:'hidden'})																																																			 
				})
		},
		preFu:function(){
			var _=this
			_.itms.css({position:'absolute', visibility:'hidden'});
			_.itms.find('.box').css({opacity:'0.88', width:'0', height:'0', marginLeft:'350px', marginTop:'248px'});
			_.itms.find('.text').css({opacity:'0', visibility:'hidden', zIndex:'1'})
		}
	})
	
	$('#page_0').css({visibility:'visible'});
	$('#page_0').find('.text').css({visibility:'visible',opacity:'1'}).css({opacity:'none'});
	
	page=location.hash.slice(0,-1);
	if ((page!='')&&(page!='#')) {
		content.cont_sw(page);
		navigation=parseInt(page.substr(6));
		if (navigation!=NaN) {
			$('#menu > ul > li').eq(navigation-1).addClass('active');
		}
		
	}
	
	$('a').click(function(){
		page=$(this).attr('href');
		if (page.substr(page.indexOf('#'),6)=='#page_') {
			if (page=='#page_0') {
				location.hash='/';
			} else {
				location.hash=page+'/';
			}
		}
	});
	// animate list
	$('.list1 a').hover(function(){$(this).stop().animate({paddingLeft:'22'},400,'easeOutCirc')}, function(){$(this).stop().animate({paddingLeft:'12'},400, 'easeOutCirc')})
	
	//tabs
	tabs.init();
	
	// gallery1
	$("#gallery1").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible: 4,
		speed: 400,
		easing: 'easeOutCirc'
	});
	$("#gallery2").jCarouselLite({
		btnNext: ".next2",
		btnPrev: ".prev2",
		visible: 4,
		speed: 400,
		easing: 'easeOutCirc'
	});
	$("#gallery3").jCarouselLite({
		btnNext: ".next3",
		btnPrev: ".prev3",
		visible: 4,
		speed: 400,
		easing: 'easeOutCirc'
	});
	$('#gallery1 a, #gallery2 a, #gallery3 a').hover(function(){
			$(this).find('img').stop().animate({opacity:'0.8', width:'110%', height:'110%', marginTop:'-5%', marginLeft:'-5%'},400)					  
		}, function(){
			$(this).find('img').stop().animate({opacity:'1', width:'100%', height:'100%', marginTop:'0%', marginLeft:'0%'},400)			
		}
	)
	$(".folio ul li a").click(function(){
  	var largePath = $(this).attr("href");
  	$(".largeImg").animate({ opacity: "0" }, "middle",function(){
   		 $(".largeImg").attr({ src: largePath})
		 })
	$(".largeImg").animate({ opacity: "1" }, "middle")
      return false;
   })
	$(".folio2 ul li a").click(function(){
  	var largePath = $(this).attr("href");
  	$(".largeImg2").animate({ opacity: "0" }, "middle",function(){
   		 $(".largeImg2").attr({ src: largePath})
		 })
	$(".largeImg2").animate({ opacity: "1" }, "middle")
      return false;
   })
	$(".folio3 ul li a").click(function(){
  	var largePath = $(this).attr("href");
  	$(".largeImg3").animate({ opacity: "0" }, "middle",function(){
   		 $(".largeImg3").attr({ src: largePath})
		 })
	$(".largeImg3").animate({ opacity: "1" }, "middle")
      return false;
   })
	//bg animate
	$('#bgSlider').bgSlider({
		duration:1000,
		pagination:'.pagination',
		preload:true,
		spinner:'.bg_spinner'
	})
	$('.caption > div').css({opacity:'none'}).css({opacity:'0'});
	$('.caption_1').css({opacity:'1'}).css({opacity:'none'});
	$('.pagination a').click(function(){
		var number = parseInt($(this).attr('rel'));	
		$('.caption > div').stop().animate({opacity:'0'},1000);
		$('.caption_'+(number+1)).stop().animate({opacity:'1'},1000, function(){$(this).css({opacity:'none'})})
	})
	var w_img=1200, h_img=1050;
	var w,new_w,h, new_h, num;
	setWidth();
	setHeight();
	w=new_w;h=new_h;
	setSize();
	function setWidth(){
		new_w=$(window).width();
	}
	function setHeight(){
		new_h=$(window).height();
	}
	function setSize(){
		if ((w/w_img) > (h/h_img)) {
			w_img_new=w+20;
			h_img_new=~~((w+20)*h_img/w_img);
		} else {
			h_img_new=h+20;	
			w_img_new=~~((h+20)*w_img/h_img);
		}
		$('#bgSlider img').css({width:w_img_new, height:h_img_new});
	}
	setInterval(setNew,1);
	function setNew(){
		setWidth();
		setHeight();
		if ((w!=new_w)|(h!=new_h)) {
			w=new_w;h=new_h;
			setSize();
		}
	}
 });
