// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

//Thanks yayhooray (http://yayhooray.com/js/global.js)
function insertAtCursor(myField, myValue) {
	if (document.selection) { // IE
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	} else if (myField.selectionStart || myField.selectionStart == 0) {//MOZILLA/NETSCAPE support
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}

function update_postcount_in_title(count){
	count_string = '('+count+')';
	//wen title bereits ( enthält - ersetzen ), sonst anfügen
	if(matches = document.title.match(/(.*)\(\d\)(.*)/)){
		document.title = matches[1]+count_string+matches[2];
	}
	else{
		document.title = document.title + ' ' + count_string;	
	}
}