

	// ajaxlib.js JavaScript Document
var xmlHttp
function GetCheck(div_id,content_id,email,name)
//create new function
{
xmlHttp=GetXmlHttpObject()
//set variable
if (xmlHttp==null)
{
alert ("Your browser doesnt support HTTP Request. please use Firefox, Internet Explorer, or Safari")
// if browser doesn’t support xmlHttp, show error message
}
subject_id = div_id;
content = document.getElementById(content_id).value;
email = document.getElementById(email).value;
name = document.getElementById(name).value;
xmlHttp.onreadystatechange=FetchComplete
//if the state of xmlHttp change, go to FetchComplete function
xmlHttp.open("GET", "forms/subscription/subscription.php?content=" + escape(content)+"&email=" + escape(email)+"&name=" + escape(name)+"&sid="+Math.random(), true)
//use get method
xmlHttp.send(null)
}
function FetchComplete()
//this is our defined function to get the AJAX status
{
/*
there is 5 readystate status :
0=uninitialized
1=loading
2=loaded
3=interactive
4=complete
you can modify the status state at your own
*/
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
//if AJAX state is complete (4)
{
document.getElementById(subject_id).innerHTML=xmlHttp.responseText
//get element where the id is “Result”, in this case it goes to the <div> tag
}
if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
//if AJAX state is loading (loading)
{
document.getElementById(subject_id).innerHTML="<img src=\"images/loading.gif\"/> Please wait"
//get element where the id is “Result”, in this case it goes to the <div> tag
//send the loading image (loading.gif) that show us the data is being prepared
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// check browser firefox, opera 8.0+, safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// browser Internet Explorer
try
{
// IE 6.0+
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
// IE 5.0
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
//return the value
}

