function limitText() {
  var limitField = $('#advertiseMessage').get(0);  
  var limitNum = 800;
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

var p = "()-. 0123456789";
var e = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890@._-";
var n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .',-";
var s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

function res(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
		w += x;
	}
	t.value = w;
}
function res2(t){
	if (t.selectedIndex == 0) {
		alert("fill it out yo");
	}
}


$(document).ready(function() {

	
  $('#advertiseMessage').keydown(function(event){ limitText();});
  $('#advertiseMessage').keyup(function(event){ limitText();});
  
  $('#formSubmit').click(function(evt) {
    var form = $('#contactForm').get(0);
    var messageBox = $('#messageBox');
    
    if (! form.validator.validate()) return false;
    messageBox.html('<img src="images/loadingAnimation.gif">');
    $.ajax({
       type: "POST",
       timeout: 15000,
       url:  form.action,
       data: $('input[@type=text],input[@type=hidden],input[@type=checkbox][@checked],textarea').serialize(),
       success: function(msg){	
		form.reset();
        messageBox.html('Message sent!');
       },
       error: function(msg){
        messageBox.html('Message send error.');
       } 
    });
    return false;
  });
});

function clearStatus() {
	var messageBox = $('#messageBox');
	messageBox.html('');
}
<!--
function clearInput(){
   objForm=document.forms["contactForm"];
   // objForm.reset();
   objForm.validator.resetValidators(objForm);
   for(x=0; x<objForm.elements.length;x++){
      if(objForm.elements[x].type != "reset" && objForm.elements[x].type !="submit"  && objForm.elements[x].type !="button"){
         objForm.elements[x].value="";
      }
   }
}
//-->
