//get first login form
function firstLogin(){          
	 document.getElementById('status').innerHTML = "<img src='images/checking.gif'>";    
     http("POST","includes/login/dsp_FirstLogin.cfm",returned_firstLogin);
}


//display first login form
function returned_firstLogin(obj){
     document.getElementById('status').innerHTML = "";
	 document.getElementById('contentBlock').innerHTML = obj;
}

//check fields and send password
function sendPassword(){
     var d = document.emailCk;    
	
	 //first, check form for blank fields///////////////////////////////////////////////////////////	 
	    var d = document.emailCk;
		var fields = new Array ();
		fields[0] = "userTitle";
		fields[1] = "department";
		fields[2] = "hospital";
		fields[3] = "city";
		fields[4] = "state";
		fields[5] = "timeAtJob";
		fields[6] = "timeWithAbiomed";
		fields[7] = "centerType";
		fields[8] = "email";
		
		
		var warning = false;
		//reset labels to default color///////////////////////////////////////////////////////////	
		for(x=0;x<fields.length;x++){
			document.getElementById(fields[x]).style.color = "#7f99ce";
			}	
		//reset radio button fields to default colors////////////////////////////////////////////
		document.getElementById('expWithVads').style.color = "#7f99ce";
		document.getElementById('bvsAb').style.color = "#7f99ce";
			
		for(x=0;x<fields.length;x++){
				if(eval("d."+fields[x]+".value")==""){
				if(warning==false){warning=true;}
				document.getElementById(fields[x]).style.color = "#a40248";
				}
		}
	    
		//check radio button fields
		if(d.expWithVads[0].checked==false&&d.expWithVads[1].checked==false){
		   document.getElementById('expWithVads').style.color = "#a40248";
		   if(warning==false){warning=true;}
		}
	    
		if(d.bvsAb[0].checked==false&&d.bvsAb[1].checked==false){
		   document.getElementById('bvsAb').style.color = "#a40248";
		   if(warning==false){warning=true;}
		}
	 
	 //show alert if blank fields
	 if(warning){alert("fields in red are required!");}else{
	    if(d.agreeToTerms.checked!=true){
	          alert("Please review the terms and conditions of the use of this website and check the I agree to terms checkbox");
			  return false;
	      }else{ 
		      document.getElementById('status').innerHTML = "<img src='images/checking.gif'>";
		      http("POST","includes/login/act_FirstLogin.cfm",returned_sendPassword,document.emailCk);
			 }
   }
}


function returned_sendPassword(obj){  
       document.getElementById('status').innerHTML = "";
	   if(obj.error=="false"){
             document.getElementById('contentBlock').innerHTML = obj.message;
		  }else{
		     document.getElementById('contentBlock').innerHTML = obj.error;
		}  
    }