var linktext=new Array()
linktext[0]="Bold: [b]text[/b]"
linktext[1]="Italic: [i]text[/i]"
linktext[2]="Underline: [u]text[/u]"
linktext[3]="Insert URL: [url=http://url]url text[/url]"
linktext[4]="Insert mail: [mail=mail@address]mail text[/mail]"
linktext[5]="Insert image: [img]http://image_url[/img]"
linktext[6]="Insert code: [code]code text[/code]"
linktext[7]="Insert quote: [quote]quote text[/quote]"
linktext[8]="Font color: [color=#000000]text[/color]"
linktext[9]="Font size: [size=]text[/size]"
linktext[10]="Glowing text: [glo=#a1f7a1]text[/glo]"

 var ns6=document.getElementById&&!document.all
 var ie=document.all

function show_text(thetext, whichdiv){
 if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
 else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}

function resetit(whichdiv){
 if (ie) eval("document.all."+whichdiv).innerHTML=' '
 else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}

function AddText(text) {
	if (document.input.message.createTextRange && document.input.message.caretPos) {      
		var caretPos = document.input.message.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else document.input.message.value += text;
	document.input.message.focus(caretPos)
}

function showcolor(color) {
	AddTxt="[color="+color+"] [/color]";
	AddText(AddTxt);
}

function showsize(size) {
	AddTxt="[size="+size+"] [/size]";
	AddText(AddTxt);
}

function countlimit(maxlength,e,placeholder){
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder)){
		if (lengthleft<0)
		theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}

function displaylimit(theform,thelimit){
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b>'
	if (document.all||ns6)
		document.write(limit_text)
	if (document.all){
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
	document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
	}
}

function storeCaret(text) { 
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

function restrictinput(maxlength,e,placeholder){
	if (window.event&&event.srcElement.value.length>=maxlength)
		return false
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
		if (pressedkey.test(String.fromCharCode(e.which)))
			e.stopPropagation()
		}
}

function go(){
	var URL = document.drop.fid.options[document.drop.fid.selectedIndex].value;
	window.location.href = URL;
}

function showavatar(){
	document.images.avatar.src=document.myform.newavatar.options[document.myform.newavatar.selectedIndex].value;
}

function MI(iid){
	document.getElementById(iid).style.cursor = "";
	document.getElementById(iid).style.backgroundColor = "transparent";
}

function MO(iid){
	document.getElementById(iid).style.cursor = "";
	document.getElementById(iid).style.backgroundColor = "";
}

function CheckSize() {
	var r = document.myform;
	if (r.day.value.length < 2) {
		mesg = "You have entered " + r.day.value.length + " character(s) for day\n"
		mesg = mesg + "Valid entry must be 2 characters in length.\n"
		mesg = mesg + "Please verify your input and try again."
		alert(mesg);
		r.day.focus();
		return (false);
	}
	if (r.month.value.length < 2) {
		mesg = "You have entered " + r.month.value.length + " character(s) for month\n"
		mesg = mesg + "Valid entry must be 2 characters in length.\n"
		mesg = mesg + "Please verify your input and try again."
		alert(mesg);
		r.month.focus();
		return (false);
	}
	if (r.year.value.length < 4) {
		mesg = "You have entered " + r.year.value.length + " character(s) for year\n"
		mesg = mesg + "Valid entry must be 4 characters in length.\n"
		mesg = mesg + "Please verify your input and try again."
		alert(mesg);
		r.year.focus();
		return (false);
	}
	return (true);
}

function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Enter numerals only in birthday field.");
        return false;
    }
    return true;
}