

function charLimit(fieldRef,wordLimit,countRef) {
	//alert(fieldRef.value.length);
	/*var countRef = $("#countRef");
	
	charCount = charLimit - fieldRef.value.length;
	
	if(charCount < 0)
		fieldRef.value = fieldRef.value.substring(0,charLimit);
	
	countRef.innerHTML = charCount;*/
	
	var number = 0;
    var matches = $(fieldRef).val().match(/\b/g);
    if(matches)
        number = matches.length/2;
	
	if(number > wordLimit)
		alert("You have exceeded the "+ wordLimit+" word limit!");
		
	$(fieldRef).focus();
		
    $("#"+countRef).html( wordLimit - number );
	
}

function submitApp() {
	setConfirmUnload(false);
	$("#application").submit();
}

function setConfirmUnload(on) {
   
	window.onbeforeunload = (on) ? unloadMessage : null;

}

function unloadMessage() {
   
     return 'You have entered new data on this page.  If you navigate away from this page without first saving your data, the changes will be lost.';

}
