<!-- Start DHTML Script -->

function Hidecolumn(column) { 
   var table = document.getElementById('table_name'); 
   var colIndex = parseInt(column.substring(1, column.length)); 
   for (var i = 4; i < table.rows.length; i++) 
      table.rows[i].cells[colIndex].style.display = 'none'; 
} 

function addStyleSheets(name,style){
try{
 if(!document.styleSheets.length){document.createStyleSheet()}
 document.styleSheets[document.styleSheets.length-1].addRule(name,style);
} catch(e){}
}

// style sheet definitions
addStyleSheets('.STarrow', 'font-family:webdings;font-size:10;text-decoration:none;cursor:pointer;')
addStyleSheets('.STtab',   'font-family:verdana;font-size:11;')
addStyleSheets('.STbutt',  'font-family:verdana;font-size:11;border:1 solid;')
addStyleSheets('.STip',    'font-family:verdana;font-size:11;border:1 solid;')
addStyleSheets('.STtxt',   'font-family:verdana;font-size:10;')

// column assosiations (default 26 columns, but can add more)
function  dataArray(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,
a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68 ) {
this.col1=a;this.col2=b;this.col3=c;this.col4=d;this.col5=e;this.col6=f;this.col7=g;this.col8=h;this.col9=i;this.col10=j;this.col11=k;this.col12=l;this.col13=m;this.col14=n;this.col15=o;this.col16=p;this.col17=q;this.col18=r;this.col19=s;this.col20=t;
this.col21=u;this.col22=v; this.col23=w; this.col24=x; this.col25=y; this.col26=z; this.col27=a1; this.col28=a2; this.col29=a3; this.col30=a4; this.col31=a5; this.col32=a6; this.col33=a7; this.col34=a8; this.col35=a9; this.col36=a10; this.col37=a11;
this.col38=a12;this.col39=a13;this.col40=a14;this.col41=a15;this.col42=a16;this.col43=a17;this.col44=a18;this.col45=a19;this.col46=a20;this.col47=a21;this.col48=a22;this.col49=a23;this.col50=a24;this.col51=a25;this.col52=a26;this.col53=a27;
this.col54=a28;this.col55=a29;this.col56=a30;this.col57=a31;this.col58=a32;this.col59=a33;this.col60=a34;this.col61=a35;this.col62=a36;this.col63=a37;this.col64=a38;this.col65=a39;this.col66=a40;this.col67=a41;this.col68=a42;this.col69=a43;
this.col70=a44;this.col71=a45;this.col72=a46;this.col73=a47;this.col74=a48;this.col75=a49;this.col76=a50;this.col77=a51;this.col78=a52;this.col79=a53;this.col80=a54;this.col81=a55;this.col82=a56;this.col83=a57;this.col84=a58;this.col85=a59;
this.col86=a60;this.col87=a61;this.col88=a62;this.col89=a63;this.col90=a64;this.col91=a65;this.col92=a66;this.col93=a67;this.col94=a68;

}
var ignoreRowsQty=0
var colnum=0;

