
function winkle(f){
	var s = '#commentbody';
	$(s).val(filterInput( $(s).val() ));
	f.action = f.action + "&chk=cheeseyfringe";
	f.submit();
}
function preview(selector)
{
	var filtered = filterInput($(selector).val());
	$("#preview-pane").html(filtered);
}
/* @see
	http://komodomedia.com/blog/2008/07/using-jquery-to-save-form-details
*/
function remember(selector){
	$(selector).each(function(){
		var name = $(this).attr('name');
    		if($.cookie(name)) $(this).val( $.cookie(name) );
		$(this).change(function(){
			$.cookie(name, $(this).val(), { path: '/', expires: 365 });
		});
	});
}
/* Convert hrefs and line-feeds, strip out certain tags */
function filterInput(markup)
{
	// 1. Convert links
	var f = markup.replace(/(\w+:\/\/[^\s]*)/g, '<a href=\"$1\">$1</a>');
	// 2. Convert ampersands and linefeeds
	f = f.replace(/&/g, '&amp;');
	f = f.replace(/\n/g, "<br />");
	// 3. Convert scripts and objects
	f = f.replace(/<\s*script[^>]*>[\s\S]*?<\/script>/mig, "(Naughty script removed)");
	f = f.replace(/<\s*object[^>]*>[\s\S]*?<\/object>/mig, "(Naughty object removed)");
	return f;
}

