// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
	// will store the reference to the XMLHttpRequest object
	var xmlHttp;
	// this should work for all browsers except IE6 and older
	try
	{
		// try to create XMLHttpRequest object
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		// assume IE6 or older
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
		"MSXML2.XMLHTTP.5.0",
		"MSXML2.XMLHTTP.4.0",
		"MSXML2.XMLHTTP.3.0",
		"MSXML2.XMLHTTP",
		"Microsoft.XMLHTTP");
		// try every prog id until one works
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				// try to create XMLHttpRequest object
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch (e) {}
		}
	}
	// return the created object or display an error message
	if (!xmlHttp){
	alert("Error creating the XMLHttpRequest object.");
	}
	return xmlHttp;
}
function count_home_click(){
	var serverPage = "functions/count_home_click.php";
	xmlHttp.open("GET",serverPage);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
		{			
			if(document.getElementById(id_name)==null){
				var temp = xmlHttp.responseText;
			}			
		}
	}
	xmlHttp.send(null)
}
function show_homepage(){
	var serverPage = "functions/show_homepage.php";
	xmlHttp.open("GET",serverPage);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
		{
			var id_name = "show_homepage";
			if(document.getElementById(id_name)==null)
			{
				
				var newdiv = document.createElement('div');
				newdiv.setAttribute('id', id_name);

				newdiv.innerHTML = xmlHttp.responseText;
				document.body.appendChild(newdiv);
				var obj = document.getElementById(id_name);

				var width = 401;
				var height = 204;
				obj.style.width=width;
				obj.style.height=height;	
				
				var top = document.documentElement.scrollTop+100;
				var left = 	(document.documentElement.clientWidth/2)-(width/2);

				obj.style.top=""+top+"px";
				obj.style.left=""+left+"px";

				obj.style.position='absolute';
				obj.style.zIndex="3";

				Drag.init(obj);
			}			
		}
	}
	xmlHttp.send(null)
}
