function changeClass(element,className)
{
  element.className = className;
}

function openWindowNoControl(url){
  window.open(url,'','width=600,height=400,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no')
}

function showProcessing() 
{
if (document.getElementById("content"))
	{
		// getElementByID() is the preffered way to access page variables (but it doesn't work in all instances, that's why there an else if)
		// document.getElementById("content").style.display = "none"; // this line was commented out because it was breaking post backs to the same page on mozilla
		  document.getElementById("content").style.visibility = "hidden";
		document.getElementById("processing").style.display = "inline";
		document.getElementById("processing").style.visibility = "visible";
		document.images["progressImage"].src = document.images["progressImage"].src;
	}
	else if (document.all) 
	{
		// old versions of msie support document.all instead of getElementByID()
		document.all["content"].style.display = "none";
		document.all["content"].style.visibility = "hidden";
		document.all["processing"].style.display = "inline";
		document.all["processing"].style.visibility = "visible";
		document.images["progressImage"].src = document.images["progressImage"].src;
	}
	else if (document.layers)
	{
		// and some browsers only support layers (nn4)
		document.layers["content"].display = "none";
		document.layers["content"].visibility = "hidden";
		document.layers["processing"].display = "inline";
		document.layers["processing"].visibility = "visible";
	}
	window.scroll(0,0);
}

function hideProcessing() 
{
	if (document.getElementById("content")) 
	{
		// getElementByID() is the preffered way to access page variables (but it doesn't work in all instances, that's why there an else if)
		document.getElementById("processing").style.visibility = "hidden";
		document.getElementById("processing").style.display = "none";
		document.getElementById("content").style.visibility = "visible";
		document.getElementById("content").style.display = "inline";
	}
	else if (document.all) 
	{
		// old versions of msie support document.all instead of getElementByID()
		document.all["processing"].style.visibility = "hidden";
		document.all["processing"].style.display = "none";
		document.all["content"].style.visibility = "visible";
		document.all["content"].style.display = "inline";
	}
	else if (document.layers) 
	{
		// and some browsers only support layers (nn4)
		document.layers["processing"].visibility = "hidden";
		document.layers["processing"].display = "none";
		document.layers["content"].visibility = "visible";
		document.layers["content"].display = "inline";
	}
	window.scroll(0,0);
}

function getHiddenFormInputData(thisform){
	
	var myURL
	//var myDataSetKey
	//var myDataSetKey
	
	//myDataSetKey = thisform.elements.DataSetKey.value
	//myDataSetKeyValue = thisform.elements.DataSetKeyValue.value

	myURL = "/ContentMap/ContentViewer.aspx?Dynamic=1"

	window.open(myURL,'ContentViewer');
	//window.showHelp(myURL);

}
function getHiddenFormInputDataStatic(){
	
	var myURL
	//var myDataSetKey
	//var myDataSetKey
	
	//myDataSetKey = thisform.elements.DataSetKey.value
	//myDataSetKeyValue = thisform.elements.DataSetKeyValue.value

	myURL = "/ContentMap/ContentViewer.aspx"

	window.open(myURL,'ContentViewer');
	//window.showHelp(myURL);

}
function openHelpWindow(URL){
	HelpWindow=window.open(URL,"Help","toolbar=1,location=1,status=1,menubar=1,scrollbars,resizable")
	HelpWindow.focus();
	hideProcessing();
}

function getHiddenFormInputToChild()
{
	var myDataSetKey
	var myDataSetKeyValue
	var bothKeys
	var retval = ""
	for (var i = 0; i < document.forms[0].elements.length; i++) 
	{ 
		if(document.forms[0].elements[i].name == "DataSetKey") {
			myDataSetKey = document.forms[0].elements.DataSetKey.value
			
			myDataSetKeyValue = document.forms[0].elements.DataSetKeyValue.value
			
			bothKeys = myDataSetKey + "|" + myDataSetKeyValue
	
			retval = bothKeys 

			break;
		}
		else
		{
			retval = 0
		}
	}
	return retval;
}

function getHiddenFormInputToChildReportInfo()
{
	var myReportInformation
	var retval = ""
	try{
		for (var i = 0; i < document.forms[0].elements.length; i++) 
		{ 
			if(document.forms[0].elements[i].name == "ReportInformation") {
				myReportInformation = document.forms[0].elements.ReportInformation.value
			
				retval = myReportInformation 
				break;
			}
			else
			{
				retval = 0
			}
		}
		return retval;
		}
	catch(er){
	return 0;
	}
}

function getHiddenFormInputToChildConInfo()
{
	var mySName
	var myDName
	var myCString
	var theKeys
try{
	mySName = document.forms[0].elements.SName.value;
	
	myDName = document.forms[0].elements.DName.value;
	
	myCString = document.forms[0].elements.CString.value;
	
	theKeys = mySName + "|" + myDName + "|" + myCString;
		
	return theKeys;
	}
catch(er){
	return 0;
}

}

