//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
try
{
	//If the javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
	//If not, then use the older active x object.
	try
	{
		//If we are using IE.
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (E)
	{
		//Else we must be using a non-IE browser.
		xmlhttp = false;
	}
}

//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
	xmlhttp = new XMLHttpRequest();
}
function pagecontents(pagename)
{
	var obj = document.getElementById("header");
	serverPage="header.php?header="+pagename;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 1 || xmlhttp.readyState == 2 || xmlhttp.readyState == 3)
		{
			document.body.style.cursor = 'wait';
		}
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;
			document.body.style.cursor = 'default';
			main(pagename);
		}
	}
xmlhttp.send(null);
}
function main(pagename)
{
	var obj = document.getElementById("main");
	serverPage="main.php?content="+pagename;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 1 || xmlhttp.readyState == 2 || xmlhttp.readyState == 3)
		{
			document.body.style.cursor = 'wait';
		}
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;
			document.body.style.cursor = 'default';
		}
	}
xmlhttp.send(null);
}

function project(projectname)
{
	var obj =  document.getElementById("projectloader");
	var obj2 = document.getElementById("project");
	serverPage2="project.php?project="+projectname;
	xmlhttp.open("GET", serverPage2);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 1 || xmlhttp.readyState == 2 || xmlhttp.readyState == 3)
		{
			obj.style.visibility="visible";
			document.body.style.cursor = 'wait';
		}
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.style.visibility="hidden";
			obj2.style.visibility="visible";
			obj2.innerHTML = xmlhttp.responseText;
			document.body.style.cursor = 'default';
		}
	}
xmlhttp.send(null);
}

function send()
{
	var errormsg;
	errormsg="";
	if(document.contact.con_name.value=="")
		errormsg=errormsg +" (Name) ";
	if(document.contact.con_comments.value=="")
		errormsg=errormsg+" (Comments) ";
	if(document.contact.con_email.value=="")
		errormsg=errormsg+" (Email) ";
	if(errormsg!="")
		document.getElementById("errors").innerHTML="<font color=red>Errors: </font>"+errormsg;
	else
		sendemail()
}
function sendemail()
{
		var obj = document.getElementById("sending");
		var con_name = document.contact.con_name.value;
		var con_comments = document.contact.con_comments.value;
		var con_email = document.contact.con_email.value;
		var serverPage3="sendemail.php?con_name=" + con_name + "&con_comments=" + con_comments + "&con_email=" + con_email;
		xmlhttp.open("GET", serverPage3);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 1 || xmlhttp.readyState == 2 || xmlhttp.readyState == 3)
			{
				obj.innerHTML = " <b> Sending...</b>";
				document.body.style.cursor = 'wait';
			}
			else if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
			{
				obj.innerHTML = xmlhttp.responseText;
				document.body.style.cursor = 'default';
			}
		}
xmlhttp.send(null);
}

function hideproject()
{
	document.getElementById("project").style.visibility="hidden";
}