	function roomError()
	{
		toggleBox('div8',1);
	}

	function cFF(fface)
	{
		  document.getElementById("font_face").value=fface;
		  window.frames["doFont"].location.href='font.php?font_face='+fface;
	}

	function cFC(fcolor)
	{
		  document.getElementById("font_color").value=fcolor;
		  window.frames["doFont"].location.href='font.php?font_color='+fcolor;
 	}

	function cFS(fsize)
	{
		document.getElementById("font_height").value=fsize;
		window.frames["doFont"].location.href='font.php?font_height='+fsize;
 	}

	function cFST(fstyle)
	{
		 window.frames["doFont"].location.href='font.php?font_style='+fstyle;

		 fstyle = fstyle.replace('-', '');
		 document.getElementById("font_style").value='<'+fstyle+'>';
	}
	
	function launchHelp()
	{
		window.open("help/index.php","helpfile","");
	}
	
	function getmaxlength(obj)
	{
		var thelength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
		if (obj.getAttribute && obj.value.length>thelength)
		obj.value=obj.value.substring(0,thelength)

	}

	function addavatar(code)
	{
		document.frmmain.user_avatar.value = '';
		var pretext = document.frmmain.user_avatar.value;	
		this.code = code;
		document.frmmain.user_avatar.value = pretext + code;

		var newAvatar = document.frmmain.user_avatar.value;
		window.frames["update_avatar"].location.href='avatar.php?i=1&new=' + newAvatar;
		toggleBox('div2',0);
		document.getElementById('txt_message').focus();
	}

	function addsmiley(code)
	{
		var pretext = document.frmmain.txt_message.value;	
		this.code = code;
		document.getElementById('txt_message').focus();
		document.frmmain.txt_message.value = pretext + code;

	}

	
	var topLevel = 100;
	function toggleBox(szDivID)
	{
		

		if(document.layers)	   //NN4+
		{
			if(document.layers[szDivID].visibility == "visible")
			{
				document.layers[szDivID].visibility = "hidden";
			}
			else
			{
				document.layers[szDivID].zIndex = topLevel++;
				document.layers[szDivID].visibility = "visible"; 
			}

		    }
		    else if(document.getElementById)	  //gecko(NN6) + IE 5+
		    {
			var obj = document.getElementById(szDivID);

			if(obj.style.visibility == "visible")
			{
				obj.style.visibility = "hidden";
			}
			else
			{
				obj.style.zIndex = topLevel++;
				obj.style.visibility = "visible";
			}

		    }
		    else if(document.all)	// IE 4
		    {
			
			if(document.all[szDivID].style.visibility == "visible")
			{
				document.all[szDivID].style.visibility = "hidden";
			}
			else
			{
				document.all[szDivID].style.zIndex = topLevel++;
				document.all[szDivID].style.visibility = "visible"; 
			}
		    }

		if(topLevel > 32000)
		{
			topLevel = 10;
		}
	}

 	function clearWhisper(toUser)
	{
		if (toUser.value == toUser.defaultValue) {
			 toUser.value = ""
		}
	}

 	function clearWhisperShare(share_user) 
	{
		if (share_user.value != "") {
			share_user.value = ""
		}
	}

 	function clearWhisperBan(banthisuser) 
	{
		if (banthisuser.value != "") {
			banthisuser.value = ""
		}
	}

	function submitenter(myfield,e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		if (keycode == 13)
		{
			sendChatText();
			return false;
		}
		else
		return true;
	}

	function doSFX(code)
	{
		var pretext = document.frmmain.txt_message.value;	
		this.code = code;
		document.frmmain.txt_message.value = pretext + code;
		document.getElementById('txt_message').focus();
		sendChatText();

	}

	function ringbell(code)
	{
		var pretext = document.frmmain.txt_message.value;	
		this.code = code;
		document.frmmain.txt_message.value = pretext + code;
		document.getElementById('txt_message').focus();
		sendChatText();

	}

	function shareImage()
	{
		window.open('share/upload.php?room=' + room,'share_image','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=220,height=220,left=380,top=220');
	}

	function playGames()
	{
		window.open('games/index.php','playgames','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=320,height=250,left=380,top=220');
	}

	function appMessages()
	{
		if(document.getElementById('approvemesages').checked==true)
		{
			window.open("moderated_chat/index.php?chat=1&room=" + room,"moderated_chat","");
			document.getElementById('approvemesages').checked=false
		}
	}

	function showTranscripts()
	{
		window.open("transcripts.php");
	}

	function roomCreated()
	{
		toggleBox('div7',1);
		document.getElementById('ajax_loader').innerHTML = '<img src="images/ajax_loader.gif">';
		setTimeout("toggleBox('div7',0)", 3000);
	}

	function disConnect()
	{
		if(getSender || getUser){
			parent.window.location = "private_logout.php?room=" + room;
		}else{
			parent.window.location = "logout.php";
		}
	}

	function blockSubmit() 
	{
		sendChatText();
		return false;
	}

	function handleResetChat() 
	{
		document.getElementById('div_chat').innerHTML = '';
		getChatText();
	}

	function rollbg(chosen, objectID) 
	{
		if(chosen == "menu_roll") {
			document.getElementById(objectID).className="menu_roll";
		}else{
			document.getElementById(objectID).className="menu_over";
		}
	}

	function showError(dError, mError)
	{
		document.getElementById("char_error").innerHTML = mError;
		document.getElementById("char_error").style.backgroundColor='#FFFFFF';
		document.getElementById("char_error").style.border='thin solid #84B2DE';
		document.getElementById("char_error").style.padding='3px';
		document.getElementById(dError).style.backgroundColor='#FFFFCC';
		document.getElementById(dError).focus();
	}

	function def(dError)
	{
		document.getElementById("char_error").innerHTML = '';
		document.getElementById("char_error").style.backgroundColor='';
		document.getElementById("char_error").style.border='';
		document.getElementById("char_error").style.padding='';
		document.getElementById(dError).style.backgroundColor='#FFFFFF';
	}

	function formCheckReg(form) 
	{
		if (form.reg_uname.value == "") {
			showError("reg_uname", regNameError);
			return false ;

		}
		var fchars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>? ";
		for (var x = 0; x < form.reg_uname.value.length; x++) {
			if (fchars.indexOf(form.reg_uname.value.charAt(x)) != -1) {
				showError("reg_uname", regNameErrorChr);
				return false;
			}
		}


		if (form.reg_email.value == "") {
			showError("reg_email", regEmailError);
			return false;
		}

		validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		strEmail = form.reg_email.value;

		if (strEmail.search(validRegExp) == -1) {
			showError("reg_email", regEmailErrorChr);
			return false;
		} 

		if (form.reg_password.value == "") {
			showError("reg_password", regPassError);
			return false;
		}

		if (!(form.terms.checked)) {
			showError("terms", regTermsError);
			return false;
		}

	}

	function formCheckLost(form) 
	{
		if (form.lost_uname.value == "") 
		{
			showError("lost_uname", lostName);
			return false ;
		}

		if (form.lost_email.value == "") 
		{
			showError("lost_email", lostEmail);
			return false ;
		}

		validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		strEmail = form.lost_email.value;

		if (strEmail.search(validRegExp) == -1) 
		{
			showError("lost_email", lostEmailChr);
			return false;
		} 

	}

	function formCheckLogin(form) 
	{

		if (form.uname.value == "") {
			showError("uname", loginNameError);
			return false ;

		}
		var fchars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		for (var x = 0; x < form.uname.value.length; x++) {
			if (fchars.indexOf(form.uname.value.charAt(x)) != -1) {
				showError("uname", loginNameErrorChr);
				return false;
			}
		}

		

	}

	function doGuest(uname) {

		if (uname.value != "" || uname.value == "") {

			uname.value = uGuest;

		}


	}