/*
written by meg hourihan
http://www.megnut.com
meg@megnut.com

and modified quite a bit (to include image
src and email writing) by Avi Muchnick
http://www.worth1000.com
avi@worth1000.com

warning: it only works for IE4+/Win 
feel free to take it for your site
but leave this text in place.
any problems, let meg know.
*/


function mouseover(el) {
	el.className = "raise";
	}

function mouseout(el) {
	el.className = "buttons";
}

function mousedown(el) {
	el.className = "press";
}

function mouseup(el) {
	el.className = "raise";
}
	
	
function format_me(v) {
	var str = document.selection.createRange().text;
	document.form1.comments.focus();
	document.selection.createRange().text = "[" + v + "]" + str + "[/" + v + "]";
	return;
}

function insert_image() {
	var str = document.selection.createRange().text;
	document.form1.comments.focus();
	var my_link = prompt("Enter the Image URL:","http://");
	if (my_link != null) {
		document.selection.createRange().text = "[img=\"" + my_link + "\"]" + str + "";
	}
	return;
}

function insert_link() {
	var str = document.selection.createRange().text;
	document.form1.comments.focus();
	var my_link = prompt("Enter URL:","http://");
	if (str != "") {
		var my_text = str;
	}
	if (str == "") {
		var my_text = prompt("Enter some text:","");
	}
	if (my_text == "") {
		my_text = my_link;
	}
	if (my_link != null) {
		document.selection.createRange().text = "[URL=\"" + my_link + "\"]" + my_text + "[/URL]";
	}
	return;
}

function insert_email() {
	var str = document.selection.createRange().text;
	document.form1.comments.focus();
	var my_link = prompt("Enter email address:","email@address.com");
	if (str == "") {
		str = my_link;
	}
	if (my_link != null) {
		document.selection.createRange().text = "[URL=\"mailto:" + my_link + "\"]" + str + "[/URL]";
	}
	return;
}

function shortCuts() {
	if (event.ctrlKey != true) return;
	if (event.keyCode == 1) insert_link();
	if (event.keyCode == 5) insert_email();
	if (event.keyCode == 16) insert_image();
	if (event.keyCode == 2) format_me('b');
	if (event.keyCode == 9) format_me('i');
}


