var errorInt;

function showError() {

	errBox = document.getElementById('errorbox');
	

	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	
	errBox.style.display = "inline";
	errBox.style.left = ((winWidth/2)-200)+"px";
	errBox.style.top = "10px";

	errorInt = setInterval('hideError()', 2000);
}

function hideError() {
	
	clearInterval(errorInt);
	document.getElementById('errorbox').style.display = "none";
	
}

function confirmDelete(obj) {

	if (confirm("Are you sure you want to delete this "+obj+"?"))
		return true;
	else
		return false;

}


function validateForm() {
	// used to validate user reg form
	
	if (document.regForm['nick'].value == "") {
		alert("Please enter a nick name");
		return false;
	} else if (document.regForm['email'].value == "" || !validateEmail(document.regForm['email'].value) ) {
		alert("Please enter a valid email address");
		return false;
	} else if (document.regForm['password'].value == "") {
		alert("Please enter a password name");
		return false;
	} else if (document.regForm['password'].value != document.regForm['cpassword'].value) {
		alert("The entered passwords do not match!");
		return false;
	}
	
	return true;

}

function validateEmail(email) {

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if (filter.test(email))
		return true;
	else
		return false;
}
