	//
	//	This function will create a new child node for the given parent.
	//	The new node will be created after the last child for this parent.
	//
	function appendNode(docpath, sNewName, sParentName, sStyle, sContent, sNewNodeType) {
		var MainNode = docpath.getElementById(sParentName);
		var newNode = docpath.createElement(sNewNodeType);	// this will create a new div
		newNode.setAttribute('name', sNewName);
		newNode.setAttribute('id', sNewName);
		setStyle(newNode, sStyle);
		MainNode.appendChild(newNode);		// add on the new div
		if (sContent.length > 0 ) {
			newNode.innerHTML = sContent;
		}
	}
	
	//	
	//	This function loops through all elements of a radio group to determine which
	//	one is selected and returns the value of the selected item
	//
	function getRadioValue(rRadioObject) {
		var nRadioElements = rRadioObject.length;
		
		for (var i=0; i < nRadioElements; i++) {
  			    if (rRadioObject[i].checked == true) {
	            return rRadioObject[i].value;
			}
		}    
	}
	
	//
	//	This function will toggle the given element between inline and none display values
	//
	function toggleElement(sElement) {
		ThisElement = document.getElementById(sElement);
		if (ThisElement.style.display == "inline") {
			ThisElement.style.display = "none";
		} else {
			ThisElement.style.display = "inline";
		}
	}
		

	//
	//	This function expands on the round method to allow us to specify the number of decimals
	//
	function round(nValue, nDecimals) {
//		alert(nValue + ":" + nDecimals);
		nDecimals = (!nDecimals ? 0 : nDecimals);
		return Math.round(nValue*Math.pow(10,nDecimals))/Math.pow(10,nDecimals);
	}
	
	function numberOrder(a,b) { 
		return a-b;
	}

	//
	//	This function will check to see if the filename is one of the approved types and return true
	//	or false.  If a block number is passed, the alert message will mention the block.
	//	
	function checkFileType(sImageName, nBlockID) {
		sFileExtension = sImageName.substring(sImageName.length-4).toLowerCase();
		if ( (sFileExtension == ".jpg") || (sFileExtension == ".gif") || (sFileExtension == ".png")) {
			return true
		} else {
			if (nBlockID > 0) {
				alert("You can only upload JPG, GIF, or PNG images.  " 
				+ "You need to change the image " + sImageName
				+ "you selected in block " + nBlockID + ".");
			} else {
				alert ("You can only upload JPG, GIF, or PNG images.");
			}
			return false;
		}
	}

	// Removes leading and trailing spaces from the passed string. Also removes
   	// consecutive spaces and replaces it with one space. If something besides
   	// a string is passed in (null, custom object, etc.) then return the input.
	function trim(inputString) {
		if (typeof inputString != "string") {
			return inputString; 
		}
		var retValue = inputString;
		var ch = retValue.substring(0, 1);
		
		// Check for spaces at the beginning of the string
		while (ch == " ") {
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		
		// Check for spaces at the end of the string
		while (ch == " ") { 
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
		}
		
		// Note that there are two spaces in the string - look for multiple spaces within the string		
		while (retValue.indexOf("  ") != -1) {
			// Again, there are two spaces in each of the strings
			retValue = retValue.replace("  ", ""); 
		}
   		
		// Return the trimmed string back to the user
		return retValue;
	}
	
	//
	//	This function takes an Element and then applies a given style string to it
	//	by breaking it up into key:value pairs and applying each seperatly
	//
	function setStyle(rElement, sStyle) {
		arProperties = sStyle.split(";");
		var i;
		for (i=0; i<arProperties.length; i++) {
			arKeyValue = arProperties[i].split(":");
			sKey = trim(arKeyValue[0]);
			if (sKey.indexOf("-") > 0) {
				nDashPos = sKey.indexOf("-");
				sKey = sKey.substring(0, nDashPos) 
					+ sKey.substring(nDashPos+1, nDashPos+2).toUpperCase() 
					+ sKey.substring(nDashPos+2, sKey.length);
			}
			sValue = trim(arKeyValue[1]);
			rElement.style[sKey]=sValue;
		}
	}
