// Copyright 2006-2009, Centova Technologies Inc.; unauthorized use prohibited
function vv0(app){browser.register_handler('mousedown',this.vv1);browser.register_handler('mouseup',this.vv2);browser.register_handler('mousemove',this.vv3);this.application=app;this.vv4=false;this.vv5=false;this.vv6=null;this.dragelement=null;this.vv7=null;this.vv8=false;this.vv9=false;this.vva=0;this.vvb=0;this.vvc=false;this.vvd=0;this.vve=0;this.disabled=false;this.vvf=5;this.vvg();window.dragdrop=this;}
vv0.prototype.vv3=function(e){window.dragdrop.mouse_move_event={'clientX':e.clientX,'clientY':e.clientY}
if(!window.dragdrop.vv9){window.dragdrop.fire_mouse_move();return;}
if(window.dragdrop.vvh){return;}
window.dragdrop.vvh=true;setTimeout('window.dragdrop.fire_mouse_move()',50);}
vv0.prototype.fire_mouse_move=function(){this.vvh=false;this.mouse_move(this.mouse_move_event);}
vv0.prototype.mouse_move=function(e){var dd=window.dragdrop;if(dd.disabled)return;if(dd.vv4&&dd.vv8&&!dd.vv5){var dX=Math.abs(e.clientX-dd.vvd);var dY=Math.abs(e.clientY-dd.vve)
if(dX>=dd.vvf||dY>=dd.vvf){dd.vv5=true;dd.dragelement=null;var o=dd.vv6;var dragdata=o.ondraggrab(o);dd.vv9=(dragdata!=false)&&(dragdata!=null);dd.vv7=dragdata;dd.vva=e.clientX;dd.vvb=e.clientY;if(dd.vv9&&dragdata.dragelement){dd.dragelement=dragdata.dragelement;dd.dragelement_dispose=dragdata.dragelement_dispose;dd.dragelement_class=dd.dragelement.className;}
if(dd.vv9)dd.vvi(dd.vv7.dataclass,dd.vv7.offset_top,dd.vv7.offset_left);dd.vvj=browser.windowScrollPos();}}
if(dd.vv9){var sp=dd.vvj;var vvk=dd.vvl(e.clientX+sp.x,e.clientY+sp.y,dd.vv7.dataclass)
var candrop=(vvk!=null);if(vvk!=dd.vvm){if(dd.vvm&&dd.vvm.ondragzoneexit)dd.vvm.ondragzoneexit(dd.vvm,dd.vv7);if(candrop&&vvk.ondragzoneenter){if(vvk.ondragzonetest)candrop=vvk.ondragzonetest(vvk,dd.vv7);if(candrop)vvk.ondragzoneenter(vvk,dd.vv7);}
dd.vvm=vvk;}
if(dd.candrop!=candrop){if(dd.dragelement!=null){var vvn="";if(candrop){if(dd.vv7.dragelement_class_candrop)vvn=dd.vv7.dragelement_class_candrop;}else{if(dd.vv7.dragelement_class_cantdrop)vvn=dd.vv7.dragelement_class_cantdrop;}
dd.dragelement.className=dd.dragelement_class+' '+vvn;}
dd.candrop=candrop;}
var o=dd.vv6;if(typeof o.ondragmove=='function')o.ondragmove(o);if(dd.dragelement!=null){var el=dd.dragelement;var pX=parseInt(el.style.left);var pY=parseInt(el.style.top);var dX=e.clientX-dd.vva;var dY=e.clientY-dd.vvb
el.style.left=(pX+dX)+'px';el.style.top=(pY+dY)+'px';dd.vva=e.clientX;dd.vvb=e.clientY;}}}
vv0.prototype.vv1=function(e){var dd=window.dragdrop;if(dd.disabled)return;window.dragdrop.mouse_move_started=false;var target=e.target;while(target&&!dd.vv8){dd.vv8=(target&&target.vv8&&(typeof target.ondraggrab=='function'))?true:false;if(dd.vv8)break;target=target.parentNode;}
dd.vv6=target;dd.vv4=true;dd.vvd=e.clientX;dd.vve=e.clientY;}
vv0.prototype.vv2=function(e){var dd=window.dragdrop;if(dd.disabled)return;if(dd.vv9){document.body.style.cursor='auto';var candrop=dd.candrop;if(dd.vvm&&dd.vvm.ondragzoneexit)dd.vvm.ondragzoneexit(dd.vvm,dd.vv7);var o=dd.vv6;if(typeof o.ondragdone=='function')o.ondragdone(o,e.target,candrop);if(candrop){var sp=browser.windowScrollPos();sp.x+=e.clientX;sp.y+=e.clientY;var cp=browser.clickPos(e)
var dropzone=dd.vvm;if(dropzone.ondragrelease)dropzone.ondragrelease(dropzone,dd.vv7,cp);}
if((dd.dragelement!=null)&&(dd.dragelement_dispose)){document.body.removeChild(dd.dragelement);dd.dragelement=null;}}
dd.vv6=null;dd.dragelement=null;dd.vv7=null;dd.vv9=false;dd.vv4=false;dd.vv5=false;dd.vvm=null;dd.vv8=false;dd.candrop=false;}
vv0.prototype.vvo=function(zoneelement,acceptedclass){if(!this.dropzones[acceptedclass])this.dropzones[acceptedclass]=new Array();this.dropzones[acceptedclass].push(zoneelement);}
vv0.prototype.vvg=function(){this.dropzones=new Array();}
vv0.prototype.vvi=function(itemclass,offsettop,offsetleft){if(!this.dropzones[itemclass])return;if(!offsetleft)offsetleft=0;if(!offsettop)offsettop=0;var s='';for(var i=0;i<this.dropzones[itemclass].length;i++){var p=layer_get_pos(this.dropzones[itemclass][i]);p.y+=this.dropzones[itemclass][i].scrollTop;p.x+=this.dropzones[itemclass][i].scrollLeft;if(this.dropzones[itemclass][i].dragcheckparentscroll&&!IE4){var pn=this.dropzones[itemclass][i].parentNode;if(pn){p.y-=pn.scrollTop;p.x-=pn.scrollLeft;}}
this.dropzones[itemclass][i].vvp=p.x-offsetleft;this.dropzones[itemclass][i].vvq=p.y-offsettop;this.dropzones[itemclass][i].vvr=p.x-offsetleft+parseInt(this.dropzones[itemclass][i].offsetWidth);this.dropzones[itemclass][i].vvs=p.y-offsettop+parseInt(this.dropzones[itemclass][i].offsetHeight)}}
vv0.prototype.vvl=function(x,y,itemclass){if(!this.dropzones[itemclass])return;if(this.vvc){var vvt=this.dropzones[itemclass].length-1;var vvu=0;var vvv=-1;}else{var vvt=0;var vvu=this.dropzones[itemclass].length-1;var vvv=1;}
for(var i=vvt;this.vvc?(i>=vvu):(i<=vvu);i+=vvv){var p=layer_get_pos(this.dropzones[itemclass][i]);var dz=this.dropzones[itemclass][i];if(x>=dz.vvp&&x<dz.vvr&&y>=dz.vvq&&y<=dz.vvs)return dz;}
return null;}
function vvw(name){this.name=name;}
vvw.prototype.vvx=function(){document.body.style.overflowX='hidden';window.vvy=false;this.vvz(false);this.vvA(true);window.rpc=new RPCClient('rpc.php','window.rpc','playlist');window.rpc.set_callback("playlist.list_all",this.name+".playlists.set");window.rpc.set_callback("playlist.get_tracks",this.name+".playlist.set");window.rpc.set_callback("playlist.set_tracks",this.name+".playlist.tracks_set");window.rpc.set_callback("playlist.add",this.name+".playlists.add_complete");window.rpc.set_callback("library.get_artists",this.name+".artists.set");window.rpc.set_callback("library.get_albums",this.name+".albums.set");window.rpc.set_callback("library.get_tracks",this.name+".tracks.set");window.rpc.set_callback("library.get_genres",this.name+".set_genres");window.rpc.set_callback("library.get_folders",this.name+".folders.add");window.rpc.set_callback("library.search",this.name+".set_search_results");window.rpc.set_callback("library.get_track_details",this.name+".tracks.set_track_details");this.playlistsmenu=new vvB(this,'playlistsmenu');this.playlistsmenu.vvx();this.playlists=new vvC(this,'playlists');this.playlists.vvx();this.playlists.vvD(this.playlistsmenu,window.playlists_menu_items);this.artistmenu=new vvB(this,'artistmenu');this.artistmenu.vvx();this.artists=new vvE(this,'artists');this.artists.vvx();this.artists.vvD(this.artistmenu,window.artist_menu_items);this.albummenu=new vvB(this,'albummenu');this.albummenu.vvx();this.albums=new vvF(this,'albums');this.albums.vvx();this.albums.vvD(this.albummenu,window.album_menu_items);this.trackmenu=new vvB(this,'trackmenu');this.trackmenu.vvx();this.tracks=new vvG(this,'tracks');this.tracks.vvx();this.tracks.vvD(this.trackmenu,window.track_menu_items);this.playlist=new vvH(this,'playlist');this.playlist.vvx();this.folders=null;this.tip=new vvI(this,'tip');this.tip.vvx('tipbox');this.popupmenu=new vvB(this,'popupmenu');this.popupmenu.vvx();window.vvJ=new vv0(null);window.vvJ.vvc=true;this.playlists.vvK();if(window.showreindextip){this.tip.vvL(window.loctext.reindextip_title_text,window.loctext.reindextip_text);}}
vvw.prototype.show_menu=function(anchorelement){if(!this.generated_medialib_menu){this.generated_medialib_menu=this.popupmenu.vvM(window.medialib_menu_items);this.vvN(this.vvO);}
this.popupmenu.show_menu(anchorelement,this.generated_medialib_menu);}
vvw.prototype.vvP=function(){var genre=0;var sel=document.getElementById('genres');if(sel&&sel.options)genre=sel.options[sel.selectedIndex].value;return genre;}
vvw.prototype.vvQ=function(){window.status='';}
vvw.prototype.set_status=function(obj,newstatus){obj.onmouseout=window.cclibrary.vvQ;obj.title=newstatus;window.status=newstatus;return true;}
vvw.prototype.vvR=function(vvS,vvT,issaving){if(window.vvy==vvS)return;var shading=document.getElementById('panelshaded');var loading=document.getElementById('panelloading');var savemsg=document.getElementById('panelloading_save');var loadmsg=document.getElementById('panelloading_load');savemsg.style.display=issaving?'':'none';loadmsg.style.display=issaving?'none':'';window.vvy=vvS;if(window.vvy){shading.className=vvT+'cover panelloading';loading.className=vvT+'cover panelloading';}else{shading.className=vvT+'cover panelnotloading';loading.className=vvT+'cover panelnotloading';}}
vvw.prototype.set_genres=function(genres){var sel=document.getElementById('genres');sel.options.length=0;sel.options[sel.options.length]=new Option(window.loctext.all_genres_text,0);for(var i=0;i<genres.length;i++){sel.options[sel.options.length]=new Option(genres[i].name,genres[i].id);}
sel.disabled=false;}
vvw.prototype.set_search_results=function(keyword,field,artists,albums,tracks){this.artists.set(artists,'',true);this.albums.set('',albums,'',true);this.tracks.set('',tracks,'');}
vvw.prototype.search=function(){var keyword=document.getElementById('search_keyword').value;var field='all';var sel=document.getElementById('search_type');if(sel&&sel.options)field=sel.options[sel.selectedIndex].value;if(this.vvO==1){this.playlist.vvU(keyword,field);}else{if(!keyword.length){this.artists.vvK();return;}
this.vvR(true,'artists');this.vvR(true,'albums');this.vvR(true,'tracks');window.rpc.execute('library.search',keyword,field,this.vvP());}}
vvw.prototype.vvV=function(){var el=document.getElementById('search_keyword');if(el)el.value='';var sel=document.getElementById('search_type');if(sel)sel.selectedIndex=0;sel=document.getElementById('genres');if(sel)sel.selectedIndex=0;}
vvw.prototype.vvN=function(pageid){var pages=new Array('librarypage','playlistpage','folderpage');var visiblepage='';this.vvV();var searchel=document.getElementById('searchform');var genreel=document.getElementById('genres');var importm3uel=document.getElementById('importm3u');var showcovers=document.getElementById('albumcovertoggle');switch(pageid){case 2:visiblepage='folderpage';searchel.style.display='none';if(importm3uel)importm3uel.set_disabled(true);if(showcovers)showcovers.set_disabled(true);break;case 1:visiblepage='playlistpage';genreel.style.display='none';searchel.style.display='';if(importm3uel)importm3uel.set_disabled(false);if(showcovers)showcovers.set_disabled(true);break;default:case 0:visiblepage='librarypage'
searchel.style.display='';genreel.style.display='';if(importm3uel)importm3uel.set_disabled(true);if(showcovers)showcovers.set_disabled(false);break;}
this.vvO=pageid;for(var p=0;p<pages.length;p++){var el=document.getElementById(pages[p]);if(!el)return false;el.style.display=(pages[p]==visiblepage)?'':'none';}}
vvw.prototype.vvW=function(playlistid){this.playlist.clear();this.vvN(1);this.artists.clear();this.albums.clear();this.tracks.clear();this.vvR(true,'playlist');this.playlist.vvK(playlistid);}
vvw.prototype.vvA=function(displayonly){if(this.library_type=='folder'){this.vvX(displayonly);}else{this.vvY(displayonly);}}
vvw.prototype.vvY=function(displayonly){if(displayonly){this.vvN(0);return;}
this.artists.clear();this.albums.clear();this.tracks.clear();this.vvN(0);this.playlist.clear();this.artists.vvK();}
vvw.prototype.vvX=function(displayonly){if(displayonly){this.vvN(2);return;}
this.artists.clear();this.albums.clear();this.tracks.clear();this.vvR(true,'folders');this.vvN(2);this.playlist.clear();this.folders.clear();this.folders.vvK();}
vvw.prototype.toggle_folder_view=function(el){var folderview=el.vvZ;if(folderview==this.folder_view)return;this.vvz(folderview);this.vvA(false);}
vvw.prototype.vvz=function(folderview){if(this.folder_view==folderview)return;this.folder_view=folderview;if(this.folder_view){if(!this.folders){this.folders=new vv10(this,'folders');this.folders.vvx();}
this.library_type='folder';}else{this.library_type='media_browser';}}
function library_resize_timed(){window.cclibrary.playlists.lbplaylists.resize();window.cclibrary.tracks.lbtracks.resize();window.library_resizing=null;}
function library_resize(){if(window.library_resizing)return;window.library_resizing=setTimeout('library_resize_timed()',150);}
function library_startup(){window.cclibrary=new vvw('window.cclibrary');window.cclibrary.vvx();}
add_onload(library_startup);add_onresize(library_resize);function vvF(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;this.show_covers=true;window.rpc.set_callback("library.update_album",this.name+".album_updated");}
vvF.prototype.vvD=function(menu,items){this.lbalbums.vv11(menu,items);}
vvF.prototype.vvx=function(){this.lbalbums=new vv12('albums',this.name+'.lbalbums','system/');this.lbalbums.owner=this;this.lbalbums.dragdataclassname='mediaitem';this.lbalbums.vv13('spawn_draggable_row',this.vv14);this.lbalbums.vv13('selection_change',this.vv15);this.vv16=layer.get('albums');}
vvF.prototype.vv14=function(sender,row){if(window.cclibrary.albums.show_covers){row.className+=' lbt_row_album_cover';}else{row.className+=' lbt_row_album';}}
vvF.prototype.clear=function(){this.lbalbums.vv17();}
vvF.prototype.vv15=function(sender,itemcount){if(!sender||!sender.selected_items||!sender.selected_items.length)return;var lbalbums=sender;var albums=sender.owner;albums.activealbums=new Array();var albumidlist=new Array();for(var i=0;i<lbalbums.selected_items.length;i++){var rowid=lbalbums.selected_items[i];var row=lbalbums.vv18(rowid);if(!row||!row.vv19||!row.vv19.id)continue;albumidlist[albumidlist.length]=row.vv19.id;albums.activealbums[row.vv19.id]=[row.data,row.vv19.artistid];}
albums.owner.tracks.vvK(albumidlist);}
vvF.prototype.vv1a=function(obj){return true;}
vvF.prototype.vvK=function(artistidlist){this.owner.vvR(true,'albums');window.rpc.execute('library.get_albums',0,artistidlist,'albums',this.owner.vvP());}
vvF.prototype.set=function(artistidlist,albums,destination,setallactive){if(setallactive)this.activealbums=new Array();this.owner.tracks.clear();this.clear();if(albums&&albums.length){for(var i=0;i<albums.length;i++){var artistname=this.owner.artists.activeartists[albums[i].artistid];if(setallactive)this.activealbums[albums[i].id]=[albums[i].name,albums[i].artistid];this.add(albums[i].id,albums[i].name,albums[i].releaseyear,albums[i].artistid,artistname,albums[i].genrename,albums[i].cover);}}
this.owner.vvR(false,'albums');}
vvF.prototype.add=function(id,name,releaseyear,artistid,artistname,genrename,coverurl){if(typeof name=='number')name=name+' ';var data={'id':id,'artistid':artistid}
var shortartist=artistname;if(!shortartist)shortartist='';if(shortartist.length>25){shortartist=shortartist.substring(0,21)+' ...';}
var row=this.lbalbums.vv1b(name,'lbt_row_album',data,null,artistname+(releaseyear?', '+releaseyear:'')+(genrename?', '+genrename:''),shortartist+(releaseyear?', '+releaseyear:''),genrename);if(!coverurl)coverurl='../theme/images/startpage/nocover.png';row.coverurl=coverurl;if(this.show_covers){row.className=row.className+' lbt_row_album_cover';row.style.backgroundImage='url('+coverurl+')';}}
vvF.prototype.toggle_covers=function(el){var show=el.vvZ;if(show==this.show_covers)return;this.show_covers=show;for(var i=0;i<this.lbalbums.vv1c.childNodes.length;i++){row=this.lbalbums.vv1c.childNodes[i];var cn=row.className;cn=cn.replace(/lbt_row_album_cover/,'');if(this.show_covers){cn=cn+' lbt_row_album_cover';row.style.backgroundImage='url('+row.coverurl+')';}else{row.style.backgroundImage='';}
row.className=cn;}}
vvF.prototype.edit_selected=function(){var selected=this.lbalbums.vv1d();if(!selected)return;window.cclibrary.tip.vvL(window.loctext.edit_album,window.loctext.album_name+': <input type="text" id="edit_albumname" value="'+selected.data+'" size="30" />',this.vv1e,true);setTimeout('if (el=document.getElementById("edit_albumname")) el.focus();',250);}
vvF.prototype.vv1e=function(){var albumname=document.getElementById('edit_albumname').value;window.cclibrary.tip.clear();var lbalbums=window.cclibrary.albums.lbalbums;var selected=lbalbums.vv1d();if(!selected)return;var albumid=selected.vv19.id;window.rpc.execute('library.update_album',albumid,albumname);}
vvF.prototype.album_updated=function(albumid,albumname){for(var i=0;i<this.lbalbums.vv1c.childNodes.length;i++){var row=this.lbalbums.vv1c.childNodes[i];if(!row||!row.vv19||!row.vv19.id)continue;if(row.vv19.id==albumid){this.lbalbums.vv1f(row,albumname);if(this.show_covers)row.className=row.className+' lbt_row_album_cover';break;}}}
function vvE(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;window.rpc.set_callback("library.update_artist",this.name+".artist_updated");}
vvE.prototype.vvD=function(menu,items){this.lbartists.vv11(menu,items);}
vvE.prototype.clear=function(){this.lbartists.vv17();}
vvE.prototype.vvx=function(){this.lbartists=new vv12('artists',this.name+'.lbartists','system/');this.lbartists.owner=this;this.lbartists.dragdataclassname='mediaitem';this.lbartists.vv13('selection_change',this.vv15);this.vv1g=layer.get('artists');}
vvE.prototype.vv15=function(sender,itemcount){if(!sender||!sender.selected_items||!sender.selected_items.length)return;var lbartists=sender;var artists=sender.owner;artists.activeartists=new Array();var artistidlist=new Array();for(var i=0;i<lbartists.selected_items.length;i++){var rowid=lbartists.selected_items[i];var row=lbartists.vv18(rowid);if(!row||!row.vv19||!row.vv19.id)continue;artistidlist[artistidlist.length]=row.vv19.id;artists.activeartists[row.vv19.id]=row.data;}
artists.owner.albums.vvK(artistidlist);}
vvE.prototype.vv1a=function(obj){return true;}
vvE.prototype.vvK=function(){this.owner.vvR(true,'artists');window.rpc.execute('library.get_artists',0,'artists',this.owner.vvP());}
vvE.prototype.set=function(artists,destination,setallactive){if(setallactive)this.activeartists=new Array();this.lbartists.vv17();if(artists&&artists.length){for(var i=0;i<artists.length;i++){if(setallactive)this.activeartists[artists[i].id]=artists[i].name;this.add(artists[i].id,artists[i].name,artists[i].albums);}}
this.owner.vvR(false,'artists');}
vvE.prototype.add=function(artistid,name,albums){if(typeof name=='number')name=name+' ';var data={'id':artistid}
var albumtip='('+albums+' '+(albums==1?window.loctext.album_text.toLowerCase():window.loctext.albums_text.toLowerCase())+')';var row=this.lbartists.vv1b(name,'lbt_row_artist',data,null,name+' '+albumtip,albumtip);}
vvE.prototype.edit_selected=function(){var selected=this.lbartists.vv1d();if(!selected)return;window.cclibrary.tip.vvL(window.loctext.edit_artist,window.loctext.artist_name+': <input type="text" id="edit_artistname" value="'+selected.data+'" size="30" />',this.vv1h,true);setTimeout('if (el=document.getElementById("edit_artistname")) el.focus();',250);}
vvE.prototype.vv1h=function(){var artistname=document.getElementById('edit_artistname').value;window.cclibrary.tip.clear();var lbartists=window.cclibrary.artists.lbartists;var selected=lbartists.vv1d();if(!selected)return;var artistid=selected.vv19.id;window.rpc.execute('library.update_artist',artistid,artistname);}
vvE.prototype.artist_updated=function(artistid,artistname){for(var i=0;i<this.lbartists.vv1c.childNodes.length;i++){var row=this.lbartists.vv1c.childNodes[i];if(!row||!row.vv19||!row.vv19.id)continue;if(row.vv19.id==artistid){this.lbartists.vv1f(row,artistname);break;}}}
function vvH(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;}
vvH.prototype.vvx=function(){this.lbplaylist=new vv12('playlist',this.name+'.lbplaylist','system/');this.lbplaylist.owner=this;this.lbplaylist.dragdataclassname='mediaitem';this.lbplaylist.vv13('selection_change',this.vv15);this.vv1i=layer.get('playlist');}
vvH.prototype.clear=function(){this.lbplaylist.vv17();}
vvH.prototype.vvK=function(playlistid){this.owner.vvR(true,'playlist');window.rpc.execute('playlist.get_tracks',playlistid);}
vvH.prototype.set=function(playlistid,tracks,artists,albums,destination){this.vv1j=false;this.vv1k=playlistid;this.lbplaylist.vv17();if(tracks&&tracks.length){for(var i=0;i<tracks.length;i++){var albumname=albums['i'+tracks[i].albumid]?albums['i'+tracks[i].albumid]:'ERROR';var artistname=artists['i'+tracks[i].artistid]?artists['i'+tracks[i].artistid]:'ERROR';this.add(tracks[i].id,tracks[i].title,tracks[i].bitrate,tracks[i].length,albumname,artistname);}}else{this.add(0,'Empty playlist',0,0,'','',true);}
this.lbplaylist.resize();this.vv1l();this.owner.vvR(false,'playlist');}
vvH.prototype.vv1m=function(secs){var mins=Math.floor(secs/60);secs-=(mins*60);return(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs;}
vvH.prototype.vv1n=function(secs){var hours=Math.floor(secs/60/60);secs-=(hours*60*60);var mins=Math.floor(secs/60);secs-=(mins*60);return(hours<10?'0':'')+hours+':'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs;}
vvH.prototype.vv1l=function(fromcache,updateplaylistslist){var tracksecs=0;if(fromcache){tracksecs=this.cached_tracksecs;}else{for(var i=0;i<this.lbplaylist.vv1c.childNodes.length;i++){if(!this.lbplaylist.vv1c.childNodes[i].vv1o)continue;tracksecs+=this.lbplaylist.vv1c.childNodes[i].vv19.lengthsecs;}
this.cached_tracksecs=tracksecs;}
var trackcount=this.lbplaylist.vv1c.childNodes.length;var el=document.getElementById('trackcount');if(el)el.innerHTML=trackcount;var el=document.getElementById('tracktime');if(el)el.innerHTML=this.vv1n(tracksecs);if(updateplaylistslist)this.vv1p(tracksecs);}
vvH.prototype.vv1p=function(tracksecs){var playlists=this.owner.playlists;var row=playlists.lbplaylists.vv1d();if(row.vv19==this.vv1k)playlists.vv1q(row,tracksecs);}
vvH.prototype.add=function(id,title,bitrate,length,albumname,artistname,staticitem){if(staticitem){var data='';var extracolumns=null;var itemclass='lbt_row_empty';}else{var vv1r=length?this.vv1m(length):'';var details='';if(artistname)details+=artistname;if(albumname)details+=(details?', ':'')+albumname;if(vv1r)details+=(details?', ':'')+vv1r;var tip=details;if(bitrate)tip+=(tip?', ':'')+bitrate+' kbps';var data={'id':id,'bitrate':bitrate,'length':vv1r,'lengthsecs':length?length:0}
var extracolumns=[artistname,albumname,vv1r,bitrate+'kbps'];var itemclass='lbt_row_track';}
var row=this.lbplaylist.vv1b(title,itemclass,data,null,tip,extracolumns);if(staticitem)row.vv1o=false;}
vvH.prototype.vv1s=function(enabled){var btnids=new Array('top','up','down','bottom','remove');for(var b=0;b<btnids.length;b++){var el=document.getElementById('btn_'+btnids[b]);if(!el)continue;el.disabled=!enabled;}}
vvH.prototype.vv15=function(sender,itemcount){if(!sender)return;var lbplaylist=sender;var playlist=sender.owner;if(!sender.selected_items||!sender.selected_items.length){playlist.vv1s(false);return;}else{playlist.vv1s(true);}}
vvH.prototype.move_track=function(destination){this.vv1j=true;this.lbplaylist.vv1t(destination);}
vvH.prototype.remove_track=function(){this.vv1j=true;if(this.lbplaylist.selected_items.length>0){for(var i=0;i<this.lbplaylist.selected_items.length;i++){var idx=this.lbplaylist.vv1u(this.lbplaylist.selected_items[i]);this.cached_tracksecs-=this.lbplaylist.vv1c.childNodes[idx].vv19.lengthsecs;}}
this.lbplaylist.vv1v();this.vv1l(true);}
vvH.prototype.vv1w=function(){var data='';for(var i=0;i<this.lbplaylist.vv1c.childNodes.length;i++){data+=this.lbplaylist.vv1c.childNodes[i].vv19.id+",";}
return data;}
vvH.prototype.savechanges=function(){var data=this.vv1w();this.owner.vvR(true,'playlist',true);window.rpc.execute('playlist.set_tracks',this.vv1k,data);}
vvH.prototype.revert=function(){if(this.vv1j){if(!confirm(window.loctext.playlist_revert_text))return;}
this.vvK(this.vv1k);}
vvH.prototype.tracks_set=function(playlistid){this.vv1j=false;this.owner.vvR(false,'playlist');this.vv1l(false,true);}
vvH.prototype.vvU=function(keyword,field){keyword=keyword.toLowerCase();var showall=(!keyword.length)?true:false;for(var i=0;i<this.lbplaylist.vv1c.childNodes.length;i++){var node=this.lbplaylist.vv1c.childNodes[i];if(!node||!node.data||!node.floatright)continue;var candisplay=true;if(!showall){var trackname=node.data;var artistname=node.floatright[0];var albumname=node.floatright[1];if(typeof trackname=='number')trackname=trackname.toString();if(typeof artistname=='number')artistname=artistname.toString();if(typeof albumname=='number')albumname=albumname.toString();switch(field){case'all':candisplay=(trackname.toLowerCase().indexOf(keyword)>=0)||(artistname.toLowerCase().indexOf(keyword)>=0)||(albumname.toLowerCase().indexOf(keyword)>=0);break;case'artists':candisplay=(artistname.toLowerCase().indexOf(keyword)>=0);break;case'albums':candisplay=(albumname.toLowerCase().indexOf(keyword)>=0);break;case'tracks':candisplay=(trackname.toLowerCase().indexOf(keyword)>=0);break;}}
node.style.display=candisplay?'':'none';node.vv1o=candisplay;}
this.vv1l();}
vvH.prototype.import_m3u=function(){if(this.vv1j){if(!confirm(window.loctext.playlist_modified_text))return;}
this.vv1j=false;window.location='index.php?page=importm3u&playlistid='+this.vv1k;}
function vvC(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;window.rpc.set_callback("playlist.toggle_status",this.name+".playlist_status_updated");}
vvC.prototype.vvD=function(menu,items){this.lbplaylists.vv11(menu,items);}
vvC.prototype.vv1n=function(secs){var hrs=Math.floor(secs/3600);secs-=(hrs*3600);var mins=Math.floor(secs/60);secs-=(mins*60);return(hrs<10?'0':'')+hrs+':'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs;}
vvC.prototype.vvx=function(){this.lbplaylists=new vv12('playlists',this.name+'.lbplaylists','system/');this.lbplaylists.owner=this;this.lbplaylists.vv1x=1;this.lbplaylists.vv1y=false;this.lbplaylists.vv13('selection_change',this.vv15);this.vv1z(window.loctext.media_text,'lbt_row_mediaroot');this.vv1A=this.vv1z(window.loctext.medialib_text,'lbt_row_library',false,true);this.vv1z(window.loctext.playlists_text,'lbt_row_playlistroot');}
vvC.prototype.vv1B=function(){this.lbplaylists.vv1C(this.vv1A,true);}
vvC.prototype.set=function(playlists){if(playlists&&playlists.length){for(var i=0;i<playlists.length;i++){this.add(playlists[i].title,playlists[i].id,playlists[i].status,playlists[i].type,playlists[i].lengths);}}
this.owner.vvR(false,'playlists');this.vv1B();}
vvC.prototype.add=function(title,id,status,type,lengths){var desc=window.loctext.playlist_type_text[type]+', '+this.vv1n(lengths);var styledtitle=title;if(status=='disabled')styledtitle='<span style="color: #909090; text-decoration: line-through">'+styledtitle+'</span>';var row=this.lbplaylists.vv1b(styledtitle,'lbt_row_playlist',id,null,desc,'','<span style="color: #909090; font-size: 10px">'+desc+'</span>');window.vvJ.vvo(row,'mediaitem');row.ondragrelease=this.vv1D;row.ondragzoneenter=this.vv1E;row.ondragzoneexit=this.vv1F;row.vv8=false;row.dragcheckparentscroll=true;}
vvC.prototype.vv1q=function(row,newtime){row.secondline=row.secondline.replace(/[0-9]{2}:[0-9]{2}:[0-9]{2}/,this.vv1n(newtime));row.title=row.title.replace(/[0-9]{2}:[0-9]{2}:[0-9]{2}/,this.vv1n(newtime));this.lbplaylists.vv1G(row);}
vvC.prototype.vv1z=function(caption,itemclass,candrag,canselect){node=this.lbplaylists.vv1b(caption,itemclass,'*');node.vv8=candrag?true:false;node.vv1o=canselect?true:false;node.disable_context=true;return node.vv1H;}
vvC.prototype.vvK=function(){this.owner.vvR(true,'playlists');window.rpc.execute('playlist.list_all');window.rpc.execute('library.get_genres');}
vvC.prototype.add_complete=function(playlistid,result,message,newtime){for(var i=1;i<this.lbplaylists.vv1c.childNodes.length;i++){var row=this.lbplaylists.vv1c.childNodes[i];if(!row||!row.vv19)continue;if(row.vv19==playlistid){row.savesinprogress--;if(row.savesinprogress<=0){row.savesinprogress=0;if(result){this.vv1q(row,newtime);row.className=row.pre_drop_class+' lbt_row_playlist_ok';window.setTimeout(this.name+".add_clear('"+row.id+"')",2000);}else{row.className=row.pre_drop_class+' lbt_row_playlist_error';}}}}
if(!result){alert(message);}}
vvC.prototype.add_clear=function(elementid){var el=document.getElementById(elementid);if(!el)return;if(el.pre_drop_class)el.className=el.pre_drop_class;}
vvC.prototype.vv1D=function(target,dragdata,pos){if(!dragdata.data.length)return false;if(!target)return;var listbox=target.owner;if(!listbox)return;var listobj=listbox.owner;if(!listobj)return;var cclibrary=listobj.owner;if(!cclibrary)return;var playlistid=target.vv19;var itemtype=dragdata.datasender;var sourcelist=null;var fromplaylist=false;var fromfolders=false;switch(itemtype){case'tracks':sourcelist=cclibrary.tracks.lbtracks;break;case'albums':sourcelist=cclibrary.albums.lbalbums;break;case'artists':sourcelist=cclibrary.artists.lbartists;break;case'folders':fromfolders=true;break;case'playlist':sourcelist=cclibrary.playlist.lbplaylist;fromplaylist=true;if(playlistid==cclibrary.playlist.vv1k)return;break;default:alert('Internal error - unknown data source: '+itemtype);return;break;}
var idlist=new Array();if(fromfolders){for(var i=0;i<dragdata.data.length;i++){idlist[idlist.length]=dragdata.data[i].tree_id;}}else{for(var i=0;i<dragdata.data.length;i++){var trackrow=sourcelist.vv18(dragdata.data[i]);idlist[idlist.length]=trackrow.vv19.id;}}
if(!target.pre_drop_class)target.pre_drop_class=target.className;target.className+=' lbt_row_playlist_save';if(!target.savesinprogress)target.savesinprogress=0;target.savesinprogress--;if(fromplaylist){itemtype='tracks';cclibrary.playlist.remove_track();}
window.rpc.execute('playlist.add',playlistid,itemtype,idlist);}
vvC.prototype.vv15=function(sender,itemcount){if(!sender||!sender.selected_items||!sender.selected_items.length)return;var lbplaylists=sender;var playlists=sender.owner;var sel=lbplaylists.vv1d();if(!sel.vv19)return;if((playlists.display_type==1)&&(playlists.owner.playlist.vv1j)){if(!confirm(window.loctext.playlist_modified_text)){lbplaylists.vv1I();lbplaylists.vv1C(playlists.newselindex,true,true);return;}}
playlists.newselindex=lbplaylists.selectedIndex;if(sel.vv19=='*'){playlists.display_type=0;playlists.owner.vvA();}else{playlists.display_type=1;playlists.owner.vvW(sel.vv19);}}
vvC.prototype.vv1E=function(sender,dragdata){sender.oldClassName=sender.className;sender.className+=' lbt_row_plhover';}
vvC.prototype.vv1F=function(sender,dragdata){sender.className=sender.oldClassName;}
vvC.prototype.toggle_selected=function(){var selected=this.lbplaylists.vv1d();if(!selected)return;var playlistid=selected.vv19;window.rpc.execute('playlist.toggle_status',playlistid);}
vvC.prototype.playlist_status_updated=function(playlistid,newstatus){for(var i=0;i<this.lbplaylists.vv1c.childNodes.length;i++){var row=this.lbplaylists.vv1c.childNodes[i];if(!row||!row.vv19)continue;if(row.vv19==playlistid){var plaintitle=row.data.replace(/<\/?span.*?>/,'');var styledtitle=plaintitle;if(newstatus=='disabled')styledtitle='<span style="color: #909090; text-decoration: line-through">'+styledtitle+'</span>';this.lbplaylists.vv1f(row,styledtitle);break;}}}
function vvI(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;}
vvI.prototype.vvx=function(elementid){this.elementid=elementid;this.vv1J=layer.get(this.elementid);this.vv1K=layer.get(this.elementid+'_title');this.vv1L=layer.get(this.elementid+'_content');this.vv1M=layer.get(this.elementid+'_button');this.vv1M.owner=this;this.vv1M.onclick=this.vv1N;this.hide();}
vvI.prototype.vv1N=function(evt){sendertip=null;if(!evt){sendertip=window.event.srcElement.owner;}else{sendertip=evt.target.owner;}
if(sendertip&&sendertip.vv1O)sendertip.vv1O();}
vvI.prototype.vv1O=function(){this.hide();if(this.onclick_event!=null)this.onclick_event();}
vvI.prototype.hide=function(){if(this.modal)this.vv1P(false);this.vv1J.className='hide';}
vvI.prototype.vv1Q=function(){if(this.modal)this.vv1P(true);this.vv1J.className='show';}
vvI.prototype.vv1P=function(dofade){if(dofade){if(!this.fadediv){this.fadediv=document.createElement('div');this.fadediv.id='tipfade';document.body.insertBefore(this.fadediv,document.body.childNodes[0]);}
this.fadediv.style.display='';}else{if(this.fadediv)this.fadediv.style.display='none';}}
vvI.prototype.vvL=function(title,content,onclick,modal){this.vv1K.innerHTML=title;this.vv1L.innerHTML=content;this.onclick_event=onclick;this.modal=modal;this.vv1Q();}
vvI.prototype.clear=function(){this.vv1K.innerHTML='';this.vv1L.innerHTML='';}
function vvG(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;window.rpc.set_callback("library.update_track",this.name+".track_updated");}
vvG.prototype.vvx=function(){this.lbtracks=new vv12('tracks',this.name+'.lbtracks','system/');this.lbtracks.owner=this;this.lbtracks.dragdataclassname='mediaitem';this.lbtracks.vv13('selection_change',this.vv15);this.vv1R=layer.get('tracks');}
vvG.prototype.vvD=function(menu,items){this.lbtracks.vv11(menu,items);}
vvG.prototype.vv15=function(sender,itemcount){if(!sender)return;var lbtracks=sender;var tracks=sender.owner;if(!sender.selected_items||!sender.selected_items.length){tracks.vv1s(false);return;}else{if(vv1S&&vv1T){var track=lbtracks.vv18(lbtracks.selected_items[0]);var trackid=track.vv19.id;window.rpc.execute('library.get_track_details',trackid);}
tracks.vv1s(true);}}
vvG.prototype.set_track_details=function(track){var values={'Title':track.title+' ('+track.id+')','Artist':track.artistname+' ('+track.artistid+')','Album':track.albumname+' ('+track.albumid+')','Released':track.releaseyear,'Genre':track.genrename,'Length':track.length+' sec','Path':track.pathname,'Last refresh':track.lastrefresh,'Account ID':track.accountid,'Amazon ID':track.amazonid,'Bit rate':track.bitrate,'Frequency':track.frequency,'VBR':track.vbr?'Yes':'No','Size':track.size,'MPEG version':track.mpeg_version,'MPEG layer':track.layer,'Frame offset':track.frameoffset,'ID3 v1':track.id3v1?'Yes':'No','ID3 v1.1':track.id3v11?'Yes':'No','ID3 v2':track.id3v2?'Yes':'No','ID3 warning':track.warning?track.warning:'None','ID3 error':track.error?track.error:'None'}
if(track.title!=track.raw_id3.title)values['ID3 title']=track.raw_id3.title+' (mismatch)';if(track.artistname!=track.raw_id3.artist)values['ID3 artist']=track.raw_id3.artist+' (mismatch)';if(track.albumname!=track.raw_id3.album)values['ID3 album']=track.raw_id3.album+' (mismatch)';dump="";for(k in values){dump+='<tr><td width="100">'+k+':&nbsp;</td><td>'+values[k]+'</td></tr>';}
dump='<table cellspacing="1" cellpadding="0" border="0" width="100%">'+dump+'</table>';this.owner.tip.vvL('Track details: '+track.title,dump);}
vvG.prototype.clear=function(){this.lbtracks.vv17();}
vvG.prototype.vvK=function(albumidlist){this.owner.vvR(true,'tracks');window.rpc.execute('library.get_tracks',0,albumidlist,'tracks');}
vvG.prototype.set=function(albumid,tracks,destination){this.lbtracks.vv17();if(tracks&&tracks.length){var albumname='';var artistname='';for(var i=0;i<tracks.length;i++){var activealbum=this.owner.albums.activealbums[tracks[i].albumid];if(activealbum&&activealbum.length>1){albumname=activealbum[0];artistname=this.owner.artists.activeartists[activealbum[1]];}else{albumname='';artistname='';}
this.add(tracks[i].id,tracks[i].title,tracks[i].bitrate,tracks[i].length,albumname,artistname);}}
this.owner.vvR(false,'tracks');}
vvG.prototype.vv1m=function(secs){var mins=Math.floor(secs/60);secs-=(mins*60);return(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs;}
vvG.prototype.add=function(id,title,bitrate,length,albumname,artistname){if(typeof title=='number')name=name+' ';if(typeof albumname=='number')albumname=albumname+' ';if(typeof artistname=='number')artistname=artistname+' ';var vv1r=length?this.vv1m(length):'';var details='';if(artistname)details+=artistname;if(albumname)details+=(details?', ':'')+albumname;if(vv1r)details+=(details?', ':'')+vv1r;var tip=details;if(bitrate)tip+=(tip?', ':'')+bitrate+' kbps';var data={'id':id,'bitrate':bitrate,'length':vv1r}
var row=this.lbtracks.vv1b(title,'lbt_row_track',data,null,tip,[artistname,albumname,vv1r,bitrate+'kbps']);}
vvG.prototype.vv1s=function(enabled){var btnids=new Array('preview');for(var b=0;b<btnids.length;b++){var el=document.getElementById('btn_'+btnids[b]);if(!el)continue;el.disabled=!enabled;}}
vvG.prototype.preview=function(){var data='';for(var i=0;i<this.lbtracks.selected_items.length;i++){var track=this.lbtracks.vv18(this.lbtracks.selected_items[i]);data+=track.vv19.id+',';}
window.location='index.php?page=preview&tracks='+escape(data);}
vvG.prototype.edit_selected=function(){var selected=this.lbtracks.vv1d();if(!selected)return;window.cclibrary.tip.vvL(window.loctext.edit_track,window.loctext.track_name+': <input type="text" id="edit_trackname" value="'+selected.data+'" size="30" />',this.vv1U,true);setTimeout('if (el=document.getElementById("edit_trackname")) el.focus();',250);}
vvG.prototype.vv1U=function(){var trackname=document.getElementById('edit_trackname').value;window.cclibrary.tip.clear();var lbtracks=window.cclibrary.tracks.lbtracks;var selected=lbtracks.vv1d();if(!selected)return;var trackid=selected.vv19.id;window.rpc.execute('library.update_track',trackid,trackname);}
vvG.prototype.track_updated=function(trackid,trackname){for(var i=0;i<this.lbtracks.vv1c.childNodes.length;i++){var row=this.lbtracks.vv1c.childNodes[i];if(!row||!row.vv19||!row.vv19.id)continue;if(row.vv19.id==trackid){this.lbtracks.vv1f(row,trackname);if(this.show_covers)row.className=row.className+' lbt_row_track_cover';break;}}}
function vv10(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;}
vv10.prototype.vvD=function(menu,items){this.tvfolders.vv11(menu,items);}
vv10.prototype.clear=function(){this.tvfolders.clear();}
vv10.prototype.vvx=function(){this.tvfolders=new vv1V('folders',this.name+'.tvfolders','../system/');this.tvfolders.owner=this;this.tvfolders.multiselect=true;this.tvfolders.candragnodes=true;this.tvfolders.onfetchitems=this.vv1W;this.tvfolders.onselectchange=this.vv15;this.tvfolders.dragdataclassname='mediaitem';this.elfolders=layer.get('folders');}
vv10.prototype.vv15=function(sender,node){if(node==null)return;var isfolder=node.tree_haschildren;if(!isfolder&&vv1S&&vv1T){var trackid=node.tree_id;window.rpc.execute('library.get_track_details',trackid);}}
vv10.prototype.vv1W=function(sender,node){if(!node){alert('notnode');return;}
var tvfolders=node.owner;var isfolder=node.tree_haschildren;if(!isfolder)return;if(node&&node.tree_parent&&node.tree_parent.caption)this.current_folder=node.tree_parent.caption.innerHTML;sender.owner.owner.vvR(true,'folders');var parentid=node.tree_id;var filepath=node.tree_data;var depth=filepath.substr_count('/')-1;tvfolders.owner.vv1X(tvfolders,parentid,depth);}
vv10.prototype.vv1a=function(obj){return true;}
vv10.prototype.vvK=function(){this.owner.vvR(true,'folders');window.rpc.execute('library.get_folders',0,0);}
vv10.prototype.vv1X=function(sender,parentid,depth){if(!depth)depth=0;sender.owner.owner.vvR(true,'folders');window.rpc.execute('library.get_folders',parentid,depth);}
vv10.prototype.vv1Y=function(parentid,parentpath,nodes){for(i=0;i<nodes.length;i++){node=this.vv1Z(parentid,parentpath,nodes[i]);}
if(!nodes.length){this.tvfolders.vv20(parentpath);}
this.owner.vvR(false,'folders');}
vv10.prototype.vv1Z=function(parentid,parentpath,vv21){if(parentpath==null)parentpath='';var nodepath=parentpath+vv21.filename+(vv21.isfolder?'/':'');vv21.details=nodepath;var nodeid=vv21.id;if(vv21.isfolder)nodeid+=':'+nodepath.substr_count('/');return this.tvfolders.vv22(parentid,vv23(nodeid,vv21.filename,'#',vv21.isfolder?true:false,nodepath,vv21.details),true);}
vv10.prototype.add=function(parentid,parentpath,nodes){if(parentpath==0){parentpath='';}
this.vv1Y(parentid,parentpath,nodes);}
vv10.prototype.edit_selected=function(){var selected=this.tvfolders.vv1d();if(!selected)return;window.cclibrary.tip.vvL(window.loctext.edit_folder,window.loctext.folder_name+': <input type="text" id="edit_foldername" value="'+selected.data+'" size="30" />',this.vv24,true);setTimeout('if (el=document.getElementById("edit_foldername")) el.focus();',250);}
vv10.prototype.vv24=function(){var foldername=document.getElementById('edit_foldername').value;window.cclibrary.tip.clear();var tvfolders=window.cclibrary.folders.tvfolders;var selected=tvfolders.vv1d();if(!selected)return;var folderid=selected.vv19.id;window.rpc.execute('library.update_folder',folderid,foldername);}
vv10.prototype.vv25=function(folderid,foldername){for(var i=0;i<this.tvfolders.vv1c.childNodes.length;i++){var row=this.tvfolders.vv1c.childNodes[i];if(!row||!row.vv19||!row.vv19.id)continue;if(row.vv19.id==folderid){this.tvfolders.vv1f(row,foldername);break;}}}
function vv26(popup,parentmenu){this.vv27=150;this.vv28=null;this.vv29=parentmenu;this.vv2a=popup;}
vv26.prototype.vvM=function(items,zindex){if(!zindex)zindex=200;var menudiv=document.createElement('div');menudiv.menu=this;menudiv.style.zIndex=zindex;menudiv.className='mnu_container';menudiv.menuidx=++this.menucounter;menudiv.onmouseover=function(e){this.menu.vv2b();}
menudiv.onmouseout=function(e){this.menu.vv2c();}
menudiv.oncontextmenu=function(){return false;}
menudiv.onselectstart=function(){return false;}
for(i in items){var itemdata=items[i];if(typeof itemdata!='object')continue;var item=document.createElement('div');item.menudividx=menudiv.menuidx;item.menu=this;if(itemdata[0]==null){item.className='mnu_separator';}else{item.className='mnu_item';item.innerHTML=itemdata[0];if((itemdata.length>2)&&(itemdata[2]!=null)){var itemoptions=itemdata[2];item.id=itemoptions.shift();if(itemoptions.indexOf('checkbox')>=0){item.vv2d=true;item.vvZ=(itemoptions.indexOf('checked')>=0);if(item.vvZ)item.className+=' mnu_item_checked';}
if(itemoptions.indexOf('disabled')>=0){item.is_disabled=true;item.className+=' mnu_item_disabled';}}
if(itemdata[1]!=null){item.onmouseup=function(e){if(!this.is_disabled&&this.vv2d){this.vvZ=!this.vvZ;this.className+=' mnu_item_checked_hover';}
this.menu.vv2e();}
item.click_method=itemdata[1];item.onclick=function(e){if(!this.is_disabled)this.click_method(e);};}
if((itemdata.length>3)&&(itemdata[3]!=null)){item.submenu=new vv26(this.vv2a,this);item.submenu.vvM(itemdata[3],zindex+1);item.className+=' mnu_item_sub';item.onmouseover=function(e){this.className='mnu_item mnu_item_hover mnu_item_sub_hover';this.menu.vv2b();this.submenu.vv1Q(this);}
item.onmouseout=function(e){this.className='mnu_item mnu_item_sub';this.submenu.vv2c();this.menu.vv2b();}}else{item.onmouseover=function(e){this.className='mnu_item mnu_item_hover'+(this.vvZ?' mnu_item_checked_hover':'')+(this.is_disabled?' mnu_item_disabled_hover':'');this.menu.vv2b();}
item.onmouseout=function(e){this.className='mnu_item'+(this.vvZ?' mnu_item_checked':'')+(this.is_disabled?' mnu_item_disabled':'');}
item.set_disabled=function(isdisabled){this.is_disabled=isdisabled;this.className='mnu_item'+(this.vvZ?' mnu_item_checked':'')+(this.is_disabled?' mnu_item_disabled':'');}}}
menudiv.appendChild(item);}
menudiv.style.display='none';document.body.insertBefore(menudiv,document.body.childNodes[0]);this.menudiv=menudiv;}
vv26.prototype.vv2c=function(){var self=this;var hide_menu=function(){self.hide();self.vv28=null;}
this.vv28=setTimeout(hide_menu,this.vv27);if(this.vv29)this.vv29.vv2c();}
vv26.prototype.vv2b=function(){if(this.vv28){clearTimeout(this.vv28);this.vv28=null;}
if(this.vv29)this.vv29.vv2b();}
vv26.prototype.vv1Q=function(anchorelement,coordinates){if(anchorelement==null){var p=coordinates;p.x-=2;p.y-=2;var s={x:0,y:0}}else{var p=layer.absposition(anchorelement);var s=layer.size(anchorelement);}
this.menudiv.style.display='';this.menudiv.style.left=p.x+'px';this.menudiv.style.top=(p.y+s.y+1)+'px';var ms=layer.size(this.menudiv);if(anchorelement==null){}else if(anchorelement.className.match(/mnu_item/)){this.menudiv.style.left=(p.x-ms.x)+'px';this.menudiv.style.top=p.y+'px';}else{this.menudiv.style.left=(p.x+s.x-ms.x)+'px';}}
vv26.prototype.hide=function(){this.menudiv.style.display='none';}
vv26.prototype.vv2e=function(){this.hide();if(this.vv29)this.vv29.vv2e();}
function vvB(owner,name){this.owner=owner;this.name=this.owner.name+'.'+name;this.menucounter=0;this.hide_timers=[];this.menus=[];}
vvB.prototype.vvx=function(){}
vvB.prototype.vvM=function(items){var submenu=new vv26(this);submenu.vvM(items,210);return submenu;}
vvB.prototype.show_menu=function(anchorelement,submenu,coordinates){submenu.vv1Q(anchorelement,coordinates);}
var vv1S=false;var vv1T=false;function vv2f(){this.owner.vv2g(this);}
function vv2h(s){return;document.getElementById('tookie').innerHTML='shift: '+(vv1S?'DOWN':'UP')+' '+'ctrl: '+(vv1T?'DOWN':'UP')+' '+'<br/>'+s;}
function vv12(elementid,name,path){this.elementid=elementid;this.name=name;this.path=path;this.rowwidth=0;this.vv1x=0;this.vv1c=null;this.vv2i=0;this.vv1y=true;this.selected_items=new Array();this.vv2j=new Array();this.vv2k=new Array();this.container=layer.get(this.elementid);this.vv2g=null;this.double_click_timer=null;this.dragdataclassname='';this.editing_row=false;this.vvx();this.context_popupmenu=null;this.context_popupmenu_items=null;}
vv12.prototype.vv1u=function(rowid){for(var i=0;i<this.vv1c.childNodes.length;i++){if(this.vv1c.childNodes[i].vv1H==rowid)return i;}
return-1;}
vv12.prototype.vv2l=function(idx){if(idx<this.vv1c.childNodes.length){return this.vv1c.childNodes[idx].vv1H;}else{return-1;}}
vv12.prototype.vv2m=function(){this.vv2i++;return this.vv2i;}
vv12.prototype.vv17=function(){this.vv2k=new Array();this.selected_items=new Array();this.selectedIndex=null;if(this.vv1c.hasChildNodes()){while(this.vv1c.firstChild){this.vv1c.removeChild(this.vv1c.firstChild);}}
if(IE4)this.vv2n();}
vv12.prototype.vv2n=function(){this.vv1c.innerHTML='<div style="height: 0px"></div>';this.vv1c.removeChild(this.vv1c.firstChild);}
vv12.prototype.vv1b=function(item,classname,data,before,details,floatright,secondline){var row=document.createElement('div');row.className='lbt_row'+(classname?' '+classname:'');row.origClass=row.className;row.data=item;row.vv19=data;row.floatright=floatright;row.secondline=secondline;row.owner=this;row.vv1H=this.vv2m();row.onmouseover=this.vv2o;row.onmouseout=this.vv2p;row.onmousedown=this.vv2q;row.onmouseup=this.vv2r;row.oncontextmenu=function(){return false;}
row.id=this.elementid+'_row_'+row.vv1H;row.style.overflow='hidden';row.style.textOverflow='ellipsis';row.vv8=true;row.vv1o=true;row.ondraggrab=this.vv2s;var rowtext=(item.length>0?item:'&nbsp;');if(floatright){if(typeof floatright=='object'){var frhtml='';for(var i=0;i<floatright.length;i++){frhtml+='<div class="lbt_row_right_col lbt_'+this.elementid+'_col_'+i+'">'+floatright[i]+'</div>'}
floatright=frhtml;}
rowtext='<div style="float: right" class="lbt_row_right">'+floatright+'</div>'+rowtext;}
if(secondline){rowtext+='<div class="'+row.className+'_secondline">'+secondline+'</div>'}
row.innerHTML=rowtext;row.title=details?details:item;if(this.vv2g)this.vv2g(row);if(before){this.vv1c.insertBefore(row,before);}else{this.vv1c.appendChild(row);}
this.vv2k[item.id]=row.vv1H;return row;}
vv12.prototype.vv1G=function(row){var item=row.data;var floatright=row.floatright;var secondline=row.secondline;row.className=row.origClass;var rowtext=(item.length>0?item:'&nbsp;');if(floatright){if(typeof floatright=='object'){var frhtml='';for(var i=0;i<floatright.length;i++){frhtml+='<div class="lbt_row_right_col lbt_'+this.elementid+'_col_'+i+'">'+floatright[i]+'</div>'}
floatright=frhtml;}
rowtext='<div style="float: right" class="lbt_row_right">'+floatright+'</div>'+rowtext;}
if(secondline){rowtext+='<div class="'+row.className+'_secondline">'+secondline+'</div>'}
row.innerHTML=rowtext;if(this.vv2g)this.vv2g(row);if(this.vv2t(row.vv1H))this.vv2u(row.vv1H,true);}
vv12.prototype.vv1f=function(row,value){row.data=value;this.vv1G(row);}
vv12.prototype.vv2v=function(){this.vv2k=new Array();for(var i=0;i<this.vv1c.childNodes.length;i++){var row=this.vv1c.childNodes[i];var itemid=row.data.id;this.vv2k[itemid]=row.vv1H;}}
vv12.prototype.vv2w=function(rowid){var row=this.vv18(rowid);if(row){this.vv1c.removeChild(row);row=null;this.vv2v();}}
vv12.prototype.vv2x=function(items){for(var i=0;i<items.length;i++){this.vv1b(items[i]);}}
vv12.prototype.vv18=function(rowid){return document.getElementById(this.elementid+'_row_'+rowid);}
vv12.prototype.vv2u=function(rowid,selected){var obj=this.vv18(rowid);if(obj){if(!obj.vv1o)return false;var newclass=obj.className;if(newclass&&newclass.length){newclass=newclass.replace(/^lbt_row(_selected)?/,"lbt_row"+(selected?"_selected":""));obj.className=newclass;}}
return true;}
vv12.prototype.vv1I=function(notrigger){if(this.selected_items.length>0){for(var i=0;i<this.selected_items.length;i++)this.vv2u(this.selected_items[i],false);this.selected_items=new Array();if(!notrigger)this.vv2y();}}
vv12.prototype.vv2t=function(rowid){for(var i=0;i<this.selected_items.length;i++){if(this.selected_items[i]==rowid)return true;}
return false;}
vv12.prototype.vv1C=function(rowid,selected,notrigger){if(!this.vv2u(rowid,selected))return;if(selected){this.selected_items[this.selected_items.length]=rowid;}else{var sel=new Array();for(var i=0;i<this.selected_items.length;i++){if(this.selected_items[i]!=rowid)sel[sel.length]=this.selected_items[i];}
this.selected_items=sel;}
if(!notrigger)this.vv2y();this.vv2z();}
vv12.prototype.vv2z=function(msg){return;var s="";var rowid=-1;for(var i=0;i<this.selected_items.length;i++){rowid=this.selected_items[i];s+=rowid+":"+this.vv1u(rowid)+' ';}
if(msg)s+=msg;document.getElementById('mookie').innerHTML=s;}
vv12.prototype.vv2A=function(rowid){if((this.selected_items.length==1)&&this.vv2t(rowid)&&!vv1S&&!vv1T){return;}
this.suppress_selection_change=true;if(this.vv1y&&(this.selectedIndex>=0)&&(vv1S||vv1T)){if(vv1S){this.vv1I();loIdx=this.vv1u(parseInt(this.selectedIndex));hiIdx=this.vv1u(parseInt(rowid));if(hiIdx<loIdx){var x=hiIdx;hiIdx=loIdx;loIdx=x;}
for(var i=loIdx;i<=hiIdx;i++){var rowid=this.vv2l(i);if(this.vv2u(rowid,true))this.selected_items[this.selected_items.length]=rowid;}}else if(vv1T){var was_selected=this.vv2t(rowid);this.vv1C(rowid,!was_selected);this.selectedIndex=was_selected?null:rowid;}}else{this.vv1I();var was_selected=this.vv2t(rowid);this.vv1C(rowid,!was_selected);this.selectedIndex=was_selected?null:rowid;}
this.suppress_selection_change=false;this.vv2z('multi?');this.vv2y();this.vv2B('row_mouseclick',rowid);}
vv12.prototype.vv2o=function(){this.owner.vv2B('row_mouseover',this.vv1H);vv2h('row over '+this.owner.elementid+' '+this.vv1H);}
vv12.prototype.vv2p=function(){this.owner.vv2B('row_mouseout',this.vv1H);vv2h('row out '+this.owner.elementid+' '+this.vv1H);}
vv12.prototype.vv2q=function(){this.vv2C=false;this.owner.vv2B('row_mousedown',this.vv1H);if(!(this.owner.vv1y&&(this.owner.selected_items.length>1))){vv2h('c1 row down '+this.owner.elementid+' '+this.vv1H+' ms: '+(this.owner.vv1y?'y':'n')+' selitems: '+this.owner.selected_items.length);this.vv2D=true;this.owner.vv2A(this.vv1H);}else{vv2h('c2 row down '+this.owner.elementid+' '+this.vv1H+' ms: '+(this.owner.vv1y?'y':'n')+' selitems: '+this.owner.selected_items.length);this.vv2D=false;}}
vv12.prototype.double_click_timeout=function(){this.double_click_timer=null;}
vv12.prototype.vv2r=function(e){e=browser.get_event(e);var clickpos=browser.clickPos(e);vv2h('row up '+this.owner.elementid+' '+this.vv1H+' e.button: '+e.button);var leftclick=(NOTIE&&(e.button==0))||e.button==1;var rightclick=e.button==2;if(leftclick){this.owner.vv2B('row_mouseup',this.vv1H);vv2h('row up '+this.owner.elementid+' '+this.vv1H);if(this.owner.vv1y&&(this.owner.selected_items.length>1)&&!this.vv2D&&!this.vv2C){this.owner.vv2A(this.vv1H);}
this.vv2D=false;this.vv2C=false;if(this.owner.double_click_timer==null){this.owner.double_click_rowid=this.vv1H;this.owner.double_click_timer=setTimeout(this.owner.name+'.double_click_timeout()',500);}else{this.owner.double_click_timeout();if(this.vv1H==this.owner.double_click_rowid)this.owner.vv2B('row_mousedblclick',this.vv1H);}}
if(rightclick){var vv2E=layer.position(e.target);var vv2F=layer.position(this.owner.container);this.owner.vv2B('row_context',this.vv1H,{rowx:vv2E.x-vv2F.x+e.layerX,clickxy:clickpos});}}
vv12.prototype.vv2s=function(obj){if(!obj.owner)return false;if(!obj.owner||(typeof obj.vv1H=='undefined'))return false;this.vv2C=true;obj.owner.vv2B('row_draggrab',obj.vv1H);obj.owner.vv2z('row drag start '+obj.owner.elementid+' '+obj.vv1H);vv2h('row drag start '+obj.owner.elementid+' '+obj.vv1H);var dragitems=obj.owner.selected_items.copy();var dragdata={"datatype":'listitem',"dataclass":obj.owner.dragdataclassname?obj.owner.dragdataclassname:"listbox-row","datasender":obj.owner.elementid,"data":dragitems,"dragelement":obj.owner.vv2G(obj),"dragelement_dispose":true,"dragelement_class_candrop":"lbt_row_candrop","dragelement_class_cantdrop":"lbt_row_cantdrop"};return dragdata;}
vv12.prototype.vv2G=function(row){var el=false;var p=layer_get_pos(row);if(!IE4)p.y-=this.vv1c.scrollTop;if(IE4&&!IE7&&row.floatright&&row.childNodes&&row.childNodes.length>0){p.x-=row.childNodes[0].offsetLeft;}
var div=document.createElement('div');div.className='lbt_row_dragging';div.style.left=p.x+'px';div.style.top=p.y+'px';var rowwidth=this.container.offsetWidth+'px';var totalheight=0;var itemcount=0;if(this.selected_items.length<=1){totalheight+=row.offsetHeight;var el=row.cloneNode(true);el.className='lbt_row';el.id=this.elementid+'_dragrow_'+this.selected_items[0];this.vv2B('spawn_draggable_row',el);div.appendChild(el);itemcount=1;}else{itemcount=this.selected_items.length;if(itemcount>4)itemcount=3;for(var i=0;i<itemcount;i++){var elementid=this.elementid+'_row_'+this.selected_items[i];var vv2H=document.getElementById(elementid);if(vv2H){totalheight+=vv2H.offsetHeight;var el=vv2H.cloneNode(true);el.id=this.elementid+'_dragrow_'+this.selected_items[i];el.className='lbt_row';this.vv2B('spawn_draggable_row',el);div.appendChild(el);}}
if(this.selected_items.length>itemcount){el=document.createElement('div');el.className='lbt_row';var remaining=(this.selected_items.length-itemcount);el.innerHTML=remaining+' more item'+(remaining>1?'s':'')+' ...';div.appendChild(el);itemcount++;totalheight+=20;}}
div.style.width=rowwidth;document.body.insertBefore(div,document.body.childNodes[0]);var divheight=totalheight+'px';div.style.height=divheight;return div;}
vv12.prototype.vv2I=function(){this.owner.vv2B('row_dragstop',this.vv1H);vv2h('row drag stop '+this.owner.elementid+' '+this.vv1H);}
vv12.prototype.vv2J=function(){this.owner.vv2B('row_dragover',this.vv1H);vv2h('row drag over '+this.owner.elementid+' '+this.vv1H);}
vv12.prototype.vv2B=function(eventname,eventdata,auxiliarydata){if(this.vv2j[eventname]){event_handler=this.vv2j[eventname];if(typeof event_handler=='string'){event_handler=this.vv2j[eventname]=eval(event_handler);}
if(typeof event_handler=='function')event_handler(this,eventdata,auxiliarydata);}}
vv12.prototype.vv13=function(eventname,handler){this.vv2j[eventname]=handler;}
vv12.prototype.vvx=function(){this.lb=document.createElement('div');this.lb.className='lbt';this.lb.setAttribute('id','listbox_'+this.elementid);this.lb.onselectstart=function(){return false;}
this.container.appendChild(this.lb);this.vv2K();this.vv2L();this.vv2M=this.container.offsetWidth;}
vv12.prototype.vv2K=function(){this.vv1c=document.createElement('div');this.vv1c.className='lbt_content';this.lb.appendChild(this.vv1c);this.vv1c.onscroll=this.vv2N;if(IE4)this.vv2n();this.resize();}
vv12.prototype.vv2L=function(){if(window.lbkhinstalled)return;window.lbkhinstalled=true;document.modifyKeyState=this.vv2O;if(!document.vv2P)document.vv2P=document.onkeydown;if(!document.vv2Q)document.vv2Q=document.onkeyup;document.onkeydown=this.vv2R;document.onkeyup=this.vv2S;}
vv12.prototype.vv2O=function(e){if(!e)e=window.event;vv1S=e['shiftKey'];vv1T=e['ctrlKey'];vv2h('key state changed');}
vv12.prototype.vv2S=function(e){document.modifyKeyState(e);if(document.vv2Q)document.vv2Q(e);}
vv12.prototype.vv2R=function(e){document.modifyKeyState(e);if(document.vv2P)document.vv2P(e);}
vv12.prototype.vv2N=function(){}
vv12.prototype.resize=function(){var scrollable_height=this.container.offsetHeight-2;if(scrollable_height>0)this.vv1c.style.height=scrollable_height+'px';}
vv12.prototype.vv2y=function(){if(this.suppress_selection_change)return;this.vv2B('selection_change',this,this.selected_items.length);}
vv12.prototype.vv2T=function(location){if(this.vv1c.childNodes.length==0)return;switch(location){case 0:var row=this.vv1c.childNodes[0];this.vv2A(row.vv1H);return;case 3:var row=this.vv1c.childNodes[this.vv1c.childNodes.length-1];this.vv2A(row.vv1H);return;}
if(this.selected_items.length==0)return;var obj=this.vv18(selectedrowid);var selectedrowid=this.selected_items[0];this.vv1I();switch(location){case-2:break;case-1:break;case 1:break;case 2:break;}}
vv12.prototype.vv1t=function(destination){if(this.selected_items.length==0)return;var referencenode=null;switch(destination){case-2:referencenode=this.vv1c.childNodes[this.vv1x];break;case-1:var itemindex=this.vv1u(this.selected_items[0]);if(itemindex==this.vv1x)return;referencenode=this.vv1c.childNodes[itemindex-1];break;case 1:var itemindex=this.vv1u(this.selected_items[this.selected_items.length-1]);referencenode=this.vv1c.childNodes[itemindex+2];break;case 2:referencenode=null;break;}
for(var i=0;i<this.selected_items.length;i++){var idx=this.vv1u(this.selected_items[i]);this.vv1c.insertBefore(this.vv1c.childNodes[idx],referencenode);}}
vv12.prototype.vv1v=function(){if(this.selected_items.length==0)return;var referencenode=null;for(var i=0;i<this.selected_items.length;i++){var idx=this.vv1u(this.selected_items[i]);this.vv1c.removeChild(this.vv1c.childNodes[idx]);}
this.selected_items=new Array();this.vv2y();}
vv12.prototype.vv1d=function(){if(!this.selected_items.length)return false;rowid=this.selected_items[0];return this.vv18(rowid);}
vv12.prototype.vv2U=function(vv2V){var lastnode=null;var vv2W=0;for(var i=0;i<this.vv1c.childNodes.length;i++){vv2W+=this.vv1c.childNodes[i].offsetHeight;if(vv2W>vv2V)return this.vv1c.childNodes[i];}
return null;}
vv12.prototype.vv2X=function(){if(!this.vv1c.childNodes.length)return false;var onerowheight=this.vv1c.childNodes[0].offsetHeight;var pagerowcount=Math.floor(this.container.offsetHeight/onerowheight);var firstvisible=Math.floor(this.vv1c.scrollTop/onerowheight);var lastvisible=firstvisible+pagerowcount;return{first:firstvisible,last:lastvisible}}
vv12.prototype.vv2Y=function(topofselection){var vb=this.vv2X();if(!vb)return false;if(!this.selected_items.length)return false;var selectedrowid=-1;if(topofselection){selectedrowid=this.selected_items[0];}else{selectedrowid=this.selected_items[this.selected_items.length-1];}
selectedrowindex=this.vv1u(selectedrowid);if(selectedrowindex<0)return;var needscroll=false;needscroll=(selectedrowindex<vb.first)||(selectedrowindex>vb.last);if(needscroll)this.vv1c.childNodes[selectedrowindex].scrollIntoView(topofselection);}
vv12.prototype.vv2Z=function(sender,rowid,data){var row=sender.vv18(rowid);if(row.disable_context)return;sender.vv30(data.clickxy);}
vv12.prototype.vv30=function(clickpos){if(!this.context_popupmenu)return false;if(!this.generated_popupmenu)this.generated_popupmenu=this.context_popupmenu.vvM(this.context_popupmenu_items);this.context_popupmenu.show_menu(null,this.generated_popupmenu,clickpos);}
vv12.prototype.vv11=function(menu,items){this.vv13('row_context',this.vv2Z);this.context_popupmenu=menu;this.context_popupmenu_items=items;}
function vv1V(elementid,name,imageroot){this.elementid=elementid;this.container=layer.get(elementid);this.imageroot=imageroot;this.name=name;this.idindex=new Array();this.selectednode=null;this.selectednodes=new Array();this.multiselect=false;this.onfetchitems=null;this.onselectchange=null;this.candragnodes=false;this.dragdataclassname='';this.folderimage='folder.gif';this.folderopenimage='folderopen.gif';this.pageimage='page.gif';this.vvx();}
vv1V.prototype.vvx=function(){this.container.className=this.container.className+' tvt';this.container.onselectstart=function(){return false;}}
vv1V.prototype.clear=function(){while(this.container.childNodes.length>0){var node=this.container.childNodes[this.container.childNodes.length-1];this.container.removeChild(node);node=undefined;}
this.selectednode=null;this.idindex=new Array();}
vv1V.prototype.vv31=function(nodeindex){var node=this.container.childNodes[nodeindex];this.container.removeChild(node);}
vv1V.prototype.vv32=function(nodeindex){var node=this.container.childNodes[nodeindex];node.style.display='none';}
vv1V.prototype.vv33=function(nodeindex){var node=this.container.childNodes[nodeindex];node.style.display='block';}
vv1V.prototype.vv22=function(parentid,node,expandparent){var el=document.createElement('div');el.className='treenode';el.owner=this;if(node.details)el.title=node.details;if(this.candragnodes){el.vv8=true;el.ondraggrab=this.vv34;el.ondragdone=this.vv35;}
var stateimage=document.createElement('img');stateimage.onclick=this.vv36;stateimage.owner=el;stateimage.style.width='18px';stateimage.style.height='18px';stateimage.src=node.children?this.imageroot+'images/collapsed.gif':this.imageroot+'images/spacer.gif';stateimage.align='absmiddle';el.appendChild(stateimage);el.stateimage=stateimage;var typeimage=document.createElement('img');typeimage.onclick=this.vv36;typeimage.owner=el;typeimage.style.width='18px';typeimage.style.height='18px';typeimage.align='absmiddle';typeimage.src=node.children?this.imageroot+'images/'+this.folderimage:this.imageroot+'images/'+this.pageimage;el.appendChild(typeimage);el.typeimage=typeimage;var caption=document.createElement('span');caption.innerHTML=node.name;caption.onclick=this.vv37;caption.ondblclick=this.vv36;caption.style.whiteSpace='nowrap';caption.className='treenode_caption';caption.owner=el;el.caption=caption;el.appendChild(caption);el.owner=this;el.tree_url=node.url;el.tree_id=node.id;el.tree_data=node.data;el.tree_parent=parentid?this.idindex[parentid]:null;el.tree_haschildren=node.children;el.tree_populated=false
el.tree_collapsed=true;el.style.whiteSpace='nowrap';if(node.children){el.tree_childnodes=document.createElement('div');el.tree_childnodes.className='treechildren';el.tree_childnodes.style.display='none';el.appendChild(el.tree_childnodes);}
this.idindex[node.id]=el;if(el.tree_parent){if(!el.tree_parent.tree_childnodes){alert('NO el.tree_parent.tree_childnodes - tree_parent is ...');var_dump(el.tree_parent);alert('tree_childnodes is ...');var_dump(el.tree_parent.tree_childnodes);alert('haschildren is '+(el.tree_parent.tree_haschildren?'true':'false'));return;}
el.tree_parent.tree_childnodes.appendChild(el);el.tree_parent.tree_populated=true;if(expandparent)this.vv38(el.tree_parent,false);}else{this.container.appendChild(el);}
return el;}
vv1V.prototype.vv2x=function(parentid,values){this.container.style.cursor='default';for(var i=0;i<values.length;i++){this.vv22(parentid,values[i],i==values.length-1);}}
vv1V.prototype.vv38=function(node,iscollapsed){if(node.tree_childnodes){node.tree_collapsed=iscollapsed;node.tree_childnodes.style.display=iscollapsed?'none':'block';node.stateimage.src=iscollapsed?this.imageroot+'images/collapsed.gif':this.imageroot+'images/expanded.gif';node.typeimage.src=iscollapsed?this.imageroot+'images/'+this.folderimage:this.imageroot+'images/'+this.folderopenimage;}}
vv1V.prototype.vv39=function(node){if(node.tree_haschildren){if(node.tree_populated){this.vv38(node,!node.tree_collapsed);}else{this.container.style.cursor='wait';this.onfetchitems(this,node);}}}
vv1V.prototype.vv20=function(parentid){var tree_parent=parentid?this.idindex[parentid]:null;if(!tree_parent)return false;this.vv38(tree_parent,false);this.container.style.cursor='default';}
vv1V.prototype.vv3a=function(){var i=0;while(i<this.container.childNodes.length){node=this.container.childNodes[i];if(node&&node.style&&(node.style.display!='none'))return node;i++;}
return false;}
vv1V.prototype.vv3b=function(id){return this.idindex[id];}
vv1V.prototype.vv3c=function(node){if(this.callback)this.callback(node.tree_url);this.selectednode=node;}
vv1V.prototype.vv37=function(){var mytreeview=this.owner.owner;mytreeview.vv3d(this.owner);if(!mytreeview.multiselect)mytreeview.vv3c(this.owner);}
vv1V.prototype.vv36=function(){var mytreeview=this.owner.owner;mytreeview.vv39(this.owner);}
vv1V.prototype.vv3d=function(node){if(this.multiselect){this.vv3e(node);}else{if(this.selectednode&&this.selectednode.caption){if(this.selectednode==node)return;this.selectednode.caption.className='treenode_caption';}
node.caption.className='treenode_caption_selected';}}
vv1V.prototype.vv3f=function(node){var container=null;if(!node.tree_parent){container=this.container;}else{if(!node.tree_parent.tree_childnodes){return null;}
container=node.tree_parent.tree_childnodes;}
if(!container.childNodes||!container.childNodes.length){return null;}
return container;}
vv1V.prototype.vv3g=function(node,containerdiv){var siblings=containerdiv?containerdiv:this.vv3f(node);if(!siblings)return-1;var s='';for(var i=0;i<siblings.childNodes.length;i++){s+='['+node.tree_id+']<br>['+siblings.childNodes[i]+']<br><br>';if(node.tree_id==siblings.childNodes[i].tree_id)return i;}
return-1;}
vv1V.prototype.vv3h=function(node){var idlist=new Array();idlist[idlist.length]=node.tree_id;if(node.tree_haschildren&&node.tree_children){for(var i=0;i<node.tree_children.childNodes.length;i++){var childnode=node.tree_children.childNodes[i];var childidlist=this.vv3h(childnode);idlist=idlist.concat(childidlist);}}
return idlist;}
vv1V.prototype.vv3e=function(node){if(this.vv3i(node)&&!vv1S&&!vv1T){return;}
if((this.selectednode)&&(vv1S||vv1T)){var firstdiv=this.vv3f(this.selectednode);var lastdiv=this.vv3f(node);if(firstdiv!=lastdiv){this.vv3j(node);return;}else{parentdiv=firstdiv;}
if(vv1S){this.vv1I();loIdx=this.vv3g(this.selectednode,parentdiv);hiIdx=this.vv3g(node,parentdiv);if(hiIdx<loIdx){var x=hiIdx;hiIdx=loIdx;loIdx=x;}
var s='';for(var i=loIdx;i<=hiIdx;i++){var thisnode=parentdiv.childNodes[i];s+=thisnode+':'+thisnode.tree_id+' ';this.selectednodes[this.selectednodes.length]=thisnode;this.vv3k(thisnode,true);}
if(typeof this.onselectchange=='function')this.onselectchange(this,this.selectednodes.length==1?this.selectednodes[0]:NULL);}else if(vv1T){var was_selected=this.vv3i(node);if((was_selected)&&(this.selectednodes.length==1)){}else{this.vv3l(node,!was_selected);if(typeof this.onselectchange=='function')this.onselectchange(this,this.selectednodes.length==1?this.selectednodes[0]:NULL);}}}else{this.vv3j(node);}}
vv1V.prototype.vv3j=function(node){this.vv1I();this.vv3l(node,true);this.selectednode=node;if(typeof this.onselectchange=='function')this.onselectchange(this,node);}
vv1V.prototype.vv3m=function(node){this.vv3d(node);this.selectednode=node;}
vv1V.prototype.vv3n=function(node){var tvtop=layer.position(this.container);var nodetop=layer.position(node);var distance=nodetop.y-(tvtop.y+this.container.scrollTop);this.container.scrollTop=distance;}
vv1V.prototype.vv3o=function(targetnode){node=targetnode;while(node.tree_parent!=null){node=node.tree_parent;if(node.tree_collapsed)this.vv38(node,false);}
this.vv3m(targetnode);this.vv3n(targetnode);}
vv1V.prototype.vv3p=function(node){var el=false;var p=layer_get_pos(node);var div=document.createElement('div');div.className='treenode_dragging';div.style.left=p.x+'px';div.style.top=p.y+'px';var rowwidth=this.container.offsetWidth+'px';var itemcount=0;itemcount=this.selectednodes.length;if(itemcount>4)itemcount=3;var itemheight=0;for(var i=0;i<itemcount;i++){var el=this.selectednodes[i].cloneNode(true);el.id=this.elementid+'_dragnode_'+this.selectednodes[i].tree_id;div.appendChild(el);if(!itemheight)itemheight=parseInt(el.offsetHeight);}
if(this.selectednodes.length>itemcount){el=document.createElement('div');var remaining=(this.selectednodes.length-itemcount);el.innerHTML=remaining+' more item'+(remaining>1?'s':'')+' ...';div.appendChild(el);itemcount++;}
if(!itemheight)itemheight=18;div.style.width=rowwidth;document.body.insertBefore(div,document.body.childNodes[0]);div.style.height=(itemheight*itemcount)+'px'
return div;}
vv1V.prototype.vv34=function(obj){if(!obj.owner)return false;if(obj.owner.onnodegrab){if(!obj.owner.onnodegrab(obj))return false;}
if(obj.owner.multiselect){var dragitems=obj.owner.selectednodes.copy();}else{var dragitems=obj;}
var dragdata={"datatype":'treenode',"dataclass":obj.owner.dragdataclassname?obj.owner.dragdataclassname:"treenode","datasender":obj.owner.elementid,"data":dragitems,"dragelement":obj.owner.vv3p(obj),"dragelement_dispose":true,"dragelement_class_candrop":"treenode_candrop","dragelement_class_cantdrop":"treenode_cantdrop"};obj.originaloverflow=document.body.style.overflowX;document.body.style.overflowX='hidden';return dragdata;}
vv1V.prototype.vv35=function(obj){document.body.style.overflowX=obj.originaloverflow;}
vv1V.prototype.vv3q=function(targetcaption,dragdata){var dragnode=dragdata.data;var targetnode=targetcaption.owner;if(dragnode==targetnode)return;try{if(dragnode.tree_parent==null){this.owner.owner.container.removeChild(dragnode);}else{dragnode.tree_parent.tree_childnodes.removeChild(dragnode);if(dragnode.tree_parent.tree_childnodes.childNodes.length==0){dragnode.tree_parent.removeChild(dragnode.tree_parent.tree_childnodes);dragnode.tree_parent.tree_childnodes=null;dragnode.tree_parent.tree_haschildren=false;dragnode.tree_parent.stateimage.src=this.owner.owner.imageroot+'images/spacer.gif';dragnode.tree_parent.typeimage.src=this.owner.owner.imageroot+'images/'+this.pageimage;}}}catch(e){return;}
dragnode.tree_parent=targetnode;targetnode.tree_populated=true;if(!targetnode.tree_haschildren){targetnode.tree_childnodes=document.createElement('div');targetnode.tree_childnodes.className='treechildren';targetnode.tree_childnodes.style.display='none';targetnode.appendChild(targetnode.tree_childnodes);targetnode.tree_haschildren=true;}
targetnode.tree_childnodes.appendChild(dragnode);this.owner.owner.vv38(targetnode,false);}
vv1V.prototype.vv3k=function(node,selected){if(node)node.caption.className='treenode_caption'+(selected?'_selected':'');}
vv1V.prototype.vv1I=function(){if(this.selectednodes.length>0){for(var i=0;i<this.selectednodes.length;i++)this.vv3k(this.selectednodes[i],false);this.selectednodes=new Array();}}
vv1V.prototype.vv3i=function(node){for(var i=0;i<this.selectednodes.length;i++){if(this.selectednodes[i].tree_id==node.tree_id)return true;}
return false;}
vv1V.prototype.vv3l=function(node,selected){this.vv3k(node,selected);if(selected){this.selectednodes[this.selectednodes.length]=node;}else{var sel=new Array();for(var i=0;i<this.selectednodes.length;i++){if(this.selectednodes[i].tree_id!=node.tree_id)sel[sel.length]=this.selectednodes[i];}
this.selectednodes=sel;}}
function vv23(id,name,url,children,data,details){this.id=id;this.name=name;this.url=url;this.children=children;this.data=data;this.details=details;return this;}
