(function() {
   $("#commentform").submit(function(e){
      var $this = this; var status=true;
	  
      if(jQuery.trim($('#get_nameape').val())==""){
		  $("#msg_getnamape").html($('#get_nameape').attr('title')).addClass('msg-error');$('#get_nameape').focus();
		  status=false;}else{
		  $("#msg_getnamape").html("").removeClass('msg-error');
	  }
	  
      if(jQuery.trim($('#get_mail').val())==""){$("#msg_mail").html($('#get_mail').attr('title')).addClass('msg-error'); $('#get_mail').focus(); status=false;
      }else{ 
        var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
        if(!filter.test($('#get_mail').val())) { $("#msg_mail").html($('#get_mail').attr('title')).addClass('msg-error');$('#get_mail').focus(); status=false;}
        else{ $("#msg_mail").html("").removeClass('msg-error'); }
      }

      if(jQuery.trim($('#get_comments').val())==""){$("#msg_comments").html($('#get_comments').attr('title')).addClass('msg-error');$('#get_comments').focus(); status=false;
      }else{ $("#msg_comments").html("").removeClass('msg-error');}


      if(jQuery.trim($('#get_securecode').val())=="" || $('#get_securecode').val().length!=5 ){$("#msg_sc").html($('#get_securecode').attr('title')).addClass('msg-error');$('#get_securecode').focus(); status=false;
      }else{ $("#msg_sc").html("").removeClass('msg-error');}
      
	  if(!status) return false;
   });
   
   $('#get_comments').keyup(function() {
     var charLength = $(this).val().length;
     var color = "";
     charLength = 2000 - charLength;
     if(charLength < 0) color = "#F00"; else color="#000";
     $('#count .counter').html(charLength).css("color",color);
   });
   var clearform = function(form){
      $(':input', form).each(function() {
        var type = this.type;
        var tag = this.tagName.toLowerCase();
        if (type == 'text' || tag == 'textarea'){
          this.value = "";
        }
      });
   }
   $('#get_comments').keyup();
})(jQuery);
