window.onload=function() 
{ 
fadeIn(); 
} 

function fadeIn() { 

  // check if IE or .... other 
  var isIE = (navigator.appName=="Microsoft Internet Explorer") ; 
  
  // set the opacity to 0 
  if (isIE) 
  { 
    // internet explorer 
    document.getElementById("slideshow").style.filter = "alpha(opacity=0)"; 
  } 
  else 
  { 
    // firefox... 
    document.getElementById("slideshow").style.opacity = 0; 
  } 

  var inter = setInterval(function () { 

      if ( isIE ) 
      { 
        var op = document.getElementById("slideshow").filters.alpha.opacity; // IE Only 
      } 
      else 
      { 
        var op = document.getElementById("slideshow").style.opacity; // other 
      } 
    
    
    // op wil be between 0 and 100 for IE and for the rest between 0 and 1 
    if ( ( ( isIE ) && ( op >= 100 )) || ( ( !isIE ) && ( op >= 1 )  ) ) 
    { 
      clearInterval(inter); 
    } 
    else 
    { 
      if (isIE) 
      { 
        document.getElementById("slideshow").style.filter =  "alpha(opacity=" + parseInt(document.getElementById("slideshow").filters.alpha.opacity + 5) + ")"; 
      } 
      else 
      { 
        document.getElementById("slideshow").style.opacity = parseFloat(document.getElementById("slideshow").style.opacity)+5/100; 
      } 
    } 
  }, 50 ); 
} 


function nextAd()
{
    var now = new Date();
    var url = "http://" + window.location.hostname + "/scripts/naslovnica.php?ts=" + now.getTime();
    makeHttpRequest(url, 'loadBanner', true);
}

window.onload = nextAd;

function makeHttpRequest(url, callback_function, return_xml)
{
   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)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } 
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}

function loadBanner(xml)
{
    var html_content = xml.getElementsByTagName('oglasi').item(0).firstChild.nodeValue;
    var reload_after = xml.getElementsByTagName('reload').item(0).firstChild.nodeValue;
    document.getElementById('slideshow').innerHTML = html_content;
    fadeIn();
    try {
        clearTimeout(to);
    } catch (e) {}

    to = setTimeout("nextAd()", parseInt(reload_after));

}