function createTable(tableName,tableHolderName){
 thn=document.getElementById(tableHolderName)
str='<br><table class="STtab" cellpadding="5" border=0 id="'+tableName+'" style="background:'+tableBgColor+';"><tr><td type="header" colspan="'+tableHeadings.length+'" align="center" '; 
str+='style="background:'+headerBgColor+';color:'+headerTxtColor+';">'+tableTitle+'</td></tr>';
str += '<tr><td type="header" colspan="' + tableHeadings.length + '" align="left" valign="top" style="background:' + headerBgColor + ';color:' + headerTxtColor + ';">' + extraTableData + '</td></tr>'; 
str+='<tr><td type="header" colspan="' + tableHeadings.length + '" style="background:' + headerBgColor + ';color:' + headerTxtColor + ';" class="STip" align=left><input type="STtxt" id="findText">&nbsp;<button class="STbutt" '; 
str+='onclick="this.blur();findData()">Find</button>&nbsp;<button class="STbutt" ';
str+='onclick="this.blur();findData()">Clear</button><div id="findResult" class="STtxt">(Search Results)</div></td></tr>';
str+='<tr><td style="background:'+headerBgColor+';" colspan="'+tableHeadings.length+'">&nbsp;</td></tr>';
str+='<tr>';
 for(a=0;a<tableHeadings.length;a++){
  if(a==0){
   if(rowNumbersEnabled){
//    str+='<td type="header"></td>'
      str += '<td type="header" style="background:' + headerBgColor + ';"></td>'; 
   }
  }else{
   //colnum = colnum + 1;	
   //tmpcol = 'c' + colnum;
   var tmpcol = 'c' + a;  	
   mycol = "'" +tmpcol + "'";
   mycol2 = ' id="' +'HD' +tmpcol+ '" ';
 //  mystr='&nbsp;&nbsp;<a href="javascript:Hidecolumn(' +mycol + ');">[Hide]</A>';
str+='<td onclick="sortBy(\'col'+a+'\',\''+tableName+'\',this)" valign=top ' +mycol2+ 'type="header" style="background:' + headerBgColor + ';color:' + headerTxtColor + ';';
//insert extra css here for the cells
str += '"><b>'+tableHeadings[a]+'</b>&nbsp';
//str += '<a href="#" ';
//str += 'onclick="sortBy(\'col'+a+'\',\''+tableName+'\',this)" title="Ascending '; 
//str+='Order">
str += '<img id="col' + a + '" src="/charts/upsimple.png" border="0"></a>';
//str = str + mystr;
str += '</td>';

  }
 }
 str+='</tr></table>'
 thn.innerHTML=str
ignoreRowsQty = document.getElementById(tableName).getElementsByTagName('tr').length;
 makeTable(tableName)
}


