
function clearFirst() {
	if ($('r_given').value == 'First') {
		$('r_given').value = '';
	}
	$('r_given').style.color = '#000';
}

function clearLast() {
	if ($('r_surname').value == 'Last') {
		$('r_surname').value = '';
	}
	$('r_surname').style.color = '#000';
}

function locationFix() {
	if ($('out_of_us').checked == true) {
		$('zip_block').style.display = 'none';
		$('country_block').style.display = 'block';
		$('citysel').style.display = 'block';
	} else {
		$('zip_block').style.display = 'block';
		$('country_block').style.display = 'none';
		$('citysel').style.display = 'none';
	}
}

function try_register() {
	if ($('tos_agree').checked == false) {
		$('r_notification').innerHTML='<span style="color:#F00">You must agree to the Terms of Service</span>';
	} else if ($('over_13').checked == false) {
		$('r_notification').innerHTML='<span style="color:#F00">You must be 13 or order to use this service.</span>';
	}
	else {
		$('r_notification').innerHTML='<div style="color:#FF8040">[Working...]</div>';
		new Ajax.Request('/cgi-bin/register.cgi', {
	    method: 'post',
	    parameters: {
	    	r_user: $('r_email').value,
	    	r_pass: $('r_pass').value,
	    	r_repass: $('r_repass').value,
	    	r_given: $('r_given').value,
	    	r_surname: $('r_surname').value,
	    	r_email: $('r_email').value,
	    	r_sex: $('r_sex').value,
	    	r_zip: $('r_zip').value,
	    	out_of_us: $('out_of_us').checked,
	    	r_country: $('r_country').value,
	    	r_city: $('r_city').value
	    },	    
	    onSuccess: function(transport) {
	      if (transport.responseText == 1) {
					redirectPage();
				} else {
					$('r_notification').innerHTML = '<div style="color:#FF0000">'+transport.responseText+'</div>';
				}
	    },
	    onFailure: function(){
	    	$('r_notification').innerHTML='<div style="color:#FF0000">[Registration failed.  Try again.]</div>';
	    }
	  });
		
	}
}

function passwordSame() {
	if ($('r_pass').value == $('r_repass').value && $('r_pass').value != '') {
		$('repeatOk').innerHTML = "<span style='color:#0A0'><img src='/global/check.png'> passwords match</span>";
	}
	else {$('repeatOk').innerHTML = "<span style='color:#F00'>passwords do not match</span>";}
}

function emailSame() {
		if ($('r_email').value == $('r_reemail').value && $('r_email').value != '') {
			$('emailRepeatOk').innerHTML = "<span style='color:#0A0'><img src='/global/check.png'> e-mails match</span>";
		} 
		else {$('emailRepeatOk').innerHTML = "<span style='color:#F00'>e-mails do not match</span>";}
}
