var edit_in_place_tabs=new Array();var edit_title_in_place=function(e,c){if(!_support_ajax()){return false}var d=$(e);d.form_content="";d.hover_text="Click to edit";d.empty_text="<i>Click to add a title</i>&nbsp;";d.tag="input";var b=(d.getWidth()>0)?(d.getWidth()-6)+"px":"100%";var a=d.getStyle("marginTop")||"7px";d.getForm=function(){if(this.nodeName=="H1"){return'<input name="content" value="'+this.form_content.str_replace('"',"&#34;")+'" style="font-size:25px; font-weight:bold; padding:3px; width:'+b+"; border:1px inset #e9e9ae; margin-top:"+a+'" class="highlight" />'}else{if(this.nodeName=="H4"){return'<input name="content" value="'+this.form_content.str_replace('"',"&#34;")+'" style="font-size:13px; font-weight:bold; padding:3px; width:'+b+"; border:1px inset #e9e9ae; margin-top:"+a+'" class="highlight" />'}}};_edit_in_place(e,c)};var edit_content_in_place=function(e,c){if(!_support_ajax()){return false}var d=$(e);d.form_content="";d.hover_text="Click to edit";d.empty_text="<i>Click to add a description</i>&nbsp;";d.tag="textarea";var b=(d.getWidth()>0)?(d.getWidth()-6)+"px":"100%";var a=d.getStyle("marginTop")||"7px";d.getForm=function(){return'<textarea name="content" style="font-size:12px; padding:3px; width:'+b+"; height:70px; border:1px inset #e9e9ae; margin-top:"+a+'" class="highlight">'+this.form_content+"</textarea>"};_edit_in_place(e,c)};var edit_share_in_place=function(c){if(!_support_ajax()){return false}var b=$(c);b.form_content="";b.hover_text="Click to modify";b.empty_text="";b.tag="select";var a=b.getStyle("marginTop")||"7px";b.getForm=function(){var d=b.form_content;return'<select name="content" style="margin-bottom:3px;margin-top:'+a+'"><option '+((d==0)?'selected="selected"':"")+' value="0">Private</option><option '+((d==1)?'selected="selected"':"")+' value="1">Shared with family</option><option '+((d==2)?'selected="selected"':"")+' value="2">Shared with friends</option><option '+((d==3)?'selected="selected"':"")+' value="3">Shared with family &amp; friends</option><option '+((d==31)?'selected="selected"':"")+' value="31">Public</option></select>'
};b.updateInfo=function(){var e=b.form_content;var d='<img src="'+URL.L+'/z.gif" width="15" height="15" alt="" class="privacy s'+e+'"/>&nbsp;';if(e==0){d+="No sharing (<b>private</b>)"}else{if(e==1){d+="Shared with <b>family</b>"}else{if(e==2){d+="Shared with <b>friends</b>"}else{if(e==3){d+="Shared with <b>family</b> &amp; <b>friends</b>"}else{d+="Sharing <b>public</b>"}}}}this.innerHTML=d};_edit_in_place(c)};var edit_com_in_place=function(c){if(!_support_ajax()){return false}var b=$(c);b.form_content="";b.hover_text="Click to modify";b.empty_text="";b.tag="select";var a=b.getStyle("marginTop")||"7px";b.getForm=function(){var d=b.form_content;return'<select name="content" style="margin-bottom:3px;margin-top:'+a+'"><optgroup label="Who is permitted to add comments?"><option '+((d==0)?'selected="selected"':"")+' value="0">Only you</option><option '+((d==3)?'selected="selected"':"")+' value="3">Family &amp; Friends</option><option '+((d==7)?'selected="selected"':"")+' value="7">Your whole network</option><option '+((d==15)?'selected="selected"':"")+' value="15">All members</option></optgroup></select>'};b.updateInfo=function(){var d=b.form_content;var e='<img src="'+URL.L+"/share/c"+d+'.gif" width="15" height="15" alt="" align="top"/> ';if(d==0){e+="Comments denied"}else{if(d==3){e+="<b>Family</b> &amp; <b>friends</b> are allowed to comment"}else{if(d==7){e+="<b>Your whole network</b> is allowed to comment"}else{e+="<b>All members</b> are allowed to comment"}}}this.innerHTML=e};_edit_in_place(c)};var _edit_in_place=function(d,a){if(!_support_ajax()){return false}var b=d.split("_");var c=$(d);c.el_object=b[0];c.el_id=b[1];c.el_field=b[2];c.api_get=b[0]+".get";c.api_set=b[0]+".set";c.title=c.hover_text;if(!Data[c.el_object][c.el_id]){IOL.debug("error: can not edit "+c.el_object+" "+c.el_id,"err");return false}c.form_content=Data[c.el_object][c.el_id][c.el_field];c.generic_get_onApi=function(k,m,i,g){var l;var j;var n;var f;var h=this.el_object;var e=this.el_id;if(k){l=Data[h][e]["title"]=m[h].title;j=Data[h][e]["content"]=m[h].content;
n=Data[h][e]["share"]=m[h].share;f=Data[h][e]["com"]=m[h].com}else{modal.complain(m,{},1);return}if(this.el_field=="title"){this.form_content=l;this.innerHTML=(l=="")?"&nbsp;":l.xmlentities();this.startEdit()}else{if(this.el_field=="content"){this.form_content=j;this.innerHTML=(j=="")?"&nbsp;":j.nl2br().escape()+"&nbsp;";this.startEdit()}else{if(this.el_field=="share"||this.el_field=="com"){this.form_content="";this.startEdit()}}}};c.saveForm=function(e){var g=e.content.value;if(g==c.form_content){this.endEdit();if(this.afterSaveEdit!=undefined){var f=this.afterSaveEdit;$(edit_in_place_tabs[f]).startEdit();this.afterSaveEdit=undefined}return}this.form_div.hide();this.show();this.innerHTML="<i>"+_MSG.saving+"&hellip;</i>";var h={callback:"generic_set"};h[this.el_object+"_id"]=this.el_id;h[this.el_field]=g;IOL.API.request(this.api_set,h,c)};c.generic_set_onApi=function(g,f,e,j){if(g){var i=f[this.el_object];if(this.el_field=="title"){this.form_content=i.title.escape();this.innerHTML=i.title.escape()+"&nbsp;";Data[this.el_object][this.el_id]["title"]=i.title}else{if(this.el_field=="content"){this.form_content=i.content.escape();this.innerHTML=i.content.nl2br()+"&nbsp;";Data[this.el_object][this.el_id]["content"]=i.content;if(this.el_object=="doc"&&Data[this.el_object][this.el_id].embed.match(/flv|mp3/)&&window.doc_id&&typeof window.timecodes_replace=="function"){this.originalHTML=this.innerHTML;timecodes_replace($(d))}}else{if(this.el_field=="share"){this.form_content=i.share;this.updateInfo();Data[this.el_object][this.el_id]["share"]=i.share}else{if(this.el_field=="com"){this.form_content=i.com;this.updateInfo();Data[this.el_object][this.el_id]["com"]=i.com}}}}}else{modal.complain(f,{},1)}this.endEdit();if(this.afterSaveEdit){var h=this.afterSaveEdit;$(edit_in_place_tabs[h]).startEdit();this.afterSaveEdit=undefined}};c.startEdit=function(){if(!window.allow_user_actions||window.user_action){return}if(this.form_content==undefined){this.innerHTML="<i>"+_MSG.loading+"&hellip;</i>";var f={callback:"generic_get",extra:"content"};
f[this.el_object+"_id"]=this.el_id;return IOL.API.request(this.api_get,f,c)}window.doing_edit_in_place=1;Event.observe(window,"keydown",c.onKeyESC_observer);this.endHover();this.style.display="none";var e=this.getFormDiv().show();if(this.tag=="input"||this.tag=="textarea"){var g=e.select(this.tag)[0];if(g){setTimeout(function(){g.select();g.focus()},150);Event.observe(g,"keydown",c.onKeyCode_observer);c.text_div=g;if(this.tag=="textarea"){new autoGrowTextarea(g)}}else{console.log("bad, I could not find the edit_in_place INPUT or TEXTAREA");this.endEdit()}}window.user_action="edit_in_place"};c.endEdit=function(){window.doing_edit_in_place=0;this.form_div.update();this.form_div.style.display="none";Event.stopObserving(window,"keydown",c.onKeyESC_observer);if(c.text_div){Event.stopObserving(c.text_div,"keydown",c.onKeyCode_observer)}c.text_div=null;this.style.display="block";window.user_action=""};c.onKeyCode=function(h){if(0&&h.keyCode==Event.KEY_ESC){h.stop();return c.endEdit()}if(h.keyCode==Event.KEY_TAB&&edit_in_place_tabs.length>1){h.stop();var g=Event.element(h);while(g&&g.nodeName!="FORM"){g=g.parentNode}if(!g){return}var i=edit_in_place_tabs.indexOf(d);if(h.shiftKey){var f=i-1;if(f<0){f=edit_in_place_tabs.length-1}}else{var f=i+1;if(f==edit_in_place_tabs.length){f=0}}c.afterSaveEdit=f;c.saveForm(g)}};c.onKeyESC=function(f){if(f.keyCode==Event.KEY_ESC){f.stop();return c.endEdit()}};c.getFormDiv=function(){if(!this.form_div){this.form_div=new Element("div").setStyle({marginLeft:this.style.marginLeft,marginRight:this.style.marginRight});this.parentNode.insertBefore(this.form_div,this);this.form_div.O=this}var e;e='<form style="margin:0" onsubmit="this.parentNode.O.saveForm(this); return false;">';e+=this.getForm();e+='<div style="margin:0 0 7px 0"><input type="submit" class="submit" value="SAVE" />&nbsp;&nbsp;OR&nbsp;&nbsp;<input type="button" class="reset" value="CANCEL" onclick="this.form.parentNode.O.endEdit();" /></div>';e+="</form>";this.form_div.update(e);return this.form_div};c.startHover=function(){if(!window.allow_user_actions||window.user_action){return
}if(this.hover_timer){clearTimeout(this.hover_timer)}Element.addClassName(this,"highlight");if(this.empty_text&&this.innerHTML!=undefined){try{this.innerHTML.is_empty()}catch(f){}}if(this.empty_text&&(this.innerHTML!=undefined&&this.innerHTML.is_empty())){this.style.color="#888";this.innerHTML=this.empty_text;this.is_empty=true}};c.endHover=function(){if(this.hover_timer){clearTimeout(this.hover_timer)}if(!window.allow_user_actions){return}Element.removeClassName(this,"highlight");if(this.is_empty){this.style.color="#000";this.innerHTML="&nbsp;";this.is_empty=false}};c.onmouseover=function(){this.startHover()};c.onmouseout=function(){if(this.hover_timer){clearTimeout(this.hover_timer)}var e=this;this.hover_timer=setTimeout(function(){e.endHover()},1000)};c.onclick=c.startEdit;c.onKeyCode_observer=c.onKeyCode.bindAsEventListener(c);c.onKeyESC_observer=c.onKeyESC.bindAsEventListener(c);if(a){edit_in_place_tabs.push(d)}};