$(document).ready(function(){

    $(window).load(function () {
  $(".menu-link-top").dropShadow({left: 0, top: 1, blur: 1, opacity: 0.2});	
		});
  $('img').load(function () {
 
   $(".cover").animate({top:'160px'});
    $(".cover2").animate({top:'80px'});
    $(".cover100").animate({top:'0px'});
    $(".cover3").animate({top:'80px'});
    
   				//Full Caption Sliding (Hidden to Visible)
				$('.boxgrid.captionfull').hover(function(){
					$(".cover", this).stop().animate({top:'105px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
				});
				//Caption Sliding (Partially Hidden to Visible)
				$('.boxgrid2.caption').hover(function(){
					$(".cover2", this).stop().animate({top:'68px'},{queue:false,duration:160});
				}, function() {
					$(".cover2", this).stop().animate({top:'80px'},{queue:false,duration:160});
				});
				$('.boxgrid3.caption').hover(function(){
					$(".cover3", this).stop().animate({top:'68px'},{queue:false,duration:160});
				}, function() {
					$(".cover3", this).stop().animate({top:'80px'},{queue:false,duration:160});
				});
				$('.boxgrid100.caption100').hover(function(){
					$(".cover100", this).stop().animate({top:'0px'},{queue:false,duration:160});
				}, function() {
					$(".cover100", this).stop().animate({top:'0px'},{queue:false,duration:160});
				});
  });
    
  $("#street-input-load").load("select.php");
  $(".logs").load("/js_logs.php");
  
  $(".img-light").hover(
      function () {
	  var button = $(this).attr("real");
        $(".b"+button).addClass("lightG");
	}, 
      function () {
	    var button = $(this).attr("real");
        $(".b"+button).removeClass("lightG");
      }
    );
    
    $(".cover").css("top","205px");
    $(".cover2").css("top","105px");
    $(".cover100").css("top","-40px");
    $(".cover3").css("top","105px");
      
  
				
	 $("#shadow").css("height", $(document).height()).hide();
            $(".lightSwitcher").click(function(){
                $("#shadow").toggle();
                if ($("#shadow").is(":hidden"))
                    $(this).html("Выключить свет").removeClass("turnedOff");
                 else
                    $(this).html("Включить свет").addClass("turnedOff");
            });
   a_width=0;
$(".prev").each(function(){
a_width+=jQuery(this).width()+2;
$('.width-prev').css('width',a_width);
});

 $("#refresh").click(function(){
 	
 	 $(".logs").load("js_logs.php");
 });
 

 var height_text = jQuery('#openText').height();
 var i=0;
 if(height_text > 99){
 	
 $('.open_text').html('Открыть описание &darr;');
 $('#openText').animate({
    height: '100px'
  }, 1000);

  
  $(".open").click(function(){
  	if(i == 0){
               $('#openText').animate({
    height: height_text
  }, 1000);
  $('.open_text').html('Закрыть описание &uarr;');
  i = 1;
  	}
  	else{
  	            $('#openText').animate({
    height: '100px'
  }, 1000);
  $('.open_text').html('Открыть описание &darr;');
  i = 0;
  	}
            });
 }

 
 
				$('a.open_img').click(function(){

					var href = $(this).attr("href");
					
					
					$("body").before("<div class='lightbox_img'><img src='"+href+"'></div><div class='black_background'></div>");
					$(".black_background").animate({opacity: 0}, 1).animate({opacity: 0.6}, 1000);
					var window_width = $(window).width();				
					var img_width = $(this).attr("rel");
					
					$(".lightbox_img").css("left",-((window_width-img_width)/2+img_width));
					$('.lightbox_img img').load(function () {
					
					if(window_width-50 < img_width){
						$(".lightbox_img img").css("width",window_width-50);
						$(".lightbox_img").animate({left: (window_width-50)/2}, 500);
					}else{
					$(".lightbox_img").animate({left: (window_width-img_width)/2}, 500);
					}
					$(".black_background").css("backgroundImage","url()");
					});
					
					return false;

				});
				$(window).click(function(){
					$(".lightbox_img").animate({opacity:"0"}, 500, function() {
						$(".lightbox_img").hide();
						});
					$(".black_background").animate({opacity:"0"}, 500, function() {
						$(".black_background").hide();
						});			
							
					
				});
  });
