function ajax_toggle(action, elem){


           $.ajax({
           type: "GET",
           url: action,        
           success: function(msg){
                
                $(elem).html(msg); // this updates the internal html of the a - so we can toggle 1 and 0
				            
           }
           });



}



function limitChars(textid, limit, infodiv){
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
		return true;
	}
}
/**
*	Add a listener to all links with a class of toggle
*	Then call the ajax_toggle function with a param of the action to be called
*/

$(document).ready(function(){ 

	$('a.toggle').click(function() {
	
		ajax_toggle($(this).attr('href'), $(this));
		
		return false; // remember to disable the normal click function
	
	});
	
	
	
  	

	
    
});