function makeTable(tableName){
 tb=document.getElementById(tableName)
 ft=document.getElementById('findText')
 fr=document.getElementById('findResult')
 for (a=0;a<tableData.length;a++){
  tb.insertRow(tb.rows.length) 
  r=tb.rows[tb.rows.length-1];r.type="tableDataRow";r.style.background=dataBgColor;
   if(rowNumbersEnabled){
   c0 = r.insertCell(r.cells.length);c0.innerHTML=a+1;c0.type='header';c0.id='test'; 	
  }
 for(b=1;b<tableHeadings.length;b++){
   tmp='tableData['+a+'].col'+b
   tmp2=eval(tmp);
   switch (true){
	// web address
case (tmp2.indexOf('http://')>=0||tmp2.indexOf('https://')>=0):
 		  mycol='c' + b;

 break;
// Price Sort:
	case (tmp2.indexOf('pricesort://')>=0||tmp2.indexOf('PRICESORT://')>=0):
 	mycol='c' + b;
        mynum = tmp2.substring(12, 26);
//	mynum=stripZeros(mynum);
var nf = new NumberFormat();
	nf.setNumber(mynum);
	mynum = nf.toFormatted();
	mynum = "<DIV ALIGN='RIGHT'>" + " " + mynum + "</DIV>"
  	//com='c'+b+'=r.insertCell();c'+b+'.innerHTML="'+mynum+'";c'+b+'.id="'+mycol+'";';
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML="'+mynum+'";c'+b+'.id="'+mycol+'";';
        break;
// image only
	case (tmp2.indexOf('img://')>=0||tmp2.indexOf('IMG://')>=0):
 	mycol='c' + b;
        lansarow='tableData[' +a+ '].col2';
	lansarow2=eval(lansarow);
        imgrow = "'http://" + lansarow2 + "'";
        img ="<IMG BORDER='0' SRC="+ imgrow + ">";
	//com='c'+b+'=r.insertCell();c'+b+'.innerHTML="'+img+'";c'+b+'.id="'+mycol+'";';
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML="'+img+'";c'+b+'.id="'+mycol+'";';
        break;

// imagelink
	case (tmp2.indexOf('imglnk://')>=0||tmp2.indexOf('IMGLNK://')>=0):
 	mycol='c' + b;
        lansarow='tableData[' +a+ '].col2';
	lansarow2=eval(lansarow);
        linkrow='tableData[' +a+ '].col3';
	linkrow2=eval(linkrow);
	linkrow = linkrow2;
	imgrow = "'" + lansarow2 + "'";
        img ="<A HREF="+linkrow+"><IMG BORDER='0' SRC="+ imgrow + "></a>";
	//com='c'+b+'=r.insertCell();c'+b+'.innerHTML="'+img+'";c'+b+'.id="'+mycol+'";';
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML="'+img+'";c'+b+'.id="'+mycol+'";';
        break;

case (tmp2.indexOf('spllnk://')>=0||tmp2.indexOf('SPLLNK://')>=0):
 	mycol='c' + b;
        lansarow='tableData[' +a+ '].col2';
	lansarow2=eval(lansarow);
        linkrow='tableData[' +a+ '].col3';
	linkrow2=eval(linkrow);
	linkrow = linkrow2;
	imgrow = "'" + lansarow2 + "'";
	inhtml = '<div style=\\"Height:98; width=150; cursor: Pointer;background-image: url(' + lansarow2 + ');\\"';
	inhtml+= 'onclick=\\"' + linkrow2 + '\\">'
	inhtml += '<H2 style=color:red; background-color:white>Sample</H1></div>'
	//com='c'+b+'=r.insertCell();c'+b+'.innerHTML=\"'+inhtml+'\";c'+b+'.id=\"'+mycol+'\";';
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML=\"'+inhtml+'\";c'+b+'.id=\"'+mycol+'\";';
	break;

//js link
case (tmp2.indexOf('js:')>=0||tmp2.indexOf('call:')>=0):
	mycol='c' + b;
	//offset the lansa row #
        lansarow='tableData[' +a+ '].col1';
	lansarow2=eval(lansarow);
	jsrow = "'" + lansarow2 + "'";
	//Take out program name
            program = tmp2.substring(3, 15);
	//filter out all the extra
	tmp2 = tmp2.substring(15);
 	inhtml = '<A class=hrsJobLink HREF=\\\"JavaScript:' +program+'('+jsrow+')\\\";>' +tmp2+ '<br><img src=/images/hfmore.gif border=0></A>';	
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML=\"'+inhtml+'\";c'+b+'.id=\"'+mycol+'\";';
	break;

// Second JS call
case (tmp2.indexOf('js2:')>=0||tmp2.indexOf('call:')>=0):
// May need to play with the colums here..
	mycol='c' + b;
	//offset the lansa row #
            lansarow='tableData[' +a+ '].col1';
	lansarow2=eval(lansarow);
	jsrow = "'" + lansarow2 + "'";
	//Take out program name
            program = tmp2.substring(3, 15);
	//filter out all the extra
	tmp2 = tmp2.substring(15);
 	inhtml = '<A HREF=\\\"JavaScript:' +program+'('+jsrow+')\\\";>' +tmp2+ '</A>';
	//com='c'+b+'=r.insertCell();c'+b+'.innerHTML=\"'+inhtml+'\";c'+b+'.id=\"'+mycol+'\";';
	com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML=\"'+inhtml+'\";c'+b+'.id=\"'+mycol+'\";';
            break;
    // email
	case (tmp2.indexOf('@')>=0&&tmp2.indexOf('.')>=0):
mycol='c' + b;
//com='com='c'+b+'=r.insertCell();c'+b+'.innerHTML="<a href=\'#\' value=\''+tmp2+'\ style=\'color:'+linkTxtColor+';\' onmouseover=this.style.color=\''+linkHoverColor+'\ onmouseout=';
//com+='' ; this.style.color=\''+linkTxtColor+'\' onclick=\'gotoAddress(this.value)\' type=\'linker\' title=\'Click here open a window for this location.\'>'+tmp2+'</a>";c'+b+'.id="'+mycol+'";';
break;
	// standard text
    default:
		  mycol='c' + b;
		  //com='c'+b+'=r.insertCell();c'+b+'.innerHTML="'+tmp2+'";c'+b+'.id="'+mycol+'";';
		  com='c'+b+'=r.insertCell(r.cells.length);c'+b+'.innerHTML="'+tmp2+'";c'+b+'.id="'+mycol+'";';	
		  break;
   }
eval(com);
}
 }
 i=document.getElementsByTagName('TD')
 for(a=0;a<i.length;a++){
  if(i[a].type=='header'){
   i[a].style.background=headerBgColor
   i[a].style.color=headerTxtColor
   i[a].style.cursor='default'
  }
 }
 fr.innerText='(Search Results)'

//Hide a few colums to store data
// Javascript data to hide
Hidecolumn('c1');
//images data to hide
Hidecolumn('c2');
// link data to hide
Hidecolumn('c3');
// Misc
Hidecolumn('c4');
}

