// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function postLinksInNewWindow() {
	$$('.post .body a').each(function(a) {
		if(!a.href.match(window.location.protocol+'//'+window.location.host)) {
			//alert(a.href);
			a.target = '_blank';
		}
	});
}

function appendTag(element, tag) {
	if(element.value== "") {
		element.value = tag
	}
	else {
		var tags = element.value.split(/ *, */);
		var i;
		if((i = tags.indexOf(tag)) < 0) {
			tags.push(tag);
		}
		else {
			tags = tags.without(tag)
		}
		element.value = tags.sort().join(', ');
	}
}