$(document).ready(function()
{
    // Video player
    var container = document.getElementById("player");

    if (container)
    {
        if (flashembed.getVersion()[0] > 0)
        {
            // flash installed
            if (flashembed.isSupported([9, 115]))
            {
                // mp4 supported, otherwise Flowplayer itself needs [9, 0]
                // Player for video files
                flowplayer("player", "flowplayer.swf",
                { 
                    // commercial version requires product key 
                    key: '#$0d95a66eedf369cf285', 
       
                    canvas:
                    { 
                    backgroundColor: '#251B12', 
                    backgroundGradient: [0.2, 0.0], 
                    borderRadius: 10 
                    },

                    plugins:
                    { 
                        controls:
                        { 
                            url: 'flowplayer.controls.swf',
                            backgroundColor: '#774F37',
                            timeColor: '#EF6D21',
                            bufferColor: '#774F37',
                            progressColor: '#EF6D21',
                            buttonColor: '#462F20', 
                            buttonOverColor: '#2C1E14'
                        } 
                    },

                    clip:
                    { 
                        scaling: 'fit'
                    } 
                });
            }

            else
            {
                container.innerHTML = "Your Flash version is too old. " +
                "Please get the latest version from " +
                "<a href=\"http://get.adobe.com/flashplayer\">here</a>."
            }
        }

        else
        {
            container.innerHTML = "<img src=\"img/play_large.png\" alt=\"Flash placeholder\" />"
        }
    }

    // Audio player
    var aud_container = document.getElementById("aud_player");

    if (aud_container)
    {
        if (flashembed.getVersion()[0] > 0)
        {
            // flash installed
            if (flashembed.isSupported([9, 0]))
            {
                // Flowplayer itself needs [9, 0]
                // Player for audio files
                flowplayer("aud_player", "flowplayer.swf",
                { 
                    // commercial version requires product key 
                    key: '#$0d95a66eedf369cf285', 
       
                    canvas:
                    { 
                    backgroundColor: '#251B12', 
                    backgroundGradient: [0.2, 0.0], 
                    borderRadius: 10 
                    },

                    plugins:
                    { 
                        controls:
                        { 
                            url: 'flowplayer.controls.swf',
                            backgroundColor: '#774F37',
                            timeColor: '#EF6D21',
                            bufferColor: '#774F37',
                            progressColor: '#EF6D21',
                            buttonColor: '#462F20', 
                            buttonOverColor: '#2C1E14',
                            autoHide: false,
                            mute: false,
                            time: false,
                            fullscreen: false
                        } 
                    },

                    clip:
                    { 
                        scaling: 'fit',
                        autoPlay: false, 
                        autoBuffering: false
                    } 
                });
            }

            else
            {
                aud_container.innerHTML = "Your Flash version is too old. " +
                "Please get the latest version from " +
                "<a href=\"http://get.adobe.com/flashplayer\">here</a>."
            }
        }

        else
        {
            aud_container.innerHTML = "<img src=\"img/play_large.png\" alt=\"Flash placeholder\" />"
        }
    }

    $(function()
    {
        var settings = 
        {
            showArrows:true, 
            scrollbarWidth: 20,
            dragMaxHeight: 180
        };

        $('.scroll-pane')
            .jScrollPane(settings)
            .onImagesLoad(
            {
                callback: function(ref) 
                {
                    $(ref).jScrollPane(settings);
                }
            }
        );
    });
});

