﻿var Videos = function() { var f = ''; var g = 0; var h = null; var j = { playerPath: '/_assets/flowplayer-3.1.5.swf' }; var k = { videosList: [], videoQueue: [], currentPlaylist: [] }; var l = function(b, c) { f = b; g = typeof c == "undefined" ? 0 : parseInt(c); $("a[id^='videoitem_']").unbind('click').click(function() { var a = $(this).attr('id').substring('videoitem_'.length); p(a) }); $("a[id^='item_']").unbind('click').click(function() { var a = $(this).attr('id').substring('item_'.length); p(a) }); flowplayer("preview", j.playerPath); m() }; var m = function() { var a = g; if (a > 0) { p(a) } }; var n = function(v) { if (v) { $('#stitle').html(v.Title); $('#sabstr').html(v.Description) } }; var o = function(v) { mvurl = f + v.VideoUrl; n(v); if (mvurl) { $(".vplay").hide(); $("#vo_" + v.VideoID).show(); flowplayer("preview", j.playerPath, { clip: { autoPlay: true, url: mvurl} }) } }; var p = function(b) { var c; if (!c) { var d = {}; h.invoke(b + '/GetVideoByID', d, r, function(a) { alert(a.message) }) } else { o(c, b) } }; var r = function(a) { k.videosList.push(a); o(a) }; var s = function(a, b) { for (var i = 0; i < k.videoQueue.length; i++) { if (videoQueue[i].id == a) return } var c = '/ajaxData.ashx' + '?qId=video&id=' + a; $.ajax({ url: mccUtils.Home.ajax_url, type: 'GET', data: 'qId=video&id=' + a, dataType: 'json', success: y }) }; var t = function(a) { for (var i = 0; i < k.videoQueue.length; i++) { if (k.videoQueue[i].id == a) { k.videoQueue.splice(i, 1); k.currentPlaylist.splice(i, 1); mccUtils.Tools.Set_Cookie('mcc_video_playlist', k.currentPlaylist.join(";")); return } } }; var u = function() { document.getElementById("queue").style.left = '0px' }; var w = function() { document.getElementById("queue").style.left = '-504px' }; var x = function(a) { var b = "ajaxData.ashx?qId=video&id=" + a; $.get(b, y) }; var y = function(a) { if (a) { var b = document.createElement("li"); if (!k.videoQueue) { k.videoQueue = new Array() } var c = '/imageThumb.ashx' + '?uuid=' + a.id + '&w=130&h=100'; var d = { id: a.id, author: a.author, description: a.description, duration: a.duration, file: a.file, link: a.link, image: c, start: a.start, title: a.title, type: a.type }; var e = '<div style="position:relative;"><a href="javascript:void(0);" vfile="' + a.file + '" vid="' + a.id + '" onclick="Play(this);return false;"><img border="0" src="' + c + '" /></a>'; e += '<div style="position:absolute;bottom:0;right:0;padding:2px;background-color:#eaeaea;"><a  vid="' + a.id + '"  href="javascript:void(0);" onclick="Remove(this)">remove</a></div></div>'; b.setAttribute('vid', a.id); b.innerHTML = e; document.getElementById("queue").appendChild(b); k.videoQueue.push(d); k.currentPlaylist.push(d.id); mccUtils.Tools.Set_Cookie('mcc_video_playlist', k.currentPlaylist.join(";")) } }; var z = function(a) { var b = $(a).attr('vfile'); if (b) { o(b) } }; var A = function(a) { var b = $(a).attr('vid'); if (b) { t(b); var q = '#queue > li[vid=' + b + ']'; var c = $(q)[0]; c.parentNode.removeChild(c) } }; return { Init: function(a, b, c) { h = new serviceProxy(a); l(b, c) } } } ();
