var _flight_path = "/UBF/getDeals.aspx?dealType=flight";
var _hotel_path = "/UBF/getDeals.aspx?dealType=hotel";

function TravelDeals(type, output, loader, message, error) {
	this.type = type;
	this.output = output;
	this.loader = loader;
	this.message = message;
	this.error = error;
}

TravelDeals.prototype.getDeals = function(from, to, noLoader) {
  this.hideOutput();
  if (noLoader == null)
    this.displayLoader();
	var url = "";
	switch (this.type) {
		case "flight":
		  url = _flight_path;
			break;
		case "hotel":
		  url = _hotel_path;
			break;
	}
	if (from != null)
	  url += "&origin=" + from
	if (to != null)
	  url += "&destination=" + to;
	this.getResults(url);
}

TravelDeals.prototype.xmlLoaded = function(data) {
	this.output.innerHTML = data.responseText;
	this.hideLoader();
        this.displayOutput();
        this.onload();
        initLightbox();
	// display number of results in selection panel
}

TravelDeals.prototype.onload = function() {}

TravelDeals.prototype.getResults = function(url) {
	var o = this;
	var callback = {
		success: o.xmlLoaded,
		failure: o.displayError,
		scope: o
	}
	url += "&= " + Math.random();
	YAHOO.util.Connect.asyncRequest("GET", url, callback);
}

TravelDeals.prototype.displayOutput = function() {
	this.output.className = this.output.className.replace("off-left", "");
}

TravelDeals.prototype.hideOutput = function() {
	this.output.className = this.output.className.replace("off-left", "") + "off-left";
}

TravelDeals.prototype.displayLoader = function() {
	this.loader.className = this.loader.className.replace("off-left", "");
}

TravelDeals.prototype.hideLoader = function() {
	this.loader.className = this.loader.className.replace("off-left", "") + "off-left";
}

TravelDeals.prototype.displayError = function() {
  this.hideLoader();
  this.error.className = this.error.className.replace("off-left", "")
}

TravelDeals.prototype.hideError = function() {
	this.error.className = this.error.className.replace("off-left", "") + "off-left";
}