//Center Popup
function NewWindow(mypage, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function checkEmail(emailid)
{
	var error = "";
	if (emailid == '')
	{
		error = "You did not enter an email-address.\n";
	}

	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|#~`+*$%&';

	for (i=0; i<invalidChars.length; i++)
	{
		if (emailid.indexOf(invalidChars.charAt(i),0) > -1)
		{
			error = "Please enter a valid email address.\n";
		}
	}

	for (i=0; i<emailid.length; i++)
	{
		if (emailid.charCodeAt(i)>127)
		{
			error = "Please enter a valid email address.\n";
		}
	}

	var atPos = emailid.indexOf('@',0);
	if (atPos == -1 || atPos == 0 || emailid.indexOf('@', atPos + 1) > - 1 || emailid.indexOf('.', atPos) == -1 || emailid.indexOf('@.',0) != -1 || emailid.indexOf('.@',0) != -1 || emailid.indexOf('..',0) != -1)
	{
		error = "Please enter a valid email address.\n";
	}
	
	var suffix = emailid.substring(emailid.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum')
	{
		error = "Please enter a valid email address.\n";
	}
	return error;
}