function clearTable(tableName) { 
   var tb = document.getElementById(tableName); 
   i = tb.rows.length; 
   for (var a = ignoreRowsQty; a < i; a++) 
      //tb.deleteRow(0); 
      tb.deleteRow(ignoreRowsQty);
} 


var sortProp;

function sortBy(prop, tableName, dir) { 
	//alert(prop + " " + tableName + " " + dir);
   var retVal = 0; 
   sortProp = prop; 
   sortPic = document.getElementById(prop);

   if ((sortPic.src == 'http://www.maronda.com:82/charts/downsimple.png' && document.LANSA._PARTITION.value=='DEV')
	|| (sortPic.src == 'http://www.maronda.com/charts/downsimple.png' && document.LANSA._PARTITION.value=='PRD')) { 
      sortPic.src = '/charts/upsimple.png'; 
      dir.title = 'Descending Order'; 
      tableData = tableData.sort(sortFuncDn); 
   } else {
      sortPic.src = '/charts/downsimple.png'; 
      dir.title = 'Ascending Order'; 
      tableData = tableData.sort(sortFuncUp);
   } 
   clearTable(tableName); 
   makeTable(tableName);
} 

function sortFuncUp(dataArray1,dataArray2) {
 if (dataArray1[sortProp]>dataArray2[sortProp]) retVal=1;
 else if (dataArray1[sortProp]<dataArray2[sortProp]) retVal=-1;
 else retVal=1;
 return retVal;
}

function sortFuncDn(dataArray1, dataArray2) { 
   if (dataArray1[sortProp] < dataArray2[sortProp]) 
      return 1; 
   else 
      return -1; 
} 

var clearingTable=false

function findData(){
 var seperator='~'
 ft=document.getElementById('findText')
 fr=document.getElementById('findResult')
 if(event.srcElement.innerText=='Clear'){
  clearingTable=true
  ft.value=clearingTable
 }
 if(ft.value!=''){
  var dataQty=0
  i=document.getElementsByTagName('TR')
  for(a=ignoreRowsQty;a<i.length;a++){
    if(i[a].type!='header'){
	 var startNum
	 if(rowNumbersEnabled=='yes'){
	  startNum=1
	 }else{
	  startNum=0
	 }
	 tmp=''
	 for(x=startNum;x<i[a].childNodes.length;x++){
	  tmp+=i[a].childNodes[x].innerText.toLowerCase()+seperator
	 }
     if(tmp.indexOf(ft.value.toLowerCase())>=0){
      i(a).style.background=hilightBgColor
     	  dataQty++
     }else{
      i(a).style.background=dataBgColor
     }
    }
  }
 fr.innerText=dataQty+" occurences of '"+ft.value+"' were found."
  if(clearingTable){
   ft.value=''
   fr.innerText='(Search Results)'
   clearingTable=false
  }
 }
}

var lastColor

function hilightRow(e) { 
   var targ; 
   if (!e) var e = window.event; 
   if (e.target) targ = e.target; 
   else if (e.srcElement) targ = e.srcElement; 
   if (targ.nodeType == 3) 
      targ = targ.parentNode; 
   if (targ.parentNode.tagName == "TR" && targ.parentNode.type == "tableDataRow") {
      bgc = targ.parentNode; 
	
      if (bgc.style.backgroundColor == hilightRowColor) { 
         bgc.style.background = lastColor; 
      } else { 
         lastColor = bgc.style.backgroundColor;
         bgc.style.backgroundColor = hilightRowColor; 
	 hilightRowColor = bgc.style.backgroundColor;
      } 
   } 
} 

function blurMe(e) { 
   var targ; 
   if (!e) var e = window.event; 
   if (e.target) targ = e.target; 
   else if (e.srcElement) targ = e.srcElement; 
   if (targ.nodeType == 3) 
      targ = targ.parentNode; 

   if (targ.tagName == 'a') { 
      targ.blur(); 
   } 
} 

