function addShError(li,msg){var sh_messages=new Hash({'sender_name_blank':'You must enter your Name','sender_email_blank':'You must enter a valid E-Mail address','forward_email_invalid':'Forward email address is invalid','empty_subject':'You must enter a subject for the email'});if(!li.hasClassName('withErrors')){var error_message='<div class="error">'+sh_messages.get(msg)+'</div>';li.addClassName("withErrors").insert({bottom:error_message});}}
function checkSHForm(default_subject){var error_count=0;var email_regexp=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;$$('#sh_form li.withErrors').each(function(error_li){error_li.removeClassName("withErrors")
error_li.down('.error').remove();});if($('sender_name').value==""){addShError($('sender_name').up('li'),'sender_name_blank');error_count+=1;}
if(!email_regexp.test($('sender_email').value)){addShError($('sender_email').up('li'),'sender_email_blank');error_count+=1;}
$$('#forwards li').each(function(li){if(li.down('input').present()&&!email_regexp.test(li.down('input').value)){addShError(li,'forward_email_invalid');error_count+=1;}});if($('subject').value==""){$('subject').value=$('sender_name').value+" "+default_subject;}
if(error_count==0){return true;}else{return false;}}