//swfobject.embedSWF("/flash/flash.swf", "flash-35swbtipper", "124", "93", "8");

$(function () {
    //scroll pane
    $('.scroll-pane').jScrollPane({ showArrows: true, scrollbarWidth: 13, scrollbarMargin: 16, dragMaxHeight: 9 });

    //tabs
    var initab = true;
    var specsPaddingTop = 24;
    $('.tab').tabs({
        selected: 0,
        show: function (event, ui) {

            if ($(ui.tab).attr('title') != '') {
                var swfContent = ui.panel.id + '-swfContent';
                $('.showbox').html('<div id="' + swfContent + '"><img src="Images/placeholder.jpg" alt="Fuso Truck Image" /></div>')

                //http://www.codingforums.com/showthread.php?t=137848
                var flashvars = { // These are variables which are passed to the Flash document - they have to be already defined in the SWF
                    buttonText: "Press Me Please",
                    imageURL: "funnypicture.jpg" // Don't put anything after the last ", if you add more variables use a comma to separate entries but leave the last entry without one, same applies to the params and attributes
                };
                var params = { // Parameters for display
                    menu: "false",
                    wmode: "opaque" // a common request to make the 
                };
                var attributes = {
                    id: "newID",
                    name: "newID"
                };

                swfobject.embedSWF("Flash/product/" + $(ui.tab).attr('title') + ".swf", swfContent, "579", "375", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
            }

            $('.specs').css('padding-top', 0)
            if ($(ui.tab).next('.subnav').size() > 0) {
                $(ui.panel).children('.specs').css('padding-top', specsPaddingTop)
            }
            //when click on sub nave
            if ($(ui.tab).parents('.subnav').size() > 0) {
                $(ui.tab).parents('.subnav').parent().addClass('ui-tabs-selected')
                $(ui.panel).children('.specs').css('padding-top', specsPaddingTop)
            }
        }
    })

    // tab resize
    //var tabNumber = $('.tab-nav > li').size(),
    //		tabMargin = $('.tab-nav > li').size() * 2,
    //		tabContentWidth = $('.tab').width(),
    //		tabWidth = (tabContentWidth - tabMargin) / tabNumber;

    //$('.tab-nav > li').width(Math.round(tabWidth) - 3)

    // home page slide show
    $('#photos').galleryView({
        panel_width: 812,
        panel_height: 440,
        frame_width: 52,
        frame_height: 35,
        background_color: 'black',
        filmstrip_position: 'none',
        border: 'none',
        nav_theme: 'App_Themes/DMNew/images',
        easing: 'easeInOutQuad',
        pause_on_hover: true
    });

    //gallery lightbox
    $("a[rel=gallery-group]").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'over',
        'scrolling': true,
        'titleShow': true,
        'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
        }
    });

    //create first/last
    $('.nav-series').children(':first-child').addClass('first');
    $('.nav-series,.nav,.nav-footer,.subnav').children(':last-child').addClass('last');

    //see more
    $('#fuso-model').children('li').click(function () {
        window.location = $(this).find('.see-more').attr('href')
    })
});

