// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//oLD FUNTION RIMOSSA DOPO AVER MESSO IL CODEPRESS
// function insertContentLinkAtCursor(myValue, id, type) {
// 	if (type != "link") {
// 		myValue = '!'+myValue+'! ';
// 	}else{
// 		myValue = '<'+myValue+'> ';
// 	}
// 
// 	if($(id) != null){
// 		insertAtCursor(myValue, id);
// 	}
// 	return false;
// }

function cpInsertContentLinkAtCursor(myValue, id, type) {
	
	if (type != "link") {
		myValue = '!'+myValue+'! ';
	}else{
		myValue = '<'+myValue+'> ';
	}

	if($(id) != null){
		cpInsertAtCursor(myValue, id);
	}
	return false;
}

function insertLinkAtCursor(myValue, id) {
	if($(id) != null){	
		cpInsertAtCursor(myValue, id);
	}
	return false;
}


// function insertAtCursor(myValue, id) {
// 	var myField = $(id);
// 
// 	if (document.selection){ //IE support
// 		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;
// 		}
// 		return false;
// 	}

function cpInsertAtCursor(myValue, id) {
	var nobj = eval(id.replace("_cp", ""))
	nobj.insertCode(myValue, false);
	return false;
}


