var ErrorHint = {
	initialize: function () {
		this.element = $('element_hint');
		this.title = $('element_hint_title');
		this.content = $('element_hint_content');
	},
	show: function (element, title, body, offsetLeft) {
		if (arguments.length < 4) var offsetLeft = 3;
		var element = $(element);
		var pos = Position.cumulativeOffset(element);
		this.element.style.top = pos[1] + (element.type == 'checkbox' ? - 5 : 0 ) + "px";
		this.element.style.left = pos[0] + element.offsetWidth + offsetLeft + "px";

		this.title.innerHTML = title;
		this.content.innerHTML = body;
		this.element.style.display = 'block';
	},
	hide: function () {
		this.element.style.display = 'none';
	}
}

function showErrorForInput (input, text, timeoutClose, offsetLeft) {
	if (arguments.length < 3) var timeoutClose = 0;
	if (arguments.length < 4) var offsetLeft = 0;
	input = $(input);
	Element.addClassName(input, 'error');
	window.lastErrorInputShown = input;
	ErrorHint.show(input, 'Error', text, offsetLeft);
	if (timeoutClose > 0)
		setTimeout('hideInputError()', timeoutClose);
}
function showHintForInput (input, title, text, offsetLeft) {
	if (arguments.length < 3) var offsetLeft = 0;
	input = $(input);
	Element.addClassName(input, 'error');

	ErrorHint.show(input, title, text, offsetLeft);
}
function hideInputError () {
	Element.removeClassName(window.lastErrorInputShown, 'error');
	window.lastErrorInputShown = null;
	ErrorHint.hide();
}
window.lastErrorInputShown = null;