$(document).ready(function(){
  //засветить экран (как на bwc)
   // Fade out when click link
  $("a[href$='.htm']").click(function(){
    if (!$.browser.msie, !$.browser.opera) {
      //$("body").fadeOut("normal");
      $("#page").fadeOut("normal");
    } else {
      $("body").css({"filter":"progid:DXImageTransform.Microsoft.MotionBlur(strength=8, direction=180)"});
    }
  });
  rnd_img();
		function rnd_img(){
  			var rnd = Math.floor(Math.random() * (4 - 1));
			switch (rnd) {
				case 0: $('.rnd_img').attr('src','http://dive-baikal.ru/ru/files/images/gallery/14/9e4c7a0d1c9150b745f0750f1ec4aec5_s.jpg'); break;
				case 1: $('.rnd_img').attr('src','http://dive-baikal.ru/ru/files/images/gallery/14/9a98ea849e6962ef9ba93e8f1fef78a1_s.jpg'); break;
				case 2: $('.rnd_img').attr('src','http://dive-baikal.ru/ru/files/images/gallery/14/38782c7ac73263de100d3fcb65c3cab3_s.jpg'); break;
				case 3: $('.rnd_img').attr('src','http://dive-baikal.ru/ru/files/images/gallery/14/11bcb2647b5685e1432383baba32a356_s.jpg'); break;
				case 4: $('.rnd_img').attr('src','http://dive-baikal.ru/ru/files/images/gallery/14/9e4c7a0d1c9150b745f0750f1ec4aec5_s.jpg'); break;
			}
		}
  setInterval(rnd_img, 4000);
  //смотрим где мы
  var page = window.location.pathname.substr(1);
  if ($("#p1_menu a[href='" + page + "']").length>0){
    $("#act_photo").addClass("p1_static");
  }
  if ($("#p2_menu a[href='" + page + "']").length>0){
    $("#act_photo").addClass("p2_static");
  }
  
  
  $("#menu ul").hover(function(){
    $(this).css('background','#7292B9');
    
  }, function(){
    if ($(this).find("div").length>0){
      $(this).find("div").hide('slow', function(){
        $(this).parent().css('background','');
      });
    } else {
      $(this).css('background','');
    }
  });
  $("#menu ul").click(function(){
    if ( $(this).find('div').css('display') != 'block') {
      $("#menu ul div").hide('slow');
      $(this).find("div").show('slow');
    }
  });
  
  $("#p1_menu").hover(function(){
    $("#act_photo").addClass("p2");
  }, function(){
    $("#act_photo").removeClass("p2");
  });
  $("#p2_menu").hover(function(){
    $("#act_photo").addClass("p1");
  }, function(){
    $("#act_photo").removeClass("p1");
  });
  
 //////////////?

  
  $("#menu2 ul").hover(function(){
    $(this).css('background','#7292B9');
  }, function(){
    if ($(this).find("div").length>0){
      $(this).find("div").hide('slow', function(){
        $(this).parent().css('background','');
      });
    } else {
      $(this).css('background','');
    }
  });
  $("#menu2 ul").click(function(){
    if ( $(this).find('div').css('display') != 'block') {
      $("#menu2 ul div").hide('slow');
      $(this).find("div").show('slow');
    }
  });
  
  $("#p1_menu2").hover(function(){
    $("#act_photo").addClass("p2");
  }, function(){
    $("#act_photo").removeClass("p2");
  });
  $("#p2_menu2").hover(function(){
    $("#act_photo").addClass("p1");
  }, function(){
    $("#act_photo").removeClass("p1");
  });
 
 //////////////?


  
  if ($.browser.msie && $.browser.version == 6) {
    //код только для ИЕ шестой версии!
    var c_height = $("#content").height();
    var r_height = $("#right").height();
    var m_t = (c_height>r_height?c_height:r_height+170);
    if (m_t<300) {m_t = 400;}
    $("#page").height(m_t+550);
  }
});
