/*
*	OneScreen Inc.
*	LightBox 0.3
*	using Player 1.7 
*/
(function(){if(window.com){if(!window.com.onescreen)window.com.onescreen={}}else window.com={onescreen:{}};window.com.onescreen.lightbox={}})();
com.onescreen.lightbox.init=function(a){var i=document.createDocumentFragment(),k=document.createElement("DIV"),h=document.createElement("DIV"),c=document.createElement("DIV"),b=document.createElement("DIV"),o=document.createElement("DIV"),l=document.createElement("DIV"),m=document.createElement("DIV"),e=document.createElement("DIV"),f=document.createElement("DIV"),j=document.createElement("DIV"),d=document.createElement("DIV"),g=document.createElement("DIV"),r=document.createElement("DIV"),q=document.createElement("DIV"),
s=document.createElement("DIV");k.setAttribute("id","os_lb_shader");h.setAttribute("id","os_lb_box");r.setAttribute("id","companion-300X250");q.setAttribute("id","companion_wrap");c.setAttribute("id","os_lb_innerb");b.setAttribute("id","os_lb_player");l.setAttribute("id","os_lb_scroller_outter");m.setAttribute("id","os_lb_scroller_inner");d.setAttribute("id","os_lb_controls");e.setAttribute("id","os_lb_prev");f.setAttribute("id","os_lb_next");j.setAttribute("id","os_lb_closebox");g.setAttribute("id",
"os_lb_titlebar");s.setAttribute("id","os_lb_pages");j.innerHTML="[ X ] CLOSE";i.appendChild(k);c.appendChild(b);q.appendChild(r);l.appendChild(m);d.appendChild(f);d.appendChild(s);d.appendChild(e);o.appendChild(l);o.appendChild(d);c.appendChild(o);h.appendChild(c);c.appendChild(q);c.appendChild(j);c.appendChild(g);i.appendChild(h);$(document.body).append(i);i={div_id:"os_lb_player",width:576,height:419};a.player_def&&$.extend(a.player_def,i);var i=new com.onescreen.player.init(a.player_def),n=new com.onescreen.lightbox.Display(i,
a.xml),p=new com.onescreen.Generator(a.xml,5),t=window.setInterval(function(){p.thumbs&&(window.clearInterval(t),$(p.thumbs).each(function(d){n.addThumb(p.thumbs[d])}),$("."+a.link_class).click(function(d){var g=$(this).attr("id").substr(a.id_prefix.length);p&&n.show(g,d)}),n.setPagination(1,p.pages))},300);return this};var g_thumbs;function endVideo(a){g_thumbs[a]&&$("#"+g_thumbs[a]).trigger("click")}
com.onescreen.lightbox.Display=function(a,i){var k=[];g_thumbs=k;var h=$("#os_lb_box"),c=$("#os_lb_shader"),b=$("#os_lb_scroller_outter"),o=$("#os_lb_scroller_inner"),l=$("#os_lb_pages"),m=0,e=1,f=function(){return"Page "+e+" / "+m};$("#os_lb_prev").click(function(){b.animate({scrollTop:"-="+b.css("height")},"fast");1!=e&&e--;l.text(f);1==e?$(this).css("visibility","hidden"):$(this).css("visibility","visible");$("#os_lb_next").css("visibility","visible")});$("#os_lb_next").click(function(){e!=m&&
(b.animate({scrollTop:"+="+b.css("height")},"fast"),e++,l.text(f));e==m?$(this).css("visibility","hidden"):$(this).css("visibility","visible");$("#os_lb_prev").css("visibility","visible")});$("#os_lb_closebox").click(function(){document.getElementById(a.did).innerHTML="";c.css("display","none");h.css("display","none");try{a.pause("os_lb_player",!1)}catch(d){}document.getElementById("companion-300X250").innerHTML="";$("#os_lb_prev").css("visibility","hidden");$("#os_lb_next").css("visibility","visible");
e=1;l.text(f)});this.show=function(d,g){if(0==k.length)throw"OS Lightbox: No movies found. Check the XML source and try again.";if(!k[d])throw"OS Lightbox: No movie at index '"+d+"'. Check the number at the end of the prefix id and try again.";var a=void 0!==document.height?document.height:document.body.scrollHeight;if(document.height)a=document.height;else if(document.documentElement.scrollHeight)a=document.documentElement.scrollHeight;else if(document.body.scrollHeight)a=document.body.scrollHeight;
var e=(g||window.event).clientY,f;"undefined"!=typeof window.innerWidth?f=window.innerHeight+window.pageYOffset:"undefined"!=typeof document.documentElement&&"undefined"!=typeof document.documentElement.clientWidth&&0!=document.documentElement.clientWidth?f=document.documentElement.clientHeight:(document.getElementsByTagName("body"),f=document.getElementsByTagName("body")[0].clientHeight+document.body.scrollTop);var j=e+(window.pageYOffset?window.pageYOffset:document.body.scrollTop)+490;j>f&&(e-=
j-f);f=window.pageYOffset?window.pageYOffset:$(window).scrollTop();e=e+f+"px";c.css("height",a);0>parseInt(e)&&(e=50);h.css("top",e);c.css("display","block");h.css("display","block");$("#"+k[d]).trigger("click")};this.hide=function(){};this.setPagination=function(a,g){$("#os_lb_prev").css("visibility","hidden");e=a;m=g;l.text(f)};var j;this.addThumb=function(d){var g=document.createElement("DIV"),c=document.createElement("DIV");c.setAttribute("class","os_barth_info");g.setAttribute("id","os_lb_th_"+
d.ind);var b=document.createElement("IMG");b.setAttribute("src",d.src);b.style.display="inline-block";b.style.width="100px";b.style.height="56px";var h=document.createElement("SPAN"),n=document.createElement("SPAN");h.setAttribute("class","os_lb_ttl");h.innerHTML=d.title+"<br>";n.setAttribute("class","os_lb_tdesc");n.innerHTML="undefined"!==typeof d.desc&&80<d.desc.length?d.desc.substr(0,80)+" [...]":d.desc;g.appendChild(b);c.appendChild(h);c.appendChild(n);g.appendChild(c);g.setAttribute("class",
"os_barth");o.append(g);k.push(g.getAttribute("id"));$(g).bind({click:function(){j&&$(j).css("background-color","#191919");$(g).css("background-color","#323234");j=$(g);$(h);$("#os_lb_titlebar").html('Now Playing: <b style="font-size:12px;vertical-align:top">'+d.title+"</b>");a.setSrc(i);a.setAuto(!0);a.setInd(d.ind);a.go(a.did);var c=d.onPage,b=$("#os_lb_scroller_outter");b.scrollTop(b.height()*(c-1));e=c;l.text(f);1==e?($("#os_lb_prev").css("visibility","hidden"),$("#os_lb_next").css("visibility",
"visible")):e==m?($("#os_lb_prev").css("visibility","visible"),$("#os_lb_next").css("visibility","hidden")):($("#os_lb_prev").css("visibility","visible"),$("#os_lb_next").css("visibility","visible"))},mouseenter:function(){$(g)[0]!=j[0]&&$(g).css("background-color","#252525")},mouseleave:function(){$(g)[0]!=j[0]&&$(g).css("background-color","#191919")}});return g};return this};
com.onescreen.Generator=function(a,i){var k=a.split("/")[4],h=a.split("/")[5].split(".")[0],c={};$.ajax("http://data.1sfx.net/playlists/"+k+"/"+h+".jsonp",{dataType:"jsonp",cache:!0,jsonp:"jsoncallback",jsonpCallback:"playlist_"+h,success:function(b){if(b.items){var h=b.items,l=h.length;c.thumbs=[];c.title=b.name||"";c.pages=0!=i?Math.ceil(l/i):1;try{$(h).each(function(a){var f={},b=$(this)[0];f.id=b.index;f.ind=a;f.onPage=Math.floor(a/i)+1;f.title=b.title;f.src=b.thumbnails[3].url;f.desc=b.description?
b.description:"";c.thumbs.push(f)})}catch(k){}}else throw"OS Generator : The XML file '"+a+"' returned nothing. Please verify and try again.";}});return c};
