function $(str){return document.getElementById(str);}

function createXMLHttpRequest() {
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
  try { return new XMLHttpRequest(); } catch(e) {}
  alert("XMLHttpRequest not supported");
  return null;
}

function replaceText(myText, myFind, myReplace){
	this.myText = myText;
	this.myFind = myFind;
	this.myReplace = myReplace;
	this.replace = function replace(){
		this.myText = this.myText.replace(this.myFind, this.myReplace);
		if(this.myText.indexOf(this.myFind) != -1){
			this.replace();
		}
	}
	this.replace();
}


var sch = new function(){
	this.pHotel = function(){
		var obj = $("lyRecommendedHotels");
		var http = new createXMLHttpRequest() ;
		http.onreadystatechange = function() {
			if(http.readyState == 4) {
				var myText = http.responseText
				if(obj) obj.innerHTML = myText;
			}
		}
		var myurl = "/Promotion/RecommendedHotels.php";
		var myHTML = obj.innerHTML
		var temp = new replaceText(myHTML, "&", "%a%n%d%");
		//temp = new replaceText(temp.myText, "abc", "%a%b%b%");
		http.open("POST", myurl,  true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("myHTML="+temp.myText);
	};

	this.pPromotion = function(){
		var obj = $("lyHotelsPromotions");
		var http = new createXMLHttpRequest() ;
		http.onreadystatechange = function() {
			if(http.readyState == 4) {
				var myText = http.responseText
				if(obj) obj.innerHTML = myText;
			}
		}
		var myurl = "/Promotion/RecommendedPromotions.php";
		var myHTML = obj.innerHTML
		var temp = new replaceText(myHTML, "&", "%a%n%d%");
		//temp = new replaceText(temp.myText, "abc", "%a%b%b%");
		http.open("POST", myurl,  true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("myHTML="+temp.myText);
	};

	this.pTransfer = function(){
		var obj = $("lyTransferServices");
		var http = new createXMLHttpRequest() ;
		http.onreadystatechange = function() {
			if(http.readyState == 4) {
				var myText = http.responseText
				if(obj) obj.innerHTML = myText;
			}
		}
		var myurl = "/Promotion/RecommendedTransfers.php";
		var myHTML = obj.innerHTML;
		var temp = new replaceText(myHTML, "&", "%a%n%d%");
		//temp = new replaceText(temp.myText, "abc", "%a%b%b%");
		http.open("POST", myurl,  true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("myHTML="+temp.myText);
	};

	this.pSightseeing = function(){
		var obj = $("lyRecommendedSightseeing");
		var http = new createXMLHttpRequest() ;
		http.onreadystatechange = function() {
			if(http.readyState == 4) {
				var myText = http.responseText
				if(obj) obj.innerHTML = myText;
			}
		}
		var myurl = "/Promotion/RecommendedSightseeings.php";
		var myHTML = obj.innerHTML
		//prompt("", myHTML );
		var temp = new replaceText(myHTML, "&", "%a%n%d%");
		//temp = new replaceText(temp.myText, "abc", "%a%b%b%");
		http.open("POST", myurl,  true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("myHTML="+temp.myText);
	};
}

//sch.pHotel ();
sch.pPromotion ();
//sch.pTransfer ();
//sch.pSightseeing ();