$(document).ready(function(){
   $(".switch").dragToEnvoke({
      onFunc : function() {
         $('.calc1').stop().animate({right: 367}, 400);
         $('.calc2').stop().animate({right: 0}, 400);
         $('.switch-text1 .switch-text2').stop().fadeOut(400);
         $('.switch-text1').css({'color' : '#bbc6cc'});
         $('.switch-text1').css({'text-shadow' : '0px -1px 0px #333333'});
         $('.switch-text2').css({'color' : '#304A65'});
         $('.switch-text2').css({'text-shadow' : '0px 0px 0px #FFFFFF'});
         $('.switch-text1 .switch-text2').stop().fadeIn(400);
         $('.find-by a').css({'color' : '#394D68'});
         $('.find-by').css({'border-bottom' : '1px solid #B1BAC3'});
      },
      offFunc : function() {
         $('.calc1').stop().animate({right: 0}, 400);
         $('.calc2').stop().animate({right: -367}, 400);
         $('.switch-text1 .switch-text2').fadeOut(400);
         $('.switch-text1').css({'color' : '#304A65'});
         $('.switch-text1').css({'text-shadow' : '0px 0px 0px #FFFFFF'});
         $('.switch-text2').css({'color' : '#bbc6cc'});
         $('.switch-text2').css({'text-shadow' : '0px -1px 0px #333333'});
         $('.switch-text1 .switch-text2').fadeIn(400);
         $('.find-by a').css({'color' : '#CAE2FE'});
         $('.find-by').css({'border-bottom' : '1px solid #5C7DA0'});
      }
   });
   
   $(".second-handle").click(function(){
      $(".switch .handle").mousedown();
      $(".switch .handle").mouseup();
   });
   
   $(".menu-list").hover(
       function(){
         $(this).children(".submenu").css("visibility","visible");
       },
        function(){
         $(".submenu").css("visibility","hidden");
       }
   )
   
   $('.size').keyup(function(){
      var newVal = $(this).val().replace(/\,/g, ".");
      $(this).val(newVal);
   })
   
   //Home scroller
   jQuery(".scroller-images-wrapper").scrollable({circular: true, prev: ".prev", next: ".next"}).navigator(".navi").autoscroll({autoplay: true, interval:8000});
   jQuery('.navi a').attr('href', '#');
   
   //About us gallery
   jQuery(".gallery-wrapper ul.gallery li a").colorbox();
   
   //Search
   jQuery('#query-public').focus(function(){
      if(jQuery(this).val().localeCompare('Търсене в сайта') == 0){
         $(this).val("");
      }
   })
   
   jQuery('#query-public').blur(function(){
      if(jQuery(this).val().localeCompare('') == 0){
         $(this).val("Търсене в сайта");
      }
   })
   
   
   //Product Pics
   $(".product-pics-scroller-tabs").tabs(".product-pics-scroller li", {effect: 'fade', fadeOutSpeed: 200, fadeInSpeed: 200, rotate: true, event: 'click'});//.slideshow({autoplay: false, interval: 5000, clickable: false});
   
   /*$(".product-pics-scroller li").click(function(){
      $(this).css({'display' : 'list-item'});
      $(".product-pics-scroller li")
   })*/
   
   var height = $('.product-pics-scroller li:first-child img').height();
   
   $('.product-scroller-wrapper').css({'height' : height+20})
   $('.video-link').css({'top' : height+10})
   $(".product-pics-scroller-tabs").stop().animate({top: height+20}, 20);
   
   if ($('.product-pics-scroller li:nth-child(2) img').height()) {
      $(".product-pics-scroller-tabs li").click(function(){
         var index = $(this).index();
         index++;
         var img = $(".product-pics-scroller li:nth-child(" + index + ") img");

         $(".product-scroller-wrapper").height(img.height());
         $(".product-pics-scroller-tabs").stop().animate({top: img.height()+15}, 20);
         $('.video-link').stop().animate({top: img.height()+15}, 20);
      })
   } else {
      $(".product-pics-scroller-tabs").css({'display' : 'none'});
   }
   
   jQuery('.side-compare.empty').click(function(){
      alert('Няма избрани климатици за сравнение. Моля, изберете климатици и сравнете отново.')
   })
   
   
   jQuery('button.ask').click(function(){
   //jQuery('form#feedback-form').submit(function(){
       jQuery('form#feedback-form input[type="hidden"]').attr('value', 'post');
   });
})
