// JavaScript Document
// TOOLBOX COLLECTION
/* These functions are used throughout the site to do cleanup & processing of strings & xml data */


//this function removes extra spaces and tabs from string data
function cleanSpaces(thisString) {
	//alert("cleanSpaces was called");
	
	thisString = thisString.replace(/(^\s*)|(\s*$)/g, "");
	thisString = thisString.replace(/(^\s*)/g, "");
	thisString = thisString.replace(/(\s*$)/g, "");
	thisString = thisString.replace("\t", "");	
	
	return thisString;
}

//this function turns line breaks in a string (from xml) into separate items so they can be converted into HTMl <p> 
function splitLineBreaks(thisString) {
	//alert("splitLineBreaks was called");
	
	thisString = thisString.split("\n");
	
	return thisString;
}

//this function create <p> tags and adds them to a specified DOM element
function addParagraphs(thisString, parentNode) {
	//alert("addParagraphs called");
	
	if (thisString.length >= 1) {
		var thisP = document.createElement("p");
		var thisText = document.createTextNode(thisString);
		thisP.appendChild(thisText);
		parentNode.appendChild(thisP);
	}
}


//this function returns the text from a specified text node
function getValue(num, list, name) {
	//alert("getValue was called");
	var myValue = null;
	var myList = list[i].getElementsByTagName(name);
	if (myList[0].childNodes[0] != null)
	{
		myValue = myList[0].childNodes[0].nodeValue;
	}
	
	else 
	{
		myValue = "";	
	}
	//alert("getValue is returning: " + myValue);
	return myValue;
}


