MSG.doc_delete_confirm="Do you want to delete this doc?\n("+_MSG.cannot_undo+")";MSG.tag_add_empty="Enter at least one keyword tag";MSG.tag_too_many="Sorry, you cannot enter more than 50 tags";MSG.tag_add_nok="Sorry, this tag is invalid";MSG.tag_del_confirm="Do you really want to remove the tag %s?";MSG.tag_too_spaces="You are about to add %d tag(s):<ul><li>%s</li></ul>If the result is not what you expect, please use the following syntax:\n<b><span style='color:red'>&quot;</span>%s<span style='color:red'>&quot;</span></b>";MSG.album_loading="Loading albums";MSG.album_creation="Creating album";MSG.album_creation_ok="Album created";MSG.album_creation_nok="Creating album has failed";MSG.album_doc_added="This doc has been added to the album %s";MSG.album_doc_removed="This doc has been removed from the album %s";MSG.note_add_text="type a note";MSG.group_loading="Loading groups";MSG.group_doc_private="<b>Wait! This doc is private!</b>\n If you add it to <b>%s</b>, visitors of this group will be able to view, to comment, to add tags and notes on this doc.\nIs this what you want?";MSG.group_doc_added="This doc has been added to the group %s";MSG.group_doc_pending="Done! This doc has been submitted to the group %s (moderated). It must be approved by the administrator before publication.";MSG.group_proposed="You've suggested adding this doc to the group %s. Now its author must approve your proposal.";MSG.group_proposed_invited="(Consequently, the author will be able to join your group without having to be invited).";MSG.group_unproposed="You've canceled your suggestion of adding this doc to %s.";MSG.group_unaccepted="You've ignored the suggestion of adding this doc to %s.";MSG.group_doc_refused="Sorry, this type of docs is not allowed in the group %s";MSG.group_doc_removed="This doc has been removed from the group %s";MSG.group_is_closed="closed";MSG.group_bad_type="doesn't accept this type of doc";MSG.group_quota="Limit is %d doc(s) %s";MSG.group_quota_period={d:"per day",w:"per week",m:"per month",a:"in total"};MSG.too_much_albums="Sorry, this doc is added to too many albums. Remove this doc from one album then try again.";
MSG.too_much_groups="Sorry, this doc is added to too many groups. Remove this doc from one group then try again.";MSG.group_error_ADD="Sorry, an error occurred when adding this doc to the group %s.";MSG.group_error_DEL="Sorry, an error occurred when removing this doc from the group %s.";MSG.group_error_3="You cannot add docs in the group %s for the moment.\n(You've reached the quota of authorized contributions decided by the group)";MSG.group_error_4="Sorry, the group %s doesn't accept contributions anymore.";MSG.album_error_ADD="Sorry, an error occurred when adding this doc to the album %s.";MSG.album_error_DEL="Sorry, an error occurred when removing this doc from the album %s.";MSG.picnik_redirect="We'll take you now to Picnik.\nWhen you're done, click on <b>Export</b> or <b>Back to ipernity</b>.";var init_tools=function(a){var b=init_tools_menu();if(!b){return}b.menu_on_show=function(){_hide_doc_player("doc.tools",true)};b.menu_on_hide=function(){_hide_doc_player("doc.tools",false)};b.album_ids=[];b.recent_album_ids=[];b.group_ids=[];b.recent_group_ids=[];b.loaded={album:[],group:[]};b.stp=50;b.startAlbumList=function(){this.showAlbumList(0)};b.showAlbumList=function(e){$("album_create").style.display="none";$("album_choose").style.display="block";if(!this.loaded.album[e]){$("album_list").update();var f=new Element("div").setStyle({padding:"10px",textAlign:"center",color:"#777"}).update(MSG.album_loading+"...");$("album_list").appendChild(f);var g={off:e,stp:b.stp,callback:"showAlbumList"};if(e==0){g.recents=1}return IOL.API.request("album.search",g,b)}if(!this.album_ids.length){$("album_create").style.display="block";$("album_choose").style.display="none";$("album_pagination").style.display="none";return}var c=$("album_list");c.innerHTML="";var n=this.loaded.album.total;if(n>15){c.style.height="300px";c.style.overflow="auto"}var l=this.recent_album_ids;if(e==0&&l.length){var h=document.createElement("div");h.className="line_under";for(var j=0;j<l.length;j++){var p=this.getAlbumListItem(l[j]);h.appendChild(p)}c.appendChild(h)
}var k=this.album_ids.slice(e,e+this.stp);for(var j=0;j<k.length;j++){var d=k[j];if(e==0&&l.length&&l.indexOf(d)>=0){continue}var p=this.getAlbumListItem(d);c.appendChild(p)}if(n>this.stp){$("album_pagination").style.display="block";pagination($("album_pagination"),{off:e,stp:this.stp,max:n},{max:8,callback:function(i){b.showAlbumList(i)}})}else{$("album_pagination").style.display="none"}};b.getAlbumListItem=function(i){var f=Data.album[i];var d=document.createElement("div");d.id="album_choose_"+i;var h=(f.doc_url)?f.doc_url+".t.jpg":URL.L+"/tool_menu/album_cover.png";var e='<img src="'+h+'" width="20" height="20" alt="" class="absmiddle" style="margin-right:5px"/>';var g=f.title.truncate_nice(25);if(Data.doc[a].album_ids.indexOf(_pi(i))>=0){var c='<span class="block" style="color:#888">'+e+g+' <a href="#" onclick="$(\'tools\').removeFromAlbum('+i+');return false;" class="trash">[x]</a></span>'}else{var c='<a href="#" class="block" onclick="$(\'tools\').addToAlbum('+i+');return false;">'+e+g+"</a>"}d.innerHTML=c;return d};b.showAlbumList_onApi=function(j,e,c,h){if(j){var g=e.r.off;for(var f=0;f<e.albums.length;f++){var d=e.albums[f];d.album_id=_pi(d.album_id);Data.album[d.album_id]=d;b.album_ids[g+f]=d.album_id}if(e.recents){b.recent_album_ids=[];for(var f=0;f<e.recents.length;f++){var d=e.recents[f];d.album_id=_pi(d.album_id);Data.album[d.album_id]=d;b.recent_album_ids.push(d.album_id)}}this.loaded.album[g]=true;this.loaded.album.total=e.r.max;this.loaded.album.offset=e.r.off;return this.showAlbumList(g)}else{modal.complain(e,{},1);b.hide_menu()}};b.addToAlbum=function(d,c){c=c||false;this.hide_menu();modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("album.add.doc",{album_id:d,doc_id:a,callback:"addToAlbum",_cancel:c},b)};b.addToAlbum_onApi=function(j,e,c,i){this.hide_menu();modal.shutup();var d=Data.album[i.album_id];var h='<b><a href="/doc/'+glob_u.folder+"/album/"+d.album_id+'">'+d.title+"</a></b>";if(j){d.doc_count++;if(!i._cancel){var g=MSG.album_doc_added.replace("%s",h);modal.say(g,{icon:"ok"},1,{onclick:function(){b.removeFromAlbum(d.album_id,true)
}})}$("albums_and_groups").style.display="block";if(Data.doc[a]["album_ids"].indexOf(_pi(d.album_id))<0){Data.doc[a]["album_ids"].push(d.album_id)}var f=$("rubix_album_"+d.album_id);if(f){f.style.display="block";f.open()}else{init_rubix("album",d.album_id,a,true)}}else{if(Data.doc[a].album_ids.length==20){var g=MSG.too_much_albums.replace("%s",h)}else{var g=MSG.album_error_ADD.replace("%s",h)+"(#"+e.error.id+")"}modal.say(g,{icon:"nok"},1)}};b.removeFromAlbum=function(d,c){c=c||false;this.hide_menu();modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("album.del.doc",{album_id:d,doc_id:a,callback:"removeFromAlbum",_cancel:c},b)};b.removeFromAlbum_onApi=function(k,e,c,j){this.hide_menu();modal.shutup();var d=Data.album[j.album_id];var h='<b><a href="/doc/'+glob_u.folder+"/album/"+d.album_id+'">'+d.title+"</a></b>";d.album_id=_pi(d.album_id);if(k){d.doc_count--;if(!j._cancel){var g=MSG.album_doc_removed.replace("%s",h);if(d.doc_count>0){modal.say(g,{icon:"ok"},1,{onclick:function(){b.addToAlbum(d.album_id,1)}})}else{modal.say(g,{icon:"ok"},1)}}if(d.doc_count==0){var f=this.album_ids.indexOf(d.album_id);if(f>=0){b.album_ids.splice(f,1);b.loaded.album.total--}}var f=Data.doc[a]["album_ids"].indexOf(d.album_id);if(f>=0){Data.doc[a]["album_ids"].splice(f,1)}if(Data.doc[a]["album_ids"].length==0&&Data.doc[a]["group_ids"].length==0){$("albums_and_groups").style.display="none"}$("rubix_album_"+d.album_id).remove()}else{var g=MSG.album_error_DEL.replace("%s",h)+"(#"+e.error.id+")";modal.say(g,{icon:"nok"},1)}};b.startGroupList=function(){this.showGroupList(0)};b.showGroupList=function(e){$("group_create").style.display="none";$("group_choose").style.display="block";if(!this.loaded.group[e]){$("group_list").update();var f=new Element("div").setStyle({padding:"10px",textAlign:"center",color:"#777"}).update(MSG.group_loading+"...");$("group_list").appendChild(f);var g={off:e,stp:b.stp,callback:"showGroupList"};if(!isyou){g.rel=3}if(e==0){g.recents=1}return IOL.API.request("group.search",g,b)}if(!this.group_ids.length){$("group_create").style.display="block";
$("group_choose").style.display="none";$("group_pagination").style.display="none";return}var c=$("group_list");c.innerHTML="";var n=this.loaded.group.total;if(n>15){c.style.height="300px";c.style.overflow="auto"}var l=this.recent_group_ids;if(e==0&&l.length){var h=document.createElement("div");h.className="line_under";for(var j=0;j<l.length;j++){var p=this.getGroupListItem(l[j]);h.appendChild(p)}c.appendChild(h)}var k=this.group_ids.slice(e,e+this.stp);for(var j=0;j<k.length;j++){var d=k[j];if(e==0&&l.length&&l.indexOf(d)>=0){continue}var p=this.getGroupListItem(d);c.appendChild(p)}if(n>this.stp){$("group_pagination").style.display="block";pagination($("group_pagination"),{off:e,stp:this.stp,max:n},{max:8,callback:function(i){b.showGroupList(i)}})}else{$("group_pagination").style.display="none"}};b.getGroupListItem=function(i){if(!isyou){return this.getGroupProposalItem(i)}var f=Data.group[i];var d=document.createElement("div");d.id="group_choose_"+i;var h=(f.doc_url)?f.doc_url+".t.jpg":URL.L+"/tool_menu/album_cover.png";var e='<img src="'+h+'" width="20" height="20" alt="" class="absmiddle" style="margin-right:5px"/>';var g=f.title.truncate_nice(25);if(Data.doc[a].group_ids.indexOf(_pi(i))>=0){var c='<span class="block" style="color:#888">'+e+g+' <a href="#" onclick="$(\'tools\').removeFromGroup('+i+');return false;" class="trash">[x]</a></span>'}else{if(Data.doc[a].group_proposed_ids.indexOf(_pi(i))>=0||f.open){var c='<a href="#" class="block" onclick="$(\'tools\').addToGroup('+i+');return false;">'+e+g+"</a>"}else{var c='<span class="block" style="color:#888">'+e+g+" ("+MSG.group_is_closed+")</span>"}}d.innerHTML=c;return d};b.getGroupProposalItem=function(h){var f=Data.group[h];var d=document.createElement("div");d.id="group_choose_"+h;var e='<img src="'+f.doc_url+'" width="20" height="20" alt="" class="absmiddle" style="margin-right:5px"/>';var g=f.title.truncate_nice(25);if(Data.doc[a].group_ids.indexOf(_pi(h))>=0){var c='<span class="block" style="color:#888">'+e+g+' <a href="#" onclick="$(\'tools\').removeFromGroup('+h+');return false;" class="trash">[x]</a></span>'
}else{if(Data.doc[a].group_proposed_ids.indexOf(_pi(h))>=0){var e='<img src="'+URL.L+'/rubix/group_proposed.png" width="20" height="19" alt="" class="absmiddle" style="margin-right:5px"/>';var c='<span class="block" style="color:#888">'+e+g+' <a href="#" onclick="$(\'tools\').unproposeFromGroup('+h+');return false;" class="trash">[x]</a></span>'}else{if(Data.doc[a].group_pending_ids.indexOf(_pi(h))>=0){var e='<img src="'+URL.L+'/rubix/group_pending.png" width="20" height="19" alt="" class="absmiddle" style="margin-right:5px"/>';var c='<a href="#" class="block" onclick="$(\'tools\').proposeToGroup('+h+');return false;">'+e+g+"</a>"}else{if(f.open){var c='<a href="#" class="block" onclick="$(\'tools\').proposeToGroup('+h+');return false;">'+e+g+"</a>"}else{var c='<span class="block" style="color:#888">'+e+g+" ("+MSG.group_is_closed+")</span>"}}}}d.innerHTML=c;return d};b.showGroupList_onApi=function(j,d,c,h){if(j){var g=d.r.off;for(var e=0;e<d.groups.length;e++){var f=d.groups[e];f.group_id=_pi(f.group_id);f.open=_pi(f.open);f.types=_pi(f.types);Data.group[f.group_id]=f;b.group_ids[g+e]=f.group_id}if(d.recents){for(var e=0;e<d.recents.length;e++){var f=d.recents[e];f.group_id=_pi(f.group_id);f.open=_pi(f.open);f.types=_pi(f.types);Data.group[f.group_id]=f;b.recent_group_ids.push(f.group_id)}}this.loaded.group[g]=true;this.loaded.group.total=d.r.max;this.loaded.group.offset=d.r.off;return this.showGroupList(g)}else{modal.complain(d,{},1);b.hide_menu()}};b.addToGroup=function(d,c,e){c=c||false;e=e||false;this.hide_menu();if(Data.doc[a].share<4&&!e){var f=MSG.group_doc_private.replace("%s",Data.group[d].title);return modal.say(f,{icon:"warn"},{onclick:function(){b.addToGroup(d,false,true)}},{label:_MSG.no})}modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("group.add.doc",{group_id:d,doc_id:a,callback:"addToGroup",_cancel:c},b)};b.addToGroup_onApi=function(k,d,c,j){this.hide_menu();modal.shutup();var f=Data.group[j.group_id];var h='<b><a href="/group/'+f.folder+'">'+f.title+"</a></b>";f.group_id=_pi(f.group_id);
if(k){if(d.group.added||d.group.pending){if(this.recent_group_ids.indexOf(f.group_id)<0){this.recent_group_ids.push(f.group_id)}if(d.group.pending){return this.addedToModeratedGroup(j.group_id)}f.doc_count++;if(Data.doc[a]["group_proposed_ids"].indexOf(f.group_id)>=0){$("rubix_group_"+f.group_id).remove();var e=Data.doc[a]["group_proposed_ids"].indexOf(f.group_id);Data.doc[a]["group_proposed_ids"].splice(e,1);if(Data.doc[a]["group_proposed_ids"].length==0){$("groups_proposed").style.display="none"}}if(!j._cancel){var g=MSG.group_doc_added.replace("%s",h);modal.say(g,{icon:"ok"},1,{onclick:function(){b.removeFromGroup(f.group_id,true)}})}$("albums_and_groups").style.display="block";if(Data.doc[a]["group_ids"].indexOf(f.group_id)<0){Data.doc[a]["group_ids"].push(f.group_id)}init_rubix("group",f.group_id,a,true)}else{if(d.group.doc[0].error==1){var g=MSG.too_much_groups.replace("%s",h);return modal.say(g,{icon:"warn"},1)}else{if(d.group.doc[0].error==2){var g=MSG.group_doc_refused.replace("%s",h);return modal.say(g,{icon:"warn"},1)}else{return modal.say(_MSG.failed,{icon:"nok"},1)}}}}else{if(d.error.id==3){var g=MSG.group_error_3.replace("%s",h)}else{if(d.error.id==4){var g=MSG.group_error_4.replace("%s",h)}else{var g=MSG.group_error_ADD.replace("%s",h)+"(#"+d.error.id+")"}}modal.say(g,{icon:"nok"},1)}};b.removeFromGroup=function(d,c){c=c||0;this.hide_menu();modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("group.del.doc",{group_id:d,doc_id:a,callback:"removeFromGroup",_cancel:c},b)};b.removeFromGroup_onApi=function(k,d,c,j){this.hide_menu();modal.shutup();if(k){var f=Data.group[j.group_id];var h='<b><a href="/group/'+f.folder+'">'+f.title+"</a></b>";f.group_id=_pi(f.group_id);f.doc_count--;if(!j._cancel){var g=MSG.group_doc_removed.replace("%s",h);if(f.doc_count>0&&isyou){modal.say(g,{icon:"ok"},1,{onclick:function(){b.addToGroup(f.group_id,1)}})}else{modal.say(g,{icon:"ok"},1)}}if(f.doc_count==0){var e=this.group_ids.indexOf(f.group_id);if(e>=0){b.group_ids.splice(e,1);b.loaded.group.total--
}}var e=Data.doc[a]["group_ids"].indexOf(f.group_id);if(e>=0){Data.doc[a]["group_ids"].splice(e,1)}var e=Data.doc[a]["group_pending_ids"].indexOf(f.group_id);if(e>=0){Data.doc[a]["group_pending_ids"].splice(e,1)}if(Data.doc[a]["group_ids"].length==0&&Data.doc[a]["group_ids"].length==0){$("albums_and_groups").style.display="none"}if(Data.doc[a]["group_pending_ids"].length==0){$("groups_pending").style.display="none"}$("rubix_group_"+f.group_id).remove()}else{var g=MSG.group_error_DEL.replace("%s",h)+"(#"+d.error.id+")";modal.say(g,{icon:"nok"},1)}};b.proposeToGroup=function(c){this.hide_menu();modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("group.add.doc",{group_id:c,doc_id:a,callback:"proposeToGroup"},b)};b.proposeToGroup_onApi=function(j,m,f,e){this.hide_menu();modal.shutup();var k=_pi(e.group_id);var l=Data.group[k];var h='<b><a href="/group/'+l.folder+'">'+l.title+"</a></b>";if(j&&m.group.total==1){if($("rubix_group_"+k)){$("rubix_group_"+k).remove()}if(m.group.added==1){var g=Data.doc[a]["group_pending_ids"].indexOf(k);Data.doc[a]["group_pending_ids"].splice(g,1);if(Data.doc[a]["group_pending_ids"].length==0){$("groups_pending").style.display="none"}l.doc_count++;if(Data.doc[a]["group_ids"].indexOf(k)<0){Data.doc[a]["group_ids"].push(k)}init_rubix("group",l.group_id,a,true);var d=MSG.group_doc_added.replace("%s",h);return modal.say(d,{icon:"ok"},1)}if(m.group.pending==1){var c=document.createElement("div");c.innerHTML=$("rubix_pending_tpl").innerHTML;c.id="rubix_group_"+k;c.getElementsByTagName("img")[0].src=URL.L+"/rubix/group_proposed.png";c.getElementsByTagName("a")[0].href="/group/"+l.folder;c.getElementsByTagName("a")[0].innerHTML=l.title;c.getElementsByTagName("a")[1].onclick=function(){this.unproposeFromGroup(k);return false}.bind(this);c.getElementsByTagName("a")[1].title=c.getElementsByTagName("a")[1].title.replace("%s",l.title);$("groups_proposed_container").appendChild(c);$("groups_proposed").style.display="block";if(Data.doc[a]["group_proposed_ids"].indexOf(k)<0){Data.doc[a]["group_proposed_ids"].push(k)
}var d=MSG.group_proposed.replace("%s",h);return modal.say(d,{icon:"ok"},1)}if(m.group.doc.length&&m.group.doc[0].error==1){var d=MSG.too_much_groups.replace("%s",h);return modal.say(d,{icon:"warn"},1)}else{if(m.group.doc.length&&m.group.doc[0].error==2){var d=MSG.group_doc_refused.replace("%s",h);return modal.say(d,{icon:"warn"},1)}else{return modal.say(_MSG.failed,{icon:"nok"},1)}}}else{if(m.error.id==3){var d=MSG.group_error_3.replace("%s",h)}else{if(m.error.id==4){var d=MSG.group_error_4.replace("%s",h)}else{var d=MSG.group_error_DEL.replace("%s",h)+"(#"+m.error.id+")"}}modal.say(d,{icon:"nok"},1)}};b.unproposeFromGroup=function(c){this.hide_menu();modal.say(_MSG.processing+"...",{icon:"wait",timeout:10000});IOL.API.request("group.del.doc",{group_id:c,doc_id:a,callback:"unproposeFromGroup"},b)};b.unproposeFromGroup_onApi=function(j,l,f,e){modal.shutup();var k=Data.group[e.group_id];var h='<b><a href="/group/'+k.folder+'">'+k.title+"</a></b>";k.group_id=_pi(k.group_id);if(j){var g=Data.doc[a]["group_proposed_ids"].indexOf(k.group_id);if(g>=0){Data.doc[a]["group_proposed_ids"].splice(g,1)}if(Data.doc[a]["group_proposed_ids"].length==0){$("groups_proposed").style.display="none"}var c=$("rubix_group_"+k.group_id);if(c){c.remove()}if(isyou){var d=MSG.group_unaccepted.replace("%s",h)}else{var d=MSG.group_unproposed.replace("%s",h)}return modal.say(d,{icon:"ok"},{})}else{var d=MSG.group_error_DEL.replace("%s",h)+"(#"+l.error.id+")";modal.say(d,{icon:"nok"},1)}};b.addedToModeratedGroup=function(c){var e=$("rubix_group_"+c);var d=Data.group[c];d.group_id=_pi(d.group_id);d.doc_count++;if(e){e.remove()}var h=document.createElement("div");h.innerHTML=$("rubix_pending_tpl").innerHTML;h.id="rubix_group_"+c;h.getElementsByTagName("img")[0].src=URL.L+"/rubix/group_pending.png";h.getElementsByTagName("a")[0].href="/group/"+d.folder;h.getElementsByTagName("a")[0].innerHTML=d.title;h.getElementsByTagName("a")[1].onclick=function(){$("tools").removeFromModeratedGroup(c);return false};h.getElementsByTagName("a")[1].title=h.getElementsByTagName("a")[1].title.replace("%s",d.title);
$("groups_pending_container").appendChild(h);$("groups_pending").style.display="block";if(Data.doc[a]["group_pending_ids"].indexOf(d.group_id)<0){Data.doc[a]["group_pending_ids"].push(d.group_id)}var g='<b><a href="/group/'+d.folder+'">'+d.title+"</a></b>";var f=MSG.group_doc_pending.replace("%s",g);return modal.say(f,{icon:"ok"},{})};b.removeFromModeratedGroup=function(c){IOL.API.request("group.del.doc",{group_id:c,doc_id:a,callback:"removeFromModeratedGroup"},b)};b.removeFromModeratedGroup_onApi=function(j,l,g,e){var k=Data.group[e.group_id];var c=$("rubix_group_"+k.group_id);k.group_id=_pi(k.group_id);b.hide_menu();if(j){var h='<b><a href="/group/'+k.folder+'">'+k.title+"</a></b>";k.doc_count--;var d=MSG.group_doc_removed.replace("%s",h);modal.say(d,{icon:"ok"},1);var f=Data.doc[a]["group_pending_ids"].indexOf(k.group_id);if(f>=0){Data.doc[a]["group_pending_ids"].splice(f,1)}if(Data.doc[a]["group_pending_ids"].length==0){$("groups_pending").style.display="none"}if(c){c.remove()}}else{modal.complain(l,"",1)}};b.acceptInModeratedGroup=function(c){IOL.API.request("group.add.doc",{group_id:c,doc_id:a,callback:"acceptInModeratedGroup"},b)};b.acceptInModeratedGroup_onApi=function(j,m,f,e){var k=e.group_id;var c=$("rubix_group_"+k);var l=Data.group[k];l.group_id=_pi(l.group_id);b.hide_menu();if(j){l.doc_count++;var g=Data.doc[a]["group_pending_ids"].indexOf(k);if(g>=0){Data.doc[a]["group_pending_ids"].splice(g,1)}c.remove();init_rubix("group",k,a,true);var h='<b><a href="/group/'+l.folder+'">'+l.title+"</a></b>";var d=MSG.group_doc_added.replace("%s",h);modal.say(d,{icon:"ok"},1)}else{var d=MSG.group_error_ADD.replace("%s",h)+"(#"+m.error.id+")";modal.say(d,{icon:"nok"},1)}};b.showAlbumCreate=function(){setTimeout("document.fa.title.focus()",500);$("album_create").style.display="block";$("album_choose").style.display="none";$("album_pagination").style.display="none";document.fa.title.onchange=document.fa.title.onblur=function(){if(this.value.trim()){document.fa.submit.disabled=false;document.fa.submit.className="submit"
}else{document.fa.submit.disabled=true;document.fa.submit.className="reset"}};document.fa.submit.disabled=true;document.fa.submit.className="reset"};b.createAlbum=function(){var e=document.fa.title.value.trim();var d=document.fa.content.value.trim();if(!e){return}b.hide_menu();modal.say(MSG.album_creation,{icon:"wait"});var c=IOL.API.request("album.add",{title:e,content:d,cover_id:a,callback:"createAlbum"},b)};b.createAlbum_onApi=function(g,e,c,f){if(g){var d=e.album;d.album_id=_pi(d.album_id);d.doc_url=Data.doc[f.cover_id].doc_url;Data.album[d.album_id]=d;this.album_ids.unshift(d.album_id);this.loaded.album.total++;modal.say(MSG.album_creation_ok,{timeout:500});return this.addToAlbum(d.album_id)}else{this.hide_menu();modal.say(MSG.album_creation_nok,{icon:"nok"},{});return}};b.add_note=function(c){pn.add_note({note_id:0,user_id:glob_user_id,content:MSG.note_add_text,type:0})};b.showBlackBackground=function(){var h=$("blackbackground");if(!h||!bulb){var j=Data.doc[a];var f=URL.L+"/skin/o90.png";h=new Element("div",{id:"blackbackground"}).setStyle({display:"none",position:"absolute",top:0,left:0,zIndex:9999}).observe("click",function(){b.hideBlackBackground()});var g=new Element("div").setStyle({position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"black"}).setOpacity(0.96);h.appendChild(g);var d=new Element("div").setStyle({position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"white",display:"none"}).setOpacity(0.98);h.appendChild(d);var e=new Element("img",{src:"#",width:bulb.width,height:bulb.height,alt:""}).setStyle({position:"absolute",display:"none",border:"solid 10px black"}).setOpacity(0.2).observe("load",function(){e.show()});e.setAttribute("src",j.doc_url+".560.jpg");h.appendChild(e);var c=new Element("img",{src:"#",width:bulb.width,height:bulb.height,alt:""}).setStyle({display:"none",position:"absolute",border:"solid 10px black"}).observe("load",function(){e.hide();c.hide();new Effect.Appear(c,{duration:0.1,fps:40})});c.setAttribute("src",bulb.url);h.appendChild(c);var l=new Element("img",{src:URL.L+"/z.gif",width:bulb.width,height:bulb.height,alt:""}).setStyle({position:"absolute",padding:"10px"});
h.appendChild(l);var i=new Element("div",{on:"black"}).setStyle({position:"absolute",backgroundColor:"#111111",padding:"5px",textAlign:"center",width:"80px",top:"0",right:"0"}).observe("mouseover",function(){var m=(this.getAttribute("on")=="black")?true:false;this.setStyle({cursor:"pointer",backgroundColor:(m)?"#cccccc":"#333333"})}).observe("mouseout",function(){var m=(this.getAttribute("on")=="black")?true:false;this.setStyle({backgroundColor:(m)?"#333333":"#cccccc"})}).observe("click",function(n){n.stop();var m=(this.getAttribute("on")=="black")?true:false;this.setAttribute("on",(m)?"white":"black");h.select("div")[0].style.display=(m)?"none":"block";h.select("div")[1].style.display=(m)?"block":"none";this.setStyle({backgroundColor:(m)?"#333333":"#eeeeee"})});var k=new Element("a",{href:"#"}).update(_MSG.close).setStyle({color:"white",fontSize:"10px",textDecoration:"underline"}).observe("click",function(m){m.stop();b.hideBlackBackground()}).observe("mouseover",function(m){m.stop();i.setStyle({backgroundColor:"black"})});i.appendChild(k);h.appendChild(i);$(document.body).insert(h);b.resizeBlackBackgroundObserver=b.resizeBlackBackground.bindAsEventListener(b);b.keypressBlackBackgroundObserver=b.keypressBlackBackground.bindAsEventListener(b)}b.resizeBlackBackground();Event.observe(window,"resize",b.resizeBlackBackgroundObserver);Event.observe(window,"scroll",b.resizeBlackBackgroundObserver);Event.observe(document,"keydown",b.keypressBlackBackgroundObserver);h.show()};b.hideBlackBackground=function(){var c=$("blackbackground");if(c.getAttribute("hiding")){return}c.setAttribute("hiding","true");Event.stopObserving(window,"resize",b.resizeBlackBackgroundObserver);Event.stopObserving(window,"scroll",b.resizeBlackBackgroundObserver);Event.stopObserving(document,"keydown",b.keypressBlackBackgroundObserver);new Effect.Fade(c,{duration:0.3,fps:40,afterFinish:function(){c.setAttribute("hiding","")}})};b.keypressBlackBackground=function(c){if(c.keyCode==Event.KEY_ESC){b.hideBlackBackground()}};b.resizeBlackBackground=function(){var j=document.viewport.getDimensions();
var i=document.viewport.getScrollOffsets();var f=$("blackbackground");f.style.top=i.top+"px";f.style.left=i.left+"px";f.style.width=j.width+"px";f.style.height=j.height+"px";var d=bulb.width;var g=bulb.height;while((d+20)>j.width||(g+20)>j.height){d*=0.9;g*=0.9}var c=(j.width-d-20)/2+"px";var e=(j.height-g-20)/2+"px";f.select("img").each(function(h,k){if(k<3){h.setStyle({left:c,top:e,width:d+"px",height:g+"px"})}})};b.fave_doc=function(c){if(b.is_faving){return}$("fave_doc").style.display="none";$("unfave_doc").style.display="block";var d={fave:1,doc_id:a};if(window.glob_group){d.group_id=glob_group.group_id}b.is_faving=true;IOL.API.request("doc.set.vote",d,b)};b.unfave_doc=function(c){if(b.is_faving){return}$("fave_doc").style.display="block";$("unfave_doc").style.display="none";var d={fave:0,doc_id:a};if(window.glob_group){d.group_id=glob_group.group_id}b.is_faving=true;IOL.API.request("doc.set.vote",d,b)};b.doc_set_vote_onApi=function(f,d,c,e){b.is_faving=false;if(f){}else{if(e.fave){$("fave_doc").style.display="block";$("unfave_doc").style.display="none"}else{$("fave_doc").style.display="none";$("unfave_doc").style.display="block"}modal.complain(d,"",1)}};b.rotate_doc=function(f){if(!this.rotate_initialized){var d=Data.doc[a];var c='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="160" height="150" id="rotate" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="/E/Flash/doc_rotate.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#f7f7f7" /><param name="flashvars" value="doc_url='+d.doc_url+'.s.jpg" /><embed src="/E/Flash/doc_rotate.swf" quality="high" bgcolor="#f7f7f7" width="160" height="150" name="rotate" align="middle" flashvars="doc_url='+d.doc_url+'.s.jpg" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';$("rotate_doc_tool").innerHTML=c;this.rotate_initialized=true
}};b.rotate_doc_done=function(c){b.hide_menu();if(c){modal.say(_MSG.processing,{icon:"wait",overlay:1});IOL.API.request("doc.rotate",{doc_id:a,degree:c},b)}};b.doc_rotate_onApi=function(f,d,c,e){if(f){modal.say(_MSG.success,{icon:"ok"});location.reload()}else{modal.complain(d,{},1)}};b.print_doc=function(c){modal.say(MSG.processing,{icon:"wait"});$("print_doc_div_wait").style.display="block";$("print_doc_div_nok").style.display="none";$("print_doc_div_ok").style.display="none";IOL.API.request("cart.add",{doc_id:a,callback:"print_doc"},b)};b.print_doc_onApi=function(g,d,c,f){$("print_doc_div_wait").style.display="none";if(g){modal.shutup();$("print_doc_div_ok").style.display="block";$("print_doc_count").innerHTML=" "+d.doc_count+" ";var e=$("print_doc_div_ok").getElementsByTagName("div");e[0].style.display=(d.affected)?"block":"none";e[1].style.display=(d.affected)?"none":"block"}else{this.hide_menu();modal.complain(d,{},1)}};b.delete_doc=function(c){if(!confirm(MSG.doc_delete_confirm)){return false}IOL.API.request("doc.del",{doc_id:a},b)};b.doc_del_onApi=function(j,k,g,e){if(j){var h="?c=1&s=doc.del&doc_id="+e.doc_id;var l=(window.context)?window.context:"";if(window.glob_rubix_thumbs&&window.glob_rubix_thumbs.length){var c=window.glob_rubix_thumbs;var d=0;for(var f=0;f<c.length;f++){if(c[f].doc_id==e.doc_id){d=f;break}}if(c[d-1]){document.location="/doc/"+c[d-1].user_id+"/"+c[d-1].doc_id+l+h}else{if(c[d+1]){document.location="/doc/"+c[d+1].user_id+"/"+c[d+1].doc_id+l+h}else{document.location="/doc/"+glob_u.user_id+"/home"+l+h}}}else{document.location="/doc/"+glob_user.user_id+"/home"+l+h}}else{modal.complain(k,"",1)}};b.picnik=function(){var c="/doc/"+glob_u.folder+"/"+a+"/picnik";setTimeout(function(){document.location.replace(c)},3000);modal.say(MSG.picnik_redirect,{flash:"wait",timeout:3000},{click:function(){document.location.replace(c)}})}};function init_keyword_tags(c){var a=$("keyword_tags");if(!a){return}a.select("a.trash").each(function(d){d.title=a.getAttribute("deltag")});a.add_tag=function(e,g){var d=e.trim();
var f=d.split(/\s/);if(!d.match(/\"/)&&!d.match(/\,/)&&f.length>2&&!g){var i=MSG.tag_too_spaces.replace("%d",f.length).replace("%s",f.join("</li><li>")).replace("%s",d);return modal.say(i,{icon:"warn",width:300},{label:_MSG.goahead,onclick:function(){a.add_tag(e,true)}},{label:_MSG.cancel})}if(d){var h={keywords:d,doc_id:c};if(window.glob_group){h.group_id=glob_group.group_id}IOL.API.request("doc.add.tag",h,a)}else{alert(MSG.tag_add_empty)}return false};a.doc_add_tag_onApi=function(l,n,g,f){if(l){var j=n.keywords;var m=Data.doc[c];if(j.length){for(var h=0;h<j.length;h++){var e=j[h].keyword_id;if(!$("keyword_tag_"+e)){var o=$("keyword_tags").getAttribute("deltag");var d=document.createElement("dt");d.id="keyword_tag_"+e;d.innerHTML='&bull; <a href="/tag/'+glob_user.folder+"/keyword/"+e+'">'+j[h].title+'</a> <a href="#" onclick="$(\'keyword_tags\').del_tag('+e+');return false;" class="trash" title="'+o+'">[x]</a>';$("keyword_tags").appendChild(d)}}}if(b){b.keywords.value="";b.keywords.focus()}}else{if(n.error.id==2){modal.say(MSG.tag_add_nok,{icon:"nok"},1)}else{if(n.error.id==3){modal.say(MSG.tag_too_many,{icon:"nok"},1)}else{modal.complain(n,{},1)}}}};a.del_tag=function(d){var e=$("keyword_tag_"+d).select("a")[0].innerHTML;if(confirm(MSG.tag_del_confirm.replace("%s",'"'+e+'"'))){var f={keyword_id:d,doc_id:c};if(window.glob_group){f.group_id=glob_group.group_id}IOL.API.request("doc.del.tag",f,a)}};a.doc_del_tag_onApi=function(g,f,d,h){if(g){var e=h.keyword_id;$("keyword_tags").removeChild($("keyword_tag_"+e))}else{modal.complain(f,{},1)}};var b=$("keyword_tags_form");if(b){b.onsubmit=function(){a.add_tag(this.keywords.value);return false}}}profile_tags_autocompleter=Class.create(Autocompleter.Base,{initialize:function(b,a){this.element=$("profile_tags_form").select("input")[0];this.update=$("profile_tags_form").select("div")[0];this.tip=$("profile_tags_form").select("div")[1];this.nok=$("profile_tags_form").select("div")[2];this.tags=$("profile_tags");this.baseInitialize(this.element,this.update,a);Event.observe(this.element,"focus",function(){this.tip.clonePosition(this.element,{setHeight:false,offsetTop:this.element.offsetHeight-1});
this.nok.clonePosition(this.element,{setHeight:false,offsetTop:this.element.offsetHeight-1});this.element.addClassName("on");this.tip.show();this.nok.hide()}.bind(this));Event.observe(this.element,"blur",function(){this.element.clear();this.element.removeClassName("on");this.tip.hide();this.nok.hide()}.bind(this));Event.observe(this.element,"keyup",function(){if(this.element.value.blank()){this.nok.hide();this.tip.show()}}.bind(this));this.options.afterUpdateElement=function(d,c){$("profile_tags").add_tag(c.getAttribute("item"));$("profile_tags_form").select("input")[0].value="";$("profile_tags_form").select("input")[0].blur()}},startIndicator:function(){this.element.addClassName("processing")},stopIndicator:function(){this.element.removeClassName("processing")},getUpdatedChoices:function(){this.startIndicator();if(!this.data){return IOL.API.request("user.get.network",{},this)}this.stopIndicator();this.setValues();this.updateChoices(this.setValues())},user_get_network_onApi:function(g,c,a,f){if(g){c.network[c.network.length]=glob_u;this.data=[];for(var d=0;d<c.network.length;d++){var b=c.network[d];if(!Data.user[b.user_id]){Data.user[b.user_id]=b}var e={value:_pi(b.user_id),label:b.title,icon:b.doc_url};this.data.push(e)}this.element.focus();this.getUpdatedChoices()}else{modal.complain(c,{},1);this.stopIndicator();this.element.clear();$("profile_tags_form").style.display="none"}},accentInsensitive:function(a){return a.replace(/([\?\.\*\\\+\-\_\=\[\]\{\}\(\)])/g,"\\$1").replace(/a/ig,"[aàáâãäå]").replace(/e/ig,"[eèéêë]").replace(/i/ig,"[iìíîï]").replace(/o/ig,"[oòóôõöø]").replace(/u/ig,"[uùúûü]").replace(/y/ig,"[yÿ]").replace(/c/ig,"[cç]").replace(/n/ig,"[nñ]").strip()},setValues:function(){var b=this.accentInsensitive(this.element.value);if(!b){return("<ul></ul>")}var a=new RegExp("(^|\\s)"+b,"i");var d=[];for(var e=0;e<this.data.length;e++){var g=this.data[e];if(g&&a.test(g.label)){d.push(g)}}if(d.length){var f="";for(var e=0;e<d.length;e++){var g=d[e];var c=g.label.gsub(a,function(h){if(h[0][0]==" "){return" <em>"+h[0].substr(1)+"</em>"
}else{return"<em>"+h[0]+"</em>"}});f+='<li item="'+g.value+'"><img src="'+g.icon+'" width="25" height="25" alt=""/> '+c+"</li>"}this.nok.hide();this.tip.hide();return("<ul>"+f+"</ul>")}else{this.tip.hide();this.nok.show();return("<ul></ul>")}},setOptions:function(a){this.options=Object.extend({width:0,debug:false,frequency:0.1,minChars:1,autoSubmit:false,inputClass:""},a||{})}});function init_profile_tags(c){var a=$("profile_tags");if(!a){return}var b=$("profile_tags_form");if(b){b.onsubmit=function(){return false}}a.select("a.trash").each(function(d){d.title=a.getAttribute("deltag")});a.add_tag=function(d){var e={profile_id:d,doc_id:c};if(window.glob_group){e.group_id=glob_group.group_id}IOL.API.request("doc.add.tag",e,a)};a.doc_add_tag_onApi=function(g,f,d,i){if(g){var k=i.profile_id;var e=Data.user[i.profile_id];if(!$("profile_tag_"+k)){var j=$("profile_tags").getAttribute("deltag");var h=document.createElement("dt");h.id="profile_tag_"+k;h.innerHTML='&bull; <img src="'+e.doc_url+'" align="absmiddle" class="buddy" alt="" style="width:17px;height:17px"/> <a href="/tag/'+glob_user.folder+"/profile/"+k+'">'+e.title+'</a> <a href="#" onclick="$(\'profile_tags\').del_tag('+k+');return false;" class="trash" title="'+j+'">[x]</a>';$("profile_tags").appendChild(h);this.removeEmptyNote();this.removeProfileNote(i.profile_id);if(Data.doc[i.doc_id].embed=="jpg"){pn.add_note({note_id:0,user_id:glob_user_id,content:"",type:1,profile_id:i.profile_id})}}}else{if(f.error.id==2){modal.say(MSG.tag_add_nok,{icon:"nok"},1)}else{if(f.error.id==3){modal.say(MSG.tag_too_many,{icon:"nok"},1)}else{modal.complain(f,{},1)}}}};a.del_tag=function(d){var e=$("profile_tag_"+d).select("a")[0].innerHTML;if(confirm(MSG.tag_del_confirm.replace("%s",'"'+e+'"'))){var f={profile_id:d,doc_id:c};if(window.glob_group){f.group_id=glob_group.group_id}IOL.API.request("doc.del.tag",f,a)}};a.doc_del_tag_onApi=function(g,f,d,h){if(g){var e=h.profile_id;$("profile_tags").removeChild($("profile_tag_"+e));this.removeProfileNote(h.profile_id)}else{modal.complain(f,{},1)
}};a.removeProfileNote=function(f){if(pn&&pn.notes.length){for(var d=0;d<pn.notes.length;d++){var e=pn.notes[d];if(e.profile_id&&e.profile_id==f){if(e.id){e.delete_note(e)}else{pn.delete_note(e)}}}}};a.removeEmptyNote=function(f){if(pn&&pn.notes.length){for(var d=0;d<pn.notes.length;d++){var e=pn.notes[d];if(!e.id){pn.delete_note(e)}}}}}var doc_props=Class.create();doc_props.prototype.initialize=function(e){if(!$("doc_props")){return}this.doc_id=e;this.doc=Data.doc[e];this.window_div=$("doc_props");this.window_div.obj=this;this.tabs=["share","license"];this.debug_level=800;this.debug_scope="doc_tools";this.doc_props=["share","com","tag","tagme","license"];this.show_doc_props();this.nets=[1,2,7,31];this.inpo={1:document.fprops["original[1]"],2:document.fprops["original[2]"],7:document.fprops["original[7]"],31:document.fprops["original[31]"]};for(var c=0;c<this.tabs.length;c++){var b=this.tabs[c];var d=$("doc_props_tab_"+b);d.tab=b;var a=this;Event.observe(d,"click",function(g){var f=Event.element(g);a.show_tab(f.tab,f);Event.stop(g)})}};doc_props.prototype.init_window=function(){if(this.win){return}this.win=new win(this.window_div,{zindex:2000});this.overlay=new overlay()};doc_props.prototype.open=function(){_hide_flash_player(true);this.init_window();this.overlay.show();var c=this.doc;this.doc_props.each(function(g){try{$(g+"_"+c[g]).checked="true"}catch(f){}});check_share("share",c.share,1);if(0){for(var b=0;b<this.nets.length;b++){var d=this.nets[b];for(var a=0;a<4;a++){this.inpo[d][a].onclick=this.check_original;if(this.inpo[d][a].value==c.original[d]){this.inpo[d][a].checked=true}}}}this.win.show();this.is_shown=true};doc_props.prototype.check_original=function(){};doc_props.prototype.close=function(){var a=this;a.win.hide();a.overlay.hide();a.is_shown=false;_hide_flash_player(false);IOL.debug("close","",this)};doc_props.prototype.save=function(){var a=document.fprops;var b={doc_id:this.doc_id,share:a.share.value,com:_form_radio_get_value(a.com),tag:_form_radio_get_value(a.tag),tagme:_form_radio_get_value(a.tagme),license:_form_radio_get_value(a.license)};
modal.say(_MSG.saving,{icon:"wait"});IOL.API.request("doc.set",b,this)};doc_props.prototype.doc_set_onApi=function(e,b,a,d){if(e){modal.say(_MSG.saved,{timeout:500});for(var c in d){Data.doc[this.doc_id][c]=d[c]}this.show_doc_props();this.close()}else{modal.complain(b,{},1);this.close()}};doc_props.prototype.show_tab=function(c,d){for(var b=0;b<this.tabs.length;b++){var a=this.tabs[b];$("doc_props_interface_"+a).style.display=(a==c)?"block":"none";$("doc_props_tab_"+a).className=(a==c)?"on":""}if(d){d.blur()}this.tab=c};doc_props.prototype.show_doc_props=function(){var b=this.doc;var a=(b.share*1>15)?15:b.share*1;this.doc_props.each(function(f){var g=$("doc_"+f);var c=b[f]*1;if(g){try{g.innerHTML=$("doc_"+f+"_"+c).innerHTML;g.style.display=(c<a||f=="share"||f=="license")?"block":"none"}catch(d){IOL.debug("invalid doc prop : "+f+"="+c,"err")}}})};function _hide_flash_player(a){if($("doc_noplayer")){$("doc_player").style.display=(a)?"none":"block";$("doc_noplayer").style.display=(a)?"block":"none";if(a){window.who_is_hiding_player="doc.tools"}}};