	function setZipOption(country){
		
		if(country=="US"){
				document.getElementById("imageArea").innerHTML="<img src='http://files.smarter.com/images/me/star_gray.gif' align='texttop'>";
			}else{
				document.getElementById("imageArea").innerHTML="";
		}
		
	}
	
	function refreshimg(){
		var randomnum = Math.random();
		var img = document.getElementById("newimg");
		img.src="/smarterme/createimgcode.php?act=yes&" + randomnum;		
	}
	
	function isDate(str){
		if(!str.match(/^\d{4}\-\d\d?\-\d\d?$/)){
			return false;
		}
	
		var ar=str.replace(/\-0/g,"-").split("-");
		ar=new Array(parseInt(ar[0]),parseInt(ar[1])-1,parseInt(ar[2]));
		var d=new Date(ar[0],ar[1],ar[2]);
		return d.getFullYear()==ar[0] && d.getMonth()==ar[1] && d.getDate()==ar[2];
	}
	
	function MM_checkValidUserAge(birthday, dueDate, validAge){
		return (dueDate.getFullYear()-birthday.getFullYear())*12+(dueDate.getMonth()-birthday.getMonth())-1 >= (validAge * 12);
	}
	
	function checkRegForm()
	{
		var regemail=document.getElementById("regemail").value;
		var user_password=document.getElementById("user_password").value;
		var repassword=document.getElementById("repassword").value;
		var country=document.getElementById("country").value;
		var postalcode=document.getElementById("postalcode").value;
		var verification=document.getElementById("verification").value;
		
		
		//var patternEmail=/^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;  
		var patternEmail=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var patternPass=/^[\.@a-zA-Z0-9_-]{6,12}$/; 
		var patternZip=/^[0-9]{1}[0-9]{3,10}$/;
		
		
		document.getElementById("regemailInfo").innerHTML="(example: you@domain.com)";
		document.getElementById("regemailInfo").style.color="";
		document.getElementById("user_passwordInfo").innerHTML="(6-12 characters, letters and/or numbers only)";
		document.getElementById("user_passwordInfo").style.color="";		
		document.getElementById("repasswordInfo").innerHTML="(6-12 characters, letters and/or numbers only)";
		document.getElementById("repasswordInfo").style.color="";
		document.getElementById("postalcodeInfo").innerHTML="(example: 91016)";
		document.getElementById("postalcodeInfo").style.color="";
		document.getElementById("verificationInfo").innerHTML="";
		document.getElementById("verificationInfo").style.color="";
		document.getElementById("birthdayInfo").innerHTML="";
		document.getElementById("birthdayInfo").style.color="";
		
		error=0;
		rsEmail=patternEmail.test(regemail);
		if(!rsEmail){
			error=1;
			document.getElementById("regemailInfo").innerHTML="Please enter a valid E-mail Address.";
			document.getElementById("regemailInfo").style.color="red";
		}
		if(user_password==repassword){
			rsPass=patternPass.test(user_password)
			if(!rsPass){
				error=1;
				document.getElementById("user_passwordInfo").innerHTML="Please enter a password. Must be more than 6-12 characters.";
				document.getElementById("user_passwordInfo").style.color="red";
			}
		}else{
			error=1;
			document.getElementById("repasswordInfo").innerHTML="Password not matched.";
			document.getElementById("repasswordInfo").style.color="red";
		}
		
		var strBirthday = $F('birthday_year') + '-' + $F('birthday_month') + '-' + $F('birthday_day');
		if (!isDate(strBirthday)){
			error=1;
			document.getElementById("birthdayInfo").innerHTML="Birthday is NOT a valid date.";
			document.getElementById("birthdayInfo").style.color="red";
		} else {
	   		var now = new Date();
	   		var birthday = new Date($F('birthday_year'), $F('birthday_month')-1, $F('birthday_day'));
	   		if (birthday >= now) {
	   			error=1;
	   			document.getElementById("birthdayInfo").innerHTML="Birthday must less than now.";
				document.getElementById("birthdayInfo").style.color="red";
			}else if(!MM_checkValidUserAge(birthday,now,13)){
				error=1;
				document.getElementById("birthdayInfo").innerHTML="You need to be 13 years or older to create an account on Smarter.";
				document.getElementById("birthdayInfo").style.color="red";
			}
		}
		
		if(country=="US"){
			if(postalcode==''){
				error=1;
				document.getElementById("postalcodeInfo").innerHTML="Please enter a postcode.";
				document.getElementById("postalcodeInfo").style.color="red";
			}else{
				rsZip=patternZip.test(postalcode)
				if(!rsZip){
					error=1;
					document.getElementById("postalcodeInfo").innerHTML="Please enter a valid postcode.";
					document.getElementById("postalcodeInfo").style.color="red";
				}
			}
		}
		if(verification==''){
					error=1;
					document.getElementById("verificationInfo").innerHTML="Please enter a Verification Number.";
					document.getElementById("verificationInfo").style.color="red";
		}
		if(error!=1) {
			document.getElementById("regform").className='disn';
			document.getElementById("regalert").className='waiting disb';
			xajax_register(regemail,user_password,repassword,country,postalcode,verification,strBirthday);
		}	
	}