<!-- 
var ajax_memory;

function ajax_processRequestPost(ajaxUrl,ajaxParam,ajaxDiv,ajaxCallBack)
{
	var ajax_memory_temp = ajaxUrl + ajaxParam + ajaxDiv + ajaxCallBack;
	
	if (ajax_memory_temp == ajax_memory)
		return;
		
	ajax_memory = ajax_memory_temp;

	// Clear All Timers
	clearTimeout(globalTimer);
	
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	var url = ajaxUrl;
	var params = ajaxParam;
	ajaxRequest.open("POST", url, true);

	//Send the proper header information along with the request
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	
	ajaxRequest.onreadystatechange = function() {//Call a function when the state changes.
		if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200) 
		{
			// Clr previous call...
			ajax_memory = '';
			
			var ajaxDisplay = document.getElementById(ajaxDiv).innerHTML = ajaxRequest.responseText;

			// Post Request Scripts
			if (ajaxCallBack != '')
			{
				eval(ajaxCallBack);
			}
			//alert(http.responseText);
		}
	}
	ajaxRequest.send(params);
}

function ajax_processRequest(ajaxUrl,ajaxDiv,ajaxCallBack)
{
	var ajax_memory_temp = ajaxUrl + ajaxDiv + ajaxCallBack;
	
	if (ajax_memory_temp == ajax_memory)
		return;
		
	ajax_memory = ajax_memory_temp;
	
	// Clear All Timers
	clearTimeout(globalTimer);

	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			// Clr previous call...
			ajax_memory = '';

			var ajaxDisplay = document.getElementById(ajaxDiv).innerHTML = ajaxRequest.responseText;

			// Post Request Scripts
			if (ajaxCallBack != '')
			{
				eval(ajaxCallBack);
			}
		}
	}
	
	// GET Data
	ajaxRequest.open("GET", ajaxUrl, true);
	ajaxRequest.send(null); 
}

//////////////////////
// Ajax Functions
/////////////////////

function ajax_action(url,div,param,div_load,onload,onload_mode)
{
	ajax_showdiv(div_load);
	
	var callback = "ajax_hidediv('" + div_load + "');";
	callback += onload + "('" + onload_mode + "')";

	ajax_processRequestPost(url,param,div,callback)
}

function ajax_link(url,div,param,mode,onload,div_load)
{
	if (div_load != 'null')
		ajax_showdiv(div_load);

	var callback;
	var qry = url;
	
	if (mode != '')
		qry += '?mode=' + mode;
	if (param != '')
		qry += param; 
	if (onload != '')
	{
		callback = onload + "_onload('" + mode + "');"; 
		callback += "ajax_hidediv('" + div_load + "');";
	}
	else
	{
		callback = "ajax_hidediv('" + div_load + "');";
	}
	ajax_processRequest(qry,div,callback);
}

function ajax_link_textbox(url,div,type,element,mode,onload,id,msg)
{
	// Make Sure Element isn't Empty
	if (document.getElementById(element).value == '')
	{
		ajax_hidediv('div_result');
		alert('Please enter a '+ msg);
		document.getElementById(element).focus();
		return;		
	}

	var qry = url;
	
	if (mode != '')
		qry += '?mode=' + mode;
	qry += '&' + id + '=' + encodeURIComponent(document.getElementById(element).value); 

	qry += '&type=' + type; 

	if (onload != '')
		callback = onload + "_onload('" + mode + "')"; 
	else
		callback = '';

	document.getElementById(element).value = '';

	ajax_processRequest(qry,div,callback);
}

function ajax_link_dropdown(url,div,type,element,mode,onload,id,msg)
{
	// Make Sure Element is Selected
	if (document.getElementById(element).value == 0)
	{
		ajax_hidediv('div_result');
		alert('Please select a '+ msg);
		document.getElementById(element).focus();
		return;		
	}

	var qry = url;
	
	if (mode != '')
		qry += '?mode=' + mode;
	qry += '&' + id + '=' + encodeURIComponent(document.getElementById(element).value); 

	qry += '&type=' + type; 

	if (onload != '')
		callback = onload + "_onload('" + mode + "')"; 
	else
		callback = '';

	document.getElementById(element).value = 0;

	ajax_processRequest(qry,div,callback);
}

function ajax_link_dropdown_textbox(url,div,type,dropdown,textbox,mode,onload,dropdown_id,textbox_id,dropdown_msg,textbox_msg)
{
	// Make Sure Dropdown is Selected
	if (document.getElementById(dropdown).value == 0)
	{
		ajax_hidediv('div_result');
		alert('Please select a '+ dropdown_msg);
		document.getElementById(dropdown).focus();
		return;		
	}
	// Make Sure Textbox is not empty
	if (document.getElementById(textbox).value == 0)
	{
		ajax_hidediv('div_result');
		alert('Please enter a '+ textbox_msg);
		document.getElementById(textbox).focus();
		return;		
	}

	var qry = url;
	
	if (mode != '')
		qry += '?mode=' + mode;
	
	qry += '&' + dropdown_id + '=' + document.getElementById(dropdown).value; 
	qry += '&' + textbox_id + '=' + encodeURIComponent(document.getElementById(textbox).value); 

	qry += '&type=' + type; 

	if (onload != '')
		callback = onload + "_onload('" + mode + "')"; 
	else
		callback = '';

	document.getElementById(dropdown).value = 0;
	document.getElementById(textbox).value = '';

	ajax_processRequest(qry,div,callback);
}

function ajax_test(qry,div,callback)
{
	ajax_processRequest(qry,div,"ajax_showpopup('div_popup_1','div_result');");
}

function ajax_url(url,div,callback)
{
	ajax_processRequest(url,div,callback);
	return false;
}

function ajax_edit(url,div,id,callback)
{
	var qry = url + '?mode=edit&' + id; 
	if(callback == '')
		ajax_processRequest(qry,div,"ajax_showpopup('div_popup_1','div_result');");
	else
		ajax_processRequest(qry,div,callback);
}

function ajax_delete(url,mode,param,div,div_load,callback)
{
	ajax_showdiv(div_load)
	var answer = confirm("This item will be permanently deleted\n\n Click OK to continue or CANCEL to quit.")
	if (answer)
	{
		var qry = url;
		qry += '?mode=' + mode;
		qry += param; 
		ajax_processRequest(qry,div,callback);
		return false;
	}
	else
	{
		ajax_hidediv(div_load);	
	}
}

function ajax_pagination(url,div,div_ajax)
{
	ajax_showdiv(div_ajax);

	var qry = url + '?page_num=' + document.getElementById('page_num').value; 
	ajax_processRequest(qry,div,'');
	return false;
}

function ajax_showpopup(div,load_div)
{
	Popup.showModal(div,'reference','center center',{'screenColor':'#A6A6A6','screenOpacity':.7,'offsetTop':50});
}

function ajax_hidepopup(popup_div,qry,qry_div)
{
//	alert(popup_div);
	if (qry != '')
	{
		ajax_processRequest(qry,qry_div,Popup.hide(popup_div));
	}
	else
	{
		Popup.hide(popup_div);
	}
	return false;
}

function ajax_showdiv(elem) 
{
	document.getElementById(elem).style.visibility = 'visible';
}

function ajax_hidediv(elem) 
{
	document.getElementById(elem).style.visibility = 'hidden';
}
//-->
