<script language="JavaScript">
function change_color_of_text_vars(var_name,var_color,var_weight){
	eval("document.getElementById('"+var_name+"').style.fontWeight='"+var_weight+"';");
	eval("document.getElementById('"+var_name+"').style.color='"+var_color+"';");
	return;
}
function check_text_vars(){
	var message = "";
	if (document.reg.email.value=="") {
		message = "Please enter email.";
		change_color_of_text_vars('emailx','FF0000','bold');
	}
	else if (document.reg.email_2.value=="") {
		message = "Please confirm you e-mail address.";
		change_color_of_text_vars('emailx_2','FF0000','bold');
	}
	else if (document.reg.email.value!=document.reg.email_2.value) {
		message = "Confirmation e-mail does not match your initial password.\nPlease re-enter confirmation e-mail.";
		change_color_of_text_vars('emailx_2','FF0000','bold');
	}
	else if (!document.reg.email.value.match(/^[\w-\+~]+(\.[\w-\+~]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/)) {
		message = "Invalid email address.\nPlease check for invalid characters.";
		change_color_of_text_vars('emailx','FF0000','bold');
		document.reg.email_2.value="";
	}
	else if (document.reg.password_1.value=="") {
		message = "Please enter password.";
		change_color_of_text_vars('password_1x','FF0000','bold');
	}
	else if (document.reg.password_2.value=="") {
		message = "Please enter password confirmation.";
		change_color_of_text_vars('password_2x','FF0000','bold');
	}
	else if (document.reg.password_1.value!=document.reg.password_2.value) {
		message = "Confirmation password does not match your initial password.\nPlease re-enter confirmation password.";
		change_color_of_text_vars('password_2x','FF0000','bold');
	}
	else if (document.reg.fname.value=="") {
		message = "please enter first name.";
		change_color_of_text_vars('fnamex','FF0000','bold');
	}
	else if (document.reg.lname.value=="") {
		message = "please enter last name.";
		change_color_of_text_vars('lnamex','FF0000','bold');
	}
	else if (document.reg.zipcode.value=="") {
		message = "please enter zipcode.";
		change_color_of_text_vars('zipcodex','FF0000','bold');
	}
	else if (document.reg.city.value=="") {
		message = "please enter city.";
		change_color_of_text_vars('cityx','FF0000','bold');
	}
	else if (document.reg.country.options[document.reg.country.selectedIndex].value=="0") {
		message = "please select country.";
		change_color_of_text_vars('countryx','FF0000','bold');
	}
	else if (document.reg.b_month.options[document.reg.b_month.selectedIndex].value=="0") {
		message = "please specify your month of birth.";
		change_color_of_text_vars('bdayx','FF0000','bold');
	}
	else if (document.reg.b_day.options[document.reg.b_day.selectedIndex].value=="0") {
		message = "please specify your day of birth.";
		change_color_of_text_vars('bdayx','FF0000','bold');
	}
	else if (document.reg.b_year.options[document.reg.b_year.selectedIndex].value=="0") {
		message = "please specify your year of birth.";
		change_color_of_text_vars('bdayx','FF0000','bold');
	}
	else if (document.reg.gender.options[document.reg.gender.selectedIndex].value=="-1") {
		message = "please select gender.";
		change_color_of_text_vars('genderx','FF0000','bold');
	}
	else if (!document.reg.agree.checked) {
		message = "please agree to the terms and conditions.";
		change_color_of_text_vars('agreex','FF0000','bold');
	}
	if (message!="") {
		alert(message);
		return false;
	} else return true;
}
function initialize() {
	change_color_of_text_vars('emailx','000000','normal');
	change_color_of_text_vars('password_1x','000000','normal');
	change_color_of_text_vars('password_2x','000000','normal');
	change_color_of_text_vars('fnamex','000000','normal');
	change_color_of_text_vars('lnamex','000000','normal');
	change_color_of_text_vars('cityx','000000','normal');
	change_color_of_text_vars('statex','000000','normal');
	change_color_of_text_vars('zipcodex','000000','normal');
	change_color_of_text_vars('countryx','000000','normal');
	change_color_of_text_vars('hphonex','000000','normal');
	change_color_of_text_vars('bdayx','000000','normal');
	change_color_of_text_vars('genderx','000000','normal');
	change_color_of_text_vars('agreex','000000','normal');
	return;
}
function submit_form(){
	document.reg.submit_btn.disabled = true;
	document.reg.submit_btn.value='Processing...';
	document.reg.submit();
}




function main(){
	initialize();
	if (check_text_vars())
		submit_form();
}
</script>
