// JavaScript Document//start dom event
window.addEvent('domready', function(){  



/* login and signup check emails */

	// check if email is valid, then check is email already exists in our database
	
	$('emailsignup').addEvent('blur',function(e){

			e.stop();
			
			if(echeck(this.value) == true){			
				
				var request = new Request({
					url: '/a/check_email.php',
					method: 'get',
					onSuccess: function(responseText, responseXML){
							if(responseText == "true") {
								alert($('emailsignup').value+ " already exists in our database. Please use another or retreive your password");
								$('emailsignup').value = "";
								$('log').innerHTML = 'Email <span style="color:red; font-weight:bold">!!</span>';
							} else {
								$('log').innerHTML = 'Email <span style="color:green; font-weight:bold">&radic;</span>';
							}
					}
				});
				
				request.send('email='+this.value); // send out to php script to check if email exists in database
				
			} else {
				this.value = "";
				$('log').innerHTML = 'Email <span style="color:red; font-weight:bold">!!</span>';
			}
	});

	// error checking for name

	$('name').addEvent('blur',function(e){
			e.stop();
			// if the value is nothing than let it be known!!
			if(this.value == ""){			
				$('namelog').innerHTML = 'Name <span style="color:red; font-weight:bold">!!</span>';
					} else {
				$('namelog').innerHTML = 'Name <span style="color:green; font-weight:bold">&radic;</span>';
			};					
		
	});
	// error check passwords match
	
	$('passwordConfirm').addEvent('change',function(e){
				e.stop();
			// if the value is nothing than let it be known!!
			if((this.value == "") || (this.value !== $('passwordSignup').value)){
						this.value = "";
						alert('please make sure your passwords match');
					} else {
				$('passwordlog').innerHTML = 'Password <span style="color:green; font-weight:bold">&radic;</span>';
			};					
		
	});
	
	
	
											
	
}); // end of dom event