
function c(ssn) {
  window.location.href = "index.cgi?ssn=" + ssn;
}


function validateCheckout(id){

	var rg_real_name = new RegExp('^[a-zA-Z]{1,}');
	var rg_email = new RegExp(/^([a-zA-Z0-9]([-.\w]*[a-zA-Z0-9])*@([a-zA-Z0-9][-\w]*[a-zA-Z0-9]\.)+[a-zA-Z]{2,12})$/);
	var rg_phone = new RegExp('[0-9\-_\(\)\+ ]{8,}');
	var rg_usr_pwd = new RegExp(/^[\w\d~\!@\#\$%\^&\*\(\)\+\=\[\]\{\}\.,\-\;\<\>\?]{6,32}$/);

	var f=document.edit_item;
	var c=0;
	var m='Sorry, could not proceed due to the following errors.\n\nDetails of all errors are listed below. Please make sure you correctly\nfill in all specified fields.\n\n';


	if(f.full_name.value.search(rg_real_name)==-1){
		m+='    - Invalid Full Name. Must begin with one or more letter characters (a-z or A-Z).\n';
		c++;
	}
	
	if(f.email.value.search(rg_email) == -1) {
		m+='    - Email address is not valid. Please enter a valid email address.\n';
		c++;
	}

	if(f.phone_work.value.search(rg_phone)==-1 && f.phone_mobile.value.search(rg_phone)==-1 && f.phone_home.value.search(rg_phone)==-1) {
		m+='    - At lease one valid phone number (work, mobile or home) is required.\n';
		c++;
	}

	if(id==0) {
		if(f.username.value.length==0){
			m+='    - Please enter a Username.\n';
			c++;
		}
		else if(f.username.value.length<6){
			m+='    - Username too short. Must contain between 6-32 characters.\n';
			c++;
		}
		else if(f.username.value.length>32){
			m+='    - Username too long. Must contain between 6-32 characters.\n';
			c++;
		}
		else{
			if(f.username.value.search(rg_usr_pwd) == -1){
				m+='    - Username is not valid. Only use a-z A-Z 0-9 ~ ! @ # $ % ^ & * ( ) - + = [ ] { } ; < > ? . , _\n';
				c++;
			}
		}
	}

	if(id==0){
		if(f.password1.value.length>0 || f.password2.value.length>0){
			if(f.password1.value.length==0){
				m+='    - Please enter a password.\n';
				c++;
			}
			else if(f.password1.value.length<6){
				m+='    - Password too short. Must contain between 6-32 characters.\n';
				c++;
			}
			else if(f.password1.value.length>32){
				m+='    - Password too long. Must contain between 6-32 characters.\n';
				c++;
			}
			else if(f.password1.value.search(rg_usr_pwd) == -1){
				m+='    - Password is not valid. Only use a-z A-Z 0-9 ~ ! @ # $ % ^ & * ( ) - + = [ ] { } ; < > ? . , _\n';
				c++;
			}
			else {
				if(f.password1.value != f.password2.value){
					m+='    - Passwords do not match.\n';
					c++;
				}
	 		}
		}
	}


	if(c>0){
		m+='\n';
		alert(m);
		return false;
	}
	else {
		return true;
	}
}