jQuery(document).ready(function() {

	jQuery('.message').keyup(function(){
        //get the limit from maxlength attribute
        var limit = parseInt(jQuery(this).attr('maxlength'));
        //get the current text inside the textarea
        var text = jQuery(this).val();
        //count the number of characters in the text
        var chars = text.length;

        //check if there are more characters then allowed
        if(chars > limit){
            //and if there are use substr to get the text before the limit
            var new_text = text.substr(0, limit);

            //and change the current text with the new text
            jQuery(this).val(new_text);
        }
	});
  
});

function changePersonalisationSelected(checked) {
	$('personalisation').disabled = !checked;
	if (checked) {
		if ($F('personalisation').length > 1) {
			$('personalisationSelector').setOption($F('personalisation'));
		}
	} else {
		$('personalisationSelector').setOption("0");
	}
}

function changePersonalisation() {
	selectedValue = $F('personalisation');
	$('personalisationSelector').setOption(selectedValue);
}
