jQuery(function($){

    //  Vertically center .wrapper
    var ah = $('.wrapper').height();
    var ph = $(window).height();
    var mh = (ph - ah) / 2;
    $('.wrapper').css('padding-top', mh);

    switch($('body').attr('id')) {
        case 'default':
            //  Slideshow configuration
            var vars = {domain:"*"};
            var params = {
                menu: "false",
                quality: "high",
                scale: "noscale",
                salign: "tl",
                wmode: "opaque",
                bgcolor: "#153945",
                allowscriptaccess: "always",
                allowfullscreen:"false"
            };
            var attributes = {name:"flashcontent", id:"image-cycle"};
            swfobject.embedSWF("/flash/slideshow.swf?xmlPath=/xml/slideshow.xml", "image-cycle", "893", "527", "10.0.0", "js/expressInstall.swf",vars,params,attributes);

            break;

        //  Partners menus Open and Close events
        case 'partner':
            $('.partner-menu li').click(function(){
                $('#partner-'+$(this).attr('class')).slideDown(function(){
                    $("#container-"+$(this).attr('id')).mCustomScrollbar("vertical",360,"easeOutCirc",1.05,"auto","no","yes",10);
                });
                return false;
            });

            $('.partner-list .close').click(function(){
                $(this).parent().slideUp();
                return false;
            });

            $('.partner-list h3').click(function(){
                $(this).toggleClass('active');
                $('#partner-'+$(this).attr('id')).toggle();
                $(this).parent().parent().parent().parent().mCustomScrollbar("vertical",360,"easeOutCirc",1.05,"auto","no","yes",10);
            });

            break;

        //  Offer table display
        case 'offer':
            $('.offer-level-1').slideDown('slow', function() {
                $('.offer-level-2').slideDown('slow', function() {
                    $('.offer-level-3').slideDown('slow');
                })
            });

            break;
    }

    if ( $('.mcs_container').length > 0 ) {
        $('.mcs_container').mCustomScrollbar("vertical",360,"easeOutCirc",1.05,"auto","no","yes",10);
    }

    $('#legal-pages li').each(function(){
        $(this).click(function(){
            $modal = $('#modal-'+$(this).attr('id'));
            $modal.modal({closeHTML:""});
            $.fn.mCustomScrollbar.CustomScroller();
            $modal.find('.close').click(function(){
                $.modal.close();
                return false;
            });

            return false;
        });
    });
});

