/*
 	 creator: 	Scott-David Allen
	---------------------------------------------------------------------------------------------------------
	 date:		11/20/2006
	---------------------------------------------------------------------------------------------------------
	 purpose:	functions which calls Restool_REST.asp via http, returning restool layout based on vacationType.
				Based on Chip Kreis' amenity grid
	---------------------------------------------------------------------------------------------------------
	 change log:
	---------------------------------------------------------------------------------------------------------
*/
	
	// set global variables
	
	

	var g_getRestool_url2 = address + "includes/Restool_REST.asp";     //restool for index page
	var loadedobjects="";
	
	function createXmlHttpRequest2(){
		var p_xmlHttp2;
		if ( window.ActiveXObject ){
			p_xmlHttp2 = new ActiveXObject( "Microsoft.XMLHTTP" );
		}else if ( window.XMLHttpRequest ){
			p_xmlHttp2 = new XMLHttpRequest();
		}
		return p_xmlHttp2;
	}

	
	function doXmlHttpPost2( vals, postURL ){	
		var thisPostURL2 = postURL;
		
		if ( thisPostURL2 == "" ){
			thisPostURL2 = g_getRestool_url2;
		}
		var thisXmlHttpObject2 = new createXmlHttpRequest2();
		
		thisXmlHttpObject2.open( "POST", thisPostURL2, true );
			
		thisXmlHttpObject2.onreadystatechange = function(){			
			handleXmlHttpPostStateChange2( thisXmlHttpObject2 );
		}
		
		thisXmlHttpObject2.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded;" );
		thisXmlHttpObject2.send( vals );
	}
	
	function handleXmlHttpPostStateChange2( theXmlHttpObject2 ){
		if ( theXmlHttpObject2.readyState == 4 ){
			if ( theXmlHttpObject2.status == 200 ){
				if ( theXmlHttpObject2.responseText != "" ){
					// populate div with returned html
					document.getElementById("RestoolBody").innerHTML = theXmlHttpObject2.responseText;
				}
			}
		}
	}

	
	// gets destinations and their corresponding types in xml format
	function getVacationTypes(vacType, promocode, sourcecode, depDate, boolVacType, boolCokePage) {
	    var thisVals = "gsVacationType=" + vacType + "&gspromotioncode=" + promocode + "&gsSourceCode=" + sourcecode + "&gsDepartureDate=" + gsDepartureDate + "&boolVacType=" + boolVacType + "&boolCokePage=" + boolCokePage;		
		doXmlHttpPost2(thisVals,'');
	}
	
	
	function loadobjs(){
		if (!document.getElementById)
		return
		for (i=0; i < arguments.length; i++){
			var file=arguments[i]
			var fileref=""
			if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
				if (file.indexOf(".js")!=-1){ //If object is a js file
					fileref=document.createElement('script')
					fileref.setAttribute("type","text/javascript");
					fileref.setAttribute("src", file);
				}
			}
			if (fileref!=""){
				document.getElementsByTagName("head").item(0).appendChild(fileref)
				loadedobjects+=file+" " //Remember this object as being already added to page
			}
		}
	} 

