//*****************************************************************************// Do not remove this notice.//// Copyright 2000-2004 by Mike Hall.// See http://www.brainjar.com for terms of use.//*****************************************************************************//----------------------------------------------------------------------------// General utility functions.//----------------------------------------------------------------------------function getContainerWith(node, tagName, className) {  // Starting with the given node, find the nearest containing element  // with the specified tag name and style class.  while (node != null) {    if (node.tagName != null && node.tagName == tagName &&        hasClassName(node, className))      return node;    node = node.parentNode;  }  return node;}function hasClassName(el, name) {  var i, list;  // Return true if the given element currently has the given class  // name.  list = el.className.split(" ");  for (i = 0; i < list.length; i++)    if (list[i] == name)      return true;  return false;}function removeClassName(el, name) {  var i, curList, newList;  if (el.className == null)    return;  // Remove the given class name from the element's className property.  newList = new Array();  curList = el.className.split(" ");  for (i = 0; i < curList.length; i++)    if (curList[i] != name)      newList.push(curList[i]);  el.className = newList.join(" ");}function getPageOffsetLeft(el) {  var x;  // Return the x coordinate of an element relative to the page.  x = el.offsetLeft;  if (el.offsetParent != null)    x += getPageOffsetLeft(el.offsetParent);  return x;}function getPageOffsetTop(el) {  var y;  // Return the x coordinate of an element relative to the page.  y = el.offsetTop;  if (el.offsetParent != null)    y += getPageOffsetTop(el.offsetParent);  return y;}function Left(str, n){	if (n <= 0)	    return "";	else if (n > String(str).length)	    return str;	else	    return String(str).substring(0,n);}function Right(str, n){    if (n <= 0)       return "";    else if (n > String(str).length)       return str;    else {       var iLen = String(str).length;       return String(str).substring(iLen, iLen - n);    }}function Mid(str, start, len){	if (start < 0 || len < 0) return "";	var iEnd, iLen = String(str).length;	if (start + len > iLen)		iEnd = iLen;	else		iEnd = start + len;	return String(str).substring(start,iEnd);}function windowOpener( url , name , args) {	if ( typeof ( popupWin ) != "object" ) {		popupWin = window.open( url , name , args );	} else {		if (!popupWin.closed){ 			popupWin.location.href = url;		} else {			popupWin = window.open(url, name,args);		}	}	popupWin.focus();}function stringToDate ( sDate , sSeparator , nYrPos , nMthPos , nDayPos ){	var aDate = sDate.split ( sSeparator );	var returnDate = new Date ( aDate[ nYrPos ] , aDate[ nMthPos ] - 1, aDate[ nDayPos ] );	return returnDate;}function dateToString ( dStartdate , sSeparator , nYrPos , nMthPos , nDayPos ){	var aDate = new Array();		if ( nYrPos >= 0 ) { aDate[ nYrPos ] = dStartdate.getFullYear() };	if ( nMthPos >= 0 ) { aDate[ nMthPos ] = dStartdate.getMonth() + 1 };	if ( nDayPos >= 0 ) { aDate[ nDayPos ] = dStartdate.getDate() };	if ( new String ( aDate[ nMthPos ] ).length < 2 ) { aDate[ nMthPos ] = '0' + aDate[ nMthPos ] }	if ( new String ( aDate[ nDayPos ] ).length < 2 ) { aDate[ nDayPos ] = '0' + aDate[ nDayPos ] }	return aDate.join( sSeparator );}function timeToString ( dStartDate , sSeparator , nHrPos , nMinPos , nSecPos ){	var aTime = new Array();		if ( nHrPos >= 0 ) { aTime[ nHrPos ] = dStartDate.getHours()};	if ( nMinPos >= 0 ) { aTime[ nMinPos ] = dStartDate.getMinutes()};	if ( nSecPos >= 0 ) { aTime[ nSecPos ] = dStartDate.getSeconds()};		if ( aTime[ nHrPos ] == 0 ){ aTime[ nHrPos ] = 24 }	if ( aTime[ nHrPos ] > 12 ){		aTime[ nHrPos ] = aTime[ nHrPos ] - 12;		sIndicator = 'p.m.';	} else {		sIndicator = 'a.m.';	}		if ( new String ( aTime[ nHrPos ] ).length < 2 ) { aTime[ nHrPos ] = '0' + aTime[ nHrPos ] }	if ( new String ( aTime[ nMinPos ] ).length < 2 ) { aTime[ nMinPos ] = '0' + aTime[ nMinPos ] }	if ( new String ( aTime[ nSecPos ] ).length < 2 ) { aTime[ nSecPos ] = '0' + aTime[ nSecPos ] }	return aTime.join ( sSeparator ) + ' ' + sIndicator;}function dateCompare ( d1 , d2 ){	return Math.round( ( d1 - d2 )/( 86400000 ));}function dateAdvanceDays ( dDate , nDays ){	nDateNumber = dDate.getTime();	nAdvance = nDays * 86400000;	var dNewDate = new Date ( nDateNumber + nAdvance );	return dNewDate;}function replaceSubstring(inputString, fromString, toString) {// Goes through the inputString and replaces every occurrence of fromString with toString	var temp = inputString;	if (fromString == "") {		return inputString;	}	if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)		while (temp.indexOf(fromString) != -1) {			var toTheLeft = temp.substring(0, temp.indexOf(fromString));			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);			temp = toTheLeft + toString + toTheRight;		}	} else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop		var midStrings = new Array("~", "`", "_", "^", "#");		var midStringLen = 1;		var midString = "";		// Find a string that doesn't exist in the inputString to be used		// as an "inbetween" string		while (midString == "") {			for (var i=0; i < midStrings.length; i++) {				var tempMidString = "";				for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }				if (fromString.indexOf(tempMidString) == -1) {					midString = tempMidString;					i = midStrings.length + 1;				}			}		} // Keep on going until we build an "inbetween" string that doesn't exist		// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string		while (temp.indexOf(fromString) != -1) {			var toTheLeft = temp.substring(0, temp.indexOf(fromString));			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);			temp = toTheLeft + midString + toTheRight;		}		// Next, replace the "inbetween" string with the "toString"		while (temp.indexOf(midString) != -1) {			var toTheLeft = temp.substring(0, temp.indexOf(midString));			var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);			temp = toTheLeft + toString + toTheRight;		}	} // Ends the check to see if the string being replaced is part of the replacement string or not	return temp; // Send the updated string back to the user} // Ends the "replaceSubstring" functionfunction trim ( sTrimString ){	return sTrimString.replace(/^\s+|\s+$/g, '');}function fnStripTagAndContents ( sSource , sTag ){	sReturn = sSource;	var iTagStartPos = sSource.indexOf( "<" + sTag );	while ( iTagStartPos > 0 ){		var iTagEndPos = sSource.indexOf( "</" + sTag ) + sTag.length + 3;		var sTagAndContents = sReturn.substr ( iTagStartPos , iTagEndPos - iTagStartPos );  		sReturn = replaceSubstring(sReturn, sTagAndContents, "")		iTagStartPos = sReturn.indexOf( "<" + sTag );	}	return sReturn;}function fnTableToExcel( sTableName ){		if (window.ActiveXObject){		var  xlApp = new ActiveXObject("Excel.Application");		var xlBook = xlApp.Workbooks.Add(); 				xlBook.worksheets("Sheet1").activate;		var XlSheet = xlBook.activeSheet;				exportTable = $( sTableName );				for (var row = 0; row < exportTable.rows.length; row++){			for(var col = 0; col < exportTable.rows[row].cells.length; col++){				xlText = exportTable.rows(row).cells(col).innerHTML.toUpperCase();				if (xlText.indexOf("_BLANK>") > 0) {					pos1 = xlText.indexOf("_BLANK>")					pos2 = xlText.indexOf("</A>")					xlText = xlText.substring(pos1 + 7, pos2 )				}								xlText = fnStripTagAndContents ( xlText.toString() , "SCRIPT" )								if ( Left ( xlText , 4 ) == "<BR>" ){					xlText = Right ( xlText , xlText.length - 4 );				}								if ( Right ( xlText , 4 ) == "<BR>" ){					xlText = Left ( xlText , xlText.length - 4 );				}				xlText = xlText.replace(/<br>/gi, "\n")								xlText = xlText.replace(/&nbsp;/gi, " ")				xlText = xlText.replace(/<B>/gi, "")				xlText = xlText.replace(/<\/B>/gi, "")      			XlSheet.cells((row+1), (col+1)).value = xlText      		}      	}      			XlSheet.columns.autofit;		XlSheet.rows.autofit;		xlApp.visible = true;	}	else {		csvWindow = window.open('blank.html','csvWindow','width=800,height=400,left=200,top=200,screenX=200,screenY=200,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');			//csvWindow.document.open("text", "replace")		csvWindow.document.open("text/html", "replace")				csvWindow.document.writeln("123")		csvWindow.document.close()		return false				exportTable = $( sTableName );		csvRow = ""				csvWindow.document.write("123")		csvWindow.document.close()		return false				for (var row = 0; row < exportTable.rows.length; row++){			csvWindow.document.write(csvRow + "\r\n")			csvRow = ""			for(var col = 0; col < exportTable.rows[row].cells.length; col++){				xlText = exportTable.rows[row].cells[col].innerHTML.toUpperCase();				if (xlText.indexOf("BLANK") > 0) {					pos1 = xlText.indexOf("BLANK")					pos2 = xlText.indexOf("</A>")					xlText = xlText.substring(pos1 + 7, pos2)				}								xlText = fnStripTagAndContents ( xlText.toString() , "SCRIPT" )				xlText = xlText.replace(/<br>/gi, "-")				alert ( "Attempting <B> replace" );				xlText = xlText.replace(/<B>/gi, "a")				xlText = xlText.replace(/<\/B>/gi, "b")				alert ( "<B> replace done." );							xlText = xlText.replace(/&nbsp;/gi, " ")								if (csvRow == "") {	      			csvRow = xlText	      		}	      		else {	      			csvRow = csvRow + "," + xlText	      		}      		}      	}		csvWindow.document.close()	}}