﻿
$(document).ready(function () {





    jQuery('a[rel*="swf"]').each(function (index) {
        var node = $(this).attr('rel');
        $(this).addClass('swf_link');
    });


    jQuery('a[rel*="flv"]').each(function (index) {

        // $("#dnn_ctr1151_dnnTITLE_lblTitle").html($(this).attr('href'));
        var node = $(this).attr('rel');
        //    str = unescape(node).split("link=");
        //  var vhref = "/contento/portals/0/" + str[1].split(".flv")[0] + '.flv';
        //setflowplayer(node)
        //$(this).attr('newurl', vhref);
        $(this).addClass('video_link');
        $(this).attr("href", "#");
        $(this).attr("target", "_self");

    });


    jQuery('a[href*="flv"]').each(function (index) {


        var node = $(this).attr('href');
        str = unescape(node).split("link=");
        var vhref = "/contento/portals/0/" + str[1].split(".flv")[0] + '.flv';
        //setflowplayer(node)
        $(this).attr('rel', vhref);
        $(this).addClass('video_link');
        $(this).attr("href", "#");
        $(this).attr("target", "_self");

    });





    jQuery('a[href*="swf"]').each(function (index) {
        var node = $(this).attr('href');
        str = unescape(node).split("link=");
        var vhref = "/contento/portals/0/" + str[1].split(".swf")[0] + '.swf';
        //setflowplayer(node)
        $(this).attr('href', vhref);
        $(this).addClass('swf_link');
        $(this).attr("target", "_self");
    })


    jQuery(".video_link").click(function () {
        var myflv = $(this).attr("rel");
        openfancyFLV(myflv);


    });

    jQuery(".fancybox").fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'autoDimensions': true,
        'hideOnContentClick': false
    });

    $(".swf_link").fancybox({
        'padding': 0,
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'swf',
        'autoDimensions': 'true'
    });



    $(".rightpane").addClass("a");


    // END Document Ready
});





function openfancyFLV(myurl) {

//myurl="/contento/portals/0/media/videos/Remotecontrol_Optiflex_2_320.flv";
    jQuery.fancybox({
        'width': 500,
        'height': 360,
       
        'onStart': function() {
            this.height = 360;
            this.width = 500;
            flowplayer("fancybox-content", "/contento/js/flowplayer/flowplayer-3.2.7.swf", {
                clip: {
                    url: myurl,
                    autoPlay: true,
                    autoBuffering: true
                }
            })
           
        },
        'onComplete': function() {
        jQuery("#fancybox-content").height("360px");
        jQuery("#fancybox-content").width("500px");
        }

    });
    
}






function setflowplayer(mynode) {
    flowplayer("flowplayer", "/contento/js/flowplayer/flowplayer-3.2.7.swf", {
        clip: {
            url: mynode,
            autoPlay: true,
            autoBuffering: true
        },


        plugins: {
            controls: { "borderRadius": "0px",
                "timeColor": "#ffffff",
                "bufferGradient": "none", "slowForward": true,
                "backgroundColor": "rgba(0,0,0,0)", "volumeSliderGradient": "none",
                "slowBackward": false, "timeBorderRadius": 20, "time": true,
                "progressGradient": "none", "height": 26, "volumeColor": "rgba(155,205,3,1)",
                "tooltips": { "marginBottom": 5, "scrubber": true, "volume": true, "buttons": false },
                "fastBackward": false, "opacity": 1, "timeFontSize": 12, "bufferColor": "#a3a3a3", "border": "0px",
                "volumeSliderColor": "#ffffff", "buttonColor": "#ffffff", "mute": true,
                "autoHide": { "enabled": true, "hideDelay": 500, "mouseOutDelay": 500,
                    "hideStyle": "fade",
                    "hideDuration": 400, "fullscreenOnly": true
                },
                "backgroundGradient": "none", "width": "100pct",
                "display": "block", "sliderBorder": "1pxsolidrgba(128,128,128,0.7)",
                "buttonOverColor": "#ffffff", "fullscreen": true, "timeBgColor": "rgb(0,0,0,0)",
                "scrubberBarHeightRatio": 0.2, "bottom": 0, "stop": false,
                "sliderColor": "#000000",
                "zIndex": 1, "scrubberHeightRatio": 0.6,
                "tooltipTextColor": "#ffffff", "sliderGradient": "none", "timeBgHeightRatio": 0.8,
                "volumeSliderHeightRatio": 0.6, "name": "controls", "timeSeparator": "",
                "volumeBarHeightRatio": 0.2, "left": "50pct", "tooltipColor": "rgba(0,0,0,0)",
                "playlist": false, "durationColor": "rgba(155,205,3,1)", "play": true,
                "fastForward": true, "timeBorder": "0pxsolidrgba(0,0,0,0.3)",
                "progressColor": "rgba(155,205,3,1)", "scrubber": true,
                "volume": true,
                "builtIn": false, "volumeBorder": "1pxsolidrgba(128,128,128,0.7)"
            }
        },

        onLoad: function() {
            //alert("playerloaded");
        }
    });
}

