
$(document).ready(function () {
    video();
    scrollbar();
    fancy();
    welcomeNews();
    stores();
    pressCycle();
    storesList();

    //openNewsletter()


});


$(window).resize(function () {
    video();
    scrollbar();
});


//function openNewsletter() {
//    $("li#subMenuNotSel134_1 a, li#subMenuNotSel134_2 a, li#subMenuNotSel134_3 a, li#subMenuNotSel134_4 a, li#subMenuNotSel134_5 a").fancybox().trigger('click')
//}


function stores() {
    $('.stores li a').hover(function() {
        $(this).find('.stores-text').show();
    }, function()  {
        $(this).find('.stores-text').hide();
    })
}



function pressCycle() {
    $('#cycleSqu').cycle({
        fx: 'fade',
        speed: 500,
        timeout: 4000,
        next: '#nxtcycleSqu',
        prev: '#prvcycleSqu'
    });

}

function welcomeNews() {
    if ($('#page_27').length != 0) {

        $("#slideshow img").live("click", function () { window.location = 'http://www.punktgroup.com/en/13/gallery.aspx' });   

        $("#payoff").animate({
            opacity: 1,
            left: 0
        }, 1000)


        $('.news ul').cycle({
            fx: 'fade',
            speed: 500,
            timeout: 4000,
            pager: '.pager',
            pagerAnchorBuilder: function (index, el) {
                return '<a href="#">&nbsp;</a>';
            }
        });

        $('.pager a').click(function () {
            $('.news ul').cycle('pause');
        })

    }
}


function fancy() {

    jQuery("li#subMenuNotSel134_1 a, li#subMenuNotSel134_2 a, li#subMenuNotSel134_3 a, li#subMenuNotSel134_4 a, li#subMenuNotSel134_5 a, a.clock, a.ads, a.jpGall").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade'
    });

}


function video() {
    var wh = $(window).height();
    $('.video').height(wh);

}

function scrollbar() {

    var wh = $(window).height();
    if (wh > 301) {
        $('#container, #rightContent').height(wh - 300);
    }

}



function storesList() {
    $('#storesPager a').click(function () {
        $('#storesPager a').not(this).removeClass('selected');
        $(this).addClass('selected');
        var pageNr = $(this).attr('page');
        var activePage = '#pg' + pageNr;
        $(activePage).addClass('pre-selected');
        $('#storesPages ul.selected').fadeOut('fast', function () {
            $(this).removeClass('selected').show();
            $('#storesPages ul.pre-selected').addClass('selected').removeClass('pre-selected');
        })
    })
}
