function emailCheck (emailStr) 
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
		alert("Your email is invalid. This username contains invalid characters.");
		return false;
		}
	}
	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			alert("Your email is invalid. This domain name contains invalid characters.");
			return false;
		}
	}
	if (user.match(userPat)==null) 
	{
		alert("Your email is invalid. The username doesn't seem to be valid.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				alert("Your email is invalid. Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			alert("Your email is invalid. The domain name does not seem to be valid.");
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
	{
		alert("Your email is invalid. The address must end in a well-known domain or two letter " + "country.");
		return false;
	}
	if (len<2) 
	{
		alert("Your email is invalid. This address is missing a hostname!");
		return false;
	}
	return true;
}


function checkEmail(emailfrm) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailfrm.value))
	{
	return '';
	}
	else
	{
		return emailfrm.value + ' : Invalid E-mail Address! Please re-enter.\n';
	}
}

// Multiple email checking function

function checkguesses()
{
	var strError='';
	if ((document.submitform.email1.value=='') && (document.submitform.email2.value=='') && (document.submitform.email3.value=='') && (document.submitform.email4.value==''))
	{
		strError = strError + 'Please enter at least 1 email address.\n';
	}
	if (document.submitform.email1.value!='')
	{
		strError = strError + checkEmail(document.submitform.email1);
	}
	if (document.submitform.email2.value!='')
	{
		strError = strError + checkEmail(document.submitform.email2);
	}
	if (document.submitform.email3.value!='') 
	{
		strError = strError + checkEmail(document.submitform.email3);
	}
	if (document.submitform.email4.value!='') 
	{
		strError = strError + checkEmail(document.submitform.email4);
	}
	if (strError=='')
	{
		return true;
	}
	else
	{
		alert(strError);
		strError='';
		return false;
	}
}

// Bookmark function

var url="http://www.aspellonyou.com";
var title="aspellonyou.com";

function bookmark ()
{
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
	{

	document.write('<A class=menutext HREF="javascript:window.ext');
	document.write('ernal.AddFavorite(url,title);" ');
	document.write('onMouseOver=" window.status=');
	document.write("'Add our site to your favorites!'; return true ");
	document.write('"onMouseOut=" window.status=');
	document.write("' '; return true ");
	document.write('">Bookmark Site');
	}
	else 
	{
		var msg = "";
		if(navigator.appName == "Netscape") msg += "";
		document.write(msg);
	}
}

// My Signup Checker

function checkSignup(signupfrm)
{
	if (signupfrm.fullname.value == '')
	{
		alert ("Please provide your full name");
		return false;
	}
	if (signupfrm.email.value == '')
	{
		alert ("Please provide a valid email address");
		return false;
	}
	if (signupfrm.username.value == '')
	{
		alert ("Please provide a username");
		return false;
	}
	if (signupfrm.password.value == '')
	{
		alert ("Please provide a password preferably no less than 6 characters");
		return false;
	}
	if (signupfrm.confirmpassword.value == '')
	{
		alert ("Please confirm your password");
		return false;
	}
	if (signupfrm.password.value != signupfrm.confirmpassword.value)
	{
		alert ("Please confirm the correct password");
		return false;
	}
	if (emailCheck(signupfrm.email.value))
	{
		if (signupfrm.checkboxterms.checked)
		{
			return true;
		}
		else
		{
			alert ("You must agree to the terms and conditions");
			return false;
		}
	}
	else
	{
		return false;
	}
}

// My Login Checker

function checkLogin(loginfrm)
{
	if (loginfrm.username.value == '')
	{
		alert ("To login you must provide your username");
		return false;
	}
	if (loginfrm.password.value == '')
	{
		alert ("To login you must provide your password");
		return false;
	}
	return true;
}

// Print the date

function printdate()
{
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var time=new Date();
	var month=monthNames[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))  
		year="19" + year;
	if (navigator.appName == "Netscape")
		year=1900 + year;
		document.write(monthNames[time.getMonth()] + " ");
		document.write(date + ", " + year);
}

// My welcome message

function printwelcome()
{
	var currentdate = new Date();
	var currenthour = currentdate.getHours();
	if (currenthour >= 0 && currenthour < 12)
	{
		document.write("Good Morning");
	}
	if (currenthour >= 12 && currenthour < 18)
	{
		document.write("Good Afternoon");
	}
	if (currenthour >= 18 && currenthour < 24)
	{
		document.write("Good Evening");
	}
}

function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL, winName, features);
}

// My reveal form checker

function checkReveal(revealfrm)
{
	var maxlength = 9;
	var arrlength = revealfrm.elements.length;
	var keys = revealfrm.keyamount.value
	if (keys > maxlength)
	{
		keys = maxlength;
	}
	var count = 0;

	for (var i = 0; i < arrlength; i++)
	{
		var elem = revealfrm.elements[i];
		if (elem.type == 'checkbox')
		{
			if (elem.checked)
			{
				count++;
			}
		}
	}	
	// or elem.name contains (string function)
	if (count < keys)
	{
		alert("You have selected " + count + " doors.\nYou have " + keys + " keys, you must choose " + keys + " doors");
		return false;
	}
	if (count > keys)
	{
		alert("You have selected " + count + " doors.\nYou currently have " + keys + " keys - you can only choose a maximum of " + keys + " doors.\nIf you want a better chance of selecting the correct combination, you may acquire more keys.");
		return false;
	}
	if (count == 0)
	{
		alert("No doors selected");
		return false;
	}
	if (count == keys)
	{
		return true;
	}
}