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)

$(function(){
    $(".portfolio_image img").unwrap()
    $('.img-switcher').children('img').each(function(){
        $.preLoadImages($(this).attr('sw_alt'))
    })

    $('.img-switcher').mouseover(function () {
        $('.mm_item').children('table').hide()
        $('.img-switcher img').each(function() {
            var i = $(this);
            i.attr('src', i.attr('sw_orig'));
        })
        
        e = $(this).parent();
        e.children('table').show()
        var i = e.children('a').children('img')
        i.attr('src', i.attr('sw_alt'));
    })
    
    $('#main_menu').mouseleave(function() {
        $('.mm_item').children('table').hide()
        $('.img-switcher img').each(function() {
            var i = $(this);
            i.attr('src', i.attr('sw_orig'));
        })
        
    })
    
    $(".mi").hover(
        function(){
            $(this).children('td').children('.mii').addClass('hover')
            $(this).children('.sm_o').children('.sm_oi').children('table').show()
        },
        function(){
            $(this).children('td').children('.mii').removeClass('hover')
            $(this).children('.sm_o').children('.sm_oi').children('table').hide()
        }
    )
    
    var trg = $('#srok_isp');
    
    $("#vid").change(function(){
        if (this.selectedIndex == 0) {
            trg.prepend('<option value="0">1-2 дня</option>');
        } else {
            trg.children('option[value=0]').remove();
        }
    })
    if ($("#vid").length && $("#vid")[0].selectedIndex != 0) {
        trg.children('option[value=0]').remove();
    }
    
    $("#vide").change(function(){
        if (this.selectedIndex == 0) {
            trg.prepend('<option value="0">1-2 days</option>');
        } else {
            trg.children('option[value=0]').remove();
        }
    })
    
    if ($("#vide").length && $("#vide")[0].selectedIndex != 0) {
        trg.children('option[value=0]').remove();
    }
});

