var EMAIL_OK = 0;
var EMAIL_BLANK = 1;
var EMAIL_BAD_SYNTAX = 2;

function MM_openBrWindow(theURL,winName,features,width,height) 
{
	if (parseInt(navigator.appVersion) >= 4) 
	{
		var xPos = (screen.availWidth-(screen.availWidth/2)-width/2);
		var yPos = (screen.availHeight-(screen.availHeight/2)-height/2);
	}
	else 
	{
		var xPos = 550;
		var yPos = 610;
	}
	
	newWin = window.open(theURL,winName,features + "statusbar=no,toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no" + ",top=" + yPos + ",left=" + xPos);
	newWin.focus();   
}

function trim(s)
{
	if (!s)
		return '';
	return s.replace(/^\s*|\s*$/g,"");
}

function xb_get_element(thing)
{
	if (typeof(thing) == 'undefined' || !thing)
	{
		return null;
	}
	else if (typeof(thing.tagName) == 'undefined' || !thing.tagName)
	{
		if (document.all)
			el = document.getElementById(thing) ? document.getElementById(thing) : document.all[thing];
		else 
			el = document.getElementById(thing);
	
		if (el)
			return el;
		else
			return null;
	}
	else if (thing.tagName)
	{
		return thing;
	}
	else
	{
		return null;
	}
}


function is_valid_email(e)
{
	e = trim(e).toLowerCase();
	if (e == '')
		return EMAIL_BLANK;
	//regex = /^\s*[a-z0-9-+\_\.]+@[a-z0-9-_\.]+\.[a-z]{2,4}\s*$/;
	regex = /^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/;
	if(!regex.test(e))
		return EMAIL_BAD_SYNTAX;
	return EMAIL_OK;
}

