function validateArtist(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"artist");}if(C.isEmpty(B.name.value)){C.raiseError("Please enter a name",B.name);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateWork(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"work");}if((!C.isNumber(B.artist.value)||(B.artist.value<1))){C.raiseError("Please choose an artist",B.artist);}if(B.image!=null){if(C.isEmpty(B.image.value)&&(!C.isNumber(B.file.value)||(B.file.value<1))){C.raiseError("Please upload a file",B.image);}}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateTagCategory(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"tag category");}if(C.isEmpty(B.name.value)){C.raiseError("Please enter a name",B.name);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateTag(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"tag");}if(C.isEmpty(B.tag_name.value)){C.raiseError("Please enter a name",B.tag_name);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateNews(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"article");}if(C.isEmpty(B.title.value)){C.raiseError("Please enter a title",B.title);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validatePage(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"page");}if(C.isEmpty(B.title.value)){C.raiseError("Please enter a title",B.title);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateLocation(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"location");}if(C.isEmpty(B.title.value)){C.raiseError("Please enter a title",B.title);}if(C.isEmpty(B.address_1.value)){C.raiseError("Please enter an address",B.address_1);}if(C.isEmpty(B.city.value)){C.raiseError("Please enter a city",B.city);}if(C.isEmpty(B.postcode.value)){C.raiseError("Please enter a postcode",B.postcode);}if(C.isEmpty(B.country.value)){C.raiseError("Please enter a country",B.country);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateContact(B,A){var C=new formValidator();C.clearErrors();if(A){return confirmDelete(B,"contact");}if(C.isEmpty(B.firstname.value)){C.raiseError("Please enter a first name",B.firstname);}if(C.isEmpty(B.lastname.value)){C.raiseError("Please enter a last name",B.lastname);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateFAQ(B,A){var C=new formValidator();C.clearErrors();if(A){return confirmDelete(B,"FAQ");}if(C.isEmpty(B.question.value)){C.raiseError("Please enter a question",B.question);}if(C.isEmpty(B.answer.value)){C.raiseError("Please enter an answer",B.answer);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateLogin(A){var B=new formValidator();B.clearErrors();if(B.isEmpty(A.user.value)){B.raiseError("Please enter an email address",A.user);}else{if(!B.isEmailAddress(A.user.value)){B.raiseError("Please enter a valid email address",A.user);}}if(B.isEmpty(A.pwd.value)){B.raiseError("Please enter your password",A.pwd);}if(B.numErrors()>0){B.displayErrors();return false;}return true;}function validateRegister(B,A){var C=new formValidator();C.clearErrors();if(A){return confirmDelete(B,"user");}if(C.isEmpty(B.name.value)){C.raiseError("Please enter a name",B.name);}if(C.isEmpty(B.email.value)){C.raiseError("Please enter an email address",B.email);}else{if(!C.isEmailAddress(B.email.value)){C.raiseError("Please enter a valid email address",B.email);}}if(C.isEmpty(B.pwd.value)){C.raiseError("Please enter a password",B.pwd);}if(C.isEmpty(B.pwd_conf.value)){C.raiseError("Please confirm your password",B.pwd_conf);}if(B.pwd.value!=B.pwd_conf.value){C.raiseError("Please check your passwords match",B.pwd);}if(C.isEmpty(B.country.value)){C.raiseError("Please choose a country",B.country);}if(!C.isRadioChecked(B.type)){C.raiseError("Please specify the type of account",B.type[0]);}else{if(C.getRadioValue(B.type)==1){if(C.isEmpty(B.business_name.value)){C.raiseError("Please enter the name of your company",B.business_name);}if(C.isEmpty(B.business_position.value)){C.raiseError("Please specify your job title",B.business_position);}}}if(C.isEmpty(B.business_telephone.value)){C.raiseError("Please enter a phone number",B.business_telephone);}if(!C.isChecked(B.tandc)){C.raiseError("You must agree to the Terms &amp; Condiitons",B.tandc);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function validateAccount(A){var B=new formValidator();B.clearErrors();if(B.isEmpty(A.name.value)){B.raiseError("Please enter a name",A.name);}if(B.isEmpty(A.email.value)){B.raiseError("Please enter an email address",A.email);}else{if(!B.isEmailAddress(A.email.value)){B.raiseError("Please enter a valid email address",A.email);}}if(B.isEmpty(A.country.value)){B.raiseError("Please choose a country",A.country);}if(B.isRadioChecked(A.type)==false){B.raiseError("Please specify the type of account",A.type);}else{if(B.getRadioValue(A.type)==1){if(B.isEmpty(A.business_name.value)){B.raiseError("Please enter the name of your company",A.business_name);}if(B.isEmpty(A.business_position.value)){B.raiseError("Please specify your position",A.business_position);}}}if(B.numErrors()>0){B.displayErrors();return false;}return true;}function validateRequest(A){var B=new formValidator();B.clearErrors();if(B.isEmpty(A.name.value)){B.raiseError("Please enter a name",A.name);}if(B.isEmpty(A.email.value)){B.raiseError("Please enter an email address",A.email);}else{if(!B.isEmailAddress(A.email.value)){B.raiseError("Please enter a valid email address",A.email);}}if(B.isEmpty(A.country.value)){B.raiseError("Please choose a country",A.country);}if(!B.isRadioChecked(A.type)){B.raiseError("Please specify the type of account",A.type[0]);}else{if(B.getRadioValue(A.type)==1){if(B.isEmpty(A.business_name.value)){B.raiseError("Please enter the name of your company",A.business_name);}if(B.isEmpty(A.business_position.value)){B.raiseError("Please specify your job title",A.business_position);}}}if(B.isEmpty(A.business_telephone.value)){B.raiseError("Please enter a phone number",A.business_telephone);}if(B.numErrors()>0){B.displayErrors();return false;}return true;}function validatePassword(A){var B=new formValidator();B.clearErrors();if(B.isEmpty(A.pwd_current.value)){B.raiseError("Please enter your current password",A.pwd_current);}if(B.isEmpty(A.pwd_new.value)){B.raiseError("Please enter your new password",A.pwd_new);}if(B.isEmpty(A.pwd_new_conf.value)){B.raiseError("Please confirm your new password",A.pwd_new_conf);}if(!B.isEmpty(A.pwd_new.value)&&!B.isEmpty(A.pwd_new_conf.value)&&A.pwd_new.value!=A.pwd_new_conf.value){B.raiseError("Your passwords do not match!",A.pwd_new);}if(B.numErrors()>0){B.displayErrors();return false;}return true;}function validateDeactivate(A){var B=new formValidator();B.clearErrors();if(B.isEmpty(A.pwd.value)){B.raiseError("Please enter your password",A.pwd);}if(B.isEmpty(A.pwd_conf.value)){B.raiseError("Please confirm your password",A.pwd_conf);}if(!B.isEmpty(A.pwd.value)&&!B.isEmpty(A.pwd_conf.value)&&A.pwd.value!=A.pwd_conf.value){B.raiseError("Your passwords do not match!",A.pwd_new);}if(!B.isChecked(A.deactivate)){B.raiseError("You must must confirm your deactivation",A.deactivate);}if(B.numErrors()>0){B.displayErrors();return false;}return true;}function validateLightbox(B,A){var C=new formValidator();C.clearErrors(B);if(A){return confirmDelete(B,"lightbox");}if(C.isEmpty(B.name.value)){C.raiseError("Please enter a name",B.name);}if(C.numErrors()>0){C.displayErrors();return false;}return true;}function confirmDelete(A,B){if(confirm("Are you sure you sure you want to delete this "+B+"?")){if(A.action.indexOf("/account/tags/")>0){A.action="/account/tags/delete/"+A.id.value;}else{A.action=A.action.replace(/edit|create/,"delete");}return true;}else{return false;}}function confirmRevert(){if(confirm("Are you sure you want to revert to the last saved version?")){return true;}else{return false;}}function formValidator(){this.errorList=new Array;this.isEmpty=function(A){return(A.match(/^\s*$/)!=null);};this.isNumber=function(A){return(!isNaN(A));};this.isAlphabetic=function(A){return(A.match(/^[a-zA-Z]+$/)!=null);};this.isAlphaNumeric=function(A){return(A.match(/^[a-zA-Z0-9]+$/)!=null);};this.isURLValid=function(A){return(A.match(/^(http:\/\/)?[\.\/a-zA-Z0-9_-]+/)!=null);};this.isValidChars=function(B,A){return(B.match(A)!=null);};this.isWithinRange=function(C,B,A){return(C>=B&&C<=A);};this.isEmailAddress=function(A){return(A.match(/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/)!=null);};this.isChecked=function(A){return A.checked;};this.isRadioChecked=function(B){for(var A=B.length-1;A>=0;A--){if(B[A].checked==true){return true;}}return false;};this.getRadioValue=function(B){for(var A=B.length-1;A>=0;A--){if(B[A].checked==true){return B[A].value;}}};this.displayErrors=function(){for(var B=this.errorList.length-1;B>=0;B--){var A=this.errorList[B];var C=$('<div class="validation error"><p>'+A[0]+"</p></div>");$(A[1]).parents(".row:eq(0)").prepend(C);}displayError("Error","There are errors in the form. Please correct them.");$(this.errorList[0][1]).focus();};this.clearErrors=function(A){$(A).find("div.validation.error").remove();$(A).find("input.error").removeClass("error");};this.raiseError=function(B,A){this.errorList[this.errorList.length]=new Array(B,A);};this.numErrors=function(){return this.errorList.length;};}