
// Deactivate the enter key.
function keyHit( e )
{
	var pK = e ? e.which : window.event.keyCode;
	return pK != 13;
}


document.onkeypress = keyHit;

if( document.layers)
	document.captureEvents( Event.KEYPRESS );



function subscribe()
{
	if( checkEmail( document.subscribe.email.value ))
		document.subscribe.submit();
	else
	{
		alert( "Please check that you correctly typed your email address." );
		document.subscribe.email.focus();
		document.subscribe.email.select();
		
		return false;
	}
}



function checkEmail( email )
{	
	var invalidChars = "/:;";
	
	// No email address was supplied.
	if( email == "" )
		return false;
		
		
	// Scan for invalid characters.
	for( i = 0; i < invalidChars.length; i ++ )
	{
		badChar = invalidChars.charAt( i );
		
		if( email.indexOf( badChar, 0 ) > -1 )
			return false;
	}
	
	

	atPos = email.indexOf( "@", 1 )

	// @ was not found.	
	if( atPos == -1 )
		return false;
		
		
	// Make sure there are no double @ signs.
	if( email.indexOf( "@", atPos + 1 ) > -1 )
		return false;


	periodPos = email.indexOf( ".", atPos );
		
	// Check that there is a period after the @ sign.
	if( periodPos == -1 )
		return false;
	
	
	// Check that there is at least two characters after the period.
	if( periodPos + 3 > email.length )
		return false;
	
	
	return true;
}