function gotoAddress(val){
 blurMe(e)
 window.open(val,'','')
}

var lastColor

var num,newTerm
function stripZeros(num){
while (num.charAt(0) == "0") {
newTerm = num.substring(1, num.length);
num = newTerm;
}
if (num == "")
num = "0";
return num;
}


/*
 * NumberFormat 1.5.0
 * v1.5.0 - 20-December-2002
 * v1.0.3 - 23-March-2002
 * v1.0.2 - 13-March-2002
 * v1.0.1 - 20-July-2001
 * v1.0.0 - 13-April-2000
 * http://www.mredkj.com
 *
 */

/*
 * NumberFormat -The constructor
 * num - The number to be formatted.
 *  Also refer to setNumber
 */
function NumberFormat(num)
{
	// constants
	this.COMMA = ',';
	this.PERIOD = '.';
	this.DASH = '-'; // v1.5.0 - new - used internally
	this.LEFT_PAREN = '('; // v1.5.0 - new - used internally
	this.RIGHT_PAREN = ')'; // v1.5.0 - new - used internally
	this.LEFT_OUTSIDE = 0; // v1.5.0 - new - currency
	this.LEFT_INSIDE = 1;  // v1.5.0 - new - currency
	this.RIGHT_INSIDE = 2;  // v1.5.0 - new - currency
	this.RIGHT_OUTSIDE = 3;  // v1.5.0 - new - currency
	this.LEFT_DASH = 0; // v1.5.0 - new - negative
	this.RIGHT_DASH = 1; // v1.5.0 - new - negative
	this.PARENTHESIS = 2; // v1.5.0 - new - negative

	// member variables
	this.num;
	this.numOriginal;
	this.hasSeparators = false;  // v1.5.0 - new
	this.separatorValue;  // v1.5.0 - new
	this.inputDecimalValue; // v1.5.0 - new
	this.decimalValue;  // v1.5.0 - new
	this.negativeFormat; // v1.5.0 - new
	this.negativeRed; // v1.5.0 - new
	this.hasCurrency;  // v1.5.0 - modified
	this.currencyPosition;  // v1.5.0 - new
	this.currencyValue;  // v1.5.0 - modified
	this.places;

	// external methods
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setInputDecimal = setInputDecimalNF; // v1.5.0 - new
	this.setSeparators = setSeparatorsNF; // v1.5.0 - new - for separators and decimals
	this.setCommas = setCommasNF;
	this.setNegativeFormat = setNegativeFormatNF; // v1.5.0 - new
	this.setNegativeRed = setNegativeRedNF; // v1.5.0 - new
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setCurrencyValue = setCurrencyValueNF; // v1.5.0 - new - setCurrencyPrefix uses this
	this.setCurrencyPosition = setCurrencyPositionNF; // v1.5.0 - new - setCurrencyPrefix uses this
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;
	this.toPercentage = toPercentageNF;
	this.getOriginal = getOriginalNF;

	// internal methods
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;
	this.justNumber = justNumberNF;

	// setup defaults
	this.setInputDecimal(this.PERIOD); // v1.5.0 - new
	this.setNumber(num); // make sure setInputDecimal is called before setNumber
	this.setCommas(true);
	this.setNegativeFormat(this.LEFT_DASH); // v1.5.0 - new
	this.setNegativeRed(false); // v1.5.0 - new
	this.setCurrency(true);
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
}

/*
 * setInputDecimal
 * val - The decimal value for the input.
 *
 * v1.5.0 - new
 */
function setInputDecimalNF(val)
{
	this.inputDecimalValue = val;
}

/*
 * setNumber - Sets the number
 * num - The number to be formatted
 *
 * If there is a non-period decimal format for the input,
 * setInputDecimal should be called before calling setNumber.
 *
 * v1.5.0 - modified
 */
function setNumberNF(num)
{
	this.numOriginal = num;
	this.num = this.justNumber(num);
}

/*
 * toUnformatted - Returns the number as just a number.
 * If the original value was '100,000', then this method will return the number 100000
 * v1.0.2 - Modified comments, because this method no longer returns the original value.
 */
