do_progress = function() {
	$('dos').value = '';
	$('sign_up').action = '';
	$('sign_up').submit();
};

var end_months = new Array('0', '31', '*', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
validate = function() {
	if ($('dos').value) {
		var errors = '';
		if (trim($('member_name').value) == '') errors += '<li>Member name is empty. <a href="javascript:fix(\'member_name\')">[Fix]</a></li>';
		else {
			if ($('member_name').value.length < 5) errors += '<li>Member name must be 5 - 15 characters. <a href="javascript:fix(\'member_name\')">[Fix]</a></li>';
			if (!isNaN($('member_name').value.substring(0,1))) errors += '<li>Member name must start with a letter. <a href="javascript:fix(\'member_name\')">[Fix]</a></li>';
			else if (validChars($('member_name').value) != '') { errors += '<li>Member name must start with a letter, and contain only letters, numbers, and/or underscore. Spaces are not allowed.'
																				+ '<a href="javascript:fix(\'member_name\')">[Fix]</a></li>'; }
		}

		if (trim($('pwd').value) == '') errors += '<li>Password is empty <a href="javascript:fix(\'pwd\')">[Fix]</a></li>';
		else {
			if ($('pwd').value.length < 5) errors += '<li>Password must be at least 5 characters. <a href="javascript:fix(\'pwd\')">[Fix]</a></li>';
			else {
				var tmp_pwd = $('pwd').value;
				tmp_pwd = replaceString(' ', '', tmp_pwd);
				if (tmp_pwd != $('pwd').value) errors += '<li>Spaces are not allowed in the password. <a href="javascript:fix(\'pwd\')">[Fix]</a></li>';				
				if (trim($('pwd2').value) == '') errors += '<li>You must verify the Password. <a href="javascript:fix(\'pwd\')">[Fix]</a></li>';
				else if ($('pwd2').value != $('pwd').value) errors += '<li>Password and verified Password do not match. <a href="javascript:fix(\'pwd\')">[Fix]</a></li>';
			}
		}
		
		if (trim($('email').value) == '') errors += '<li>Email Address is empty. <a href="javascript:fix(\'email\')">[Fix]</a></li>';
		else {
			if (!checkEmail($('email').value)) errors += '<li>The Email Address is not correctly formatted. <a href="javascript:fix(\'email\')">[Fix]</a></li>';
			else {
				if (trim($('email2').value) == '') errors += '<li>You must verify the Email Address. <a href="javascript:fix(\'email\')">[Fix]</a></li>';
				else if ($('email2').value != $('email').value) errors += '<li>Email Address and verified Email Address do not match. <a href="javascript:fix(\'email\')">[Fix]</a></li>';
			}
		}
		
		var birthmon = $('birth_month')[$('birth_month').selectedIndex].value;
		var birthday = $('birth_day')[$('birth_day').selectedIndex].value;
		var birthyear = $('birth_year')[$('birth_year').selectedIndex].value;
		
		if (trim(birthyear) == '0') {
			errors += '<li>Birth year not selected. <a href="javascript:fix(\'birth_year\')">[Fix]</a></li>';
		}
		else {
			if (birthday.substring(0,1) == 0) birthday = birthday.substring(1,2);
			if (birthmon.substring(0,1) == 0) birthmon = birthmon.substring(1,2);
			
			for (var i = 1; i <= end_months.length; i++) {
				if (end_months[birthmon] == "*") {
					//chk for leap yr when day is 28 or 29
					if (birthday > leapYear(birthyear)) {
						errors += '<li>Invalid birth date selected. No such day exists for the month you selected. <a href="javascript:fix(\'birth_day\')">[Fix]</a></li>';
						break;
					}
				}
				else if (parseInt(birthday) > parseInt(end_months[birthmon])) {
					errors += '<li>Invalid birth date selected. No such day exists for the month you selected. <a href="javascript:fix(\'birth_day\')">[Fix]</a></li>';
				}
			}
		}

		if (trim($('zipcode').value) != '') {
			if ($('zipcode').value.length < 5) errors += '<li>Zip code must contain 5 digits. <a href="javascript:fix(\'zipcode\')">[Fix]</a></li>';
			else if (isNaN($('zipcode').value)) errors += '<li>Zip code must contain only numbers. <a href="javascript:fix(\'zipcode\')">[Fix]</a></li>';
		}
		else {
			var country = $('cid')[$('cid').selectedIndex].value;
			if (country == '') errors += '<li>No country selected for your location.</li>';
			else if (country == 37 || country == 214 || country == 215) {
				if ($('sid')) {
					var state = $('sid')[$('sid').selectedIndex].value;
					if (state == '') errors += '<li>No State/Province selected for your location.</li>';
					else {
						if ($('ccid')) {
							var city = $('ccid')[$('ccid').selectedIndex].value;
							if (city == '') errors += '<li>No City selected for your location.</li>';
						}
					}
				}
			}
			else {
				if ($('ccid')) {
					var city = $('ccid')[$('ccid').selectedIndex].value;
					if (city == '') errors += '<li>No City selected for your location.</li>';
				}
			}
		}

		if (!$('over18').checked) errors += '<li>You must agree that you are 18 years old or older to access this site.</li>';
		if (!$('terms').checked) errors += '<li>You must read and agree to the Free basic membership Terms and Conditions.</li>';
		if (trim($('word').value) == '') errors += '<li>You must enter the code shown to verify your registration. <a href="javascript:fix(\'word\')">[Fix]</a></li>';
			
		if (errors == '') {
			$('sign_up').action = '';
			return true;
		}
		else {
			if ($('errors2')) $('errors2').style.display = 'none';
			$('errors').innerHTML = '<strong>Errors with form:</strong><ul>'+errors+'</ul>';
			$('errors').style.display = 'block';
			window.scroll(0,700);
		}
		return false;
	}
	else
		return true;
};

checkMemberName = function() {
	if (trim($('member_name').value) != '') {
		var vwin = openWin("check_name.php?id=" + $('member_name').value,"","no","no","no","no","no","no","no",280,30,50,50,0,0,1);
		vwin.focus();
	}
};

reloadWord = function()  {
	if ($('wordimg')) {
		var thesrc = $("wordimg").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		$("wordimg").src = thesrc+"?"+Math.round(Math.random()*100000);
	}
};

