function menuBind(){
		$('#menu > li > a').bind ('mouseenter', function(){
			$(this).find('em').stop().animate({backgroundPosition:'-20 -100'},400, 'easeInQuad')
		});
		$('#menu > li > a').bind ('mouseleave',function(){
			$(this).find('em').stop().animate({backgroundPosition:'-250 -250'},400, 'easeOutQuad')
		});
}
function menuUlBind(){
		$('ul').bind ('mouseenter', function(){
			$(this).parent().find('> a em').stop().animate({backgroundPosition:'-20 -100'},400, 'easeInQuad')
		});
		$('ul').bind ('mouseleave',function(){
			$(this).parent().find('> a em').stop().animate({backgroundPosition:'-250 -250'},400, 'easeOutQuad')
		});
}
function closeBind(){
		$('.close').bind ('mouseenter', function(){
			$(this).stop().animate({right:'1px'},400,'easeInBack')	
		});
		$('.close').bind ('mouseleave',function(){
			$(this).stop().animate({right:'24'},400,'easeOutBack')
		});
}
$(document).ready(function() {
	  $('#content').css({display:'block'});
	  $('#bgSlider').bgSlider({
	  	duration:1000,
	  	images:['images/img1.jpg','images/img2.jpg','images/img3.jpg','images/img4.jpg','images/img5.jpg','images/img6.jpg'],
	 	preload:false,
	  	spinner:'.bg_spinner',
	  	nextBu:'.buttons > .next',
	  	prevBu:'.buttons > .prev'
	 })
    //for_buttons next, prev
	$('.next .img, .prev .img').css({ width:'100%', left:'0%'})
	$('.next, .prev').hover( function(){
			$(this).find('.img').css({zIndex:'8'}).stop().animate({width:'0%', left:'41px'},400,'easeOutCirc')
			$(this).find('.img_active').css({zIndex:'9'}).stop().animate({width:'100%', left:'0px'},400,'easeOutCirc')
		}, function(){
			$(this).find('.img').stop().css({zIndex:'9'}).animate({width:'100%', left:'0px'},400,'easeOutCirc')
			$(this).find('.img_active').css({zIndex:'8'}).stop().animate({ width:'0%', left:'41px'},400,'easeOutCirc')
		}
	)
	//logo animate
	$('h1').hover(function(){
			$(this).stop().animate({left:'0'},400,'easeInBack')			 
		}, function(){
			$(this).stop().animate({left:'-64'},400,'easeOutBack')	
		}
	)
	closeBind();
	//menu animate
	menuBind();
	menuUlBind();
	$('ul#menu').superfish({
      delay:       600,
      animation:   {opacity:'show', height:'show'},
      speed:       400,
      autoArrows:  false,
      dropShadows: false
    });
	hover_1('#menu .ul_1 > li');
	hover_1('#menu .ul_2 > li');
	// function for hover 1
	function hover_1(name){
		$(name+' .img').css({left:'0%', width:'100%'})
		$(name).hover( function(){
				$(this).find('>a .img').css({zIndex:'8'}).stop().animate({left:'10px', width:'0px'},400,'easeOutCirc')
				$(this).find('>a .img_active').css({zIndex:'9'}).stop().animate({ left:'0px', width:'21px'},400,'easeOutCirc')
			}, function(){
				$(this).find('>a .img').css({zIndex:'9'}).stop().animate({left:'0px', width:'21px'},400,'easeOutCirc')
				$(this).find('>a .img_active').css({zIndex:'8'}).stop().animate({left:'10px', width:'0px'},400,'easeOutCirc')
			}
		)
	}
	//marker animate
	hover_1('.marker1');
	//button animate
	$('.button1').hover(function(){
			$(this).find('span').stop().animate({backgroundPosition:'-20 -100'},400, 'easeInQuad',function(){$(this).css({backgroundColor:'#f77b0c'})})
		}, function(){
			$(this).find('span').css({background:'url(images/menu_hover.png) -20px -100px no-repeat'})
			$(this).find('span').stop().animate({backgroundPosition:'-250 -250'},400, 'easeOutQuad')
		}
	)
	// vertical scroll	
    $('.scroll-pane').jScrollPane({
		showArrows:true,
		scrollbarWidth:19,
		dragMaxHeight:156
	});	
	// tool tip
	$('.normaltip').aToolTip({
    	toolTipClass: 'aToolTip'});
	// bg animate
	var w_img=1980, h_img=1122;
	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();
		}
	}
 });
