	function formatCommas(inputText) 	{
		inputTextValue = inputText.value;
		inputTextValue = removeCommas(inputTextValue);
		inputTextValue = addCommas(inputTextValue); 		inputTextValue = removeExcessDecimals(inputTextValue);
		inputText.value = inputTextValue;  
		return true;
	}
	function addCommas(aStr)
    {
        var len = aStr.length;
        var pos;
        if (len >= 4)
        {
            dest = new String("");
            while (len > 3)
            {
                if (aStr.indexOf(".") != -1)
                {
                    pos = aStr.indexOf(".");
                    dest = aStr.substring(pos);
                    aStr = aStr.substring(0, pos);
                    len = aStr.length;
                }
                else if ((len == 4) && (aStr.charAt(0) == '-'))
                {
                    dest = aStr.substring(0, len) + dest;
                    aStr = "";
                    len = 0;
                }
                else
                {
                    dest = "," + aStr.substring((len - 3), len) + dest;
                    aStr = aStr.substring(0, (len - 3));
                    len = aStr.length;
                }
            }
            dest = aStr + dest;
            return dest;
        }
        return aStr;
        }
	
	function removeCommas(aField) 	{
		while(aField.indexOf(",") >= 0)     
		      aField = aField.substring(0, aField.indexOf(",")) + aField.substring(aField.indexOf(",") + 1, aField.length);
		return aField;
	}               
	function openWindow(myLink,windowName)
	{
	 var myWin;
	 if (browserName == "Netscape" ) 
	    {   
	       myWin=window.open("",windowName,"height=600,innerheight=600,width=700,innerwidth=700,dependent=yes,toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,copyhistory=0"); 
	    } 
	 else 
	    { 
	     var iTop, iLeft, childHeight, childWidth; toolbarHeight=142, statusbarHeight=20, iDelta=8; 
	      childHeight=600 + toolbarHeight + statusbarHeight; 
	      childWidth = 700 - iDelta; 
	      iTop=window.screenTop + document.body.clientHeight + statusbarHeight - childHeight; 
	      iLeft=window.screenLeft + document.body.clientWidth - childWidth; 
	      if (iTop + childHeight > window.screen.availHeight) 
	        iTop=window.screen.availHeight - childHeight; 
	      if (iLeft + childWidth > window.screen.availWidth) 
	        iLeft=window.screen.availWidth - childWidth - (2*iDelta); 
	      myWin=window.open("",windowName,"dependent=yes,toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,copyhistory=0,width=700,height=600,top=" + iTop + ",left=" + iLeft +""); 
		} 
	 myWin.focus(); 
	 myLink.target=windowName;       
	}
	
	function removeExcessDecimals(aField)
	{
	    //find the first decimal
	    pos = aField.indexOf(".");
	    retVal = new String();
	    if (pos != -1)
	    {
	        retVal = aField.substring(0, (pos + 1));

	        for (i = (pos + 1); i < aField.length; i++)
	        {
	            if (aField.charAt(i) != '.')
		            retVal += aField.charAt(i);
	        }

	        if (retVal.charAt((retVal.length - 1)) == '.')
	        {
	            if (retVal.length == 1)
	                retVal = "0";
	            else
	                retVal += "0";
	        }
	    }
	    else
	        retVal = aField;
	    return retVal;
	}
