$(window).load(function() {	
	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:100,
		trackCl:'track',
		shuttleCl:'shuttle',
	})
	// close button
	$('.close').find('.img_act').css({top:'35px',left:'35px', width:'0', height:'0'});
	$('.close').hover(function(){
		$(this).find('.img').css({zIndex:'1'}).stop().animate({top:'35', left:'35', width:'0', height:'0'},400,'easeOutCirc')
		$(this).find('.img_act').css({zIndex:'2'}).stop().animate({top:'0', left:'0', width:'100%', height:'100%'},400,'easeOutCirc')					   
	}, function(){
		$(this).find('.img_act').css({zIndex:'1'}).stop().animate({top:'35', left:'35', width:'0', height:'0'},400,'easeOutCirc')
		$(this).find('.img').css({zIndex:'2'}).stop().animate({top:'0', left:'0', width:'100%', height:'100%'},400,'easeOutCirc')					   
	})
	//form
	$('#ContactForm').forms()
	//content & menu	
	$('#menu a').click(function(){
		$('#menu span').stop().animate({height:'100%'},500, 'easeOutCirc')
		$(this).parent().find('span').stop().animate({height:'0'},500, 'easeInCirc')
	})
	
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true,
		hoverIn:function(li){
			Cufon.refresh();
			$('img',li).stop().animate({width:'120%', height:'120%', marginBottom:'-10%', marginLeft:'-10%'})
		},
		hoverOut:function(li){
			Cufon.refresh();
			$('img',li).stop().animate({width:'100%', height:'100%', marginBottom:'-0%', marginLeft:'-0%'})
		},
		hover:true
	})
	nav.navs(function(n){
		content.cont_sw(n);
		$('#menu .active').find('span').stop().animate({height:'0'},500, 'easeInCirc');
	})	

	content.cont_sw({
		showFu:function(){
			var _=this
			$.when(_.li.find('.box')).then(function(){	
			$.when(_.li).then(function(){	
				_.next.css({display:'block'});
				_.next.stop().animate({height:'100%'},500, 'easeOutCirc', function(){
					_.next.find('.box').stop().animate({opacity:'show'});											   
				});
			});	
			});	
			$('#menu').stop().animate({bottom:'0'});
		},
		hideFu:function(){
			var _=this
			_.li.find('.box').stop().animate({opacity:'hide'})
			$.when(_.li.find('.box')).then(function(){	
				_.li.stop().animate({height:'0'},500, 'easeInCirc')									
			})
			$('#menu').stop().animate({bottom:'209'});
			$('#menu').find('span').stop().animate({height:'100%'},500, 'easeOutCirc');
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none', height:'0'});
			_.li.find('.box').hide()
		}
	})
})
$(document).ready(function() {	
	function setHeight(){
		new_h=$(window).height();
	}
	setInterval(setNew,60);
	function setNew(){
		setHeight();
		if (h!=new_h) {
			h=new_h;
			center_box();
		}
	}
	function center_box(){
		if (h>h_box) {
			m_top=~~((h-h_box)/2);
		} else m_top=0
		$('.container_24').stop().animate({marginTop:m_top},1000, 'easeOutCirc')
	}
	var h_box=814
	setHeight();
	h=new_h;
	center_box();
})


