/*

ADServerDB :: The Ad Server With The Future Built In

Program:	ADServerDB AJAX Library

Author:		Tim Schaefer, tim@adserverdb.com

Latest:		July 2008

Description:	Rotate your ads via AJAX

*/

function callAHAH( url, pageElement, callMessage )
{

	document.getElementById( pageElement ).innerHTML = callMessage;

	try	{
  		req = new XMLHttpRequest();
  		}
	catch(E1){
			try
				{
				req = new ActiveXObject("Msxml2.XMLHTTP") ;
				}
			catch(E2)
				{
				try
					{
					req = new ActiveXObject("Microsoft.XMLHTTP") ;
					}
				catch(E3)
					{
					req = false ;		
					}
				}
		}

	req.onreadystatechange = function() {responseAHAH(pageElement); } ;

	req.open( "POST", url, true );
	req.send(null);

}

function responseAHAH( pageElement )
{
	var output = '' ;

	if( req.readyState == 4 )
		{

		//
		// status_string = "Server Status [ " + myRequest.status + "] statusText [" + myRequest.statusText + "] " ;
		// alert( status_string );
		//

		if ( req.status == 200 )
			{
			output =  req.responseText  ;
			document.getElementById(pageElement).innerHTML = output ;
			}
		else	{
			status_string = "Server Error [ " + myRequest.status + "] statusText [" + myRequest.statusText + "] " ;
			alert( status_string );
			}
		}
}

function getXMLHTTPRequest()
{
	var req = false ;

	try
  		{
  		req = new XMLHttpRequest();
  		}
	catch(err1)
		{
		try
			{
			req = new ActiveXObject("Msxml2.XMLHTTP") ;
			}
		catch(err2)
			{
			try
				{
				req = new ActiveXObject("Microsoft.XMLHTTP") ;
				}
			catch(err3)
				{
				req = false ;		
				}
			}
		}

	return req ;
}


function responseAjaxText()
{
	var status_string = "" ;

	if( myRequest.readyState == 4 )
		{

		//
		// status_string = "Server Status [ " + myRequest.status + "] statusText [" + myRequest.statusText + "] " ;
		// alert( status_string );
		//

		if ( myRequest.status == 200 )
			{
			document.write( myRequest.responseText ) ;
			}
		else	{
			status_string = "Server Error [ " + myRequest.status + "] statusText [" + myRequest.statusText + "] " ;
			alert( status_string );
			}
		}
}

function send_request_text( url )
{
var myRandom = parseInt(Math.random()*999999999) ;
var modURL = url +"&rand=" + myRandom ;

myRequest.open("GET", modURL , true);
myRequest.onreadystatechange = responseAjaxText ;

myRequest.send(null) ;

}

var req = getXMLHTTPRequest();

var countDownInterval = 150 ;
var countDownTime=countDownInterval+1;

if (document.getElementById)
        {
        countDown( countDownInterval );
        }

