
var xmlhttp;

function loadXMLDoc(url) {
	xmlhttp=null;
	if (window.XMLHttpRequest)
	{// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{// code for IE5 and IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null)
	{
		xmlhttp.onreadystatechange=state_Change;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}
}

function state_Change() {
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = OK
	document.getElementById('everything').innerHTML=xmlhttp.responseText;
	setTimeout("copyScript()",23);
    }
  else
    {
    alert("Problem retrieving XML data");
    }
  }
}

function copyScript() {
	e=document.getElementById('everything');

	var userAgent=navigator.userAgent.toLowerCase();
	if (/*@cc_on!@*/false) { // IE
		s = document.createElement('style');
		s.setAttribute("type", "text/css");
		s.styleSheet.cssText = e.getElementsByTagName('style')[0].text;
		document.getElementsByTagName('head')[0].appendChild(s);
	} else if (/safari/.test(userAgent)) {
		s = document.createElement('style');
		s.setAttribute("type", "text/css");
		s.appendChild(document.createTextNode(e.getElementsByTagName('style')[0].innerText));
		document.getElementsByTagName('head')[0].appendChild(s);
	}

	s = document.createElement("script");
	s.type="text/javascript";
	s.text=e.getElementsByTagName('script')[0].text;
	document.getElementsByTagName('body')[0].appendChild(s);

}


function cycleload() {
	l=document.getElementById('loading');
	if (l != null) {
		if (l.style.display == "block") {
			var a = l.getElementsByTagName('span');
			for (i=0; i<a.length; i++) {
				colstr = a[i].style.color;
				c = parseInt(colstr.substr(4,3));
				if (c == 0xee) c = 0xff;
				if (c == 0x11) c = 0;
				if (c == 2*Math.round(c/2)) {
					c = c + 0x22;
				} else {
					c = c - 0x22;
				}
				a[i].style.color = "rgb(" + c + ',' + c + ',' + c + ')';
			}
			setTimeout("cycleload()",123);
		}
	}
}

function showloading() {
	document.getElementById('loading').style.display="block";
	document.getElementById('dimmer').style.display="block";
	cycleload();
}

function setupspans() {
		a = document.getElementById('loading').getElementsByTagName('span');
			for (i=0; i<a.length; i++)
			{
				c = (7-i)*0x22;
				a[i].style.color = "rgb(" + c + ',' + c + ',' + c + ')';
			}
}

function hideloading() {
	document.getElementById('loading').style.display="none";
	document.getElementById('dimmer').style.display="none";
}




function initloading() {
	setupspans();
	showloading();
	loadXMLDoc('body.php');
}

setTimeout("initloading()", 23);
