$(function(){
    	var season = {"summer":[4,5,6,7,8,9], "winter":[0,1,2,3,10,11]};
	var t = new Date();
	//$.each(season, function(i,el){ $.each(el,function(_i, _el){ if(_el == t.getMonth()) $(".flash-map").addClass(i) }) } );
	//$(".switcher-winter").click(function(){ window.location.href='/?vg=winter' });
	//$(".switcher-summer").click(function(){ window.location.href='/?vg=summer' });

	$(".countries > a").each(function(i, el){
		$(this).hover(
				function(){
                                    var p = $(this).parent().parent();
                                    var s = ($(p).parent().hasClass('summer'))?'s':'w';
                                    $(p).append('<div class="hover" style="position:absolute;width:100%;height:100%;top:'+($(this).attr('negt')?'-':'')+$(this).attr('t')+'px;left:'+$(this).attr('l')+'px;z-index:97;background:url(/templates/alps/i/'+s+'-'+$(this).attr('class')+'-h.png) no-repeat 0 0 scroll;" />') ;
                                    $('.hover').css({opacity:0.6})
                                },
				function(){ $(".hover",$(this).parent().parent() ).remove() }
		);
	});
	$('a[rel=lightbox]').lightBox();
        $($('#choise_country>li>a').get(0)).click();        

    //Alps.getLast(0);
    $('.header-bottom li a').each(function() {
        var pat = $(this).parent();
        $(this).mouseenter(function(){
            $('.submenu').remove();
            clearTimeout(Alps.timer_menu);
            if (pat.attr('data-obj')) {
               Alps.getSubMenu(pat, pat.attr('data-obj'));
           }
        });
        $(this).mouseleave(function(e){
            Alps.timer_menu = setTimeout(function(){$('.submenu').remove();}, 1500);
        });
    });
    var wul = 0;
    $('#jcar img').each(function() { wul += $(this).width()+8; });
    $('#jcar').width(wul);
    var tmpw = $('.gallery_children').attr('scrollWidth') - 920;
    var globLeft = false;
    var globRight = false;
    $('.gallery_scroll').slider({
        min: 0,
        max:tmpw,
        step: 1,
        slide: function(event, ui)
            {
                $('.gallery_children').attr('scrollLeft', ui.value);
            }
        });
        $('.gallery_left').mousedown(function() {
            globLeft = setInterval(function() {
                var lf = $('.gallery_children').attr('scrollLeft');
                if((lf-10) > 0)
                {
                    $('.gallery_scroll').slider( "option", "value", (lf-10) );
                    $('.gallery_children').attr('scrollLeft', (lf-10));
                }
                else
                {
                    $('.gallery_scroll').slider( "option", "value", 0 );
                    $('.gallery_children').attr('scrollLeft', 0);
                }
            }, 50);
        });
        $('.gallery_left').mouseup(function() {
           clearInterval(globLeft);
        });
        $('.gallery_right').mousedown(function() {
            globRight = setInterval(function() {
                var lf = $('.gallery_children').attr('scrollLeft');
                if((lf+10) <= tmpw)
                {
                    $('.gallery_scroll').slider( "option", "value", (lf+10) );
                    $('.gallery_children').attr('scrollLeft', (lf+10));
                }
                else
                {
                    $('.gallery_scroll').slider( "option", "value", tmpw );
                    $('.gallery_children').attr('scrollLeft', tmpw);
                }
            }, 50);
        });
        $('.gallery_right').mouseup(function() {
           clearInterval(globRight);
        });
        var glSubTimer = false;
        $('.header-menu ul.menu li ul').each(function() {
            var el = $(this);
            var cl = el.clone();
            el.parent().hover(function() {
                $('.submenu').remove(); 
                clearTimeout(glSubTimer);
               $('[crsub]').remove();
               cl.attr('crsub', 1);
               cl.css({top:(el.parent().offset().top+20)+'px',left:(el.parent().offset().left)+'px'}).appendTo('body').show();
               cl.mouseenter(function(){ clearTimeout(glSubTimer) });
               cl.mouseleave(function(){ glSubTimer = setTimeout(function(){ $('[crsub]').remove(); }, 500); });
            }, function() {
                glSubTimer = setTimeout(function(){ $('[crsub]').remove(); }, 500);
            });
        });

	$('.content .video .text').jScrollPane({
		showArrows: true
	});
});