function toUnformattedNF()
{
	return (this.num);
}

/*
 * getOriginal - Returns the number as it was passed in, which may include non-number characters.
 * This function is new in v1.0.2
 */
function getOriginalNF()
{
	return (this.numOriginal);
}

/*
 * setNegativeFormat - How to format a negative number.
 *
 * format - The format. Use one of the following constants.
 * LEFT_DASH   example: -1000
 * RIGHT_DASH  example: 1000-
 * PARENTHESIS example: (1000)
 *
 * v1.5.0 - new
 */
function setNegativeFormatNF(format)
{
	this.negativeFormat = format;
}

/*
 * setNegativeRed - Format the number red if it's negative.
 *
 * isRed - true, to format the number red if negative, black if positive;
 *  false, for it to always be black font.
 *
 * v1.5.0 - new
 */
function setNegativeRedNF(isRed)
{
	this.negativeRed = isRed;
}

/*
 * setSeparators - One purpose of this method is to set a
 *  switch that indicates if there should be separators between groups of numbers.
 *  Also, can use it to set the values for the separator and decimal.
 *  For example, in the value 1,000.00
 *   The comma (,) is the separator and the period (.) is the decimal.
 *
 * Both separator or decimal are not required.
 * The separator and decimal cannot be the same value. If they are, decimal with be changed.
 * Can use the following constants (via the instantiated object) for separator or decimal:
 *  COMMA
 *  PERIOD
 *
 * isC - true, if there should be separators; false, if there should be no separators
 * separator - the value of the separator.
 * decimal - the value of the decimal.
 *
 * v1.5.0 - new
 */
function setSeparatorsNF(isC, separator, decimal)
{
	this.hasSeparators = isC;
	
	// Make sure a separator was passed in
	if (separator == null) separator = this.COMMA;
	
	// Make sure a decimal was passed in
	if (decimal == null) decimal = this.PERIOD;
	
	// Additionally, make sure the values aren't the same.
	//  When the separator and decimal both are periods, make the decimal a comma.
	//  When the separator and decimal both are any other value, make the decimal a period.
	if (separator == decimal)
	{
		this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
	}
	else
	{
		this.decimalValue = decimal;
	}
	
	// Since the decimal value changes if decimal and separator are the same,
	// the separator value can keep its setting.
	this.separatorValue = separator;

}

/*
 * setCommas - Sets a switch that indicates if there should be commas.
 * The separator value is set to a comma and the decimal value is set to a period.
 * isC - true, if the number should be formatted with separators (commas); false, if no separators
 *
 * v1.5.0 - modified
 */
function setCommasNF(isC)
{
	this.setSeparators(isC, this.COMMA, this.PERIOD);
}

/*
 * setCurrency - Sets a switch that indicates if should be displayed as currency
 * isC - true, if should be currency; false, if not currency
 */
function setCurrencyNF(isC)
{
	this.hasCurrency = isC;
}

/*
 * setCurrencyPrefix - Sets the symbol for currency.
 * val - The symbol
 */
function setCurrencyValueNF(val)
{
	this.currencyValue = val;
}

/*
 * setCurrencyPrefix - Sets the symbol for currency.
 * The symbol will show up on the left of the numbers and outside a negative sign.
 * cp - The symbol
 *
 * v1.5.0 - modified - This now calls setCurrencyValue and setCurrencyPosition(this.LEFT_OUTSIDE)
 */
function setCurrencyPrefixNF(cp)
{
	this.setCurrencyValue(cp);
	this.setCurrencyPosition(this.LEFT_OUTSIDE);
}

/*
 * setCurrencyPosition - Sets the position for currency,
 *  which includes position relative to the numbers and negative sign.
 * cp - The position. Use one of the following constants.
 *  This method does not automatically put the negative sign at the left or right.
 *  They are left by default, and would need to be set right with setNegativeFormat.
 *	LEFT_OUTSIDE  example: $-1.00
 *	LEFT_INSIDE   example: -$1.00
 *	RIGHT_INSIDE  example: 1.00$-
 *	RIGHT_OUTSIDE example: 1.00-$
 *
 * v1.5.0 - new
 */
