

var sMainDivID = '';
var sMainURL = '';

function Offer_LoadResults() {
	var sDivID = ''
	var s_URL = '/includes/xml/offercache.xml'

	var Update = new ajaxObject(sDivID, s_URL);
	var iTest = Update.update(sDivID);
	
}

function ajaxObject(sDivID, s_URL) { 

	layer = sDivID;
	aO_url = s_URL;
	

	var that=this;                                                    // A workaround for some javascript idiosyncrocies   
	var updating = false;                                             // Set to true if this object is already working on a request   
	this.callback = function() {}                                     // A post-processing call -- a stub you overwrite.   
	this.update = function(passData) {                                // Initiates the server call.      
		if (updating==true) { return false; }                          // Abort if we're already processing a call.      
		updating=true;                                                 // Set the updating flag.      
		var aO_AJAX = null;                                               // Initialize the AJAX variable.      
		if (window.XMLHttpRequest) {                                   // Are we working with mozilla?         
			aO_AJAX=new XMLHttpRequest();                                  //  Yes -- this is mozilla.      
		} else {                                                       // Not Mozilla, must be IE         
			aO_AJAX=new ActiveXObject("Microsoft.XMLHTTP");                //  Wheee, ActiveX, how do we format c: again?      
		}                                                              // End setup Ajax.      
		if (aO_AJAX==null) {                                              // If we couldn't initialize Ajax...         
			alert("Your browser doesn't support AJAX.");                // Sorry msg.                                                       
			return false                                                // Return false (WARNING - SAME AS ALREADY PROCESSING!)      
		} else {        
			aO_AJAX.onreadystatechange = function() {                      // When the browser has the request info..       
			if (aO_AJAX.readyState==4 || aO_AJAX.readyState=="complete") { //   see if the complete flag is set.   
				var sText = aO_AJAX.responseText
				
					AccommAvail_XMLDoc = aO_AJAX.responseXML.documentElement
					formatAJAX(sDivID, LayerID, AccommAvail_XMLDoc, sText);
				try{
				}catch(err){
					//alert('Parse XML error: ' + err)
					formatAJAX(layer, LayerID, '', sText);
				}
				
				delete aO_AJAX;                                          //   delete the AJAX object since it's done.               
				updating=false;                                       //   Set the updating flag to false so we can do a new request               
				that.callback();                                      //   Call the post-processing function.            
			}                                                       // End Ajax readystate check.   
		}
		var timestamp = new Date();                                 // Get a new date (this will make the url unique)        
		var uri=urlCall+'?'+passData+'&timestamp='+(timestamp*1);   // Append date to url (so the browser doesn't cache the call)         
		aO_AJAX.open("GET", uri, true);  
		aO_AJAX.send(null);                                            // Send the request.         
		return true;                                                // Everything went a-ok.     
		}                                                              // End Ajax setup aok if/else block                    
	}    
	var LayerID = document.getElementById(sDivID);                     // Remember the layer associated with this object.   
	var urlCall = s_URL;  
	// Remember the url associated with this object.

}  


function formatAJAX(olayer, oLayerID, xmldoc, sText) {
	var oFlyDrive = xmldoc.getElementsByTagName('Key');
	var arCount = 0;
	for(i=0;i<oFlyDrive.length;i++){
		if(oFlyDrive[i].childNodes.item(0).nodeValue.indexOf("/HP/TICKER") > 0) {
			slmg[arCount]='<div class="offer"><a href="'+xmldoc.getElementsByTagName('URL')[i].childNodes[0].nodeValue+'"><span class="text">'+xmldoc.getElementsByTagName('Title')[i].childNodes[0].nodeValue+'<strong><br />Only &pound;'+Math.round(xmldoc.getElementsByTagName('Price')[i].childNodes[0].nodeValue)+'</strong> per person</span><span class="OfferTickerPrice">Only &pound;'+Math.round(xmldoc.getElementsByTagName('Price')[i].childNodes[0].nodeValue)+'</span></a></div>';
			arCount = arCount + 1;
		}	
	}
	
}

function failure1(txt,status) {
	
}