// Used by the PDF printer
function StartPDFPrint(isdebug)
{
	var htmlToPrint;
	var upperCharLimit = 30000; // macs have a posting-variable size limit of 32000, that's why it's so small //90000; // 102399;
	var iter;
	var marker = 0;

	// Tell the user that we have started the pdf printing process
	window.open("/pdfGenerating.aspx","PDFWindow","width=600,height=400,resizable=yes").focus();

	// Clean out all the htmltoprinttopdf variables just in case this page has already been printed (we don't want our html to recursively double with each print)
	iter = 0;
	while (document.PDFForm.elements[iter] != null)
	{
		if (document.PDFForm.elements[iter].name.indexOf("htmltoprinttopdf") > -1)
			document.PDFForm.elements[iter].value = "";
		if (document.PDFForm.elements[iter].name.indexOf("isdebug") > -1)
			document.PDFForm.elements[iter].value = "";
		iter++;
	}

	// The outerHTML call is IE specific, so for other browsers we need to waste time parsing through the page element by element
	if (navigator.userAgent.toLowerCase().indexOf("msie") > -1)
		htmlToPrint = document.documentElement.outerHTML;
	else if (navigator.userAgent.toLowerCase().indexOf("safari") > -1)
	{  // currently we do not support printing on safari because we cannot get comments to come through
		CreateFormInput("HIDDEN", "unsupportedbrowser", "Safari", document.PDFForm);
		document.PDFForm.submit();
		return;
	}
	else
		htmlToPrint = GetOuterHTML(document.documentElement);
	htmlToPrint = CleanText(htmlToPrint, "<!-- BEGIN_PDF_PRINTABLE -->", "<!-- END_PDF_PRINTABLE -->");

	// This gets rid of the ", " that gets inserted at the end of the html because of the last line, it's kindof an interesting problem of why it gets inserted:)
	if (htmlToPrint.substring(htmlToPrint.length - 4, htmlToPrint.length) == "\", \"")
		htmlToPrint = htmlToPrint.substring(0, htmlToPrint.length - 4)
	if (htmlToPrint.substring(0, 4) == "\", \"")
		htmlToPrint = htmlToPrint.substring(4, htmlToPrint.length)

	// If the data is too big to fit in one variable split it up
	iter = 0;
	while (htmlToPrint.length - marker > upperCharLimit)
	{
		CreateFormInput("HIDDEN", "htmltoprinttopdf" + iter, htmlToPrint.substring(marker, marker + upperCharLimit), document.PDFForm);
		iter++;
		marker += upperCharLimit;
	}
	CreateFormInput("HIDDEN", "htmltoprinttopdf" + iter, htmlToPrint.substring(marker, marker + upperCharLimit), document.PDFForm);

	// If we are in debug mode pass it on to the component
	if (isdebug == 'debug')
		CreateFormInput("HIDDEN", "isdebug", "debug", document.PDFForm);

	document.PDFForm.submit();
}

// Used by the PDF printer
function StartPDFPrintFitToPage(isdebug)
{
	CreateFormInput("HIDDEN", "isFitToPage", "yes", document.PDFForm);
	StartPDFPrint(isdebug);
}

// Used by the PDF printer
function CreateFormInput(inputType, inputName, inputValue, formToAddTo)
{
	var newElement;
	var elementIndex;

	elementIndex = GetFormElementIndex(formToAddTo, inputName);
	if (elementIndex == -1)
	{
		newElement = document.createElement("INPUT");
		newElement.type = inputType;
		newElement.name = inputName;
		newElement.value = inputValue;
		formToAddTo.appendChild(newElement);
	}
	else
	{
		formToAddTo.elements[elementIndex].value = inputValue
	}
}

// Used by the PDF printer
function GetFormElementIndex(formToCheck, elementName)
{
	var iter = 0;
	var retVal = -1;

	while (formToCheck.elements[iter] != null)
	{
		if (formToCheck.elements[iter].name == elementName)
		{
			retVal = iter;
			iter = 1000; // break out of the loop
		}
		iter++;
	}
	return retVal;
}

// Used by the PDF printer
function CleanText(text, beginPrint, endPrint)
{
	var retVal = "";
	var beginLocation;
	var endLocation;

	beginLocation = text.indexOf(beginPrint);
	while (beginLocation > -1)
	{
		beginLocation = beginLocation + beginPrint.length;
		endLocation = text.indexOf(endPrint, beginLocation);
		if (endLocation > -1)
		{
			retVal = retVal + text.substring(beginLocation, endLocation);
			beginLocation = text.indexOf(beginPrint, endLocation + endPrint.length);
		}
		else
		{
			// There is no final endPrint so just grab the rest of the text
			retVal = retVal + text.substring(beginLocation, text.length);
			beginLocation = -1;
		}
	}
	return retVal;
}

