	var obj_id='';
	var left_stop=true;
	var right_stop=true;

	function w_open(url,width,height) {
		window.open( url, 'w1', 'width=' + width +',height= ' + height + ',toolbar=0, scrollbars=0,location=0,menubar=0,resizable=0' );
	}
	
	function show() {
		$("#ajaxcontent").show();
		obj_id='#ajaxcontent_cont';
		$("#under").fadeIn(500,function() {
				prepare();
		});		
	}
	
	function resize() {
		var w=$("#mainpic").innerWidth();
		var h=$("#mainpic").innerHeight();		
		if (w>screen.width) w=screen.width-51;
		if (h>screen.height) h=screen.height-234;
		window.outerWidth=w+51;
		window.outerHeight=h+$("#description").innerHeight() + 110;
	}
	
	function loadPage(url,reload) {
		 $.ajax({
		   type: "POST",
		   url: "/index.php?id_rubric=" + url,
		   async: false,
		   cache: false,
		   beforeSend: function(XMLHttpRequest) {
		   	$("#load").fadeIn(200);
		   },
		   error: function(XMLHttpRequest, textStatus, errorThrown) {
		   	alert('В процессе загрузки страницы произошла ошибка!');
		   },
		   success: function(html){
		   	 $("#load").fadeOut(200);
			 $("#ajaxcontent").html(html);
			 if (reload) {
				 show();
			 } else {
				$("#goright").hide();
				$("#goleft").hide();				 
			 	prepare();
			 }
		   }
		 });

	}
	
	function prepare() {
	$(obj_id).scrollLeft(0);		
	left_stop=true;
	right_stop=true;
	//alert($(obj_id + " table").innerWidth());
	 $("#goleft").attr({ src: '/img/left_button_off.gif'});
		 if ($(obj_id + " table").innerWidth()>841) {
		 	  $("#goright").attr({ src: '/img/right_button.gif'});
  		 	  $("#goright").css({ cursor: 'pointer'});
  		 	  left_stop=false;
		 } else {
			  $("#goright").attr({ src: '/img/right_button_off.gif'});
  		 	  $("#goright").css({ cursor: 'default'});			  
		 }
		$("#goright").fadeIn(500);
		$("#goleft").fadeIn(500);					
	}
	
	function hide() {
		$("#under").fadeOut(500);
		$("#goright").hide();
		$("#goleft").hide();		
	}
	
	function showMenu() {
			$("#menu").fadeIn(500);
		//	$('.btn img').pngFix();
			//$(document).pngFix();
			//show();
	}
	
	$(document).ready(function(){
    $("#goleft").click(function(e){
	if (right_stop==false) {
		  if ($(obj_id).scrollLeft()>0) {
			  $(obj_id).animate({
			    scrollLeft: '-=841px'
			  }, 500, function() {
			    // Animation complete.
			    var ost=$(obj_id + " table").innerWidth()-$(obj_id).scrollLeft();
			    
			    if (ost>841) {
			    	left_stop=false;
					$("#goright").attr({ src: '/img/right_button.gif'});
	  		 	  	$("#goright").css({ cursor: 'pointer'});			    	
			    }
			    
			    if ($(obj_id).scrollLeft()<=0) {
				    $(obj_id).scrollLeft(0);
			    	left_stop=false;
			    	right_stop=true;
					$("#goright").attr({ src: '/img/right_button.gif'});
	  		 	  	$("#goright").css({ cursor: 'pointer'});	
					$("#goleft").attr({ src: '/img/left_button_off.gif'});
	  		 	  	$("#goleft").css({ cursor: 'default'});		  		 	  			    	
			    }
			  });  
		  }
	}
    });   
	
	
	$("#goright").click(function(e){
	if (left_stop==false) {
		  if ($(obj_id + " table").innerWidth()>$(obj_id).scrollLeft()) {
			  $(obj_id).animate({
			    scrollLeft: '+=841px'
			  }, 500, function() {
			    // Animation complete.
			    if ($(obj_id).scrollLeft()>0) {
			    	right_stop=false;
					$("#goleft").attr({ src: '/img/left_button.gif'});
	  		 	  	$("#goleft").css({ cursor: 'pointer'});				    	
			    }
			    var ost=$(obj_id + " table").innerWidth()-$(obj_id).scrollLeft()-841;
			    if (ost<841) {
			    	left_stop=true;
			    	right_stop=false;
					$("#goright").attr({ src: '/img/right_button_off.gif'});
	  		 	  	$("#goright").css({ cursor: 'default'});	
					$("#goleft").attr({ src: '/img/left_button.gif'});
	  		 	  	$("#goleft").css({ cursor: 'pointer'});		  		 	  			    	
			    }
			  });  
		  }
	}
	});	

	   $("#button1 img").hover(function() {
    	 $(this).attr({ src: '/img/exclusive_selected.gif'});
	   },function(){
	     $(this).attr({ src: '/img/exclusive.gif'});
	   }); 

	   $("#button2 img").hover(function() {
    	 $(this).attr({ src: '/img/acs_selected.gif'});
	   },function(){
	     $(this).attr({ src: '/img/acs.gif'});
	   }); 
	   
	   $("#button3 img").hover(function() {
    	 $(this).attr({ src: '/img/carnaval_selected.gif'});
	   },function(){
	     $(this).attr({ src: '/img/carnaval.gif'});
	   }); 
	   
	   $("#button4 img").hover(function() {
    	 $(this).attr({ src: '/img/info_selected.gif'});
	   },function(){
	     $(this).attr({ src: '/img/info.gif'});
	   }); 	   	   		
		
	});