/*
 *  Author : JAMES	  
 *  Created Date : 11/12/2550 10:33
 *  Module : Control event on HotelListing for visitasiatravel.com 
 *  Description : Control event on HotelListing  for visitasiatravel.com
 *  Involve People : JAMES
 *  Last Updated : JAMES 11/12/2550 10:33
 */
var hotellisting = new function (){
	this.totalhotellist = 0;
	this.posPage = 1;
	this.opcode = "";
	this.optype = "";
	this.opsubcode = "";
	this.hotelsort = "Hotel";
	this.totallistperpage = 10;

	this.setOpCode = function (code)					{	this.opcode = code;	};
	this.setOpType = function (type)						{	this.optype = type;		};
	this.setOpSubCode = function (subcode)		{	this.opsubcode = subcode;		};
	this.setHotelSort = function (sort)						{	this.hotelsort = sort;		};
	this.setPosPage = function (pos)						{	this.posPage = pos;		};
	this.setSelectionList = function (){	
		this.opsubcode = $("cboList").value;
		this.posPage = 1;
		hotellisting.listing();
	};

	this.setHotelSort = function (sort){	
		this.hotelsort = sort;
		this.posPage = 1;
		hotellisting.listing();
	};

	this.listing = function (){
		var Path = "opcode="+this.opcode+"&optype="+this.optype+"&opsubcode="+this.opsubcode;
		Path += "&hotelsort="+this.hotelsort+"&pospage="+this.posPage+"&";
		//alert("Debug : "+Path);

		var myurl = "/hotelcontent/hotels/hotel_controller.php?act=hotellisting", http = new getXMLHTTPRequest();

		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var rpText = http.responseText;
			$("lyListing").innerHTML = rpText;			
		};
		http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(Path+new Date().getTime());
	};

	this.chnPage = function (pos){		
		this.posPage = pos;
		hotellisting.listing();
	};

	 this.ctrlPage = function (type,totalhotel){
		 this.totalhotellist = totalhotel;
		
		if(type == 'Previous'){
			this.posPage = this.posPage-this.totallistperpage;
			if(this.posPage <= 0 ) {  
				this.posPage =1 
			} else { 
				hotellisting.listing();			
			}
			
		} else if(type == 'Next'){		
			this.posPage = this.posPage+this.totallistperpage;
			if(this.posPage >= this.totalhotellist ) {
				this.posPage =this.posPage-this.totallistperpage 
			} else {
				hotellisting.listing();			
			}
		}
	};
}
