function makeHttpRequest(url, callback_function, return_xml,id)
{
   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)');
               } else {
                   eval(callback_function + '(http_request.responseText,id)');
               }
           } 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) {
   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 {


   document.getElementById('banimg' + id).src = 'thumbnailimage.aspx?filename=' + html_content + '&width=150&height=160';
            document.getElementById('banimglink' + id).href = img_link;
        }
    
    
     
     
     
    
   
	


    try {
      //  clearTimeout(to);
    } catch (e) {}


to = setTimeout(function(){nextAd(id)},parseInt(reload_after));
//document.getElementById('txt' + id ).innerHTML = to + ' - ' + parseInt(reload_after);
} catch (e) { }
}


function nextAd(id)
{

    var now = new Date();
    var url;
    if (id =='L') {
        url = 'ajax-banner.aspx?ts=' + now.getTime() + '&LeftBanner=1';
    } else {
   url = 'ajax-banner.aspx?ts=' + now.getTime();
}
if (stopbanner != "1") {

    makeHttpRequest(url, 'loadBanner', true, id);
}
}

//window.onload = nextAd;
