/*

	Alienetics AJAX function
	http://www.alienetics.com/
	
*/
var net=new Object();

net.ajax=function(url, callBack, div, method, data) 
{
	if (typeof XMLHttpRequest!='undefined') 
	{
		var ajax = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		var ajax = new ActiveXObject("Microsoft.XMLHTTP");		
	}			    
	else if (window.createRequest) 
	{ 
		var ajax = window.createRequest();
	}
	else
	{	
		alert ('Failed to initialize AJAX');
		return false;
	}
	
	if (ajax) 
	{
		if (method == 'post') 
		{
			url=url+'?r='+Math.floor(Math.random()*1000000);
			ajax.open('POST', url, true); 
			ajax.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") 
		}
		else 
		{
			url=url+'&r='+Math.floor(Math.random()*1000000);
			ajax.open('GET', url, true); 
		}
			        
		ajax.onreadystatechange = function() 
		{				
			if (ajax.readyState == 4 && ajax.status == 200) 
			{
				if ('function' == typeof callBack)
				{
					if (document.getElementById(div))
						callBack(ajax.responseText,div);
					else
						callBack(ajax.responseText);
				}
				else if (document.getElementById(div))
					document.getElementById(div).innerHTML=ajax.responseText;	
			}
			else
			{
				//show that we are loading here
			}		
		}
		
		if (method == 'post') 
		{
			ajax.send(data); 
		}
		else 
		{
			ajax.send(null); 
		}
	}
}

function ajax(url, callBack, div, method, data)
{
	new net.ajax(url, callBack, div, method, data);
	return true;
}