var clientPC=navigator.userAgent.toLowerCase();var clientVer=parseInt(navigator.appVersion);var is_ie=((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera")==-1));var is_nav=((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible')==-1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));var is_moz=0;var is_win=((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));var is_mac=(clientPC.indexOf("mac")!=-1);function getarraysize(thearray)
{for (i=0; i < thearray.length; i++)
{if ((thearray[i]=="undefined") || (thearray[i]=="") || (thearray[i]==null))
{return i;}}
return thearray.length;}
function arraypush(thearray, value)
{thearray[getarraysize(thearray)]=value;}
function arraypop(thearray)
{thearraysize=getarraysize(thearray);retval=thearray[thearraysize - 1];delete thearray[thearraysize - 1];return retval;}
var selField=false;var selMode="normal";var no_cursor="In order to use these buttons you must first place your cursor in a field.";var url_text="Enter the hyperlink URL";var webpage_text="Enter the title of the link";var title_text="Optional: Enter a title attribute";var image_text="Enter the image URL";var email_text="Enter the email address";var email_title="Enter the link title (or leave the field empty to use the email address as the title.)";var enter_text="Enter the text you want to format";var button_0=0;var button_1=0;var button_2=0;var button_3=0;var button_4=0;var tagarray=new Array();var usedarray=new Array();var running=0;function nullo()
{return;}
function styleswap(link)
{if (document.getElementById(link).className=='htmlButtonA')
{document.getElementById(link).className='htmlButtonB';}
else
{document.getElementById(link).className='htmlButtonA';}
if (document.getElementById('close_all').className=='htmlButtonA')
{document.getElementById('close_all').className='htmlButtonB';}}
function setmode(which)
{if (which=='guided')
selMode='guided';else
selMode='normal';}
function setFieldName(which)
{if (which != selField)
{selField=which;clear_state();tagarray=new Array();usedarray=new Array();running=0;}}
function clear_state()
{if (usedarray[0])
{while (usedarray[0])
{clearState=arraypop(usedarray);eval(clearState + "=0");document.getElementById(clearState).className='htmlButtonA';}
if (document.getElementById('close_all').className=='htmlButtonB')
{document.getElementById('close_all').className='htmlButtonA';}}}
function singleinsert(tagOpen)
{if (! selField)
{alert(no_cursor);return false;}
eval("document.entryform." + selField + ".value += tagOpen");curField=eval('document.entryform.' + selField);curField.blur();curField.focus();}
function taginsert(item, tagOpen, tagClose)
{var which=eval('item.name');if (! selField)
{alert(no_cursor);return false;}
if (selMode=='guided')
{data=prompt(enter_text, "");if ((data != null) && (data != ""))
{result=tagOpen + data + tagClose;eval("document.entryform." + selField + ".value += result");}
curField=eval('document.entryform.' + selField);curField.blur();curField.focus();return;}
var theSelection=false;eval("var theField=document.entryform." + selField + ";");if ((clientVer >= 4) && is_ie && is_win)
{theSelection=document.selection.createRange().text;}
if (theSelection)
{var tags=tagOpen;var tage=tagClose;document.selection.createRange().text=tags + theSelection + tage;curField=eval('document.entryform.' + selField);curField.blur();curField.focus();theSelection='';return;}
else if (theField.selectionEnd && (theField.selectionEnd - theField.selectionStart > 0))
{var selLength=theField.textLength;var selStart=theField.selectionStart;var selEnd=theField.selectionEnd;if (selEnd==1 || selEnd==2)
selEnd=selLength;var s1=(theField.value).substring(0,selStart);var s2=(theField.value).substring(selStart, selEnd)
var s3=(theField.value).substring(selEnd, selLength);theField.value=s1 + tagOpen + s2 + tagClose + s3;return;}
if (eval(which)==0)
{var result=tagOpen;eval("document.entryform." + selField + ".value += result");eval(which + "=1");arraypush(tagarray, tagClose);arraypush(usedarray, which);running++;styleswap(which);}
else
{n=0;for (i=0 ; i < tagarray.length; i++)
{if (tagarray[i]==tagClose)
{ n=i; running--;while (tagarray[n])
{closeTag=arraypop(tagarray);eval("document.entryform." + selField + ".value += closeTag");}
while (usedarray[n])
{clearState=arraypop(usedarray);eval(clearState + "=0");document.getElementById(clearState).className='htmlButtonA';}}}
if (running <= 0 && document.getElementById('close_all').className=='htmlButtonB')
{document.getElementById('close_all').className='htmlButtonA';}}
curField=eval('document.entryform.' + selField);curField.blur();curField.focus();}
function promptTag(which)
{if (! selField)
{alert(no_cursor);return;}
if (! which)
return;var theSelection="";eval("var theField=document.entryform." + selField + ";");if ((clientVer >= 4) && is_ie && is_win)
{theSelection=document.selection.createRange().text;}
else if (theField.selectionEnd && (theField.selectionEnd - theField.selectionStart > 0))
{var selLength=theField.textLength;var selStart=theField.selectionStart;var selEnd=theField.selectionEnd;if (selEnd==1 || selEnd==2)
selEnd=selLength;var s1=(theField.value).substring(0,selStart);var s2=(theField.value).substring(selStart, selEnd)
var s3=(theField.value).substring(selEnd, selLength);theSelection=s2;}
if (which=="link")
{var URL=prompt(url_text, "http://");if (! URL || URL=='http://' || URL==null)
return;var Name=prompt(webpage_text, theSelection);if (! Name || Name==null)
return;var Link = '<a href="' + URL + '" title="' + Title + '">' + Name + '<'+'/a>';}
if (which=="email")
{var Email=prompt(email_text, "");if (! Email || Email==null)
return;var Title=prompt(email_title, theSelection);if (!Title || Title==null)
return;if (Title=="")
Title=Email;var Link = '<a href="mailto:' + Email + '">' + Title + '<'+'/a>';}
if (which=="image")
{var URL=prompt(image_text, "http://");if (! URL || URL==null)
return;var Link='<img src="' + URL + '" />';}
if ((clientVer >= 4) && is_ie && is_win && theSelection != "")
{document.selection.createRange().text=Link;}
else if (theField.selectionEnd && (theField.selectionEnd - theField.selectionStart > 0))
{theField.value=s1 + Link + s3;}
else
{eval("document.entryform." + selField + ".value += Link");}
theSelection='';curField=eval('document.entryform.' + selField);curField.blur();curField.focus();return;}
function closeall()
{if (tagarray[0])
{while (tagarray[0])
{closeTag=arraypop(tagarray);eval("document.entryform." + selField + ".value += closeTag");}}
clear_state();running=0;curField=eval('document.entryform.' + selField);curField.focus();}
function insertAtCaret(obj, text) {if(document.selection) {obj.focus();var orig=obj.value.replace(/\r\n/g, "\n");var range=document.selection.createRange();if(range.parentElement() != obj) {return false;}
range.text=text;var actual=tmp=obj.value.replace(/\r\n/g, "\n");for(var diff=0; diff < orig.length; diff++) {if(orig.charAt(diff) != actual.charAt(diff)) break;}
for(var index=0, start=0;tmp.match(text)
&& (tmp=tmp.replace(text, ""))
&& index <= diff;index=start + text.length
) {start=actual.indexOf(text, index);}}
else if(obj.selectionStart) {var start=obj.selectionStart;var end=obj.selectionEnd;obj.value=obj.value.substr(0, start)
+ text
+ obj.value.substr(end, obj.value.length);}
if(start != null) {setCaretTo(obj, start + text.length);} else {obj.value += text;}}
function setCaretTo(obj, pos) {if(obj.createTextRange) {var range=obj.createTextRange();range.move('character', pos);range.select();} else if(obj.selectionStart) {obj.focus();obj.setSelectionRange(pos, pos);}}