// JavaScript Document

//below is a combo of two javascripts. One checks if both e-mail form fields math. The other makes sure that e-mails are written in the proper format.
// Email Validation. Written by PerlScriptsJavaScripts.com
// Copied from website 1/17/2005
function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){ 
return (false);
}	
} 

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);		
} 

}

}

function check_form(f) { // f is the form (passed using the this keyword)
//if(f.name.value.length < 1){
//alert("You entered less than one character in the name field.");
//f.name.focus(); // put the prompt in the name field 
//// if the browser is Netscape 6 or IE
//if(document.all || document.getElementByID){
//// change the color of text field
//f.name.style.background = "yellow";
//}
//// make sure the form is not submitted
//return false;
//}	

// check the first email address ( the exclamation means "not" )
if(!check_email(f.from.value)){
alert("You did not type in a proper e-mail address in the first e-mail text box.");
f.from.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.from.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}

// check the second email address
if(!check_email(f.confirm.value)){
alert("You did not enter the same e-mail address twice!  Try again!");
f.confirm.focus(); 
if(document.all || document.getElementByID){
f.confirm.style.background = "yellow";
}
return false;
}
//}

// Author: Carey Walker (carey.walker@citicorp.com) http://www.jsr.communitech.net/pword.htm
//JavaScript Resources - http://www.jsr.communitech.net/
//1/17/2005
//function checkPw(form) {
pw1 = f.from.value;	
pw2 = f.confirm.value;

if (pw1 != pw2) {
alert ("You did not enter the same e-mail twice. Please re-enter your e-mail address correctly.");
return false;
}
else return true;
}

//END




