this.imagePreview = function()
{
   var xOffset_left=42; //якщо зображення зліва (враховувати товщину border)
   var xOffset_right=35; //якщо зображення справа
   var yOffset=10;
   var img1_width=1;
   var img1_height=1;
   var dw=$(window).width()/2;
   var dh=$(document).height()/2;
   var top=0;
   var left=0;
   //--
   $("a.img_big_preview").hover(function(e){
      //розмір анімованого бара завантаження
      img1_width=220;
      img1_height=19;
      //--
      $("body").append("<p id='img_big_preview'><img src='/img/loading-2.gif' width='220' height='19' alt='Загрузка...' /></p>");
      //--
      top=e.pageY-yOffset;
      //if (e.pageX<dw) {left=e.pageX+xOffset;} else {left=e.pageX-xOffset-img1_width;}
      if (e.pageX<dw) {left=e.pageX+xOffset_right;} //показувати картинку справа
      else {left=e.pageX-xOffset_left-img1_width;} //показувати картинку зліва
      //--
      $("#img_big_preview").css("top", top+"px");
      $("#img_big_preview").css("left", left+"px");
      //$("#img_big_preview").fadeIn("fast");
      $("#img_big_preview").show();

      //--

      //в інакшому випадку після зменшення вікна після першого виклику розміри прев`ю не перераховуються
      dw=$(window).width()/2;
      dh=$(window).height()/2;
      //--
      var img1_src='';
      //Визначення шляху до зображення для прев`ю
      //з title посиланя <a href="..." title="img1_src">
      img1_src=this.title;
      if (img1_src=='')
      {
         //з href посиланя <a href="img1_src">
         img1_src=this.href;
      }
      var img1=new Image();
      img1.onload = function()
      {
         //wait(1);
         img1_width=this.width;
         img1_height=this.height;
         if (img1_width>dw || img1_height>dh)
         {
            //Визначення розмірів прев`ю
            w_ratio=img1_width/dw;
            h_ratio=img1_height/dh;
            if (w_ratio>h_ratio)
            {
               img1_width = Math.round(img1_width/w_ratio);
               img1_height = Math.round(img1_height/w_ratio);
            }
            else
            {
               img1_width = Math.round(img1_width/h_ratio);
               img1_height = Math.round(img1_height/h_ratio);
            }
         }
         //--
         $('#img_big_preview').html("<img src='"+img1_src+"' width='"+img1_width+"' height='"+img1_height+"' alt='Быстрый предпросмотр' />");
         //--
         top=Math.round(e.pageY-yOffset-(img1_height/2));
         $("#img_big_preview").css("top", top+"px");
         if (e.pageX<dw) {left=e.pageX+xOffset_right;} else {left=e.pageX-xOffset_left-img1_width;}
         $("#img_big_preview").css("left", left+"px");
         $("#img_big_preview").css("width", img1_width+"px");
         $("#img_big_preview").css("height", img1_height+"px");
         //--
         $("#img_big_preview").show();
      }
      img1.src=img1_src; //сначала нужно задать обработчик события, и только потом делать действия, которые могут привести к возникновению этого события
    },

   function()
   {
     $("#img_big_preview").remove();
   });

   $("a.img_big_preview").mousemove(function(e)
   {
         top=Math.round(e.pageY-yOffset-(img1_height/2));
         $("#img_big_preview").css("top", top+"px");
         if (e.pageX<dw) {left=e.pageX+xOffset_right;} else {left=e.pageX-xOffset_left-img1_width;}
         $("#img_big_preview").css("left", left+"px");
   });
};



/*GOOGLE MAPS*/
// http://prime-code.ru/google/google-maps/sobytiya-v-google-maps-javascript-api-v3/
// v1.1 2011-02-16
function google_maps_initialize(google_maps_lat, google_maps_lng, google_maps_zoom, marker_view, edit_mode)
{
   var myOptions =
   {
      zoom: google_maps_zoom,
      mapTypeId: google.maps.MapTypeId.ROADMAP
   }

   var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
   map.setCenter(new google.maps.LatLng(google_maps_lat, google_maps_lng));

   if (marker_view==1)
   {
      var markerOptions =
      {
         map: map,
         position: map.getCenter()
      };
      var marker = new google.maps.Marker(markerOptions);
      if (edit_mode==1)
      {
         marker.setDraggable(true);
         //marker
         google.maps.event.addListener(marker, 'dragend', function()
         {
            $('#google_maps_lat').val(this.getPosition().lat());
            $('#google_maps_lng').val(this.getPosition().lng());
            //alert(this.getPosition().lat());
         });
      }
   }
   if (edit_mode==1)
   {
      //zoom
      google.maps.event.addListener(map, "zoom_changed", function()
      {
         $('#google_maps_zoom').val(this.getZoom());
      });
   }
}


$(document).ready( function() {

   imagePreview();
   $("#myTable").tablesorter({sortList: [[0,0]]});

   // Выбор всех
   //При клике на ссылку "Все", активируем checkbox
   $("a[href='#select_all']").click( function()
   {
      //alert("#" + $(this).attr('rel') + " input:checkbox:enabled");
      $("#" + $(this).attr('rel') + " input:checkbox:enabled").attr('checked', true);
      return false;
   });

   // Ни одного
   $("a[href='#select_none']").click( function()
   {
      $("#" + $(this).attr('rel') + " input:checkbox").attr('checked', false);
      return false;
   });



   /*$('#sf1_submit').click(function()
   {
      var c_ids_count = $("#c_ids input:checked").length;
      var t_ids_count = $("#t_ids input:checked").length;
      //alert (n);
      if (c_ids_count==0 || t_ids_count==0)
      {
         alert("Ошибка!"+"\r\n"+"Выберите, как минимум, одну страну и один тип тура");
         return false;
      }
   });

   $('#hotels_sf_submit').click(function()
   {
      var hc_ids_count = $("#hc_ids input:checked").length;
      var r_ids_count = $("#r_ids input:checked").length;
      //alert (n);
      if (c_ids_count==0 || t_ids_count==0)
      {
         alert("Ошибка!"+"\r\n"+"Выберите, как минимум, один курорт и одну категорию отеля");
         return false;
      }
   }); */
});

