  function showNext(objectId){    
    showProgressBar(true);
    getAjaxResultAsXml('includes/index-gallery.asp?startid=' + objectId, true);
  }  
  function showProgressBar(show){
    if (show){
      document.getElementById('progress-bar').style.display = 'block';
      document.getElementById('object-wrapper').style.display = 'none';      
    }    
    else{
      document.getElementById('progress-bar').style.display = 'none';
      document.getElementById('object-wrapper').style.display = 'block';      
    }    
  }
    
  function getTransport(){
    var xmlReq;
    
  	if (window.XMLHttpRequest){
  		// Non-IE browsers
  		xmlReq = new XMLHttpRequest();
  		return xmlReq;
  	}
  	else if (window.ActiveXObject)
  	{
  		// IE
  		var ActiveXimpl = ['Microsoft.XMLHTTP', 'Msxml2.XMLHTTP'], i = ActiveXimpl.length;
  		while (i--){
  			try{
  				xmlReq = new ActiveXObject(ActiveXimpl[i]);
  				return xmlReq;
  			}
  			catch(e) { }
  		}
  	}
  
  	if (debug) alert('This browser has no suitable XMLHttpRequest functionality');
  	return null;
  }  

  function getAjaxResultAsXml(url, sync){
    var xmlhttp = getTransport();    
    
  	if (xmlhttp != null){
    	xmlhttp.open("GET", url, sync);
    	xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4){
          if (xmlhttp.status == 404){
            alert("HTTP 404: Page not found: " + xmlhttp.responseText)
            showProgressBar(false);
          }
          if (xmlhttp.status == 500){
            alert("HTTP 500: Error occured: " + xmlhttp.responseText);
            showProgressBar(false);
          }                         
          if (xmlhttp.status == 200){                                                     
            parseXml(xmlhttp.responseXML);
          }
        }
    	}
    	xmlhttp.send(null);     
  	}  
  }
  function parseXml(xmlObject){
    var objects = xmlObject.getElementsByTagName('object');
    var wrapper = document.getElementById('object-wrapper');
    
    var objTitle, imgUrl, objUrl, city, price;
    var divObj, hrefObj, imgObj, gradientObj;
    
    var nextId = 0;
    
    if (objects.length > 0){
      nextId = xmlObject.getElementsByTagName('nextobject')[0].firstChild.data;      
    
      while(wrapper.hasChildNodes()){
        wrapper.removeChild(wrapper.lastChild);
      }    
          
      for (var x=0;x<objects.length;x++){
        objTitle = objects[x].getElementsByTagName('title')[0].firstChild.data;
        imgUrl   = objects[x].getElementsByTagName('image')[0].firstChild.data;
        objUrl   = objects[x].getElementsByTagName('url')[0].firstChild.data;
        city     = objects[x].getElementsByTagName('city')[0].firstChild.data;
        price    = objects[x].getElementsByTagName('price')[0].firstChild.data;
        
        divObj = document.createElement('div');
        divObj.className = 'object';        
        divObj.innerHTML = '<a href="' +objUrl+ '"><img src="' +imgUrl+ '" alt="' +objTitle+ '" style="width: 163px; height: 94px;" /></a><br />' +city+ '<br />' +price;
                
        wrapper.appendChild(divObj);
        
        gradientObj = document.createElement('div');
        gradientObj.className = 'gradient';
        
        wrapper.appendChild(gradientObj);                     
      }
    }

    document.getElementById('next').setAttribute('href', 'javascript:showNext(' + nextId + ')')  
    window.setTimeout('showProgressBar(false)', 1000);
  }
