function checkUpload() {
	//alert("NOTE: After Previewing your post, you will have to complete the Attachment field again.")
}

function pnhTextareaInsert(taID, text1, text2, action) {

	var ta = document.getElementById(taID);
	
	// IE WINDOWS
	if (document.selection) {
		var str = document.selection.createRange().text;

		ta.focus();
		var sel = document.selection.createRange();
		
		if (action == "quote") {
			var myObject = new Object();
			myObject.sel = document.selection.createRange().text;
			var quoteInput = showModalDialog("editor/quote.aspx", myObject, "dialogWidth:25.5em;dialogHeight:15.5em");

			if (quoteInput != null && quoteInput != "") {
				startTag = quoteInput;
				endTag = "[\/quote]";
				
				// sel.text = startTag + endTag + "\n";
				sel.text = startTag + endTag + " ";
			} else {
				//sel.text = "[quote]" + "[/quote]" + "\n";
			}

		} else if (action == "url") {
			var myObject2 = new Object();
			myObject2.sel = document.selection.createRange().text;
			var urlInput = showModalDialog("editor/urls.aspx", myObject2, "dialogWidth:25.5em;dialogHeight:15.5em");

			if (urlInput != null && urlInput != "") {
				startTag = urlInput;
				endTag = "[\/url]";
				
				// sel.text = startTag + endTag + "\n";
				sel.text = startTag + endTag + " ";
			} else {
				//sel.text = "[quote]" + "[/quote]" + "\n";
			}

		} else {
			if (str != null && str != "") {
				// sel.text = text1 + str + text2 + "\n";
				sel.text = text1 + str + text2 + " ";
			} else {
				sel.text = text1 + text2 + " ";
			}
		}
		

	// MOZZILA
	} else if (ta.selectionStart | ta.selectionStart == 0) {

		if (action == "quote") {
			text1 = "[quote]";
			text2 = "[/quote]";
		} else if (action == "image") {
			text1 = "[image]";
			text2 = "[/image]";
		} else if (action == "url") {
			text1 = "[url]";
			text2 = "[/url]";
		}

		if (ta.selectionEnd > ta.value.length) { ta.selectionEnd = ta.value.length; }

		var firstPos = ta.selectionStart;
		var secondPos = ta.selectionEnd+text1.length; // cause we're inserting one at a time

		ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos);
		ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos);
		
		ta.selectionStart = firstPos+text1.length;
		ta.selectionEnd = secondPos;
		ta.focus();
	}	
}

function pnhEditTextarea(textarea_id, action) {

	var startTag = "";
	var endTag = "";
	
	switch (action) {
		case "bold":	
			startTag = "[bold]";
			endTag = "[\/bold]";
			break;
		case "italic":	
			startTag = "[italic]";
			endTag = "[\/italic]";
			break;
		case "underline":	
			startTag = "[underline]";
			endTag = "[\/underline]";
			break;
		case "codetag":	
			startTag = "[code]";
			endTag = "[\/code]";
			break;
		case "quote":
			break;
		case "image":
			startTag = "[image]";
			endTag = "[\/image]";
			break;
		case "url":
			//startTag = "[url]";
			//endTag = "[\/url]";
			break;
	
	}
	
	pnhTextareaInsert(textarea_id, startTag, endTag, action);

	return false;
}

function quoteUser() {
	var thisQuote = showModalDialog("quote.html", "", "font-family:Verdana;font-size:12;dialogWidth:30em;dialogHeight:35em");
	alert(thisQuote);
}
