function validateEmail(email) {
	invalidChars = " /:,;";
	if (email == "") {
		return false;
	}
	// checks for bad characters
	for (i = 0; i < invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) != -1) {
			return false;
		}
	}
	//finds position of @ symbol
	atPos = email.indexOf("@",1);
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos + 1) != -1) {
		return false;
	}
	//finds position of . in email
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length) {
		return false;
	}
	atSplit = email.split("@");
	beforeAt = atSplit[0];
	afterAt = atSplit[1];
	if (atSplit[0].length == 1) { 
		return false;
	}
	periodSplit = atSplit[1].split(".");
	beforePeriod = periodSplit[0];
	if (beforePeriod.length <=1) {
		return false;
	}
	return true;
}


function checkDownloadForm() {
	if (document.download.mailfrom.value=="") {
		alert("You must enter a email address")
		document.download.mailfrom.focus();
		return false;
		}
	else if (document.download.retypeemail.value=="") {
		alert("You must retype your email address")
		document.download.retypeemail.focus();
		return false;
		}
	else if (document.download.retypeemail.value!=document.download.mailfrom.value) {
		alert("Your email addresses must match")
		document.download.mailfrom.focus();
		return false;
		}
	else if (!validateEmail(document.download.mailfrom.value)) {
		alert("Your email address must be a valid address")
		document.download.mailfrom.focus();
		return false;
		}
	else
		{
		setCookie('downloademail', document.download.mailfrom.value,
					7 * 24 * 60 * 60);
		}
}	

function setCookie(name, value, expSecs)
    {
    var expires = "";
    if (expSecs)
	{
	var date = new Date();
	date.setTime(date.getTime() + (expSecs * 1000));
	expires = "; expires=" + date.toGMTString();
	}
    document.cookie = name + "=" + value.replace(/;/g, '&') +
						expires + "; path=/";
    }

function activateText(id,name) {
	if (id <4 ) {
		eval("document.feedback."+name+"Text.disabled=false");
		eval("document.feedback."+name+"Text.focus()");
	} else if (id >= 4) {
		eval("document.feedback."+name+"Text.value=''");
		eval("document.feedback."+name+"Text.disabled=true");
	}
}

function checkBetaDownloadForm() {
	if (document.download.mailfrom.value=="") {
		alert("You must enter an email address.");
		//this.location.href="afterDownload.html";
		return false;
	} else {
		return true;
		// this.location.href="afterDownload.html";
		document.download.submit();
	}
}	

