<script type="text/javascript">
//
// (C) Copyright, 2008, Leo Ørsnes. All rights reserved
//
/*
function CreateXMLHttpRequest() {
	var mitReq = null;
	if ( window.XMLHttpRequest ) {
		mitReq = new XMLHttpRequest();
	} else if ( window.ActiveXObject ) {
		try { mitReq = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
	} else {
		mitReq = false;
	}
	return mitReq;
}
*/
//var mitReq = null;

function CreateXMLHttpRequest() {
var req = false;
try
{
req = new XMLHttpRequest(); /*Firefox, Opera mm.*/
 }
 catch(fejl1)
  {
  try
  {
  req = new ActiveXObject("Msxml2.XMLHTTP"); /*IE udgaver 1*/
  }
  catch(fejl2)
   {
   try
   {
  req = new ActiveXObject("Microsoft.XMLHTTP"); /*IE udgaver 2*/
   }
   catch(fejl3)
    {
   req = false;
    }
   }
  }
  return req;
}

var mitReg = CreateXMLHttpRequest();

function getSite(site) {
	try {
		mitReq = CreateXMLHttpRequest();
		if ( mitReq.readyState == 4 || mitReq.readyState == 0 ) {
			var file = "../../sites/"+site+".php";										// hej.php svarer så "HEJSA!!"
			mitReq.open('GET', file, true);
			if (mitReq.readyState == 4) return;
			mitReq.onreadystatechange = function()
				{
					if(mitReq.readyState!=4) return;
					svarAjax('chat');
				}
			mitReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
			mitReq.send(null);
			document.getElementById('loader').style.display = 'inline';
		} else {
			// TODO: Try again
		}
	} catch (e) { /* TODO: Display message */ }
}
function svarAjax(svar) {

if (svar == "chat") {
	//alert(mitReq.responseText);											// og derfor vil responseText være "HEJSA!!"
	document.getElementById('chatcontent').innerHTML = mitReq.responseText;
	document.getElementById('loader').style.display = 'none';
}
}

// FUNKTIONER IGANGSÆTTES
</script>