function anim_but(str, marg){
		
		$(str).bind ('mouseenter', function (){
		img=$(this).find('.img');
		img_a=$(this).find('.img_active');
		img.css({zIndex:1}).stop().animate({width:'0%', height:'0%', marginTop:marg, marginLeft:marg},400, 'easeOutCirc');
		img_a.css({zIndex:2}).stop().animate({width:'100%', height:'100%', marginTop:'0', marginLeft:'0'},400, 'easeOutCirc');
		});
		
		
		$(str).bind('mouseleave', function (){
			img.css({zIndex:2}).stop().animate({width:'100%', height:'100%', marginTop:'0', marginLeft:'0'},400, 'easeOutCirc');
			img_a.css({zIndex:1}).stop().animate({width:'0%', height:'0%', marginTop:marg, marginLeft:marg},400, 'easeOutCirc');
			});
		
		
	}
$(document).ready(function() {
	w1=1269;
	min_w=1168;
   SetWidth();
   function SetWidth(){
		new_w=$(window).width();
		if (new_w<min_w) {new_w=min_w}
	}
	w=new_w;
	function setBg(pos,w){
		$('.body2').css({backgroundPosition:pos});	
		
	}
		now=~~((w-w1)/2)-w1;
		pos=now+'px 100px';
		setBg(pos, w);
	
	setInterval(SetNew,1);
	function SetNew(){
		new_w=$(window).width();
		if (new_w<min_w) {new_w=min_w};
		if (w!=new_w) {
		now=now-(w-new_w)/2;
		pos=now+'px 100px';
		setBg(pos,new_w);
		w=new_w;}
	}
	function Animation(k){
		if (now>32000) {now=now-31725;pos=now+'px 100px';$('.body2').css({backgroundPosition:pos});}
		if (now<-32000) {now=now+31725;pos=now+'px 100px';$('.body2').css({backgroundPosition:pos});}
		now=now+k*w1;
		pos=now+'px 100px';
		$('.body2').stop().animate({backgroundPosition:pos},800, 'easeOutCirc');
		
	}
	anim_but('.marker_left', '55');
	anim_but('.marker_right', '55');
	$('.marker_left').click(function(){Animation(1);return false;});
	$('.marker_right').click(function(){Animation(-1);return false;});
 });

