// JavaScript Document

// MIL'PAT WEBSITE WAS CREATED BY BAPTIST BENOIST
// ALL RIGHTS RESERVED
// FOR MORE INFORMATIONS EMAIL ME AT baptist@live.fr

//Required by changeContent2
function getXMLHttpRequest()
{
        var xhr = null;
 
        if(window.XMLHttpRequest || window.ActiveXObject)
		{
                if(window.ActiveXObject)
				{
                        try
						{
                                xhr = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch(e)
						{
                                xhr = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                }
				else
				{
                        xhr = new XMLHttpRequest();
                }
        }
		else
		{
                alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
                return null;
        }
 
        return xhr;
}

//slide up the corresponding <div> and calls changeContent2() after a few time
function changeContent(page)
{
	$("#content").slideUp("slow");
	setTimeout("changeContent2(\""+page+"\")",1000);
}

//loads in a div the content returned by the page given in param
function changeContent2(page)
{
	document.getElementById("content").innerHTML="Chargement...";
	var xhr;
	if(window.XMLHttpRequest || window.ActiveXObject)
	{
			if(window.XMLHttpRequest)
			{
					xhr = new XMLHttpRequest();
			} 
			else
			{
					try
					{
							xhr = new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch(e)
					{
							xhr = new ActiveXObject("Microsoft.XMLHTTP");
					}
			}
	}
	else
	{
			alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
			return;
	}
	xhr.onreadystatechange = function()
	{
			if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
			{
					document.getElementById("content").innerHTML=xhr.responseText;
					$("#content").slideDown("slow");;
					
			}
	} 
	xhr.open("GET", page, true);
	xhr.send(null);
}
