function xmlhttp_error(res)
{
	// Generic error handler for XMLHTTP requests
	if (res.number) {
		alert(MASTER_1);
	} else {
		alert(MASTER_2);
	}
}

function fcs(element_id) {
	var element = document.getElementById(element_id);
	element.defaultValue = '';
	element.value = '';
	element.focus();
}
function clr(element_id) {
	var element = document.getElementById(element_id);
	element.defaultValue = '';
	element.value = '';
}

function show_inline(element_id) {
	var element = document.getElementById(element_id);
	if (element !== null) element.style.display = "inline";
}

function hide(element_id) {
	var element = document.getElementById(element_id);
	if (element !== null) element.style.display = "none";
}

function submit(form_id) {
	document.getElementById(form_id).submit();
}

function validate_password(pwd_id, cnf_id) {
	var password = document.getElementById(pwd_id);
	var confirm  = document.getElementById(cnf_id);
	
	if (password.value.length <= 5) {
		alert('Passwords must be at least 6 characters long.');
		password.focus();
		return false;
	} else if (password.value != confirm.value) {
		alert('Passwords do not match, please try again.');
		password.value = '';
		confirm.value = '';
		password.focus();
		return false;
	}
	return true;
}

function get_doc_height()
{
	window_height = 0;
	if (document.documentElement && document.documentElement.clientHeight) {
		window_height = Math.max(window_height, document.documentElement.clientHeight);
	}

	if (document.body && document.body.clientHeight) {
		window_height = Math.max(window_height, document.body.clientHeight + 14);
	}
	return window_height;
}

function get_doc_width()
{
	window_width = 0;
	if(typeof( window.innerWidth ) == 'number') {
		window_width = window.innerWidth;
	}

	if (document.documentElement && document.documentElement.clientWidth) {
		window_width = Math.max(window_width, document.documentElement.clientWidth);
	}

	if (document.body && document.body.clientWidth) {
		window_width = Math.max(window_width, document.body.clientWidth);
	}
	var page = document.getElementById('page');
	window_width = Math.max(window_width, page.clientWidth + 14);
	return window_width;
}

/* Simple test to check if we're using Internet Explorer.  Does not
 * bother with version. */
function isInternetExplorer()
{
	return ((navigator.userAgent) && (navigator.userAgent.indexOf("MSIE") != -1));
}

/* Stop event bubbling.
 *
 * @param event Current event.
 */
function stopBubble(event)
{
	if (window.event) {
		window.event.cancelBubble = true;
	} else if (event.stopPropagation) {
		event.stopPropagation();
	}
}
