function login()
{
		v1=document.loginhtm.uname.value;
		v2=document.loginhtm.passwd.value;
		window.open("login.asp?u="+v1+"&p="+v2, target="_top");
}
function vote()
{
	window.document.login1.action = ("login.asp?action=vote");
	window.document.login1.submit();
}
function pundit()
{
	window.open("pundit.asp" , target="_top");
}
function invite()
{
	var error = "";
	var invname=document.login1.invite_name.value;
	if (invname == "" || invname.length==0)
	{
 	   error = "Please enter yor name for invitation.\n";
 	}
	var invlist=document.login1.invite_list.value;
	if (invlist == "" || invlist.length==0)
	{
 	   error +=  "Please invite at least one friend to join this league.\n";
 	}
	else
	{
	 	var listResult = invlist.split(",");
 		for(i = 0; i < listResult.length; i++){
 			error=error + checkEmail(listResult[i]); 
		}
	}
	if (error.length > 0)
	{
		alert (error);
	}
	else
	{
		window.document.login1.action = ("login.asp?action=invite");
		window.document.login1.submit();
	}
}

function checkEmail (addr)
{
	var error = "";
	if (addr == "" || addr.length==0)
 	{
 	   error = "Please enter an email address.\n";
 	}
	var illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\]?]/
	if (error.length==0 && addr.match(illegalChars))
	{
	   error = "The email address contains illegal characters.\n";
	}
	var atPos = addr.indexOf('@',0);
	if (error.length==0 && atPos == -1)
	{
   		error = "email address must contain an @.\n";
   	}
   	if (error.length==0 && atPos == 0)
   	{
   		error = "email address must not start with @.\n";
   	}

	if (error.length==0 && addr.indexOf('@', atPos + 1) > - 1)
	{
   		error= "email address must contain only one @.\n";
   	}

   	if (error.length==0 && addr.indexOf('.', atPos) == -1)
   	{
   		error="email address must contain a dot in the domain name.\n";
	}

	if (error.length==0 && addr.indexOf('@.',0) != -1) {
   		error="dot must not immediately follow @ in email address.\n";
    	}

    	if (error.length==0 && addr.indexOf('.@',0) != -1){
		error="dot must not immediately precede @ in email address.\n";
	}

	if (error.length==0 && addr.indexOf('..',0) != -1) {
		error="two dots must not be adjacent in email address.\n";
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (error.length==0 && 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="invalid primary domain in email address.\n";
	}

   	return error;
}

