
function loadData() {
    //updateBanner();
    updatePlaying();
    updateHistory();
    updateOnline();
    updateListeners();
    displayTimeInt();
    //updateTime();
    //Fadewl();
}

//Determine what XmlHttpRequest object we will use.
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not Internet Explorer
	} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer
	} else {
           //If it gets to here, an error has occurred and we inform the user of this
alert("An Error Has Occurred!");
	}
}

//#----- Current Song Banner [Req 1] -----#
var getRequest1 = getXmlHttpRequestObject();
function updateBanner() {
	//Checks to see if you XmlHttpRequest object is ready.
	if (getRequest1.readyState == 4 || getRequest1.readyState == 0) {
        //Makes a call to Display Get_Text.html with the GET
        getRequest1.open("GET", 'trackinfo.html', true);
        //Call a function that will display the text in the span area on First_Ajax_Application.html
	    getRequest1.onreadystatechange = displayBanner;
	    //Makes the request.
	    getRequest1.send(null);
	}
    setTimeout("updateBanner()", 10000);
}
function displayBanner() {
	//Check to see if the XmlHttpRequests state is finished.
	if (getRequest1.readyState == 4) {
        //Set the contents of our span element to the result of the asyncronous call.
        document.getElementById('banner').innerHTML = getRequest1.responseText;
	}
}

//#----- Current Song Playing [Req 2] -----#
var getRequest2 = getXmlHttpRequestObject();
function updatePlaying() {
	//Checks to see if you XmlHttpRequest object is ready.
	if (getRequest2.readyState == 4 || getRequest2.readyState == 0) {
        //Makes a call to Display Get_Text.html with the GET
        getRequest2.open("GET", '/iddw/system/addon/SAM/data/SAM.playing.php', true);
        //Call a function that will display the text in the span area on First_Ajax_Application.html
	    getRequest2.onreadystatechange = displayPlaying;
	    //Makes the request.
	    getRequest2.send(null);
	}
    setTimeout("updatePlaying()", 10000);
}
function displayPlaying() {
	//Check to see if the XmlHttpRequests state is finished.
	if (getRequest2.readyState == 4) {
        //Set the contents of our span element to the result of the asyncronous call.
        document.getElementById('playing').innerHTML = getRequest2.responseText;
	}
}

/*----- Song Played History [Req 3] -----*/
var getRequest3 = getXmlHttpRequestObject();
function updateHistory() {
	//Checks to see if you XmlHttpRequest object is ready.
	if (getRequest3.readyState == 4 || getRequest3.readyState == 0) {
        //Makes a call to Display Get_Text.html with the GET
        getRequest3.open("GET", '/iddw/system/addon/SAM/data/SAM.history.php', true);
        //Call a function that will display the text in the span area on First_Ajax_Application.html
	    getRequest3.onreadystatechange = displayHistory;
	    //Makes the request.
	    getRequest3.send(null);
	}
    setTimeout("updateHistory()", 10000);
}
function displayHistory() {
	//Check to see if the XmlHttpRequests state is finished.
	if (getRequest3.readyState == 4) {
        //Set the contents of our span element to the result of the asyncronous call.
        document.getElementById('history').innerHTML = getRequest3.responseText;
	}
}

//#----- Internet Listeners [Req 4] -----#
var getRequest4 = getXmlHttpRequestObject();
function updateListeners() {
	//Checks to see if you XmlHttpRequest object is ready.
	if (getRequest4.readyState == 4 || getRequest4.readyState == 0) {
        //Makes a call to Display Get_Text.html with the GET
        getRequest4.open("GET", 'inc/data/inc.listener.count.php', true);
        //Call a function that will display the text in the span area on First_Ajax_Application.html
	    getRequest4.onreadystatechange = displayListeners;
	    //Makes the request.
	    getRequest4.send(null);
	}
    setTimeout("updateListeners()", 10000);
}
function displayListeners() {
	//Check to see if the XmlHttpRequests state is finished.
	if (getRequest4.readyState == 4) {
        //Set the contents of our span element to the result of the asyncronous call.
        document.getElementById('Listeners').innerHTML = getRequest4.responseText;
	}
}

//#----- Users Online Req 5 -----#
var getRequest5 = getXmlHttpRequestObject();
function updateOnline() {
	//Checks to see if you XmlHttpRequest object is ready.
	if (getRequest5.readyState == 4 || getRequest5.readyState == 0) {
        //Makes a call to Display Get_Text.html with the GET
        getRequest5.open("GET", 'inc/uol/uol.php', true);
        //Call a function that will display the text in the span area on First_Ajax_Application.html
	    getRequest5.onreadystatechange = displayOnline;
	    //Makes the request.
	    getRequest5.send(null);
	}
    setTimeout("updateOnline()", 10000);
}
function displayOnline() {
	//Check to see if the XmlHttpRequests state is finished.
	if (getRequest5.readyState == 4) {
        //Set the contents of our span element to the result of the asyncronous call.
        document.getElementById('Online').innerHTML = getRequest5.responseText;
	}
}

//#----- Time Functions Req 6 -----#
function displayTimeInt() {
    displayTime(1,'disTime');
    displayTime(1,'disTime2');
    setInterval("displayTime(1,'disTime')",1000);
    setInterval("displayTime(1,'disTime2')",1000);
}

function displayTime(n,area) {
    var dateObj = new Date();
    thisSecond = dateObj.getSeconds();
    thisMinute = dateObj.getMinutes();
    thisHour = dateObj.getHours();

    var ampm = "";

    if (n == 1) {
        ampm = (thisHour < 12) ? " AM" : " PM"
        thisHour = (thisHour > 12) ? thisHour - 12 : thisHour;
        thisHour = (thisHour == 0) ? 12 : thisHour;
    }

    thisMinute = thisMinute < 10 ? "0" + thisMinute : thisMinute;
    thisSecond = thisSecond < 10 ? "0"+thisSecond : thisSecond;

    finalStr = thisHour + ":" + thisMinute + ampm;

    timeObj = document.getElementById(area);
    timeObj.innerHTML = finalStr;
}


/*
sajax_show_javascript();

function show_me(date_server) {
    document.getElementById("date_div").innerHTML = date_server;
}

function get_date() {
    //put the return of php's show_now func
    //to the javascript show_me func as a parameter
    x_show_now(show_me);
    //do it every 1 second
    setTimeout("get_date()", 1000);
}
*/