// JavaScript Document
var Adsecs
var AdtimerID = null
var AdtimerRunning = false
var Addelay = 3000

function AdInitializeTimer()
{
    // Set the length of the timer, in seconds
    Adsecs = 10
    StopAdClock()
    StartAdTimer()
}

function StopAdClock()
{
    if(AdtimerRunning)
        clearTimeout(AdtimerID)
    AdtimerRunning = false
}

function StartAdTimer()
{
    if (Adsecs==0)
    {
        StopAdClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        LoadAds()
		AdInitializeTimer()
    }
    else
    {
        self.status = Adsecs
        Adsecs = Adsecs - 1
        AdtimerRunning = true
        AdtimerID = self.setTimeout("StartAdTimer()", Addelay)
    }
}
function LoadAds() {		
AdxmlHttp=AdGetXmlHttpObject();
if (AdxmlHttp==null) {			
alert ("Browser does not support HTTP Request");
return;
} 			
var url="/Ads.php";
AdxmlHttp.onreadystatechange=AdRecived;
AdxmlHttp.open("POST",url,true);
AdxmlHttp.send("s");
}
function AdRecived() {
if (AdxmlHttp.readyState==4 || AdxmlHttp.readyState=="complete") {
txt=AdxmlHttp.responseText;
document.getElementById("Adlist").innerHTML=txt;
}
}
function AdGetXmlHttpObject() {
var objAdxmlHttp=null
if (window.XMLHttpRequest) {
objAdxmlHttp=new XMLHttpRequest()
}	
else if (window.ActiveXObject) {
objAdxmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objAdxmlHttp
}
AdInitializeTimer();