$(document).ready(function() { 
  
   $("#change_month_next").click(function(){
     $("#now_month").toggle();
     $("#next_month").slideToggle("fast");
     return false;
   });
   
   $("#change_month_back").click(function(){
     $("#next_month").toggle();
     $("#now_month").slideToggle("fast");     
     return false;
   });
   
   //только на подвод мышки
   var ussr_flag = 1;
   $("#ussr").mouseover(function(){
     if (ussr_flag == 1) {     
       if ($("#ussr").css('backgroundPosition') == '0px 0px') {
         $("#ussr").css('backgroundPosition', '0px -40px');
       } else {
         $("#ussr").css('backgroundPosition', '0px 0px');
       }
       ussr_flag = 0;
     }     
     return false;
   });
   $("#ussr").mouseout(function(){
     ussr_flag = 1;
     return false;
   });
   
   var balt_flag = 1;
   var balt_flags = new Array("-120", "-160", "-200");
   
   $("#balt").mouseover(function(){
     if (balt_flag == 1) {         
              
       if ($("#balt").css('backgroundPosition') == '0px -160px') {
         $("#balt").css('backgroundPosition', '0px -120px');
       } else
       if ($("#balt").css('backgroundPosition') == '0px -120px') {
         $("#balt").css('backgroundPosition', '0px -200px');
       } else
       if ($("#balt").css('backgroundPosition') == '0px -200px') {
         $("#balt").css('backgroundPosition', '0px -160px');
       } else {
         $("#balt").css('backgroundPosition', '0px -160px');
       } 
       balt_flag = 0;
     }     
     return false;
   });
   $("#balt").mouseout(function(){
     balt_flag = 1;
     return false;
   });
   
   
   
   $("#show_flash").click(function(){
     
     var clientWidth  = parseInt(getClientWidth());
     var clientHeight = parseInt(getClientHeight())
     var flashHeight  = 718;
     var flashWidth   = 974;
     
     //подгоним размеры флешки
     if (clientHeight < flashHeight) {
       flashHeight = clientHeight - 100;
       flashWidth = flashWidth * flashHeight/clientHeight;
     } 
     if (clientWidth < flashWidth) {
       flashWidth = clientWidth - 100;
       flashHeight = flashHeight * flashWidth/clientWidth;
     }
     
     $('#flash_content').css('marginTop',  -(flashHeight/2) + 'px');
     $('#flash_content').css('marginLeft', -(flashWidth/2) + 'px');
		 $('#flash_content').show();
		 $('#flash_btns').hide();
		 createFlashcode("/themes/site/flash/buklet.swf", 'flash_swf', null, flashWidth, flashHeight, null);		 
		 return false;
   });
   /*$('a[href^=/]').click(function(event){
      event.preventDefault();
      var href = this.href;
      $(document.documentElement).animate({ scrollTop: $(window).height()-80 }, 1000, 'swing' , function(){
        location = href;
      });
    });*/
});

function closeflash() {
  $('#flash_fon').hide();
  $('#flash_swf').html = '';
  document.getElementById('flash_swf').innerHTML = '';
  $('#flash_content').hide();
  $('#flash_btns').hide();  
}

function openbtns() {
  $('#flash_fon').show();
  $('#flash_btns').show(); 
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

var timer;
 
function scrolldelta(dy) {
  if (dy != 0) {
    doScroll(dy);
  } else {
    clearTimeout(timer);
  }
}

function doScroll(dy) {
  var target = document.getElementById('scrollable');
  target.scrollTop = target.scrollTop + dy
  timer = setTimeout("doScroll("+dy+");", 25);
}


