// JavaScript Document

	function loadAjax(target,url,params){
		
		var oTarget = $(target);
		var oIndicator = $(target + '-indicator');

		var state = oTarget.style.display;
		var content = oTarget.innerHTML;
		
		var htmlLoading = "<center><img style='padding:10px' src='/img/loading.gif' /></center>";
		var htmlShow = "show";
		var htmlHide = "hide";

		// we do this so that we only have to make 1 ajax call for the content

		// only if there is no content do we make the call
		if ((state == 'none')&&(!content.length > 0)){

			oIndicator.innerHTML = htmlHide;
			oTarget.style.display = 'block';
			oTarget.innerHTML = htmlLoading;
			var myAjax = new Ajax.Request(url,{
					method: 'post', 
					parameters: params,
					onSuccess: function(originalRequest){
						oTarget.innerHTML = originalRequest.responseText;
					}
				}
			);

		// if there is content then we simply show it
		} else if (state == 'none'){

			oIndicator.innerHTML = htmlHide;
			oTarget.style.display = 'block';

		// just hide the content so we can recall it easily without an ajax call
		} else if (state == 'block'){

			oIndicator.innerHTML = htmlShow;
			oTarget.style.display = 'none';

		}

	}

	function refreshAjax(target,url,params){
		
		var oTarget = $(target);
		var oIndicator = $(target + '-indicator');

		var state = oTarget.style.display;
		var content = oTarget.innerHTML;
		
		var htmlLoading = "<center><img style='padding:10px' src='/img/loading.gif' /></center>";
		var htmlShow = "Show";
		var htmlHide = "Hide";

		oIndicator.innerHTML = htmlHide;
		oTarget.style.display = 'block';
		oTarget.innerHTML = htmlLoading;
		var myAjax = new Ajax.Request(url,{
				method: 'post', 
				parameters: params,
				onSuccess: function(originalRequest){
					oTarget.innerHTML = originalRequest.responseText;
				}
			}
		);

	}