function setCurrencyPositionNF(cp)
{
	this.currencyPosition = cp
}

/*
 * setPlaces - Sets the precision of decimal places
 * p - The number of places. Any number of places less than or equal to zero is considered zero.
 */
function setPlacesNF(p)
{
	this.places = p;
}

/*
 * toFormatted - Returns the number formatted according to the settings (a string)
 *
 * v1.5.0 - modified
 */
function toFormattedNF()
{
	var pos;
	var nNum = this.num; // v1.0.1 - number as a number
	var nStr;            // v1.0.1 - number as a string
	var splitString = new Array(2);   // v1.5.0

	// round decimal places
	nNum = this.getRounded(nNum);
	nStr = this.preserveZeros(Math.abs(nNum)); // this step makes nNum into a string. v1.0.1 Math.abs

	// the separator and decimal values have to be different
	// this is enforced in justNumber
	if (nStr.indexOf(this.PERIOD) == -1)
	{
		splitString[0] = nStr;
		splitString[1] = '';
	}
	else
	{
		splitString = nStr.split(this.PERIOD, 2);
	}

	// separators
	if (this.hasSeparators)
	{
		pos = splitString[0].length;
		while (pos > 0)
		{
			pos -= 3;
			if (pos <= 0) break;

			splitString[0] = splitString[0].substring(0,pos)
				+ this.separatorValue
				+ splitString[0].substring(pos, splitString[0].length);
		}
	}
	
	// decimal
	if (splitString[1].length > 0)
	{
		nStr = splitString[0] + this.decimalValue + splitString[1];
	}
	else
	{
		nStr = splitString[0];
	}
	
	// negative and currency
	// $[c0] -[n0] $[c1] -[n1] #.#[nStr] -[n2] $[c2] -[n3] $[c3]
	var c0 = '';
	var n0 = '';
	var c1 = '';
	var n1 = '';
	var n2 = '';
	var c2 = '';
	var n3 = '';
	var c3 = '';
	var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
	var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
		
	if (this.currencyPosition == this.LEFT_OUTSIDE)
	{
		// add currency sign in front, outside of any negative. example: $-1.00	
		if (nNum < 0)
		{
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
		}
		if (this.hasCurrency) c0 = this.currencyValue;
	}
	else if (this.currencyPosition == this.LEFT_INSIDE)
	{
		// add currency sign in front, inside of any negative. example: -$1.00
		if (nNum < 0)
		{
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
		}
		if (this.hasCurrency) c1 = this.currencyValue;
	}
	else if (this.currencyPosition == this.RIGHT_INSIDE)
	{
		// add currency sign at the end, inside of any negative. example: 1.00$-
		if (nNum < 0)
		{
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
		}
		if (this.hasCurrency) c2 = this.currencyValue;
	}
	else if (this.currencyPosition == this.RIGHT_OUTSIDE)
	{
		// add currency sign at the end, outside of any negative. example: 1.00-$
		if (nNum < 0)
		{
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
		}
		if (this.hasCurrency) c3 = this.currencyValue;
	}

	nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
	
	// negative red
	if (this.negativeRed && nNum < 0)
	{
		nStr = '<font color="red">' + nStr + '</font>';
	}

	return (nStr);
}

/*
 * toPercentage - Format the current number as a percentage.
 * This is separate from most of the regular formatting settings.
 * The exception is the number of decimal places.
 * If a number is 0.123 it will be formatted as 12.3%
 *
 * !! This is an initial version, so it doesn't use many settings.
 * !! should use some of the formatting settings that toFormatted uses.
 * !! probably won't want to use settings like currency.
 *
 * v1.5.0 - new
 */
function toPercentageNF()
{
	nNum = this.num * 100;
	
	// round decimal places
	nNum = this.getRounded(nNum);
	
	return nNum + '%';
}

/*
 * getRounded - Used internally to round a value
 * val - The number to be rounded
 */
function getRoundedNF(val)
{
	var factor;
	var i;

	// round to a certain precision
	factor = 1;
	for (i=0; i<this.places; i++)
	{	factor *= 10; }
	val *= factor;
	val = Math.round(val);
	val /= factor;

	return (val);
}

