

	function getHTTPObject()
	{
  		var xmlhttp;
  			try
			{
      				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      			}
      			catch(e)
      			{
       			try
       			{
         				 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
       			}
       			catch(E)
       			{
          				xmlhttp = false;
        			}
   		 	}
    		return xmlhttp;
 	}

	var httpGetData = getHTTPObject();
	var httpSendData = getHTTPObject();
	function insertLine(chatName,chatText)
	{
		data = document.getElementById("chatField").value;
		newData = data + chatName + ":" + chatText + "\n\r";
		document.getElementById("chatField").value = newData;
	}
	function getData()
	{
		if(httpGetData.readyState == 4 || httpGetData.readyState == 0)
		{
  			httpGetData.open("GET",'index.php?module=chat&amp;action=getData', true);
    			httpGetData.onreadystatechange = handleIncomingData;
  			httpGetData.send(null);
		}
	}
	function handleIncomingData()
	{
  		if(httpGetData.readyState == 4)
		{
			alert(httpGetData.responseText);
    			result = httpGetData.responseText.split(' ');
			
    		}

  	}

	function sendMessage()
	{
		chatText = document.forms['chat'].elements['messageField'].value;
		if(chatText != '' & (httpSendData.readyState == 4 || httpSendData.readyState == 0))
		{
			parameter = 'messageField='+ chatText;	
			httpSendData.open("POST",'index.php?module=chat&amp;action=sendData', true);
			httpSendData.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  			httpSendData.onreadystatechange = handleIncomingData;
  			httpSendData.send(parameter);
  			document.forms['chat'].elements['chatbarField'].value = '';
		}
		else
		{

		}
	}

	function sendRequest(url,parameter)
	{
			httpSendData.open("POST",url, true);
			httpSendData.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  			httpSendData.onreadystatechange = handleIncomingData;
  			httpSendData.send(parameter);
	}


	function showHide(element)
	{
		if(document.getElementById(element).style.visibility=='hidden')
		{
			document.getElementById(element).style.visibility='visible';
			document.getElementById(element).style.display = 'block';
		}
		else
		{
			document.getElementById(element).style.visibility='hidden';
			document.getElementById(element).style.display = 'none';
		}
	}
	
	function setValue(element,value)
	{
		document.getElementById(element).value = value;	
	}



