
hs.graphicsDir = '/usr/system/plugins/highslide-html/graphics/';
hs.dimmingOpacity = 0.8;
/*hs.showCredits = false;
hs.dimmingOpacity = 0.7;
hs.align = 'center';
hs.captionEval = 'this.a.title';
var lang="ru";

hs.registerOverlay({
	html: '<div class="close-simple-white" onclick="return hs.close(this)" title="Закрыть"></div>',
	position: 'top right',
	useOnHtml: true,
	fade: 2 // fading the semi-transparent overlay looks bad in IE
});
*/

hs.showCredits = false;
hs.outlineType = 'rounded-black';
hs.fadeInOut = true;
hs.align = 'center';
hs.captionEval = 'this.a.title';
hs.registerOverlay({
	html: '<div class="closebutton" onclick="return hs.close(this)" title="Закрыть"></div>',
	position: 'top right',
	useOnHtml: true,
	fade: 2 // fading the semi-transparent overlay looks bad in IE
});



// Add the slideshow controller
hs.addSlideshow({
	slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		className: 'rounded-black',
		opacity: '0.75',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '-10',
		hideOnMouseOut: true
	}
});

// Add the slideshow controller
hs.addSlideshow({
	slideshowGroup: 'group2',
	interval: 5000,
	repeat: false,
	useControls: false,
	fixedControls: 'fit',
	overlayOptions: {
		className: 'rounded-black',
		opacity: '0.75',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '-10',
		hideOnMouseOut: true
	}
});

// gallery config object
var config1 = {
	slideshowGroup: 'group1',
	transitions: ['expand', 'crossfade']
};

hs.slideshowGroup='group1';
hs.transitions=['expand', 'crossfade'];

var lang="ru";

var current_slide=1;
var animating=false;

var sc=128+10;

var top_dur=500;

$(function() {
   if (!$("#sp").length) return;
   //return;
   $('#sp_scroll').jCarouselLite({
     auto: 0,
     btnPrev: '#sp_sl',
     btnNext: '#sp_sr',
     speed: 500,
     speed2: 200
   });
});

$(document).ready(function() {
   $("#sp_scroll img").hover(function () {
      $(this).attr('src', $(this).attr('hovered'));
   }, function () {
      $(this).attr('src', $(this).attr('normal'));
   });
   /*
   $("#sp_sr").click(function() {
      var an="-="+sc+"px";
      var now=Math.abs(parseInt($("#sp_scroll ul").css('margin-left')));
      var w=parseInt($("#sp_scroll ul").width());
      var maxw=parseInt($("#sp_scroll").width());
      //if (w-Math.abs(now)<maxw) an=maxw+"px";
      //alert("now="+now+"; w="+w+"; maxw="+maxw);
      //alert("tmp="+(w-now+10*($("#sp_scroll img").length-1))+"; maxw="+maxw);
      //if (w-now!=maxw) an="-"+(w-maxw)+"px";
      if (w-now-20*($("#sp_scroll img").length-1)<maxw) return false;
      if (w-now<=maxw) an=(maxw-w)+"px";
      $("#sp_scroll ul").animate({
         "marginLeft": an
      },
      {
         duration: 250, 
         queue: true
      });
      return false;
   });
   var w=0;
   $("#sp_scroll img").each(function () {
      if (w) w+=28;
      w+=parseInt($(this).width());
   });
   //alert(w);
   $("#sp_scroll ul").width(w+"px");
   $("#sp_sl").click(function() {
      var an="+="+sc+"px";
      var now=parseInt($("#sp_scroll ul").css('margin-left'));
      var maxw=parseInt($("#sp_scroll").width());
      if (now>=0 || Math.abs(now)<sc) an=0;
      $("#sp_scroll ul").animate({
         "marginLeft": an
      },
      {
         duration: 250, 
         queue: true
      });
      return false;
   });
   */
   $("#mp_s li a").click(function(e) {
      e.stopPropagation();
      return true;
   });
   $("#mp_s li").click(function() {
      if ($(this).hasClass('ha_s')) return false;
      var new_slide=$(this).attr('id').replace('s', '');
      if (new_slide==current_slide)
      {
         var e=$(this).find(".hs_a").find("a");
         e=e[0];
         hs.expand(e, { slideshowGroup: 'group2' });
         return false;
      }
      if (animating) return false;
      animating=true;
      var h=$("#s"+current_slide).height();
      $("#s"+current_slide+" div div:not(.hs_a) a").animate({
         bottom: "-100px"
      }, {
         duration: top_dur,
         complete: function () {
            $("#s"+current_slide+" div:not(.hs_a) div a").hide();
            $("#s"+current_slide+" div:not(.hs_a) div a").css('bottom', '8px');
         }
      });
      $("#s"+current_slide+" div div:not(.hs_a)").animate({
         bottom: "-100px"
      }, {
         duration: top_dur,
         complete: function () {
            $("#s"+current_slide+" div div:not(.hs_a)").hide();
            var current_slide_start=$("#s"+current_slide+"").width();
            var current_slide_to=109;
            $("#s"+new_slide+"").animate({
               width: "408px"
            },
            {
               duration: top_dur,
               step: function (now,opts) {
                  now = opts.now = Math.round(now);
                  $("#s"+current_slide+"").width(408-now+109);
                  //$("#log").append(now+" ");
               },
               complete: function () {
                  $("#s"+new_slide+" div div:not(.hs_a) a").show();
                  $("#s"+new_slide+" div div:not(.hs_a)").show().css('bottom', "-100px").animate({
                     "bottom": "0px"
                  },
                  {
                     duration: top_dur,
                     complete: function () {
                        current_slide=new_slide;
                        animating=false;
                     }
                  });
               }
            });
         }
      });
   });
});


// contacts

$(document).ready(function () {
   $("a.highslide").click(function() {
      //alert("!");
      return hs.expand(this, { slideshowGroup: 'group2' });
   });
   $("input[type=button]").each(function () {
      if ($(this).attr('href')) {
        $(this).click(function () {
           window.location.href=$(this).attr('href');
        });
      }
   });
   if ($.validationEngine) {
      $(".valForm").validationEngine({
         ajaxSubmit: true,
         ajaxSubmitFile: $(".valForm").attr('action')
      });
   }
   $(".send_cont").click(function() {
      $("#order_form").submit();
      return false;
   });
});

