//JavaScript

//*****************    A J A X    ************************* 
/* The readyState property can have the following values:
	0 = uninitialized,	1 = loading,	2 = loaded,	3 = interactive,	4 = complete */
//GET HTTP OBJECT FOR AJAX
var httpObj = null;
function getHttpObj(){
	try {
		if (window.XMLHttpRequest) httpObj = new XMLHttpRequest();
		else if (window.ActiveXObject) httpObj = new ActiveXObject("Microsoft.XMLHTTP");
		else { 
			alert("XMLHttpRequest not supported!");
			try { httpObj = new XMLHTTPRequest(); }
			catch(e) {
				httpObj = null;
				alert(e.toString());
			}
		}
	}
	catch(e) {
		httpObj = null;
	}
}
	
	
function setOutput() {
	if(httpObj.readyState == 4) {
		document.getElementById('packagesQueryOutputArea').innerHTML = httpObj.responseText;
	}
}
 
//Implement business logic    
function sortPackages( dpt, sortBy, ctgry ) { 
	getHttpObj();
	if (httpObj != null) {
		var url = "../includes/packagesQueryOutput2.inc.php?";
		url = url +"dpt="+dpt+"&sortBy="+sortBy+"&id="+ctgry+"";
		httpObj.open("GET", url, true);
		httpObj.send(null);
		httpObj.onreadystatechange = setOutput;
	}
}
 
//Implement business logic    
function sortPackagesDetails( id, sortBy ) { 
	getHttpObj();
	if (httpObj != null) {
		var url = "../includes/packagesQueryOutput.inc.php";
		url = url +"?id="+id+"&sortBy="+sortBy+"";
		httpObj.open("GET", url, true);
		httpObj.send(null);
		httpObj.onreadystatechange = setOutput;
	}
}
 
//Implement business logic    
function sortPackagesDetails725( id, sortBy ) { 
	getHttpObj();
	if (httpObj != null) {
		var url = "../includes/packagesQueryTravelZoo.inc.php";
		url = url +"?id="+id+"&sortBy="+sortBy+"";
		httpObj.open("GET", url, true);
		httpObj.send(null);
		httpObj.onreadystatechange = setOutput;
	}
}
 
// Implement business logic    
function resetPackages( pgNum ) { 
	try {
		getHttpObj();
		if (httpObj != null) {
			var url = "../includes/packagesQueryOutput2.inc.php";
			url = url + pgNum;
			httpObj.open("GET", url, true);
			httpObj.send(null); 
			httpObj.onreadystatechange = setOutput;
		}
	}
	catch(e) { alert(e.toString()); }
}
 
// Implement business logic    
function resetPackagesDetails( params ) { 
	getHttpObj();
	if (httpObj != null) {
		var url = "../includes/packagesQueryOutput.inc.php";
		url = url + params;
		httpObj.open("GET", url, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setOutput;
	}
}
 
function resetPackagesDetails725( params ) { 
	getHttpObj();
	if (httpObj != null) {
		var url = "../includes/packagesQueryTravelZoo.inc.php";
		url = url + params;
		httpObj.open("GET", url, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setOutput;
	}
}
 
function loadPHPContent( url ) { 
	getHttpObj();
	if (httpObj != null) {
		httpObj.open("GET", url, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setPHPOutput;
	} 
}

function loadPHPContent2( url, prm ) { 
	getHttpObj();
	if (httpObj != null) {
		httpObj.open("GET", url+'?dpt='+prm, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setPHPOutput;
	} 
}

function setPHPOutput() {
	if(httpObj.readyState == 4) 
	{
		document.getElementById('phpContent').innerHTML = httpObj.responseText;
	}
}
 
function submitSubscriptionForm( url, obj ) { 
	getHttpObj();
	var elmt = obj.full_name.value;
	alert(elmt);
	var urlStr = url+"?obj="+obj;
	if (httpObj != null) {
		httpObj.open("GET", obj, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setSubscriptionOutput();
	} 
}

function setSubscriptionOutput() {
	getHttpObj();
	if(httpObj.readyState == 4) 
	{
		alert(httpObj.responseText);
	}
}

/********  C A P T C H A   I M A G E  ********/
function loadCaptchaImg( url ) { 
	getHttpObj();
	if (httpObj != null) {
		httpObj.open("GET", url, true);
		httpObj.send(null); 
		httpObj.onreadystatechange = setCaptchaImg();
	} 
}

function setCaptchaImg() {
	getHttpObj();
	if(httpObj.readyState == 4) 
	{
		alert(httpObj.responseText);
		document.getElementById('captcha').src = httpObj.responseText;
	}
}
 
//*************  E N D    A J A X    *****************

