function trim( str, charlist ) {    // Strip whitespace (or other characters) from the beginning and end of a string
    charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    var re = new RegExp('^[' + charlist + ']+|[' + charlist + ']+$', 'g');
    return str.replace(re, '');
}

$(document).ready(function() { 

	$('textarea').focus(function() {
		$(this).val(trim($(this).val()));
	});
	
	$('.addpost').click(function() {
		$('#postsform').show();
		$('#message').focus();
	});

	$('#fposts').submit(function() {
		// Ajax post method

	});
	
	if (document.location.hash=='#last') {
		var targetOffset = $('#footer').offset().top + $(this).height();
		$('#postsform').show();
		$('#message').focus();
		$('#postsform').hide();
	}
	
	$('#acard1').click(function() {
		$('#buy').show(); 
		$(':radio :checked').removeAttr('checked'); 
		$('input[value="CARD 1"]').attr('checked','checked');
	});
	$('#acard5').click(function() {
		$('#buy').show(); 
		$(':radio :checked').removeAttr('checked'); 
		$('input[value="CARD 5"]').attr('checked','checked');
	});

		
});
