var aid=1;var attachexts=new Array();var attachwh=new Array();function delAttach(a){$("attachbody").removeChild($("attach_"+a).parentNode.parentNode);$("attachbody").innerHTML==""&&addAttach();$("localimgpreview_"+a+"_menu")?document.body.removeChild($("localimgpreview_"+a+"_menu")):null}function addAttach(){newnode=$("attachbodyhidden").firstChild.cloneNode(true);var b=aid;var a;a=newnode.getElementsByTagName("input");for(i in a){if(a[i].name=="attach"){a[i].id="attach_"+b;a[i].onchange=function(){insertAttach(b)};a[i].unselectable="on";a[i].name="attachfile"+b}else{if(a[i].name=="localid[]"){a[i].value=b}}}a=newnode.getElementsByTagName("span");for(i in a){if(a[i].id=="localfile[]"){a[i].id="localfile_"+b}}$("attachbody").appendChild(newnode);aid++}addAttach();function insertAttach(f){var e="";var d=$("attach_"+f).value;var b=d.lastIndexOf(".")==-1?"":d.substr(d.lastIndexOf(".")+1,d.length).toLowerCase();var a=new RegExp("(^|\\s|,)"+b+"($|\\s|,)","ig");var c=$("attach_"+f).value.substr($("attach_"+f).value.replace(/\\/g,"/").lastIndexOf("/")+1);if(d==""){return}if(extensions!=""&&(a.exec(extensions)==null||b=="")){alert(lang.post_attachment_ext_notallowed);return}attachexts[f]=is_ie&&in_array(b,["gif","jpg","png","bmp"])&&typeof supe=="undefined"?2:1;$("localfile_"+f).innerHTML='<a href="###delAttach" onclick="delAttach('+f+')">['+lang.post_attachment_deletelink+']</a> <a href="###insertAttach" title="'+lang.post_attachment_insert+'" onclick="insertAttachtext('+f+');return false;">['+lang.post_attachment_insertlink+"]</a> "+(attachexts[f]==2?'<span id="localimgpreview_'+f+'" onmouseover="showMenu(this.id, 0, 0, 1, 0)"> <span class="smalltxt">['+f+']</span> <a href="###attachment" onclick="insertAttachtext('+f+');return false;">'+c+"</a></span>":'<span class="smalltxt">['+f+"]</span> "+c);$("attach_"+f).style.display="none";addAttach()}function insertAttachtext(a){if(!attachexts[a]){return}if(attachexts[a]==2){AddText("[local]"+a+"[/local]")}else{AddText("[local]"+a+"[/local]")}}function AddText(a){obj=$("postform").message;selection=document.selection;checkFocus();if(!isUndefined(obj.selectionStart)){var c=obj.selectionStart+0;obj.value=obj.value.substr(0,obj.selectionStart)+a+obj.value.substr(obj.selectionEnd)}else{if(selection&&selection.createRange){var b=selection.createRange();b.text=a;b.moveStart("character",-strlen(a))}else{obj.value+=a}}};
