$(document).ready(function(){checkForm();$("#submitButtonRegisterArea").bind("click",function(){checkForm();checkEmailAddress($("input[name=email]").val());if($("input[name=email_confirm]").val()!=$("input[name=email]").val()){$("#confirmEmail").show();$("#confirmEmail > #dontMatch").show();}else{$("#confirmEmail").hide();$("#confirmEmail > #dontMatch").hide();}
checkPassword($("input[name=password]").val());if($("input[name=password]").val().length<5){$("#errorPassword > #passwordTooShort").show();}else{$("#errorPassword > #passwordTooShort").hide();}
if($("input[name=firstname]").val()==""){$("#errorFirstname").show();}else{$("#errorFirstname").hide();}
if($("input[name=termsofuse]:checked").val()==undefined){$("#errorTermsOfUse").show();}else{$("#errorTermsOfUse").hide();}
if($("input[name=password]").val().length>14){$("#errorPassword > #passwordTooLong").show();}else{$("#errorPassword > #passwordTooLong").hide();$("#errorPassword").hide();}
if($("input[name=firstname]").val()==""){$("#errorFirstname").show();}else{$("#errorFirstname").hide();}
if($("input[name=companyname]").val()==""){$("#errorCompanyName").show();}else{$("#errorCompanyName").hide();}
if($("input[name=lastname]").val()==""){$("#errorLastname").show();}else{$("#errorLastname").hide();}
if($("input[name=lastname]").val()==""){$("#errorLastname").show();}else{$("#errorLastname").hide();}
if($("select[name=country_id]").val()==""){$("#errorCountry").show();}else{$("#errorCountry").hide();}
if($("#primaryEmail").css("display")=="none"&&$("#confirmEmail").css("display")=="none"&&$("#errorPassword").css("display")=="none"&&$("#errorFirstname").css("display")=="none"&&$("#errorCompanyName").css("display")=="none"&&$("#errorLastname").css("display")=="none"&&$("#errorCountry").css("display")=="none"&&$("#errorTermsOfUse").css("display")=="none"){document.registerUser.submit();}else{$("#errorRegister").show("fast");}});});function checkForm(){$("input[name=email]").bind("keypress",function(){if($(this).val()==""){$("#primaryEmail").show("fast");}
if($(this).val().length-1<6){$("#primaryEmail").show("fast");$("#primaryEmail > #tooShort").show();}else{$("#primaryEmail > #tooShort").hide();}
checkEmailAddress($(this).val());if($(this).val()!=""&&$(this).val().length-1>=6&&$("#primaryEmail > #incorrectAddress").css("display")=="none"){$("#primaryEmail").hide();}});$("input[name=email_confirm]").bind("keyup",function(){if($(this).val()!=$("input[name=email]").val()){$("#confirmEmail").show();$("#confirmEmail > #dontMatch").show();}else{$("#confirmEmail").hide();$("#confirmEmail > #dontMatch").hide();}});$("input[name=password]").bind("keyup",function(){checkPassword($(this).val());if($(this).val().length<5){$("#errorPassword > #passwordTooShort").show();}else{$("#errorPassword > #passwordTooShort").hide();}
if($(this).val().length>14){$("#errorPassword > #passwordTooLong").show();}else{$("#errorPassword > #passwordTooLong").hide();}});$("input[name=firstname]").bind("keyup",function(){if($(this).val()==""){$("#errorFirstname").show();}else{$("#errorFirstname").hide();}});$("input[name=lastname]").bind("keyup",function(){if($(this).val()==""){$("#errorLastname").show();}else{$("#errorLastname").hide();}});$("input[name=companyname]").bind("keyup",function(){if($(this).val()==""){$("#errorCompanyName").show();}else{$("#errorCompanyName").hide();}});$("select[name=country_id]").bind("change",function(){if($(this).val()==""){$("#errorCountry").show();}else{$("#errorCountry").hide();}});}
function checkEmailAddress(email){var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])*([a-zA-Z])/;if(pattern.test(email)){$("#primaryEmail > #incorrectAddress").hide();}else{$("#primaryEmail").show("fast");$("#primaryEmail > #incorrectAddress").show();}}
function checkPassword(password){var pattern=/^[0-9a-zA-Z]+$/;if(pattern.test(password)){$("#errorPassword > #wrongCharacters").hide();}else{$("#errorPassword").show("fast");$("#errorPassword > #wrongCharacters").show();}}
