﻿function PlayList()
{
    var tbTotal = new Number();
    var tbByAnimationMax = new Number();
    var tbByAnimation = 7;
    var tbWidth = 106;
    var tbMarginR = 10;
    var tbParentWidth = 810;
    var presentPosition = 0;
    var presentAnimation = 1;
    var speedAnimation = 1000;

    this.Initialize = function() 
    {
        tbTotal = $('#boxPlaylist a').size();
        tbByAnimationMax = Math.ceil(tbTotal / tbByAnimation);
        $('#boxPlaylist .scroll').css({ width: ((tbWidth + tbMarginR) * tbTotal) + 'px' });
        $('.thumb').show();
    }

    this.Animate = function(pType) 
    {
        if (pType == 'proximo' && presentAnimation < tbByAnimationMax) 
        {
            presentAnimation++;
            presentPosition = presentPosition - tbParentWidth;
            $('#boxPlaylist .scroll').animate({ marginLeft: presentPosition + "px" }, speedAnimation);
        }
        else if (pType == 'anterior' && presentAnimation > 1) 
        {
            presentAnimation--;
            presentPosition = presentPosition + tbParentWidth;
            $('#boxPlaylist .scroll').animate({ marginLeft: presentPosition + "px" }, speedAnimation);
        }

    }
    
    this.EmbedPlayer = function(pYoutubeCode) {
        var player = new String();
        player = '<object width="396" height="262">';
        player += '<param name="movie" value="http://www.youtube.com/v/' + pYoutubeCode + '&hl=pt_BR&fs=1&rel=0"></param>';
        player += '<param name="allowFullScreen" value="true"></param>';
        player += '<param name="allowscriptaccess" value="always"></param>';
        player += '<embed src="http://www.youtube.com/v/' + pYoutubeCode + '&hl=pt_BR&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="396" height="262"></embed>';
        player += '</object>';

        $("#playerVideo").html(player);
        $("#ctl00_BomBril_fldUrl").val(window.location.host + "/Video/" + pYoutubeCode);
        
    }

    this.ClickEmbedPlayer = function(pYoutubeCode) 
    {
        document.location.href = "http://localhost:11075/Video/" + pYoutubeCode;
        this.EmbedPlayer(pYoutubeCode);
    }
}