// Used by the PDF printer
function GetOuterHTML(node)
{
	var html;
	var iter;

	if (node.nodeType == 3)
		return node.nodeValue;
	else if (node.nodeType == 8)
		return "<!--" + node.nodeValue + "-->"
	else if (node.nodeType == 1)
	{
		html = "";
		html += "<" + node.nodeName;
		for (iter = 0; iter < node.attributes.length; iter++)
		{
			if (node.attributes[iter].nodeValue != null)
			{
				if (node.attributes[iter].nodeValue != "")
					html += " " + node.attributes[iter].nodeName + "=\"" + node.attributes[iter].nodeValue + "\"";
				else
					html += " " + node.attributes[iter].nodeName;
			}
		}
		if (node.childNodes.length == 0)
			html += ">";
		else
		{
			html += ">";
			for (iter = 0; iter < node.childNodes.length; iter++)
				html += GetOuterHTML(node.childNodes[iter]);
			html += "<\/" + node.nodeName + ">";
		}
		return html;
	}
}

function strrev(str) 
{
	if (!str) return '';
		var revstr='';
		for (i = str.length-1; i>=0; i--)
			revstr+=str.charAt(i)
		return revstr;
}

function verttext(str)
		{
			myString = new String(str);
			myString = strrev(myString);
			splitString = myString.split("");
			document.write("<table border=0 cellpadding=0 cellspacing=0>");
			for ( var i=0; i < myString.length ; i++ ) {
		
				var upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
				var lower="abcdefghijklmnopqrstuvwxyz";
				var numbers="0123456789";

				document.write("<tr><td>");

				if (upper.indexOf(splitString[i]) != "-1")
					document.write("<img src=\"Shared/CTB/images/vertText/big" + splitString[i] + ".gif\" border=0>");

				if (lower.indexOf(splitString[i]) != "-1")
					document.write("<img src=\"Shared/CTB/images/vertText/small" + splitString[i] + ".gif\" border=0>");

				if (numbers.indexOf(splitString[i]) != "-1")
					document.write("<img src=\"Shared/CTB/images/vertText/" + splitString[i] + ".gif\" border=0>");

				if (splitString[i] == " ")
					document.write("<img src=\"Shared/CTB/images/vertText/space.gif>\"");
					
				document.write("</td></tr>");
			}
			document.write("</table>");
		}


function MM_popupMsg(msg) 
{
alert(msg);
}

function getCheckedValue() 
{
	var len = document.forms[0].elements.SelectedApp.length;
	var myBool = false;
	
	for (i = 0; i <len; i++) 
	{
		if (document.forms[0].elements.SelectedApp[i].checked) 
		{
			myBool = true;
		}
	}


	if (myBool == false)
	{
		if (document.forms[0].elements.SelectedApp.checked = true)
		{
			return 0;
		}
	else
		{
			MM_popupMsg("You must choose an application in this Control Panel before continuing.");
		}
	}
}

 
  
// Added by Andy for Test Entry Window
	function Trim(TRIM_VALUE)
	{
		if(TRIM_VALUE.length < 1)
			{
				return"";
			}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE=="")
			{
			return "";
			}
		else
			{
			return TRIM_VALUE;
			}
	} //End Function

	function RTrim(VALUE)
		{
			var w_space = String.fromCharCode(32);
			var v_length = VALUE.length;
			var strTemp = "";
			if(v_length < 0)
			{
				return "";
			}
			var iTemp = v_length -1;
			while(iTemp > -1){
				if(VALUE.charAt(iTemp) == w_space){
				}
				else{
					strTemp = VALUE.substring(0,iTemp +1);
					break;
				}
				iTemp = iTemp-1;

			} //End While
			return strTemp;

		} //End Function

	function LTrim(VALUE)
		{
			var w_space = String.fromCharCode(32);
			if(v_length < 1)
				{
					return"";
				}
			var v_length = VALUE.length;
			var strTemp = "";

			var iTemp = 0;

			while(iTemp < v_length)
				{
					if(VALUE.charAt(iTemp) == w_space)
						{
						}
					else
						{
							strTemp = VALUE.substring(iTemp,v_length);
							break;
						}
					iTemp = iTemp + 1;
				} //End While
			return strTemp;
		} //End Function
		
		function roundOff(value, precision)
				{
					if((value.substring(0,1) == '.' || value.substring(0,2) == '0.') && !(value.substring(0,4) == '0.99'))
					{
						var isDec = 'true';
					}
					else
					{
						var isDec = 'false';
					}
					value = '' + value;
					precision = parseInt(precision);
					var whole = '' + Math.round(value * Math.pow(10, precision));
					var decPoint = whole.length - precision;
					if(decPoint != 0)
					{
							result = whole.substring(0, decPoint);
							result += '.';
							result += whole.substring(decPoint, whole.length);
					}
					else
					{
							result = whole;
					}
					
					if(isDec == 'true')
					{
						return parseFloat('.' + result);
					}
					else
					{
						return parseFloat(result);
					}
				}

// End Added by Andy for Test Entry 	
