// This assigns the value of a text box to a hidden span tag for print
function loadTxtPrint(box){	 
	
	// Declare a variable to store the next DOM index of the element
	// that is calling this function.
	var nextBoxIndex;

	// Declare a variable to store a reference to the next 
	// DOM index element (our empty span tag).
	var oHidBox;

	// Get the "box" element's parent
	var boxParent = box.parentNode;

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		// Stores the DOM index of the calling Text box 
		// and adds 1 to that index. (Note: For IE Only)
		nextBoxIndex = box.sourceIndex + 1;

		// Stores a reference to the next DOM index
		// (our empty span tag, For IE only).
		oHidBox = document.all[nextBoxIndex];
	}
	else
	{
		/* 
		   Loop through the children of the "box" elements parents to find 
		   the index number of the "box" element in reference to it's parent
		*/
		var i;

		for(i=0; i<boxParent.childNodes.length; i++)
		{
			var tempNode = boxParent.childNodes[i];

			// Check to see if current element is the "box" element
			if(box == tempNode)
			{
				// Store the DOM index value of the element next to the "box" element
				nextBoxIndex = i + 1; 
			}
		}

		// Stores a reference to the next DOM element (our empty span tag).
		oHidBox = boxParent.childNodes[nextBoxIndex];
	}
	
	// Stores the text of the text box or text area.
	var sValue = box.value;

	// Writes the text into the empty span tag.
	oHidBox.innerHTML = sValue;
}

// This assigns the value of a select box to a hidden span tag for print
function loadSelPrint(box){	
	 
	// Declare a variable to store the next DOM index of the element
	// that is calling this function.
	var nextBoxIndex;

	// Declare a variable to store a reference to the next 
	// DOM index element (our empty span tag).
	var oHidBox;

	// Get the "box" element's parent
	var boxParent = box.parentNode;

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		// Stores the DOM index of the calling select box
		// and adds the number of options plus 1 to that index. (Note: For IE only)
		nextBoxIndex = box.sourceIndex + box.length + 1;

		// Stores a reference to the next DOM index
		// (our empty span tag, For IE only).
		oHidBox = document.all[nextBoxIndex];
	}
	else
	{
		/* 
		   Loop through the children of the "box" elements parents to find 
		   the index number of the "box" element in reference to it's parent
		*/
		var i;

		for(i=0; i<boxParent.childNodes.length; i++)
		{
			var tempNode = boxParent.childNodes[i];

			// Check to see if current element is the "box" element
			if(box == tempNode)
			{
				// Store the DOM index value of the element next to the "box" element
				nextBoxIndex = i + 1; 
			}
		}

		// Stores a reference to the next DOM element (our empty span tag).
		oHidBox = boxParent.childNodes[nextBoxIndex];
	}
		
	//Stores the index of the selected item of the calling Select box.
	var sel = box.selectedIndex;
		
	//Stores the text of the selected item using the Select box index.
	var sValue = box.options[sel].text;
		
	//Writes the Select box's selected text into the empty span tag.
	oHidBox.innerHTML = sValue;
}

// This assigns the check value of a radio button to a hidden check box for print.
function loadCheckBox(rdButton){

	// Get the parent of the "rdButton" element.
	var rdButtonParent = rdButton.parentNode;

	// Get the value of the name attribute of "rdButton".
	var rdButtonName = rdButton.name;

	// Find all the radio buttons related to "rdButton"
	var x = document.getElementsByName(rdButtonName);

	// Loop through all the radio buttons related to "rdButton" (input siblings) including the "rdButton" element.
	for(i=0; i<x.length; i++)
	{
		// Get the parents of all the input radio button sibling elements related 
		// to the "rdButton" element including the "rdButton" element.
		theParent = x[i].parentNode;

		// Loop through child elements of the parents of the input radio button sibling elements
		// (Note: Radio buttons related to "rdButton" can have different parents and true siblings
		//        depending on how the buttons' input tags are incased within other tags.) 
		for(j=0; j<theParent.childNodes.length; j++)
		{
			// Temporarily store the true sibling of the current radio button sibling
			tempNode = theParent.childNodes[j];

			// Check to see if current element is the original "rdButton" element
			if(tempNode == rdButton)
			{
				// Store the DOM index value of the element next to the "rdButton" element 
				// (its ture sibling, our hidden checkbox)
				nextNodeIndex = j + 1; 
			}
			else
			{
				// Check if the element in question has check value of true 
				// (if a previous button or checkbox was checked).
				if(tempNode.checked)
				{
					// Uncheck the buttons or checkboxes.
					tempNode.checked = false;
				}
			}
		}
	}

	// Stores a reference to the next DOM element after "rdButton" (our empty check box input tag).
	var hidCheckButton = rdButtonParent.childNodes[nextNodeIndex];
	
	// Set the check value of the next DOM element to the check value of the "rdButton" element.
	hidCheckButton.checked = rdButton.checked;
}
