	var isIE;
	var isNS;
	if (navigator.appName.indexOf("Explorer")>-1)
		isIE=true;
	if (navigator.appName.indexOf("Netscape")>-1)
		isNS=true;

	function showDiv(strID) {
	
		document.getElementById(strID).style.visibility="visible";
		document.getElementById(strID).style.display="block";
		
	}
	function hideDiv(strID) {
	
		document.getElementById(strID).style.visibility="hidden";
		document.getElementById(strID).style.display="none";
		
	}
	
	function toggleDiv(strID) {
		if (document.getElementById(strID).style.visibility=="hidden") {
			showDiv(strID);
		} else {
			hideDiv(strID);
		}
	
	}
	
	var x;
	var y;

	function mouser(event){
		x=event.clientX;
		y=event.clientY;
		document.getElementById('divMouseX').innerHTML = x+15;
		document.getElementById('divMouseY').innerHTML = y+10;
	}
	
	function msgbox(sMsg,sTitle) {
		document.getElementById('msgbox_text').innerHTML="<h2 style=margin-bottom:0px;>"+sTitle+"</h2>"+sMsg;
		var winW = 630, winH = 460;
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		
		scroll(0,0);
		document.getElementById('msgbox').style.left=(winW-480)/2;
		document.getElementById('msgboxshadow').style.left=(winW-480)/2+4;
		//document.getElementById('msgboxshadow').style.height=winH;
		showDiv('msgboxshadow');
		showDiv('msgbox');
	}
	
	function mouseX(event){
		x=event.clientX;
		return x;
	}

	function showTip(sText) {
		var nScrollAdd=0;
		if (navigator.appName == "Microsoft Internet Explorer")	
			{
				nScrollAdd =  document.body.scrollTop;
			}
		else
			{
				nScrollAdd = window.pageYOffset;
			}
		//alert(nScrollAdd+1*(document.getElementById('divMouseY').innerHTML));
		document.getElementById('tooltip').style.visibility="visible";
		document.getElementById('tooltip').style.display="block";
		document.getElementById('tooltip').style.left = document.getElementById('divMouseX').innerHTML ;
		document.getElementById('tooltip').style.top = nScrollAdd+1*document.getElementById('divMouseY').innerHTML ;
		document.getElementById('tooltip_content').innerHTML = sText;
	}
	function hideTip() {
		document.getElementById('tooltip').style.visibility="hidden";
		document.getElementById('tooltip').style.display="none";
	}
	
	function addBold(sField,sText)	{
		txtArea = document.getElementById(sField);
		var boldText = new String();
		boldText = getSelectedText(txtArea);
		
		
		doInsert(txtArea,"[B]"+ boldText + "[/B]");	
	}
	function addImage(sField,sImage)	{
		txtArea = document.getElementById(sField);
		
		doInsert(txtArea,"[IMG]"+ sImage + "[/IMG]");	
	}
	function addSmiley(sSmiley)	{
		txtArea = document.getElementById('post');
		
		doInsert(txtArea,sSmiley);	
	}
	
	function addLink(sField,sText,sText2)	{
		txtArea = document.getElementById(sField);
		var boldText = new String();
		boldText = getSelectedText(txtArea);
		
		if (boldText.length <1) {
			boldText = prompt(sText, "");
			if (!boldText) { 
				return; 
			}
		}
		var sURL = new String();
		sURL = prompt(sText2,"http://");
		doInsert(txtArea,"[URL=" + sURL + "]"+ boldText + "[/URL]");	
	}
	
	function getSelectedText(field){
		var value = new String()

		if (document.getSelection) {
		  value = (field.value).substring(field.selectionStart,field.selectionEnd);
		} 
		else if (document.selection && document.selection.createRange) {
			var range = document.selection.createRange();
			value = range.text
		} 
		else {
		  value = "";
		}
		return value;
	}
	
	function doInsert(field, value){
		if (isIE){
			field.focus();
			sel = document.selection.createRange();
			sel.text = value;
		}
		else if (isNS)	{
			field.value = field.value.substring(0, field.selectionStart)
						+ value
						+ field.value.substring(field.selectionEnd, field.value.length);
		}
		else{
			field.value+=value;
		}
		field.focus();
	}
	
function center(elm){

if (document.all){ //MSIE browsers
var sX = parseInt(window.document.body.clientWidth);
var sY = parseInt(window.document.body.clientHeight);
} else if (window.innerWidth){ // Netscape 4+6
var sX = parseInt(window.innerWidth);
var sY = parseInt(window.innerHeight);
}

if (document.layers) { // Netscape 4
var eW = parseInt(elm.document.width); //Netscape 4
var eH = parseInt(elm.document.height); //Netscape 4
} else if (document.all || document.getElementById){
var eW = parseInt(elm.offsetWidth); //MSIE + NS6
var eH = parseInt(elm.offsetHeight); // MSIE + NS6
}


//calculate positions:
var xPos = sX / 2 - (eW / 2);
var yPos = sY / 2 - (eH / 2);

//move layers to the above positions:
if (document.layers){ // Netscape 4
elm.left = xPos;
elm.top = yPos;
} else if (document.all){ // MSIE
elm.style.pixelLeft = xPos;
elm.style.pixelTop = yPos;
} else if (document.getElementById){ //NS6
elm.style.left = xPos + "px";
elm.style.top = yPos + "px";
}

} // end function
