if (document.location.href.substr(-12) == "?load=1.html" || document.location.href.substr(-12) == ".html?load=1") {
    $(function(){
        document.location.href = '/price.xls';
    })
}

if (typeof hs != 'undefined') {
    hs.graphicsDir = '/static/highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.wrapperClassName = 'controls-in-heading';
	hs.fadeInOut = false;
	hs.dimmingOpacity = 0.5;

    hs.showCredits = false;

    if (hs.addSlideshow) {
        hs.addSlideshow({
            interval: 5000,
            repeat: false,
            useControls: true,
            fixedControls: false,
            overlayOptions: {
                opacity: 1,
                position: 'top right',
                hideOnMouseOut: false
            }

        });
    }

}

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

var tos = {};

function sw_on(e){
    e.children('table').show()
    var i = e.children('a').children('img')
    i.attr('src', i.attr('sw_alt'));
}

function sw_off(e){
    e.children('table').hide()
    var i = e.children('a').children('img')
    i.attr('src', i.attr('sw_orig'));
}

$(function(){
    $(".portfolio_image img").unwrap()
    $('.img-switcher').children('img').each(function(){
        $.preLoadImages($(this).attr('sw_alt'))
    })
    $('.mm_item').hover(
        function(){
            var $this = $(this);
            var id = $this.attr('id')
            clearTimeout(tos[id])
            sw_on($(this))
        },
        function(){
            var $this = $(this);
            var id = $this.attr('id')
            tos[id] = 1;
            tos[id] = setTimeout(function(){
                sw_off($this);
            }, 300)
        }
    )
    
    $(".mi").hover(
        function(){
            $(this).children('td').children('.mii').addClass('hover')
            $(this).children('.sm_o').children('.sm_oi').show()
        },
        function(){
            $(this).children('td').children('.mii').removeClass('hover')
            $(this).children('.sm_o').children('.sm_oi').hide()
        }
    )
    $("#vid").change(function(){
        trg = document.getElementById('srok_isp');
        if (this.selectedIndex==0) {
            trg.options[3] = new Option("1-2 дня", "0");
        } else {
            trg.remove(3);
        }
    })
    $("#vide").change(function(){
        trg = document.getElementById('srok_isp');
        if (this.selectedIndex==0) {
            trg.options[3] = new Option("1-2 days", "0");
        } else {
            trg.remove(3);
        }
    })
});
