/******************************************************************************
 * This function will return a reference to an HTML element, or null if the
 * host browser does not support this operation.
 *
 * This function takes a single argument, a string, that specifies the name of
 * the HTML element to attempt to return.
 ******************************************************************************
 */
function getElement(element) {
	if (document.all) {
		// IE support document.all, but does not fully support
		// document.getElementById()
		return document.all[element];
	} else if (document.getElementById) {
		// Mozilla and its offspring (including NS6+) only support
		// document.getElementById()
		return document.getElementById(element);
	} else {
		// And, of course, there might be NS4 users using this - and their
		// browser doesn't support getting an element by name
		return null;
	}
}

/******************************************************************************
 * This function takes the HTML entered into the text area, and places it into
 * the innerHTML property of a div, so that the user can actually see what it
 * will look like in a browser
 ******************************************************************************
 */
function previewtext(formname,divname){
	var div = getElement(divname);
	// div will be null if the browser is not IE or not W3C DOM compliant
	if (div != null)
		div.innerHTML = formname.value;
}

/******************************************************************************
 * This function takes the HTML entered into the text area, and places it into
 * the innerHTML property of a div, so that the user can actually see what it
 * will look like in a browser
 ******************************************************************************
 */
function previewtext_code(code,divname){
	var div = getElement(divname);
	// div will be null if the browser is not IE or not W3C DOM compliant
	if (div != null)
		div.innerHTML = code;
}
