
/*****************************************************
** Last Updated: April 30, 2007
** 
** This page contains AJAX functions common to 
** all jznetwork sites.
**
** A. Ajax FUNCTIONS
**		1. goTestAjax()
**		2. getDataText(source, target, page)
**		3. getDataOption(source, target, page)
**		5. getDataTextText(source, target, page)
**		6. ajaxObjectInnerHTML(target, postGet, c_phpPage_or_URL)
**		7. ajaxObject2InnerHTML(target, postGet, c_phpPage_or_URL)
**
*****************************************************/ 

var ajaxObject = false;
	
	try {
		ajaxObject = new ActiveXObject("MSXML2.XMLHTTP");
		ajaxObject2 = new ActiveXObject("MSXML2.XMLHTTP");
	} catch (exception1) {
		try {
		ajaxObject = new ActiveXObject("Microsoft.XMLHTTP");
		ajaxObject2 = new ActiveXObject("Microsoft.XMLHTTP");
	
		} catch (exception2) { 
			ajaxObject = false;
			ajaxObject2 = false;
		}
	
	} 
	
	if (!ajaxObject &&  window.XMLHttpRequest) {
		ajaxObject = new XMLHttpRequest();
		ajaxObject2 = new XMLHttpRequest();
	}
	
/*****************************************************
** --------------------------------------------------
** 
** A. AJAX Functions --------------------------------
*****************************************************/ 


/*****************************************************
** 1. TEST AJAX
*****************************************************/ 
function goTestAjax() {
	
	if (ajaxObject) {
		document.write("<H1>AJAX Object Created</H1>");
	} else if ( ajaxObject == false ) {
		document.write("your browser does not support Ajax");
	}

}


/*****************************************************
** 2. GET DATA FROM A TEXT BOX and RETURN PAGE
*****************************************************/ 

function getDataText(a_source, b_target, c_phpPage) {

	if (ajaxObject) {
		var source = a_source;
		var target = b_target;
		
		var obj = document.getElementById(target);
		//var objSource = document.getElementById(source_id);

		ajaxObjectInnerHTML(b_target, 'POST', c_phpPage);

		//obj.outerHTML = source;

		ajaxObject.send("source=" + document.getElementById(source).value);
		
	}
	

}


/*****************************************************
** 3. GET DATA FROM A OPTION BOX and RETURN PAGE
*****************************************************/ 

function getDataOption(a_source, b_target, c_phpPage) {

	if (ajaxObject) {
		var source = a_source;
		var target = b_target;
		var sourceValue = getAnOptionValue(a_source);
		
		ajaxObjectInnerHTML(b_target, 'POST', c_phpPage);
		
		ajaxObject.send("source=" + sourceValue);
		
	}
	

}

/*****************************************************
** 4. GET DATA FROM AN OPTION BOX AND A TEXTBOX
** and RETURN PAGE
*****************************************************/ 

function getDataOptionText(a_source, a2_source, b_target, c_phpPage) {

	if (ajaxObject) {
		var source = a_source;
		var source2 = a2_source;
		var target = b_target;
		
		var sourceValue = getAnOptionValue(a_source);
		
		ajaxObjectInnerHTML(b_target, 'POST', c_phpPage);

		
		ajaxObject.send("source=" + sourceValue + "&source2=" + document.getElementById(source2).value);
		
	}
	

}



/*****************************************************
** 5. GET DATA FROM 2 TEXTBOXES
** and RETURN PAGE
*****************************************************/ 

function getDataTextText(a_source, a2_source, b_target, c_phpPage) {
	

	
		if (ajaxObject) {
		var source = a_source;
		var source2 = a2_source;
		var target = b_target;
		
		var sourceValue = getATextBoxValue(a_source);
		var sourceValue2 = getATextBoxValue(a2_source);
	


		ajaxObjectInnerHTML(b_target, 'POST', c_phpPage);
						
		ajaxObject.send("source=" + sourceValue + "&source2=" + sourceValue2);
		
	}
	

}



/*****************************************************
** 6. AjaxObject Set inner HTML
*****************************************************/ 

function ajaxObjectInnerHTML(target, postGet, c_phpPage_or_URL) {

	var object = document.getElementById(target);


	ajaxObject.open(postGet, c_phpPage_or_URL, true);
	
	if (postGet == 'GET') { } else {
		ajaxObject.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
	}
		
	ajaxObject.onreadystatechange = function() {
	
		
	
		if ((ajaxObject.readyState == 4) && (ajaxObject.status == 200)) {

			object.innerHTML = ajaxObject.responseText;
			//delete ajaxObject;
			//ajaxObject = null;
		}
	}


}


/*****************************************************
** 7. AjaxObject2 Set inner HTML
*****************************************************/ 

function ajaxObject2InnerHTML(target, postGet, c_phpPage_or_URL) {

	var object = document.getElementById(target);


	ajaxObject2.open(postGet, c_phpPage_or_URL, true);
	
	if (postGet == 'GET') { } else {
		ajaxObject.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
	}
		
	ajaxObject2.onreadystatechange = function() {
	
		
		if ((ajaxObject2.readyState == 4) && (ajaxObject2.status == 200)) {

			object.innerHTML = ajaxObject.responseText;
			//delete ajaxObject;
			//ajaxObject = null;
		}
	}


}