// JavaScript Document



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function checkForm1(){
	var why = "";
	
	if(document.forms[0].SendersName.value=="" || document.forms[0].SendersName.value.toUpperCase()=="YOUR NAME"){
		why += "Your Name\n";
	}	
	if(document.forms[0].SendersEmail.value=="" || document.forms[0].SendersEmail.value.toUpperCase()=="YOUR EMAIL"){
		why += "Your Email\n";
	} else {
	
		var address=document.forms[0].SendersEmail.value;
		if (isValidEmailStrict(address) == false) {
			why += "Your Email Address Must Be Valid!\n";
		}
	
	}
	
	if(document.forms[0].SendersEmail.value=="" || document.forms[0].EmailRecipient.value.toUpperCase()=="YOUR FRIEND'S EMAIL"){
		why += "Your Friend's Email\n";
	} else {
	
		var address=document.forms[0].SendersEmail.value;
		if (isValidEmailStrict(address) == false) {
			why += "Your Friend's Email Address Must Be Valid!\n";
		}
	
	}
	
	if (why != "") {
       alert("You left some fields blank.\nBefore continuing you must enter:\n\n" + why);
       return false;
    }
	
	return true;
}

// Check that an email address is valid based on RFC 821 (?)
function isValidEmail(address) {
   if (address != '' && address.search) {
      if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
      else return false;
   }
   
   // allow empty strings to return true - screen these with either a 'required' test or a 'length' test
   else return true;
}

// Check that an email address has the form something@something.something
// This is a stricter standard than RFC 821 (?) which allows addresses like postmaster@localhost
function isValidEmailStrict(address) {
   if (isValidEmail(address) == false) return false;
   var domain = address.substring(address.indexOf('@') + 1);
   if (domain.indexOf('.') == -1) return false;
   if (domain.indexOf('.') == 0 || domain.indexOf('.') == domain.length - 1) return false;
   return true;
}



