/**
 * @author Grace
 */


	
function process_login(){
	
	var username;
	var password;
	var seedid;
	var seedval;
	
	var hashval;
	
	// get form form elements 'username' and 'password'
	username = $('email1').value;
	password = $('pass1').value;
	seedid = $('seedid').value;
	seedval = $('seedval').value;

	// ignore if either is empty
	if (username != '' && password != '') {
		// compute the hash of the hash of the password and the seed
		hashval = SHA256(SHA256(username+password) + seedval);
		$('hashval').value = hashval;


		//erase before sending the form to the server
		$('pass1').value = '';
		$('seedval').value = '';
		return true;
	}
	
	//empty user/password
	alert('Please enter username and password');
	
	return false;
}

function process_join() {
	return true;
}

/* errorifield str - ID of element to display the error */
function process_joinpasswd(errorfield) {
	var pass1 = $('pass1').value;
	var pass2 = $('pass2').value;
	var username = $('email').value;
	var hashval;
	
	if (!pass1 || !pass2 ) {
		$(errorfield).update('Please fill in the form completely.');
		$(errorfield).show();
		return false;
	}
	if (pass1 != pass2) {
		$(errorfield).update('Passwords did not match.  Please try again.');
		$(errorfield).show();
		return false;
	}
	if (pass1.length < 6) {
		$(errorfield).update('Password must be at least 6 characters. Please try again.');
		$(errorfield).show();
		return false;
	}
	
	$('passenc').value = SHA256(username+pass1);
	return true;
}
