var timeoutFunction;if(window.restrictedSetTimeout)timeoutFunction=window.restrictedSetTimeout;else timeoutFunction=window.setTimeout;nav=navigator.userAgent.toLowerCase();ie6=0;ie5=0;moz5=0;moz0=0;opera=0;if(nav.indexOf("win")!=-1){pos=nav.indexOf("msie");v=nav.charAt(pos+5);if(pos!=-1){if(v>=6){ie6=1;ie5=1}else if(v>=5){ie5=1}}}if(nav.indexOf("compatible")==-1){if(nav.charAt(8)>=5&&nav.indexOf("7.02")==-1){moz5=1;moz0=1}}if(nav.indexOf("opera")!=-1){opera=1}flag=1;isEditMode=false;premiumUrl="http://premium.xanga.com";function InitLoad(){if(window.location.search.indexOf('plain=1')>0){XtoolsPlainInit();}else if(document.getElementById('xeditor')){var editor=GetEditorBox();if(ie5==1){try{editor.document.designMode="on";editor.document.open();editor.document.write(document.all.xcontent.value);editor.document.close();editor.document.body.contentEditable="True";editor.focus();}catch(e){SwitchTextMode();}SetCustomColor('Background',document.getElementById('xbgcolor').value);SetCustomColor('Border',document.getElementById('xbordercolor').value);SetXagazoneZone();SetProfilePic();}else if(moz5==1){try{editor.document.designMode="on";editor.document.execCommand("undo",false,null);editor.document.open();editor.document.write(document.getElementById('xcontent').value);editor.document.close();}catch(em){SwitchTextMode();}SetCustomColor('Background',document.getElementById('xbgcolor').value);SetCustomColor('Border',document.getElementById('xbordercolor').value);SetXagazoneZone();SetProfilePic();}else{SwitchTextMode();}}else{XtoolsPlainInit();}}function XtoolsPlainInit(){var plainbgcolor=document.getElementById('xbgcolor').value;if(plainbgcolor==""){plainbgcolor="removeFormat"}var plainbordercolor=document.getElementById('xbordercolor').value;if(plainbordercolor==""){plainbordercolor="removeFormat"}SetCustomColorPlain('Background',plainbgcolor);SetCustomColorPlain('Border',plainbordercolor);if(document.getElementById('txtPlainText'))document.getElementById('txtPlainText').focus();SetXagazoneZone();SetProfilePic();}function XtoolsFinal(){if(flag==1&&ie5==1){event.returnValue=""}}function SwitchTextMode(){flag=2;var choice=confirm("Rich text (WYSIWYG) editing unable to run on your current system - click \"OK\" to switch to plain text editing");if(choice){var dj;if(window.location.search!=""){dj=window.location.search+"&plain=1"}else{dj="?plain=1"}if(window.location.href.indexOf('xtoolspremium.aspx')>0){window.location.href="xtoolspremium.aspx"+dj}else{window.location.href="xtoolsclassic.aspx"+dj}}else{return false}}function Format(comm,opt){var editor=GetEditorBox();if(opt=="removeFormat"){comm=opt;opt=null}if(moz5==1){var shortcut="";if(comm=="Copy"){shortcut="Ctrl-c"}else if(comm=="Cut"){shortcut="Ctrl-x"}else if(comm=="Paste"){shortcut="Ctrl-v"}if(shortcut!=""){try{editor.document.execCommand(comm,false,null);}catch(e){alert("To use this button, you must update your browser preferences.\nPlease use "+shortcut+" (the keyboard shortcut) instead\nOr visit http://help.xanga.com/cutcopypaste.htm for more info");return false}}else{if(opt==null||opt=="null"){editor.document.execCommand(comm,false,null);}else{editor.document.execCommand(comm,false,opt);}}}else{if(opt==null||opt=="null"){editor.document.execCommand(comm,false,null);}else{editor.document.execCommand(comm,false,opt);}}EditorBoxFocus();return false}function GetSelection(){var editor=GetEditorBox();var dk=this.selection;if(!dk){dk=editor.document.selection.createRange();dk.type=editor.document.selection.type}return dk}function editcomment(id){var target="ctext-"+id;var element=document.getElementById(target);var input=document.getElementById('edit-comment');var dz=document.getElementById('choosemini');var cancel=document.getElementById('cancel-editing');if(element){var theHTML=element.innerHTML;document.getElementById('bdescr').value=theHTML;input.value=id;dz.style.display="none";cancel.style.display="inline";var imageId="img-"+id;var image=document.getElementById(imageId);if(image){var imageName=image.src.match(/\/([^\/]*\.(?:jpg|jpeg|jpe|gif|bmp|tiff|tif|emf|png))/i)[1];if(imageName.indexOf("noimage.gif",0)<0&&imageName.indexOf("nopicture.gif",0)<0){DisplayProfilePic(image.src,imageName,"previous profile pic",0);timeoutFunction(function(){DisplayProfilePic(image.src,imageName,"previous profile pic",0);},50);}}}}function InsertHtmlCode(htmlCode){EditorBoxFocus();if(ie5==1){if(htmlCode=="linebreak"){htmlCode="<br />"}var df=GetSelection();if(!isEditMode){if(df.type=="Control"){df.item(0).outerHTML=htmlCode}else{df.pasteHTML(htmlCode);}}else{df.text=htmlCode}df.select();}else{var htmlEl;if(htmlCode=="linebreak"){htmlEl=document.createElement("br");}else{htmlEl=document.createTextNode(htmlCode);}InsertNodeAtSelection(htmlEl);}return false}function InsertNodeAtSelection(insertNode){EditorBoxFocus();var win=GetEditorBox();var dn=win.getSelection();var range;var isOk=true;try{range=dn.getRangeAt(0);}catch(e){isOk=false}if(isOk){dn.removeAllRanges();range.deleteContents();var container=range.startContainer;var pos=range.startOffset;range=document.createRange();if(container.nodeType==3&&insertNode.nodeType==3){container.insertData(pos,insertNode.nodeValue);range.setEnd(container,pos+insertNode.length);range.setStart(container,pos+insertNode.length);}else{var afterNode;if(container.nodeType==3){var textNode=container;container=textNode.parentNode;var text=textNode.nodeValue;var textBefore=text.substr(0,pos);var textAfter=text.substr(pos);var beforeNode=document.createTextNode(textBefore);var afterNode=document.createTextNode(textAfter);container.insertBefore(afterNode,textNode);container.insertBefore(insertNode,afterNode);container.insertBefore(beforeNode,insertNode);container.removeChild(textNode);}else{afterNode=container.childNodes[pos];if(afterNode!=undefined)container.insertBefore(insertNode,afterNode);else{}}if(afterNode!=undefined){range.setEnd(afterNode,0);range.setStart(afterNode,0);}}try{dn.addRange(range);}catch(e){}}EditorBoxFocus();}function CheckMode(){document.getElementById('xswitchmode').checked=!isEditMode;if(isEditMode){SetMode(false);}else{SetMode(true);}return false}function SetMode(newMode){var editor=GetEditorBox();isEditMode=newMode;var toolbar=document.getElementById('tblToolbar');var toolbartext=document.getElementById('toolbartext');var db;if(newMode){if(toolbar){toolbar.style.display='none'}if(toolbartext){toolbartext.style.display='inline'}editor.document.body.style.backgroundColor='FFFFFF';if(ie5==1){db=CleanHTML(editor.document.body.innerHTML);editor.document.body.innerText=db}else{var html=document.createTextNode(editor.document.body.innerHTML);editor.document.body.innerHTML="";editor.document.body.appendChild(html);}document.getElementById('lblTextBoxType').style.display='none';document.getElementById('hlkTextBoxType').style.display='none';document.getElementById('Label2').style.display='none'}else{if(toolbar){toolbar.style.display='inline'}if(toolbartext){toolbartext.style.display='none'}editor.document.body.style.backgroundColor=document.getElementById('xbgcolor').value;if(ie5==1){db=editor.document.body.innerText;editor.document.body.innerHTML=db}else{var html=editor.document.body.ownerDocument.createRange();html.selectNodeContents(editor.document.body);editor.document.body.innerHTML=html.toString();}document.getElementById('lblTextBoxType').style.display='inline';document.getElementById('hlkTextBoxType').style.display='inline';document.getElementById('Label2').style.display='inline'}EditorBoxFocus();}function CleanFont(){var coll=document.getElementsByTagName("FONT");for(var i=coll.length-1;i>=0;i--){var col=coll[i];if(col.style.backgroundColor=="#ffffff"){style.backgroundColor="transparent";}}}function CleanHTML(code){try{code=code.replace(/<\\?\??xml[^>]>/gi,"");code=code.replace(/<\/?\w+:[^>]*>/gi,"");code=code.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi,"");code=code.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi,"");code=code.replace(/<font>/g,"");code=code.replace(/<span>/g,"");}catch(e){}return code}function GetEl(sTag,start){while((start!=null)&&(start.tagName!=sTag)){start=start.parentElement}return start}function CreateLink(){var editor=GetEditorBox();if(isEditMode){return}var isA;var dp="";if(ie5==1){isA=GetEl("A",editor.document.selection.createRange().parentElement());if(isA==null){isA=GetEl("a",editor.document.selection.createRange().parentElement());}dp=editor.document.selection.type}else{if(editor.getSelection()==""){dp="None"}}var dd=prompt("Enter link location (e.g. http://www.xanga.com):",isA?isA.href:"http:\/\/");if((dd!=null)&&(dd!="http://")){if(dp=="None"){if(ie5==1){InsertHtmlCode("<A href=\""+dd+"\">"+dd+"</A> ");}else{var htmlEl=document.createElement("a");htmlEl.href=dd;htmlEl.target="_new";htmlEl.innerHTML=dd;InsertNodeAtSelection(htmlEl);}}else{Format("CreateLink",dd);}}else{EditorBoxFocus();}return false}function InsertImage(url,height,width){if(isEditMode)return;var editor=GetEditorBox();EditorBoxFocus();var dq="";if(ie5==1){dq=editor.document.selection.type}else{if(document.getElementById('xeditor').contentWindow.getSelection()=="")dq="None"}if((url!=null)&&(url!="http://")){if(dq=="None"&&(height!=""||width!="")){if(ie5==1){if(height!=""&&width!="")InsertHtmlCode("<IMG height=\""+height+"\" src=\""+url+"\" width=\""+width+"\">");else if(height==""&&width!=""){InsertHtmlCode("<IMG src=\""+url+"\" width=\""+width+"\">");}else if(height!=""&&width==""){InsertHtmlCode("<IMG height=\""+height+"\" src=\""+url+"\">");}}else{var htmlEl=document.createElement("img");htmlEl.src=url;if(height!="")htmlEl.height=height;if(width!="")htmlEl.width=width;InsertNodeAtSelection(htmlEl);}}else{Format("InsertImage",url);}}EditorBoxFocus();return false}function CreateImage(){if(isEditMode)return;var editor=GetEditorBox();var dr="";var dg=prompt("Enter image location (e.g. http://www.xanga.com/images/xangalogo.gif):","http:\/\/");if(ie5==1){dr=editor.document.selection.type}else{if(document.getElementById('xeditor').contentWindow.getSelection()=="")dr="None"}if((dg!=null)&&(dg!="http://")){if(dr=="None"){if(ie5==1){InsertHtmlCode("<img src=\""+dg+"\">");}else{var htmlEl=document.createElement("img");htmlEl.src=dg;InsertNodeAtSelection(htmlEl);}}else{Format("InsertImage",dg);}}EditorBoxFocus();return false}function CreateCustomColor(comm){if(ie5==1){var colorValue=showModalDialog("/Private/xtools/popupcolors.htm",comm,"dialogHeight: 639px; dialogWidth: 445px; status:no; resizable:yes; help:no; scroll: yes; dialogTop: 0px");SetCustomColor(comm,colorValue);}else{var hf=open("/Private/xtools/popupcolors.htm?type="+comm,"xpopup","resizable=1,width=430,height=680,top=0");}return false}function SetCustomColor(comm,colorValue){if(typeof(colorValue)=="undefined"){colorValue=""}else{var editor=GetEditorBox();if(colorValue!=""&&editor){colorValue=CheckColor(colorValue);if(colorValue=="removeFormat")colorValue="";if(comm=="Background"){editor.document.body.style.backgroundColor=colorValue;document.getElementById('xbgcolor').value=colorValue}else if(comm=="Border"){var dc=document.getElementById('xeditor').style;if(colorValue!=""){dc.borderWidth="2px";dc.borderStyle="solid";dc.borderColor=colorValue}else{if(ie5==1){dc.borderWidth="0px";dc.borderStyle="";dc.borderColor=""}else{dc.borderWidth="2px";dc.borderStyle="inset";dc.borderColor="000000";}}document.getElementById('xbordercolor').value=colorValue}}}return false}function XangaPopUp(popupType){var editor=GetEditorBox();EditorBoxFocus();if(isEditMode){return}var da;var comm;if(popupType=="Smiley"){if(ie5==1){da=showModalDialog("/Private/xtools/popupsmiley.htm","Insert Smiley","dialogHeight:435px; dialogWidth:440px; status:no; resizable:yes; help:no; scroll:no; dialogTop: 0px");}else{var ds=open("/Private/xtools/popupsmiley.htm?textbox=rich","xpopup","resizable=1,width=440,height=397,top=0");}}else if(popupType=="BackColor"){if(ie5==1){comm=true;da=showModalDialog("/Private/xtools/popupcolors.htm","Highlight","dialogHeight: 639px; dialogWidth: 445px; status:no; resizable:yes; help:no; scroll:yes; dialogTop: 0px");var hg=document.getElementById("xbgcolor").value;if(da=="removeFormat"){var dh=GetEl("FONT",editor.document.selection.createRange().parentElement());if(dh){dh.style.backgroundColor="transparent";da=""}}}else{var ds=open("/Private/xtools/popupcolors.htm?type=Highlight","xpopup","scrollbars=1,resizable=1,width=450,height=680,top=0");}}else if(popupType=="ForeColor"){if(ie5==1){comm=true;da=showModalDialog("/Private/xtools/popupcolors.htm","Font","dialogHeight: 639px; dialogWidth: 445px; status:no; resizable:yes; help:no; scroll:yes; dialogTop: 0px");if(da=="removeFormat"){var dh=GetEl("FONT",editor.document.selection.createRange().parentElement());if(dh){dh.style.color="";da=""}}}else{var ds=open("/Private/xtools/popupcolors.htm?type=Font","xpopup","scrollbars=1,resizable=1,width=450,height=680,top=0");}}else if(popupType=="Images"){var win=open(premiumUrl+"/ImageHosting/UploadImage.aspx?textbox=rich","_imgageinsert","scrollbars=1,resizable=1,width=390,height=497,top=0");}else if(popupType=="Symbols"){if(ie5==1){da=showModalDialog("/Private/xtools/popupsymbols.htm?textbox=rich","Insert Symbol","dialogHeight: 435px; dialogWidth: 440px; status:no; resizable:yes; help:no; scroll:yes; dialogTop: 0px");}else{var ds=open("/Private/xtools/popupsymbols.htm?textbox=rich","xpopup","scrollbars=1,resizable=1,width=430,height=392,top=0");}}if(typeof(da)=="undefined"){da=""}else{if(comm){Format(popupType,da);}else{InsertHtmlCode(da);}}return false}function Send(){var editor=GetEditorBox();CopyContent(editor);CopyWeblogPost(editor);}function CopyContent(editor){var dt="\n\nIf you see this error message, please contact us at http://help.xanga.com.\nPlease send the error message along with a description of what caused it.";if(editor){var du=document.getElementById('xcontent');if(!isEditMode){try{du.value=editor.document.body.innerHTML}catch(p){alert('Richtext error: '+p+dt);}}else{if(ie5==1){try{du.value=editor.document.body.innerText}catch(j){alert('Edit error: '+j+dt);}}else{var html=editor.document.body.ownerDocument.createRange();html.selectNodeContents(editor.document.body);du.value=html.toString();}}}else{if(ie6==1&&!document.getElementById("txtPlainText")){alert('Editor not Present'+dt);}}}function CopyWeblogPost(editor){try{if(document.getElementById('xcopypost').value=="1"&&ie5==1){if(editor){Format("SelectAll");Format("Copy");Format("Unselect");}}}catch(e){}}function GetSystemFonts(fontface){if(fontface){if(ie6==1){try{var a=dlgHelper.fonts.count;var fArray=new Array();for(i=1;i<dlgHelper.fonts.count;i++){fArray[i-1]=dlgHelper.fonts(i);}fArray.sort();var dv=document.createElement("OPTION");dv.text="Font";dv.value="removeFormat";fontface.add(dv);if(fArray.length>0){var dl;for(j=0;j<fArray.length;j++){dl=document.createElement("OPTION");dl.text=fArray[j];dl.value=fArray[j];fontface.add(dl);}}}catch(e){if(document.getElementById('xfontface')){document.getElementById('xfontface').style.display="inline";fontface.style.display="none"}}}else if(document.getElementById('xfontface')){document.getElementById('xfontface').style.display="inline";fontface.style.display="none"}}}function GetColor(command){var de=dlgHelper.ChooseColorDlg();de=de.toString(16);var iColor=de.length;if(iColor<6){var ha="000000".substring(0,6-(iColor));de=ha.concat(de);}Format(command,de);}function ToolbarSwitch(picname,status){if(document.images){document.images[picname].src="/images/toolbarlight/"+picname+status+".gif"}}function CheckColor(color){var regx=/[0-9a-zA-Z]{6}/;if(color.search(regx)==-1){color=""}else{var iColor=color.length;if(iColor<6){var hb="000000".substring(0,6-(iColor));color=hb.concat(color);}}return color}function SwitchTextboxType(isRichtext){flag=2;Send();var bgcolor=document.getElementById('xbgcolor').value;var bordercolor=document.getElementById('xbordercolor').value;if(isRichtext==false){SetCustomColorPlain('Background',bgcolor);SetCustomColorPlain('Border',bordercolor);}else{SetCustomColor('Background',bgcolor);SetCustomColor('Border',bordercolor);}}function EditorBoxFocus(){if(!document.getElementById('xeditor')){return}if(ie5==1){xeditor.focus();}else{document.getElementById("xeditor").contentWindow.focus();}}function GetEditorBox(){if(!document.getElementById('xeditor')){return}if(ie5==1){return xeditor}else{return document.getElementById('xeditor').contentWindow}}function EditBoxLinkClick(){flag=2;var conf=confirm("Are you sure you want to navigate away from this page?\n\nUnsaved changes will be lost.\n\nPress OK to continue, or Cancel to stay on the current page.");return conf}function CreateLinkPlain(){var dm=prompt("Enter link location (e.g. http://www.xanga.com):","http:\/\/");if(dm){var dx=prompt("Enter link title:","");if(dx){dm="<A href=\""+dm+"\">"+dx+"</A>";prompt("Copy and paste this HTML into your Entry:",dm);}else{EditorBoxFocus();}}return false}function CreateImgagePlain(){var di=prompt("Enter image location\n(e.g. http://www.xanga.com/images/xangalogo.gif):","http:\/\/");if((di!=null)&&(di!="http://")){di="<img src=\""+di+"\">";prompt("Copy and paste this HTML into your Entry:",di);}else{EditorBoxFocus();}return false}function CreateImgagePlainPremium(){var win=open(premiumUrl+"/ImageHosting/UploadImage.aspx?textbox=plain","_imgageinsert","scrollbars=1,resizable=1,width=380,height=500,top=0");return false}function CreateCustomColorPlain(comm){var hh=open("/Private/xtools/popupcolors.htm?textbox=plain&type="+comm,"xpopup","scrollbars=1,resizable=1,width=450,height=605,top=0");return false}function SetCustomColorPlain(comm,colorValue){if(colorValue!=""){var plaineditor=document.getElementById('txtPlainText');if(plaineditor){if(colorValue=="removeFormat"){colorValue=""}else{colorValue=CheckColor(colorValue);}if(comm=="Background"){plaineditor.style.backgroundColor=colorValue;document.getElementById('xbgcolor').value=colorValue}else if(comm=="Border"){if(colorValue!=""){plaineditor.style.borderWidth="2px";plaineditor.style.borderStyle="solid";plaineditor.style.borderColor=colorValue}else{if(plaineditor.style.borderColor!=""&&moz0==1){plaineditor.style.borderWidth="1px";plaineditor.style.borderStyle="solid";plaineditor.style.borderColor="4685C4";}else{plaineditor.style.borderWidth="";plaineditor.style.borderStyle="";plaineditor.style.borderColor="";}}if(opera==1&&document.getElementById('xbordercolor').value==""){plaineditor.style.backgroundColor="FFFFFF"}document.getElementById('xbordercolor').value=colorValue}}}}function DisplaySmileys(){var hc;hc=open("/Private/xtools/popupsmiley.htm?textbox=plain","xpopup","resizable=1,width=430,height=397,top=0");return false}function DisplaySymbols(){var hd;hd=open("/Private/xtools/popupsymbols.htm?textbox=plain","xpopup","scrollbars=1,resizable=1,width=430,height=392,top=0");return false}function PreviewHtml(){var dw=open("/Private/xtools/previewhtml.htm","_preview","scrollbars=1,resizable=1,width=450,height=500,top=0");return false}function XagazonSearch(){var type=document.getElementById('xzcat').options[document.getElementById('xzcat').selectedIndex].value;var userid=document.getElementById('txtUserId').value;var hi=open("/Amazon/Xangazon.aspx?type="+type+"&zone=1&userid="+userid,"_xangazon","scrollbars=1,resizable=1,width=600,height=600");return false}function XangazonClear(){document.getElementById("xzDisplay").innerHTML="";document.getElementById("zone1").style.display='none';document.getElementById("zone0").style.display='inline';document.getElementById("xztitle1").value="";document.getElementById("xztitle2").value="";document.getElementById("xzasin1").value="";return false}function SetXagazoneZone(){if(document.getElementById('zone1')){if(document.getElementById('xztitle1').value==""){document.getElementById('zone1').style.display='none';document.getElementById('zone0').style.display='inline'}else{document.getElementById('zone1').style.display='inline';document.getElementById('xzDisplay').innerHTML=document.getElementById("xztitle2").value;document.getElementById('zone0').style.display='none'}}}function ProfilePicsClear(){document.getElementById('prof0').style.display='inline';document.getElementById('prof1').style.display='none';document.getElementById('txtProfImageName').value="";document.getElementById('proftitle1').value="";document.getElementById('proftitle2').value="";document.getElementById('proftitle3').value="";document.getElementById('profImageFull').href="#";document.getElementById('profImageUrl').src="/images/nopicture.gif";return false}function SetChoosenProfilePic(json){var profilepic=json.parseJSON();DisplayProfilePic(profilepic.url,profilepic.filename,profilepic.title,profilepic.width);}function DisplayProfilePic(imgageUrl,imageName,picName,width){if(document.getElementById('prof1')){document.getElementById('prof0').style.display='none';document.getElementById('prof1').style.display='inline';document.getElementById('lblProfPicName').innerHTML=picName+"<br />";document.getElementById('profImageFull').href="javascript: void ProfileFullPopup('"+imgageUrl+"')";document.getElementById('profImageUrl').src=imgageUrl;var width1="60";if(width<60&&width>0){width1=width}document.getElementById('profImageUrl').width=width1;document.getElementById('txtProfImageName').value=imageName;document.getElementById('proftitle1').value=imgageUrl;document.getElementById('proftitle2').value=picName;document.getElementById('proftitle3').value=width}}function ProfileFullPopup(imgageUrl){var hj=open(imgageUrl,'_profull','width=200,height=220,resizable=1');}function SetProfilePic(){if(document.getElementById('prof1')){if(document.getElementById('proftitle1').value==""){document.getElementById('prof1').style.display='none';document.getElementById('prof0').style.display='inline'}else{document.getElementById('prof1').style.display='inline';document.getElementById('prof0').style.display='none';var imgageUrl=document.getElementById('proftitle1').value;var picName=document.getElementById('proftitle2').value;if(picName!=""){document.getElementById('lblProfPicName').innerHTML=picName+"<br />"}document.getElementById('profImageFull').href="javascript: void ProfileFullPopup('"+imgageUrl+"')";document.getElementById('profImageUrl').src=imgageUrl}}}function InitLoad(){if(window.location.search.indexOf('plain=1')==-1){var editor=GetEditorBox();if(editor){if(ie5==1){editor.document.designMode="on";editor.document.open("text/html","replace");editor.document.write(document.all.xcontent.value);editor.document.close();editor.document.body.contentEditable="True"}}}}function SwitchTextMode(){var url=window.location.href;var pos=url.indexOf('#');if(pos!=-1){var url1=url.substr(0,pos);url1+="&plain=1";var url2=url.substr(pos);window.location.href=url1+url2}else{window.location.href=url+"&plain=1"}}function SetMode(newMode){var editor=GetEditorBox();isEditMode=newMode;var db;if(newMode){if(ie5==1){db=CleanHTML(editor.document.body.innerHTML);editor.document.body.innerText=db}else{var html=document.createTextNode(editor.document.body.innerHTML);editor.document.body.innerHTML="";editor.document.body.appendChild(html);}document.getElementById('tbrLinkPlain').style.display='inline';document.getElementById('tbrLink').style.display='none'}else{if(ie5==1){db=editor.document.body.innerText;editor.document.body.innerHTML=db}else{var html=editor.document.body.ownerDocument.createRange();html.selectNodeContents(editor.document.body);editor.document.body.innerHTML=html.toString();}document.getElementById('tbrLinkPlain').style.display='none';document.getElementById('tbrLink').style.display='inline'}EditorBoxFocus();}function EditorBoxFocus(){if(!document.getElementById('htmleditor')){return}if(ie5==1){htmleditor.focus();}else{document.getElementById("htmleditor").contentWindow.focus();}}function GetEditorBox(){if(!document.getElementById('htmleditor')){return}if(ie5==1){return htmleditor}else{return document.getElementById('htmleditor').contentWindow}}function GetPlainTextContent(){return document.getElementById('bdescr').value}function SetPlainTextContent(text){document.getElementById('bdescr').value=text}function GetPlainTextContent(){return document.getElementById('bdescr').value}function SetPlainTextContent(text){document.getElementById('bdescr').value=text}function PreviewHtml(){var dw=open('','_preview',"scrollbars=1,resizable=1,width=450,height=500,top=0");dw.document.body.innerHTML=CommentRestriction(GetPlainTextContent());dw.focus();return false}function insertHTML(text){InsertHtmlCode(text);}function CommentRestriction(text){text=text.replace(/&quot;/gi,"\"");text=text.replace(/</gi,"&lt;");text=text.replace(/>/gi,"&gt;");text=text.replace(/&lt;a(.*?)&gt;/gi,"<a$1>");text=text.replace(/&lt;\/a&gt;/gi,"</A>");text=text.replace(/(&lt;P&gt;&nbsp;&lt;\/P&gt;)|(&lt;P&gt;&amp;nbsp;&lt;\/P&gt;)/gi,"");text=text.replace(/&lt;p&gt;/gi,"<P>");text=text.replace(/&lt;\/p&gt;/gi,"</P>");text=text.replace(/&lt;br\s*\/?\s*&gt;/gi,"<BR/>");text=text.replace(/&lt;i&gt;/gi,"<I>");text=text.replace(/&lt;\/i&gt;/gi,"</I>");
	text = text.replace(/&lt;b&gt;/gi,"<B>");
	text = text.replace(/&lt;\/b&gt;/gi,"</B>");
	text = text.replace(/&lt;u&gt;/gi,"<U>");
	text = text.replace(/&lt;\/u&gt;/gi,"</U>");
	text = text.replace(/&lt;em&gt;/gi,"<EM>");
	text = text.replace(/&lt;\/em&gt;/gi,"</EM>");
	text = text.replace(/&lt;strong&gt;/gi,"<STRONG>");
	text = text.replace(/&lt;\/strong&gt;/gi,"</STRONG>");
	text = text.replace(/&lt;[^&gt; | ^&lt;].*?&gt;/gi,"");
	text = text.replace(/\n|\f|\r/g, "<BR/>");
	return text;
}

