function makeHttpRequest(url, callback_function, return_xml, id,uid) {
    var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }

    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }

    if (!http_request) {
        //alert('Unfortunatelly you browser doesn\'t support this feature.');
        return false;
    }
    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                if (return_xml) {
                    eval(callback_function + '(http_request.responseXML,id,uid)');
                } else {
                    eval(callback_function + '(http_request.responseText,id,uid)');
                }
            } else {
                // alert('There was a problem with the request.(Code: ' + http_request.status + ')');
            }
        }
    }
    http_request.open('GET', url, true);
    http_request.send(null);
}






function loadBanner(xml, id,uid) {
    try {

        var html_content = xml.getElementsByTagName('content').item(0).firstChild.nodeValue;
        var reload_after = xml.getElementsByTagName('reload').item(0).firstChild.nodeValue;
        var img_link
        try {
            img_link = xml.getElementsByTagName('link').item(0).firstChild.nodeValue;
        } catch (e) { }

        if (id == 'L') {
            document.getElementById('banimg' + id).innerHTML = html_content;
        } else if (id == 'P') {
            document.getElementById('banimg' + id).innerHTML = html_content;
        } else if (id == 'fpnhp') {
            document.getElementById('banimglink' + id).innerHTML = html_content;
        } else if (id == 'fpnsp') {
            document.getElementById('banimglink' + id).innerHTML = html_content;
        } else if (id == 'CAL') {
            document.getElementById('banimglink' + id).innerHTML = html_content;
        } else {
            document.getElementById('banimg' + id).src = 'thumbnailimage.aspx?filename=' + html_content + '&width=180';
            document.getElementById('banimglink' + id).href = img_link;
        }


        try {
            //  clearTimeout(to);
        } catch (e) { }


        to = setTimeout(function () { nextAd(id, uid) }, parseInt(reload_after));
        //document.getElementById('txt' + id ).innerHTML = to + ' - ' + parseInt(reload_after);
    } catch (e) {
      //  alert(e.ToString);

    }
}


function nextAd(id, uid) {

    var now = new Date();
    var url;
    if (id == 'L') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&LeftBanner=1';
    }
    else if (id == 'P') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&PBan=1&uid=' + uid;
    }
    else if (id == 'P') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&PBan=1&uid=' + uid;
    }
    else if (id == 'fpnhp') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&' + id + '=1&uid=' + uid;
    }
    else if (id == 'fpnsp') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&' + id + '=1&uid=' + uid;
    }
    else if (id == 'CAL') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&' + id + '=1&uid=' + uid;
    }
    else {
        url = 'ajax-banner.aspx?ts=' + now.getTime();
    }

    try {
        if (stopbanner != "1") {
            makeHttpRequest(url, 'loadBanner', true, id,uid);
        }
    } catch (err) {
        makeHttpRequest(url, 'loadBanner', true, id,uid);
    }


}

//window.onload = nextAd;

