function validateEmail(){
     dEmail = document.email.emailAdd;
                             if(dEmail.value==""){
							 alert("please enter your email");
							 dEmail.focus();
							 return false}
							 
							 if(dEmail.value.indexOf("@")==-1){
							 alert("please enter a valid email address");
							 dEmail.value="";
							 dEmail.focus();
							 return false}
							 
							 if(dEmail.value.indexOf(".")==-1){
							 alert("please enter a valid email address");
							 dEmail.value="";
							 dEmail.focus();
							 return false}
							 
							 if(dEmail.value.lastIndexOf(".")<dEmail.value.indexOf("@")){
							 alert("please enter a valid email address");
							 dEmail.value="";
							 dEmail.focus();
							 return false}
							 
						addEmail();	 
					}		
					
function getDataFromServer(id, url, callback) {
oScript = document.getElementById(id); 
var head = document.getElementsByTagName("head").item(0); 
if (oScript) { // Destory object 
head.removeChild(oScript); 
}
 
// Create object
oScript = document.createElement("script"); 
var dtRf = new Date(); 
oScript.setAttribute("src",url + "?rf="+dtRf.getTime()+"&email="+document.email.emailAdd.value); 
oScript.setAttribute("id",id); 
head.appendChild(oScript); 

if (oScript.readyState == null) {
            oScript.readyState = "";
            oScript.addEventListener("load", function () {
               oScript.readyState = "loaded";
               if (typeof oScript.onreadystatechange == "function")
                  oScript.onreadystatechange();
            }, false);
         }
if(oScript.readyState==null){alert("yeah");}

if (oScript.readyState!="loaded") {
 oScript.onreadystatechange = function() {
  if (this.readyState == "loaded") {
 
    eval(callback); 
   oScript.onreadystatechange = null; 
   } } } else {
    alert('Cannot load data!'); } }

function addEmail() { 
getDataFromServer("artistData","https://webapps.sph.harvard.edu/eer/cyprus/admin/add_to_email_list.cfm","populateUI()"); 
} 

function populateUI() {
document.getElementById('msgOutput').innerHTML = msgData;
}