function addReplyToLink(url,username,commentid)
{
	var tagId = "x" + Math.floor(Math.random() * 99999999);
	var theHTML = "<p id=\""+tagId+"\"><a href=\""+url+"\" class=\"replyto x--"+commentid+"--x\">@"+username+"</a>&nbsp;-&nbsp;</p>";var theSelection;var theRange;if(window.getSelection){var theTextArea=document.getElementById("bdescr");theTextArea.focus();var start=theTextArea.selectionStart;var end=theTextArea.selectionEnd;theTextArea.value=theTextArea.value.substr(0,start)+theHTML+theTextArea.value.substr(end,theTextArea.value.length);theTextArea.focus();document.location.hash="comment"}else if(document.selection){if(location.search.match("plain=1")!=null){var theTextArea=document.getElementById("bdescr");theTextArea.focus();document.selection.createRange().text=theHTML;document.location.hash="comment"}else{var theCheckBox=document.getElementById("xswitchmode");if(theCheckBox.checked){var theTextArea=document.getElementById("htmleditor");theTextArea.focus();document.selection.createRange().text=theHTML;document.location.hash="comment"}else{var theContentWindow=document.getElementById('htmleditor').contentWindow;theContentWindow.focus();theSelection=theContentWindow.document.selection;theRange=theSelection.createRange();theRange.collapse(true);theRange.pasteHTML(theHTML);var theTextNode=theContentWindow.document.getElementById(tagId);theRange.moveToElementText(theTextNode);theRange.collapse(false);theRange.select();}}}else {prompt("Copy and paste the following HTML into your comment box:",theHTML);}}function autoReplyTo(){if(location.search.match("replyto=")!=null){var he=location.search.substring(1);var pairs=he.split("&");var dy="";var commentid=-1;var username="";for(var i=0;i<pairs.length;i++){var pair=pairs[i].split("=");switch(pair[0]){case"nextdate":commentid=pair[1];break;case"replyto":username=pair[1];break;case"direction":break;default:dy+=pairs[i]+'&'}}var url=location.protocol+"//"+location.host+location.pathname;url+="?"+dy+"nextdate="+commentid+"&direction=n#"+commentid;var hk=window.onload;if(typeof window.onload!="function"){window.onload=function(){return addReplyToLink(url,username,commentid);}}else{window.onload=function(){addReplyToLink(url,username,commentid);return oldonload();}}}}