function getAjax() {
	var xmlHttp=null;
	try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
	catch (e) {
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } // Internet Explorer
		catch (e) {
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				return false;
			}
		}
	}
	return xmlHttp;
}

var xmlHttp=getAjax();

function insertAtCursor(myField, myValue, documentRef) {
	//IE support
	if (document.selection) {
		myField.focus();

		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = documentRef.selection.createRange();
		sel.text = myValue;
		self.focus();
	}
	
	//Mozilla/Firefox/Netscape 7+ support
	else if (myField.selectionStart || myField.selectionStart == '0') {
	
		//Here we get the start and end points of the
		//selection. Then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//Then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		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 validateBlank(formID, objectID, message) {
	var formRef = document.getElementById(formID);
	var objectRef = document.getElementById(objectID);
	var container = document.getElementById('error');

	if(objectRef.value=='') {
		alert(message);
	} else {
		formRef.submit();
	}
}
function showBBCode() {
	BBCode = window.open('/includes/forums/bbCodeExamples.php', 'BBCode', 'location=0,status=0,scrollbars=1,width=500,height=600');
}