// JavaScript Document
//this function writes the text into the page
	xq = new surebert;
	xq.format = "js";
	//xq.debug = true;
	xq.method="get";
	function userLogin(){
		loadingLight.toggle();
		containerHeight.hide();
		socialAreaTrans.hide();
		xq.data='a=new&nickname='+escape(document.loginForm.nickname.value);
		setTimeout("xq.fetch('xq.php')",450);
		
	}
	function newRoom(){
		loadingLight.toggle();
		socialAreaTrans.hide();
		containerHeight.hide();
		xq.data='a=newRoom';
		setTimeout("xq.fetch('xq.php')",450);
	}
	function newGame(){
		loadingLight.toggle();
		containerHeight.toggle();
		xq.data='a=newRound';
		setTimeout("xq.fetch('xq.php')",450);
	}
	function submitChat(){
		loadingLight.toggle();
		//chatFade.toggle();
		document.getElementById('chatWindow').innerHTML= document.getElementById('chatWindow').innerHTML+"<p class='userChatLine'>you: "+document.chatForm.uChat.value+"</p>";
		//setTimeout("chatFade.toggle()",500);
		document.chatForm.uChat.value="";
		var objDiv = document.getElementById("chatWindow");
		objDiv.scrollTop = objDiv.scrollHeight;
		setTimeout("loadingLight.hide();", 500);
		
	}
	function submitQuestion(){
		loadingLight.toggle();
		questionFade.toggle();
		xq.data='a=sendQ&question='+escape(document.questionForm.uQuestion.value);
		setTimeout("xq.fetch('xq.php')",450);
		questionFade.toggle();
	}
	
	function submitAnswer(){
		loadingLight.toggle();
		questionFade.toggle();
		xq.data='a=sendA&answer='+escape(document.answerForm.uAnswer.value);
		setTimeout("xq.fetch('xq.php')",450);
		questionFade.toggle();
	}
	function submitLine(){
		loadingLight.toggle();
		questionFade.toggle();
		xq.data='a=sendLine&line='+escape(document.lineForm.uLine.value);
		setTimeout("xq.fetch('xq.php')",450);
		questionFade.toggle();
	}
	function addChat(chatLine){
		
		loadingLight.toggle();
		//chatFade.hide();
		chatLine=unescape(chatLine);
		document.getElementById('chatWindow').innerHTML=document.getElementById('chatWindow').innerHTML+chatLine;
		var objDiv = document.getElementById("chatWindow");
		objDiv.scrollTop = objDiv.scrollHeight;
		//setTimeout("chatFade.toggle();",200);
		
		setTimeout("loadingLight.hide();",200);
	}
	
/////form validation for the game
//
	function validateLogin(){
		 if (document.loginForm.nickname.value == "") {
    		alert( "oops! you forgot to enter a nickname!" );
    		document.loginForm.nickname.focus();
    		return false;
		 }else{
			 return true;
		 }
	}
	function validateLine(){
		 if (document.lineForm.uLine.value == "") {
    		alert( "oops! you forgot to enter a line!" );
    		document.lineForm.uLine.focus();
    		return false;
		 }else{
			 return true;
		 }
	}
	function validateQuestion(){
		 if (document.questionForm.uQuestion.value == "") {
    		alert( "oops! you didn't enter a question!" );
    		document.questionForm.uQuestion.focus();
    		return false;
		 }else{
			 return true;
		 }
	}
	function validateAnswer(){
		 if (document.answerForm.uAnswer.value == "") {
    		alert( "oops! you didn't enter an answer!" );
    		document.answerForm.uAnswer.focus();
    		return false;
		 }else{
			 return true;
		 }
	}
	function validateChat(){
		 if (document.chatForm.uChat.value == "") {
    		document.chatForm.uChat.focus();
    		return false;
		 }else{
			 return true;
		 }
	}


/////////////////////////////////visual effects with moo.fx
// Initialise the effects
var containerHeight;

window.onload = function() {
	
	if(!NiftyCheck()){
    	return;
	}else{
		Rounded("div#navigation","#FFFFFF","#fa7aef");
		Rounded("div#footer","#FFFFFF","#fa7aef");
	}
	
        containerHeight = new fx.Opacity('gameArea', {duration: 400});
		socialAreaTrans = new fx.Opacity('socialArea', {duration: 400});
		loadingLight = new fx.Opacity('loadingIndicator', {duration: 100});
		loadingLight.toggle();
		
		document.loginForm.nickname.focus();		
		
}	
	