var viewer=function(){var k,AE,X,p,m,f,v,j=false,w,A,a,W,i,r,V,x,H,n,c,C,t,N,U=null,I,e,M,h,F,Y=false,G=false;
function b(){var AH,AG;
if(Ext.isIE){AH=document.documentElement.clientWidth;
AG=document.documentElement.clientHeight;
if(AH===0){AH=document.body.clientWidth;
AG=document.body.clientHeight
}}else{AH=window.innerWidth;
AG=window.innerHeight
}return{width:AH,height:AG}
}function o(AH){var AJ=window.location.search.substring(1),AK=AJ.split("&");
for(var AI=0,AG=AK.length;
AI<AG;
AI++){var AL=AK[AI].split("=");
if(AL[0]===AH){return AL[1]
}}}function D(AG){AG.select();
if(window.clipboardData){window.clipboardData.setData("text",AG.value)
}}function AD(AG){AG.value=AG.value.replace(/[^\d]/g,"")
}function R(){var AG=b();
x.setSize(AG.width-8,AG.height-8)
}function y(){var AH=H.items.items;
for(var AI=0,AG=AH.length;
AI<AG;
AI++){if(AH[AI].needsLesson){AH[AI].setDisabled(!j)
}}}function J(AH){var AG="toolbar,status,menubar,scrollbars,resizable,location,height=600,width=800";
window.open(f[AH].url,"newWin",AG);
return false
}function u(){var AK='<div><ul class="resources">';
for(var AJ=0,AG=f.length;
AJ<AG;
AJ++){var AI=f[AJ];
var AH=AI.size?" "+AI.size:"";
AK+="<li onclick=\"viewer.showResource('"+AJ+'\');" title="'+AI.title+'">\n<img src="'+AI.icon+'" alt="'+AI.alt+'" /><span>'+AI.link+AH+'</span><div class="filler">&nbsp;</div></li>'
}return AK+"</ul></div>"
}function P(AH,AG){d(AH)
}function d(AG){y();
l(AG);
e.setDisabled(!AG.leaf);
w=AG
}function Z(AH){var AG=AH.findChild("id",AE);
if(AG){d(AG);
AG.select()
}}function B(AH){var AI=Ext.util.JSON.decode(AH.responseText),AG=new Ext.FormPanel({frame:true,bodyStyle:"padding:5px 5px 0",width:350,defaults:{width:230,readOnly:true},defaultType:"textfield",items:[{fieldLabel:"Title",value:AI.text},{xtype:"textarea",fieldLabel:"Description",value:AI.description},{fieldLabel:"Author",value:AI.author},{fieldLabel:"Copyright",value:AI.copyright},{fieldLabel:"Rating",value:AI.rating},{fieldLabel:"Created",value:AI.created},{fieldLabel:"ID",value:AI.id}]});
var AJ=H.getItem("about");
AJ.add(AG)
}function l(AH){var AG=I.getForm();
AG.findField("btitle").setValue(AH.attributes.heading||"");
AG.findField("bdescription").setValue(AH.attributes.description||"");
AG.findField("bauthor").setValue(AH.attributes.author||"");
AG.findField("bcopyright").setValue(AH.attributes.copyright||"");
AG.findField("brating").setValue(AH.attributes.rating||"");
AG.findField("bcreated").setValue(AH.attributes.created||"");
AG.findField("btype").setValue(AH.attributes.nodetype||"");
AG.findField("bid").setValue(AH.id||"")
}function AF(AG){if(AG.hasChildNodes()){AG.lastChild.ensureVisible()
}AG.ensureVisible()
}function q(){var AG=document.getElementById("metadata-master").innerHTML;
document.getElementById("metadata-master").innerHTML="";
return AG
}function S(){window.location.href=window.location.href.replace(/([&?])(id=[0-9]+)/,"$1id="+w.id)
}function K(AH,AG){if(AH.leaf){w=AH;
S()
}}function s(){var AH,AG;
rootid=m.split("/")[1];
AH=new Ext.tree.AsyncTreeNode({text:"root",id:rootid});
AG=new Ext.tree.TreePanel({animate:true,autoScroll:true,containerScroll:true,loader:new Ext.tree.TreeLoader({url:v,requestMethod:"GET",baseParams:{articleaction:"ajax",method:"getchildren"}}),root:AH,rootVisible:false});
AH.expand(false,false);
AG.on("click",P);
AG.on("dblclick",K);
AG.on("expandnode",AF);
AG.on("load",function(AI){AG.expandPath(m);
Z(AI)
});
return AG
}function E(AI){var AK,AJ,AG,AH;
AK=(f.length!==0||Y);
AJ=new Ext.Panel({region:"north",html:'<div id="player2" style="width:100%; height:100%"></div>',width:200,height:250,split:false,margins:"3 0 3 3",cmargins:"3 3 3 3"});
AG=new Ext.Panel({title:"Resources",region:"center",autoScroll:true,html:u()});
if(AK){AH=new Ext.Panel({layout:"border",region:"west",width:200,collapsible:false,margins:"3 0 3 3",cmargins:"3 3 3 3",floatable:false,split:true,items:AI?[AJ,AG]:[AG]})
}c=new Ext.Panel({layout:"fit",region:"center",collapsible:false,margins:"3 0 3 3",cmargins:"3 3 3 3",floatable:false,html:'<div id="player1" style="width:100%; height:100%"></div>'});
n=shareform.create(k,url,AE);
C=new Ext.Panel({layout:"fit",region:"center"});
e=new Ext.Button({cls:"x-btn-text-icon",scale:"large",height:40,width:100,text:"&nbsp;&nbsp;Play&nbsp;&nbsp;",iconAlign:"left",icon:"template/lessonframe/images/play.png",disabled:!j,listeners:{click:function(){S()
}}});
I=new Ext.FormPanel({region:"center",frame:true,bodyStyle:"padding:5px 5px 0",defaults:{width:230,readOnly:true},defaultType:"textfield",items:[{fieldLabel:"Title",id:"btitle"},{xtype:"textarea",fieldLabel:"Description",id:"bdescription"},{fieldLabel:"Author",id:"bauthor"},{fieldLabel:"Copyright",id:"bcopyright"},{fieldLabel:"Rating",id:"brating"},{fieldLabel:"Created",id:"bcreated"},{fieldLabel:"Type",id:"btype"},{fieldLabel:"ID",id:"bid"}]});
t=new Ext.Panel({region:"east",split:true,layout:"border",width:370,items:[I,{xtype:"toolbar",region:"south",height:45,items:e}]});
header=new Ext.Panel({region:"north",frame:"true",height:30,autowidth:true,items:{xtype:"panel",region:"center",html:'<div class="header"><div class="left"><b>Our Player'+(j?"  -  Playing: ["+AE+"] "+k:"")+'</b></div><div class="right">'+(r&&G?'<span width="32px" class="float-right"><img src="template/lessonframe/images/logout.png" alt="logout" onclick="viewer.logout();" title="Logout" /></span>':"")+(A?"":'<span width="32px" class="float-right"><img src="template/lessonframe/images/fullscreen.png" alt="fullscreen" onclick="viewer.openFullscreen();" title="Open fullscreen" /></span>')+"</div></div>"}});
N=[{title:"Browse",id:"browse",needsLesson:false,layout:"border",items:[C,t],listeners:{activate:function(){if(U===null){U=s();
C.add(U)
}}}},{title:"Video",id:"video",disabled:!j,layout:"border",items:AK?[AH,c]:c},{title:"Now Playing",disabled:!j,id:"about",layout:"fit"},{title:"Sharing",disabled:!j,layout:"fit",html:' <div id="sharediv" style="width:100%; height:100%"></div>',listeners:{activate:function(){if(!n.rendered){n.render("sharediv")
}}}},{title:"Our Lesson",needsLesson:false,html:'<iframe src="http://www.ourlesson.co.uk/advert" width="100%" height="100%" scrolling="no" style="border:none;"></iframe>'}];
if(a){N.shift()
}H=new Ext.TabPanel({region:"center",margins:"3 3 3 0",activeTab:(j||a)?"video":"browse",items:N});
x=new Ext.Viewport({plain:true,layout:"border",items:[header,H]});
Ext.Ajax.request({success:B,url:v,requestMethod:"GET",params:{articleaction:"ajax",method:"getmetadata",node:AE}});
return x
}function g(){if(j){if(X){h=X;
F=p
}else{h=p;
F=null
}}Y=!!F;
x=E(Y);
if(j){players.setGoogleAnalyticsTracker(window.pageTracker);
players.load(h,F)
}x.on("beforeclose",function(){$f("*").each(function(){if(this.isLoaded()){this.unload()
}});
window.onbeforeunload=function(){};
return true
});
x.show();
R()
}function O(AH){var AG=window.open(W+(W.indexOf("?")===-1?"?":"&")+"articleaction=openid_popup&openid_url="+encodeURIComponent(AH),"openid_popup","width=450,height=500,location=1,status=1,resizable=yes,scrollbars=yes");
var AI=getCenteredCoords(450,500);
AG.moveTo(AI[0],AI[1])
}function AB(){var AG=window.location.href.split("?");
var AH="?articleaction=extlogin&returnarticleid="+V;
if(AG.length===2){AH=AH+"&"+AG[1]
}window.location.href=W+AH
}function AC(){window.location.reload()
}function T(){Ext.Ajax.request({url:W,method:"GET",params:{articleaction:"logout"},success:AC,failure:AC})
}function Q(AH){var AG=Ext.util.JSON.decode(AH.responseText);
if(r&&AG.fail&&AG.fail=="security"){AB()
}else{url=AG.url;
k=AG.title;
j=AG.islesson;
m=AG.articlepath;
X=AG.screencam;
p=AG.webcam;
f=AG.additional_files;
g()
}}function AA(AG){Ext.Ajax.request({success:Q,url:v,requestMethod:"GET",params:{targeturl:url,articleaction:"ajax",method:"getlessondata",node:AE}})
}function z(AK,AI,AG,AH,AJ,AL,AM,AN){url=AK;
AE=AI;
v=url;
W=AG;
A=AH==="true";
a=AJ==="true";
r=AL==="true";
V=AM;
G=AN;
AA()
}function L(){if(j){players.fullscreenPause()
}window.open(window.location.href+(url.indexOf("?")==-1?"?":"&")+"fullscreen=true","_blank","status=no,toolbar=no,menubar=no,location=no,directories=no, resizable=yes"+a?"&nobrowse=true":"")
}return{init:z,showResource:J,openFullscreen:L,logout:T}
}();