/*
 * preserveZeros - Used internally to make the number a string
 * 	that preserves zeros at the end of the number
 * val - The number
 */
function preserveZerosNF(val)
{
	var i;

	// make a string - to preserve the zeros at the end
	val = val + '';
	if (this.places <= 0) return val; // leave now. no zeros are necessary - v1.0.1 less than or equal
	
	var decimalPos = val.indexOf('.');
	if (decimalPos == -1)
	{
		val += '.';
		for (i=0; i<this.places; i++)
		{
			val += '0';
		}
	}
	else
	{
		var actualDecimals = (val.length - 1) - decimalPos;
		var difference = this.places - actualDecimals;
		for (i=0; i<difference; i++)
		{
			val += '0';
		}
	}
	
	return val;
}

/*
 * justNumber - Used internally to parse the value into a floating point number.
 * If the value is not set, then return 0.
 * If the value is not a number, then replace all characters that are not 0-9, a decimal point, or a negative sign.
 *
 *  Note: The regular expression cleans up the number, but doesn't get rid of - and .
 *  parseFloat will ignore all values after any character that is NaN.
 *
 *  A number can be entered using special notation.
 *  For example, the following is a valid number: 0.0314E+2
 *
 * This function is new in v1.0.2
 * v1.5.0 - modified
 */
function justNumberNF(val)
{
	val = (val==null) ? 0 : val;
	
	var newVal = val + ""; // to string for first round of parsing

	var isPercentage = false;
	var isFormattedNeg = false;

	// check for percentage
	// v1.5.0
	if (newVal.indexOf('%') != -1)
	{
		newVal = newVal.replace(/\%/g, '');
		
		// mark a flag
		isPercentage = true;
	}
	
	// check for negative
	// This logic does not figure out the real values for double negatives and other oddities.
	// If the value has any dash or both parenthesis, then it is counted as negative.
	// v1.5.0
	if (newVal.indexOf(this.DASH) != -1
	 || (newVal.indexOf(this.LEFT_PAREN) != -1 && newVal.indexOf(this.RIGHT_PAREN) != -1))
	{
		// get rid of the symbols
		// just hardcoding the regular expression to replace all dashes and parenthesis.
		// it's too much unnecessary work to use the constants in this situation.
		newVal = newVal.replace(/[\-\(\)]/g, '');
		
		// mark a flag to add back a negative sign later
		isFormattedNeg = true;
	}
	
	if (this.inputDecimalValue != this.PERIOD)
	{
		// then the separator might be a period
		// get rid of all periods, so they won't be evaluated as a decimal later
		newVal = newVal.replace(/\./g, '');
	}
	
	// replace the first decimal with a period and the rest with blank
	var itrDecimal;
	var tempVal = '';
	var foundDecimal = false;
	for (itrDecimal=0; itrDecimal<newVal.length; itrDecimal++)
	{
		if (newVal.charAt(itrDecimal) == this.inputDecimalValue)
		{
			if (foundDecimal)
			{
				// ignore the rest of the decimals
			}
			else
			{
				tempVal = tempVal + this.PERIOD;
				foundDecimal = true;
			}
		}
		else
		{
			tempVal = tempVal + newVal.charAt(itrDecimal);
		}
	}
  newVal = tempVal;
	
	// now that special input formatting is complete, add negative if applicable
	// v1.5.0
	if (isFormattedNeg) newVal = '-' + newVal;

	// check if a number, otherwise try to figure out what number it is
	if (isNaN(newVal))
	{
		// try taking out non-number characters.
		newVal = parseFloat(newVal.replace(/[^\d\.\-]/g, ''));

		// check if still not a number. Might be undefined, '', etc., so just replace with 0.
		// v1.0.3
		newVal = (isNaN(newVal) ? 0 : newVal);
	}
	// return 0 in place of infinite numbers.
	// v1.0.3
	else if (!isFinite(newVal))
	{
		newVal = 0;
  }

  // now that it's a number, adjust for percentage, if applicable.
  // example. if the number was formatted 24%, then divide by 100 to get 0.24
  // v1.5.0
  if (isPercentage)
  {
  	newVal = newVal / 100;
  }
	
	return newVal;
}