// JavaScript Document
/************************************************************
* Code By: Randy P. Lorenzano
* http://www.kabarkada.net
* email: randy@kabarkada.net
* You are free to reuse this code as long as you keep
* this credit section intact. If you have comments and suggestions
* you are free to email me. If you have any modifications/improvements 
* to this code i would appreciate if you can send me back the updated code.
************************************************************/
dt=new Date();

function createAjaxObj(){
	var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	} else if (window.ActiveXObject){ // if IE
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	return httprequest
}

/* main function to load php command */
function ajax_loader(Action, ElementID, divClass, pointer) {
	this.Command=Action 
	this.ElementID=ElementID
	this.divClass=divClass
	this.pointer=pointer
	this.ajaxObj=createAjaxObj()
	document.write('<div id="'+ElementID+'" class="'+divClass+'"><div><img src="http://www.philippinehotelreservations.com/new/jscripts/snake.gif" hspace=2 vspace=2></div></div>')
	this.ExecuteCommand()		
}

ajax_loader.prototype.ExecuteCommand=function(){
	if (this.ajaxObj){
		var instanceOfCommand=this
		var url=this.Command
		this.ajaxObj.onreadystatechange=function(){instanceOfCommand.Initialize()}
		this.ajaxObj.open('GET', url, true)
		this.ajaxObj.send(null)
	}
}

ajax_loader.prototype.Initialize=function(){ 
	if (this.ajaxObj.readyState == 4){ 
		if (this.ajaxObj.status==200 || window.location.href.indexOf("http")==-1){ 
			this.contentdiv=document.getElementById(this.ElementID).firstChild 
			this.contentdiv.innerHTML=this.ajaxObj.responseText
		}
	}
}

function showpage(id, thedate){

	var custwidth = 650
	var custheight = 600
	var sURL = "http://www.philippinehotelreservations.com/pop/index.php?page=hd&id=" + id + "&ci_date=" + thedate
    var sFeatures = "scrollbars=no,width="+custwidth+",height="+custheight+",top=20,left=20"

    if(document.all || document.layers) {
		var winbible = window.open(sURL, "_"+id, sFeatures)
     } else {
		window.open(sURL, "_"+id, sFeatures)
	}
}

function search_now() {
	objform=document.search_form
	if (check_null()) {
		objform.submit()
	}
}

function check_null() {
	if (document.getElementById("loccode").value == "--") {
		alert("Please select your preferred destination")
		return false
	}
	return true
}

	function get_hotel_list(loccode, hotelcode) {
		d=document;
		v = d.getElementById("location").value;
		action = "inc/gethotels.php?code="+v+"&hotel="+hotelcode;
		fillElement('hotel_layer', getResponse, action);
	}




