function ytTrim(a){var b=a.replace(new RegExp("^\\s+"),"");return b.replace(new RegExp("\\s+$"),"")}function ytStopDefaultAction(a){a.returnValue=false;if(typeof a.preventDefault!="undefined"){a.preventDefault()}}function ytGetInstances(){var a=new Array();var b=new Array();if(document.all){a=document.all}else{a=document.getElementsByTagName("div")}for(var i=0;i<a.length;i++){var c=new RegExp("ytplayerbox");if(c.test(a[i].className)){b[b.length]=a[i]}}return b}function ytAddLoadListener(a){if(typeof window.addEventListener!='undefined'){window.addEventListener('load',a,false)}else if(typeof document.addEventListener!='undefined'){document.addEventListener('load',a,false)}else if(typeof window.attachEvent!='undefined'){window.attachEvent('onload',a)}else{var b=window.onload;if(typeof window.onload!='function'){window.onload=a}else{window.onload=function(){b();a()}}}}function ytAttachEventListener(a,b,c,d){if(typeof a.addEventListener!="undefined"){a.addEventListener(b,c,d)}else if(typeof a.attachEvent!="undefined"){a.attachEvent("on"+b,c)}else{b="on"+b;if(typeof a[b]=="function"){var e=a[b];a[b]=function(){e();return c()}}else{a[b]=c}}return true}function ytPlayerBoxDraw(a,b,c){var d="480px";if(a=="normal"){d="480px"}else if(a=="wide"){d="640px"}if(b){b.style.width=d;b.innerHTML="<div id=\"ytapiplayer"+c+"\">"+"You need Flash player 8+ and JavaScript enabled to view this video."+"<\/div>"+"<h3 class=\"semantic\">Player Controls<\/h3>"+"<ul class=\"ytplayerbuttons\">"+"<li><a id=\"ytplaybut"+c+"\" href=\"/\">Play<\/a><\/li>"+"<li><a id=\"ytforwardbut"+c+"\" href=\"/\">Forward 20%<\/a><\/li>"+"<li><a id=\"ytbackbut"+c+"\" href=\"/\">Back 20%<\/a><\/li>"+"<li><a id=\"ytstopbut"+c+"\" href=\"/\">Stop<\/a><\/li>"+"<li><a id=\"ytvolupbut"+c+"\" href=\"/\">Volume Up<\/a><\/li>"+"<li><a id=\"ytvoldownbut"+c+"\" href=\"/\">Volume Down<\/a><\/li>"+"<li><a id=\"ytmutebut"+c+"\" href=\"/\">Mute<\/a><\/li>"+"<li><a id=\"ytloopbut"+c+"\" href=\"/\">Loop<\/a><\/li>"+"<\/ul>"+"<h4>Currently Playing: <span id=\"ytvidtitle"+c+"\"><\/span><\/h4>"+"<h4>Time: <span id=\"ytplayertime"+c+"\"><\/span><\/h4>"}}function ytPlayerInit(a,b,c,d){var e="480";if(b=="normal"){e="480"}else if(b="wide"){e="640"}var f=a[0].url;if(f){var g=document.getElementById("ytplaybut"+d);ytAttachEventListener(g,"click",function(){ytplay(d)},false);ytAttachEventListener(g,"click",ytStopDefaultAction,false);var h=document.getElementById("ytforwardbut"+d);ytAttachEventListener(h,"click",function(){ytforward(d)},false);ytAttachEventListener(h,"click",ytStopDefaultAction,false);var j=document.getElementById("ytbackbut"+d);ytAttachEventListener(j,"click",function(){ytback(d)},false);ytAttachEventListener(j,"click",ytStopDefaultAction,false);var k=document.getElementById("ytstopbut"+d);ytAttachEventListener(k,"click",function(){ytstop(d)},false);ytAttachEventListener(k,"click",ytStopDefaultAction,false);var l=document.getElementById("ytvolupbut"+d);ytAttachEventListener(l,"click",function(){ytvolup(d)},false);ytAttachEventListener(l,"click",ytStopDefaultAction,false);var m=document.getElementById("ytvoldownbut"+d);ytAttachEventListener(m,"click",function(){ytvoldown(d)},false);ytAttachEventListener(m,"click",ytStopDefaultAction,false);var n=document.getElementById("ytmutebut"+d);ytAttachEventListener(n,"click",function(){ytmute(d)},false);ytAttachEventListener(n,"click",ytStopDefaultAction,false);var o=document.getElementById("ytloopbut"+d);ytAttachEventListener(o,"click",function(){ytloop(d)},false);ytAttachEventListener(o,"click",ytStopDefaultAction,false);ytPlayerLoad(f,e,d);var p=document.getElementById("ytvidtitle"+d);var q=document.createTextNode("\""+a[0].text+"\"");p.appendChild(q)}if(a.length>1){var r=document.createElement("h3");r.className="playlisth";var s=document.createTextNode("Video Play List");r.appendChild(s);c.appendChild(r);var t=document.createElement("ul");t.className="ytplaylistl";c.appendChild(t);for(var i=0;i<a.length;i++){var u=document.createElement("li");if(i%2){u.className="ytlisteven"}else{u.className="ytlistodd"}var v=document.createElement("a");v.href="/";v.id=a[i].url;var w=document.createTextNode(a[i].text);v.appendChild(w);u.appendChild(v);t.appendChild(u);v.onclick=function(){ytLoadNewVideo(d,this.id,this.firstChild.nodeValue)};ytAttachEventListener(v,"click",ytStopDefaultAction,false)}}}function ytPlayerDispatch(a,b){if(a){var c=new Array();var d="normal";var e=/^ytmovieurl:.*$/;var f=/^ytmovieurl:(.*)$/;var g=/^ytplayeraspect:.*$/;var h=/^ytplayeraspect:(.*)$/;for(var i=0;i<a.childNodes.length;i++){if(a.childNodes[i].className){if(e.test(a.childNodes[i].className)){var j=a.childNodes[i].className;var k=ytTrim(j.replace(f,"$1"));var l=ytTrim(a.childNodes[i].firstChild.nodeValue);var m={url:k,text:l};c.push(m)}if(g.test(a.childNodes[i].className)){var j=a.childNodes[i].className;d=ytTrim(j.replace(h,"$1"))}}}ytPlayerBoxDraw(d,a,b);ytPlayerInit(c,d,a,b);setInterval(function(){updateButtonState(b)},250);setInterval(function(){updateTime(b)},500)}}ytAddLoadListener(function(){var a=ytGetInstances();for(var i=0;i<a.length;i++){ytPlayerDispatch(a[i],i)}});var ytplayer=new Array();function onYouTubePlayerReady(a){ytplayer.push(a)}function updateButtonState(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=document.getElementById("ytmutebut"+a);var d=document.getElementById("ytplaybut"+a);if(b.isMuted()){c.firstChild.nodeValue="Unmute"}else{c.firstChild.nodeValue="Mute"}if(b.getPlayerState()==1){d.firstChild.nodeValue="Pause"}if(b.getPlayerState()==2){d.firstChild.nodeValue="Play"}}}function prepTime(s){var a=Math.floor(s/3600);var b=Math.floor(s/60)-(a*60);var c=s-(a*3600)-(b*60);if(b<10)b="0"+b;if(c<10)c="0"+c;a=(a<1)?"":a+":";return a+b+":"+c}function updateTime(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=document.getElementById("ytplayertime"+a);var d=document.createTextNode(prepTime(Math.round(b.getCurrentTime()))+" of "+prepTime(Math.round(b.getDuration())));if(c.firstChild){var e=c.firstChild;e.parentNode.removeChild(e)}c.appendChild(d)}}var ytLoopInterval=new Array();function ytloop(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=document.getElementById("ytloopbut"+a);if(c.firstChild.nodeValue=="Loop"){c.firstChild.nodeValue="UnLoop";ytLoopInterval[a]=window.setInterval(function(){b.playVideo()},2000)}else{c.firstChild.nodeValue="Loop";clearInterval(ytLoopInterval[a])}}}function ytmute(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){if(b.isMuted()){b.unMute()}else{b.mute()}}}function ytvolup(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=b.getVolume();var d="0";if(c>=0){d="20"}if(c>=20){d="40"}if(c>=40){d="60"}if(c>=60){d="80"}if(c>=80){d="100"}b.setVolume(d)}}function ytvoldown(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=b.getVolume();var d="100";if(c<=100){d="80"}if(c<=80){d="60"}if(c<=60){d="40"}if(c<=40){d="20"}if(c<=20){d="0"}b.setVolume(d)}}function ytplay(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){if(b.getPlayerState()=="1"){b.pauseVideo()}else{b.playVideo()}}}function ytstop(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){b.pauseVideo();b.seekTo("0")}}function ytforward(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=b.getDuration();if(c>0){var d=Math.floor(c*.2)+b.getCurrentTime();if(d<c){b.seekTo(d)}else{b.seekTo(c)}}}}function ytback(a){var b=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(b.id)){var c=b.getDuration();if(c>0){var d=b.getCurrentTime()-Math.floor(c*.2);if(d>0){b.seekTo(d)}else{b.seekTo(0)}}}}function ytLoadNewVideo(a,b,c){var d=document.getElementById("thisytp"+a);if(new RegExp('^('+ytplayer.join('|')+')$').test(d.id)){d.loadVideoById(b,0);var e=document.getElementById("ytvidtitle"+a);if(e.firstChild){var f=e.firstChild;f.parentNode.removeChild(f)}var g=document.createTextNode(c);e.appendChild(g)}}function ytPlayerLoad(a,b,c){var d="thisytp"+c;var e="ytapiplayer"+c;var f={allowScriptAccess:"always",allowFullScreen:"true",cc_load_policy:"1",hd:"1"};var g={id:d};swfobject.embedSWF("http://www.youtube.com/v/"+a+"&enablejsapi=1&playerapiid="+d+"&hd=1&rel=0&fs=1",e,b,"384","8",null,null,f,g)}
