var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	var xmlHttp;
	if(window.ActiveXObject) // if IE
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	else // if mozilla or other
	{
		try
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	if(!xmlHttp)
	{
		alert("Error creating the XMLHttpRequest object!");
	}
	else
	{
		return xmlHttp;
	}
} // end of function

function processAJAX1(id)
{
	url = 'ssi/ajax1.php?id='+id;
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) // only proceed if the object isn't busy
	{
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = handleServerResponse1;
		xmlHttp.send(null);
	}
	else
	{
		setTimeout("process()",500);
	}
} // end of function

function handleServerResponse1()
{
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{
			
			xmlResponse = xmlHttp.responseXML;
			xmlDocumentElement = xmlResponse.documentElement;
			responseText = xmlDocumentElement.firstChild.data;
			
			// redirect here ...
			
			window.location = responseText;
			
		}
		else
		{
			alert("Error accessing server!");
		}
	}
} // end of function

function processAJAX2(id,id2)
{
	url = 'ssi/ajax2.php?id='+id+'&id2='+id2;
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) // only proceed if the object isn't busy
	{
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = handleServerResponse2;
		xmlHttp.send(null);
	}
	else
	{
		setTimeout("process()",500);
	}
} // end of function

function handleServerResponse2()
{
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{
			
			xmlResponse = xmlHttp.responseXML;
			xmlDocumentElement = xmlResponse.documentElement;
			responseText = xmlDocumentElement.firstChild.data;
			
			// redirect here ...
			
			window.location = responseText;
			
		}
		else
		{
			alert("Error accessing server!");
		}
	}
} // end of function

function visit1(id) // redirect to site ...
{

	// use AJAX to record hit and then refer ...
	
	processAJAX1(id);

}

function visit2(id,id2) // redirect to product page ...
{

	// use AJAX to record hit and then refer ...
	
	processAJAX2(id,id2);

}
