function loadList(url)
{
	document.body.style.cursor = 'wait';

	var opt =
	{
		method : 'post',
		asynchronous : false
	};

	var loader = new Ajax.Request(url, opt);

	var Data = new Array();
	var data = loader.transport.responseText;
	var datax = data.split("\n");

	for (x in datax)
	{
		var line = datax[x];
		if (line == 'extend') continue;
		if (line == '') continue;
		if (typeof line == 'function') continue;

		var datay = line.split("\t");
		Data[datay[0]] = datay[1];
	}

	document.body.style.cursor = 'default';

	return Data;

}

function loadText(url, post)
{
	var opt =
	{
		method : 'post',
		asynchronous : false
	};

	if (post != null) opt['parameters'] = Hash.toQueryString(post);

	var loader = new Ajax.Request(url, opt);

	return loader.transport.responseText;
}

function buildMsgBox(strText, container)
{
	var msgBox = document.createElement('div');
	var message = document.createTextNode(strText);
	var placement = $(container);
	msgBox.appendChild(message);
	msgBox.innerHTML = '<br /><br /><br />' + msgBox.innerHTML;
	msgBox.style.position = 'absolute';
	msgBox.style.height = '30%';
	msgBox.style.width = '30%';
	msgBox.style.left = '35%';
	msgBox.style.right = '35%';
	msgBox.style.top = '35%';
	msgBox.style.bottom = '35%';
	msgBox.style.padding = '8px';
	msgBox.style.display = 'block';
	msgBox.style.textAlign = 'center';
	msgBox.style.border = 'solid 1px #3399CC';
	msgBox.style.backgroundColor = '#e6f7ff';
	msgBox.style.color = '#000000';
	msgBox.id = '_msgBox';
	placement.appendChild(msgBox);

	return msgBox;
}

function dec2hex(d)
{
	var hD="0123456789ABCDEF";
	var h = hD.substr(d&15,1);

	while( d > 15)
	{
		d>>=4;
		h=hD.substr(d&15,1)+h;
	}

	return h;
}

function hex2dec(h)
{
	return parseInt(h,16);
}

function urlEncode(str)
{
	var encoded = '';

	for (var i = 0; i < str.length; i++)
	{
		var xChr = str.charAt(i);
		if (xChr.match(/[a-zA-Z0-9\-\_\.\!\~\*\'\(\)\,]/) != null)
			encoded += xChr;
		else
		{
			if (xChr.match(/ /) == ' ')
			{
				encoded += '+';
			} else
			{
				encoded += '%' + dec2hex(str.charCodeAt(i));
			}
		}
	}

	return encoded;
}

function buildParameters()
{
	if ((arguments.length % 2) != 0) return false;

	var paraList = '';
	for (var i = 0; i < arguments.length; i += 2)
	{
		if (paraList != '') paraList += '&';
		if (arguments[i] == 'action')
			paraList += urlEncode(String(arguments[i+1]));
		else
			paraList += arguments[i] + '=' + urlEncode(String(arguments[i+1]));
	}

	return paraList;
}

function parseUrlQuery()
{
	var queryString = window.location.search.substring(1);
	var parameters = queryString.split('&');
	var Query = { };

	for (i in parameters)
	{
		if ((typeof parameters[i]) == 'function') continue;
		if (i == 'extended') continue;

		var part = new String(parameters[i]);
		parts = part.split('=');

		if ((typeof parts[1]) == 'undefined') continue;

		Query[parts[0]] = parts[1];
	}

	return Query;
}

function buildUrlQuery(parameters)
{
	var paraList = '';

	for (i in parameters)
	{
		var value = parameters[i];

		if (paraList != '') paraList += '&';

		if (i == 'action')
			paraList += urlEncode(String(value));
		else
			paraList += i + '=' + urlEncode(String(value));
	}

	return paraList;
}

window.tips = Array();

var jsToolTip = Class.create();
jsToolTip.prototype =
{
	initialize : function(element, tip)
	{
		var tIndex = window.tips.length;
		if (isNaN(tIndex)) tIndex = 0;

		this.Element = element;
		this.TipText = tip;

		window.tips[tIndex] = document.createElement('div');
		window.tips[tIndex].className = 'jsToolTip';
		window.tips[tIndex].innerHTML = tip;
		document.body.appendChild(window.tips[tIndex]);

		this.Element.setAttribute('x_tip_index', tIndex);

		this.Element.style.cursor = 'pointer';
		this.Element.style.marginLeft = '4px';
		this.Element.onmouseover = this.show;
		this.Element.onmouseout = this.hide;

		return true;
	},

	show : function()
	{
		var tIndex = this.getAttribute('x_tip_index');
		var offset = Position.cumulativeOffset(this);

		window.tips[tIndex].style.top = offset[1] + 'px';
		window.tips[tIndex].style.left = (offset[0] + this.width + 16) + 'px';
		window.tips[tIndex].style.display = 'block';

		return true;
	},

	hide : function()
	{
		var tIndex = this.getAttribute('x_tip_index');
		window.tips[tIndex].style.display = 'none';

		return true;
	}
};
