var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject() {
  var xmlHttp;
  
  // IE
  if (window.ActiveXObject){
    try {
      xmlHttp = new ActiveXObject("MIcrosoft.XMLHTTP");
    } 
    catch (e) {
      xmlHttp = false;
    }
  }
  
  //Others
  else {
    try {
      xmlHttp = new XMLHttpRequest();
    }
    
    catch (e) {
      xmlHttp = false;
    }
  }
  
  if (!xmlHttp)
    msg = "error";
  else
    return xmlHttp;
      
}


function doGetFeatured() {
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
    // Open file
    xmlHttp.open("GET", "featured.php");
    
    // function to handle response
    xmlHttp.onreadystatechange = getFeatured;
    
    // Send request
    xmlHttp.send(null);
  }
  else

    setTimeout('doGetFeatured()',7000);
}

function getFeatured() {
  // Loaded data
  if (xmlHttp.readyState == 4) {
  
    // 200 HTTP OK
    if (xmlHttp.status == 200) {
      // Extract XML reply
      xmlResponse = xmlHttp.responseXML;
      
      xmlDocumentElement = xmlResponse.documentElement;
      
      var featured = xmlDocumentElement.getElementsByTagName('blogshop');
      
      document.getElementById('featured_block').innerHTML = '<div style="text-align:center">'+
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">' +
    '<a href="'+ featured[0].getAttribute('urlalias') +'"><img src="'+ featured[0].getAttribute('img') +'" alt="'+ featured[0].getAttribute('title') +'" title="'+ featured[0].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+  
  '<img src="/images/dot.gif" width="30" />'+
  
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">'+
    '<a href="'+ featured[1].getAttribute('urlalias') +'"><img src="'+ featured[1].getAttribute('img') +'" alt="'+ featured[1].getAttribute('title') +'" title="'+ featured[1].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+  
  '<div style="margin-top:10px;"></div>'+  
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">'+
    '<a href="'+ featured[2].getAttribute('urlalias') +'"><img src="'+ featured[2].getAttribute('img') +'" alt="'+ featured[2].getAttribute('title') +'" title="'+ featured[2].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+  
  '<img src="/images/dot.gif" width="30" />'+  
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">'+
    '<a href="'+ featured[3].getAttribute('urlalias') +'"><img src="'+ featured[3].getAttribute('img') +'" alt="'+ featured[3].getAttribute('title') +'" title="'+ featured[3].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+
  '<div style="margin-top:10px;"></div>'+  
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">'+
    '<a href="'+ featured[4].getAttribute('urlalias') +'"><img src="'+ featured[4].getAttribute('img') +'" alt="'+ featured[4].getAttribute('title') +'" title="'+ featured[4].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+  
  '<img src="/images/dot.gif" width="30" />'+  
  '<div style="display:inline; padding-top:5px;padding-bottom:5px;width:300px;">'+
    '<a href="'+ featured[5].getAttribute('urlalias') +'"><img src="'+ featured[5].getAttribute('img') +'" alt="'+ featured[5].getAttribute('title') +'" title="'+ featured[5].getAttribute('title') +'" width="300" height="180" border="0" style="border:1px solid #b33e7a;" /></a>'+
  '</div>'+  
'</div>';
      
      setTimeout('doGetFeatured()',7000);
    }
    else
      alert("Did not get data!");
  }
}
