	var ajaxQueue = new Array();
	
	function makeRequest(url, method, postvar, action)
	{
		var http_request = false;

		if(window.XMLHttpRequest) // Mozilla, Safari,...
		{
			http_request = new XMLHttpRequest();

			if(http_request.overrideMimeType)
			{
				http_request.overrideMimeType('text/xml');
			}
		}
		else if(window.ActiveXObject) // IE
		{
			try
			{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try
				{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e)
				{
					alert("Problems instantiating the http_request variable. ");
				}
    		}
		}

		http_request.onreadystatechange = function()
		{
			stateChange(http_request, action);
		};
		
		if(method == "POST")
		{
			http_request.open("POST", url + "?time=" + new Date().getTime(), true);
			http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
			http_request.send(postvar);
		}
		else
		{
			http_request.open("GET", url + "?time=" + new Date().getTime() + "&" + postvar, true);
			http_request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
			http_request.send(null);
		}
	}
	
	function parEncode(text)
	{
		return text.replace(/\&/g, "%26").replace(/\+/g, "%2B").replace(/\#/g, "%23");
	}
	
	function trim(str, chars) {
		return ltrim(rtrim(str, chars), chars);
	}

	function ltrim(str, chars) {
		if(chars == null)
		{
			chars = "\\s";
		}
		
		return str.toString().replace(new RegExp("^[" + chars + "]+", "g"), "");
	}

	function rtrim(str, chars) {
		if(chars == null)
		{
			chars = "\\s";
		}
		
		return str.toString().replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	
	function isNumeric(value) {
		if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
		return true;
	}
	
	function isIntegerPositive(value)
    {
        if(value == null)
		{
			return false;
		}

		for(var i = 0; i < value.length; i++)
		{
			var c = value.charAt(i);

			if(!isDigit(c))
			{
				return false;
			}
		}

		return true;
    }

	function isDigit (value)
	{
		return ((value >= "0") && (value <= "9"))
	}
   
	function getNodeValue(obj, tag, verbose) {
		if(verbose == null)
		{
			verbose = true;
		}
		
		var node = getNode(obj, tag, verbose);
		
		if(node != null)
		{
			var text = "";
			
			for(var i = 0; i < node.childNodes.length; i++)
			{
				text += node.childNodes[i].nodeValue;
			}
			
			return text;
		}
		else
		{
			return null;
		}
	}
	
	function getNode(obj, tag, verbose) {
		if(verbose == null)
		{
			verbose = true;
		}
		
		if(obj.getElementsByTagName(tag).length > 0)
		{
			return obj.getElementsByTagName(tag)[0];
		}
		else
		{
			if(verbose == true)
			{
				alert("Unable to find " + tag + " tag. ", "Error");
			}
			
			return null;
		}
	}

	function loading(what)
	{
		eval("var what_list = document.form1." + what);
		if(what_list != null)
		{
			what_list.style.display = "none";
			document.getElementById("loading_" + what).style.display = "block";
		}
		else
		{
			var what_element = document.getElementById(what);
			
			if(what_element != null)
			{
				what_element.style.display = "none";
				document.getElementById("loading_" + what).style.display = "block";
			}
		}
	}
	
	function loaded(what)
	{
		eval("var what_list = document.form1." + what);
		if(what_list != null)
		{
			what_list.style.display = "inline";
			document.getElementById("loading_" + what).style.display = "none";
		}
		else
		{
			var what_element = document.getElementById(what);
			
			if(what_element != null)
			{
				what_element.style.display = "inline";
				document.getElementById("loading_" + what).style.display = "none";
			}
		}
	}
	
	function valueExists(list, id)
	{		
		if(list != null && id != null)
		{
			var options = list.options;
			
			if(options != null)
			{
				for(i = 0; i < options.length; i++)
				{
					if(options[i].value == id)
					{
						return true;
					}
				}
				
				return false;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	
	function orderList(select)
	{
		if(select != null)
		{			
			if(select.options != null)
			{
				var temp;

				for(i = 0; i < select.options.length; i++)
				{
					for(j = 0; j < select.options.length - 1; j++)
					{
						if(select.options[j].value >= 0 && select.options[j+1].value >= 0)
						{
							if(select.options[j].text.toLowerCase() > select.options[j+1].text.toLowerCase())
							{
								temp = select.options[j].text;
								select.options[j].text = select.options[j+1].text;
								select.options[j+1].text = temp;
								
								temp = select.options[j].value;
								select.options[j].value = select.options[j+1].value;
								select.options[j+1].value = temp;
							}
						}
					}
				}
			}
		}
	}
	
	function valueExists(select, value)
	{
		for(var i = 0; i < select.options.length; i++)
		{
			if(select.options[i].value == value)
			{
				return true;
			}
		}

		return false;
	}

	function removeAllChilds(element)
	{
		if(element.hasChildNodes())
		{
			while(element.childNodes.length > 0)
			{
				element.removeChild(element.firstChild);
			}
		}
	}
	
	function addLoadEvent(func)
	{
		if(typeof func == 'function')
		{
			var actualLoad = window.onload;
			if(typeof actualLoad != 'function')
			{
				window.onload = func;
			}
			else
			{
				window.onload = function()
				{
					actualLoad();
					func();
				}
			}
		}
	}