/* script */


function getAjaxText (url, target)
{
	var xmlhttp = false;
	var ret = '';
	var r=Math.random()*100
	url = url + "?r=" + r;

	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			xmlhttp = false;
		}
	}

	if ( !xmlhttp && typeof XMLHttpRequest != 'undefined' )
	{
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open( "GET", url, true );

	xmlhttp.onreadystatechange=function() 
	{
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) 
		{
          	ret = xmlhttp.responseText;
          	var obj = document.getElementById(target);
          	obj.innerHTML=ret;
		}
	}

	xmlhttp.send(null);
}

function callURL (url)
{
	(new Image()).src=url;
}


/* Fetches XML via AJAX */
function getAjaxXML (url)
{
	var ret = '';
	var url = noCaching (url);
	
	var xmlhttp = getXMLHttpRequest();
	xmlhttp.open ("GET", url, true);

	xmlhttp.onreadystatechange=function() 
	{
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) 
		{
          	ret = xmlhttp.responseXML;
		} else
		{
				// error
		}
	}
	xmlhttp.send(null);
}

/* Fetches cross-browser XML HTTP request Object */
function getXMLHttpRequest()
{
	var xmlhttp = false;
	
	/* Try to create IE/Windows ActiveX version */
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			xmlhttp = false;
		}
	}

	/* Use native XMLHttpRequest object */
	if ( !xmlhttp && typeof XMLHttpRequest != 'undefined' )
	{
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

/* Prevents URL from being cached by adding extra random parameter */
function noCaching (url)
{
	var r=Math.random()*100;
	var nocache=(url.indexOf("?")!=-1)? "&d="+new Date().getTime() : "?d="+new Date().getTime
	nocache = nocache + "&r="+r;
	return (url + nocache);
}

/* Alternative */
function getXMLHttpRequest2()
{
  var xmlhttp;
  
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  return xmlhttp;
}
