var refreshTime = 60;

function progressCountDown(){
    setTimeout(changeProgressbar,1000);
}

function changeProgressbar(){
    if(refreshTime)
    {
        currentWidth = $("#progressbarValue").css("width") != "" ? $("#progressbarValue").css("width") : 0;
        newWidth = parseInt(currentWidth,10) + 13;

        $("#progressbarValue").css("width",newWidth+"px");
        $("#progressbarValue").html(refreshTime);

        progressCountDown();
    }else
    {
        document.location.reload();
    }
    refreshTime --;
}

$(document).ready(function(){
    if($("#progressbarValue"))
    {
        progressCountDown();
    }

    if($("#clock"))
    {
        $("#clock").countdown({until: new Date(2012, 9-1, 01, 10), format: 'dHM'});
    }

     // Menu
    $('li.menuItem').hover(function(){
      $(this).toggleClass('highlight');
    });

    $('li.hasChildren').hover(function (){
        $(this).children('ul').slideToggle('medium');
    });

    if($.fn.fancybox)
    {
        $("a.youtube").click(function() {
            $.fancybox({
                'padding'             : 0,
                'autoScale'   : false,
                'transitionIn'        : 'none',
                'transitionOut'       : 'none',
                'title'               : this.title,
                'width'               : 680,
                'height'              : 495,
                'href'                : this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
                'type'                : 'swf',    // <--add a comma here
                'swf'                 : {'allowfullscreen':'true', 'wmode':'transparent'} // <-- flashvars here
            });
            return false;
        });

        $("a.vimeo").click(function() {
            $.fancybox({
                'padding'             : 0,
                'autoScale'   : false,
                'transitionIn'        : 'none',
                'transitionOut'       : 'none',
                'title'               : this.title,
                'width'               : 680,
                'height'              : 495,
                'href'                : this.href = this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1') + '&autoplay=1',
                'type'                : 'swf',    // <--add a comma here
                'swf'                 : {'allowfullscreen':'true', 'wmode':'transparent'} // <-- flashvars here
            });
            return false;

        });

        $("a[rel=image-gallery]").fancybox({
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'titlePosition' 	: 'over',
            'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
            }
        });
    };

    $("a.help").click(function(){
        $("div#help").toggleClass("hide","show");
    });

    $.supersized({
            start_slide         : 0,
            vertical_center     : 1,		//Vertically center background
            horizontal_center   : 1,		//Horizontally center background
            min_width		: 1000,	//Min width allowed (in pixels)
            min_height		: 700,	//Min height allowed (in pixels)
            fit_portrait        : 0,		//Portrait images will not exceed browser height
            fit_landscape	: 0,		//Landscape images will not exceed browser width
            image_protect	: 1,
            slides	:  [
                { image : '/gfx/backgrounds/banaanvaren1.jpg' },
                { image : '/gfx/backgrounds/banaanvaren2.jpg' },
                { image : '/gfx/backgrounds/banaanvaren3.jpg' },
                { image : '/gfx/backgrounds/banaanvaren4.jpg' },
                { image : '/gfx/backgrounds/banaanvaren5.jpg' },
                { image : '/gfx/backgrounds/banaanvaren6.jpg' },
                { image : '/gfx/backgrounds/banaanvaren7.jpg' },
                { image : '/gfx/backgrounds/banaanvaren8.jpg' },
                { image : '/gfx/backgrounds/banaanvaren9.jpg' },
                { image : '/gfx/backgrounds/banaanvaren10.jpg' },
                { image : '/gfx/backgrounds/banaanvaren11.jpg' },
                { image : '/gfx/backgrounds/banaanvaren12.jpg' },
                { image : '/gfx/backgrounds/banaanvaren13.jpg' },
                { image : '/gfx/backgrounds/banaanvaren14.jpg' },
                { image : '/gfx/backgrounds/banaanvaren15.jpg' },
                { image : '/gfx/backgrounds/banaanvaren16.jpg' },
                { image : '/gfx/backgrounds/banaanvaren17.jpg' },
                { image : '/gfx/backgrounds/banaanvaren18.jpg' },
                { image : '/gfx/backgrounds/banaanvaren19.jpg' },
                { image : '/gfx/backgrounds/banaanvaren20.jpg' },
            ]
    });
});
