/* Feito por Pedro Boechat 24/09/2004 */
	     function Currency( number )
		   {
		       /* Fields */
		       this.__number = number;
		       this.integers;
		       this.decimals;

		       var pos;
			   var i;
			   var j;

            // Casting:
			    if (typeof(this.__number) == "number") this.__number = this.__number.toString();
            else if (typeof(this.__number)!="string") this.__number = "0";
			   
   	        /* Retirando a notação de Real */
     		this.__number = this.__number.replace(/R\$/gi, "");
 				 
 				if (this.__number.indexOf(".") > this.__number.indexOf(",")) {
 				    if (this.__number.indexOf(",") == -1) {
 				 	    pos = this.__number.indexOf(".");
 					}
 				    else {
 					    this.__number = this.__number.replace(/\./gi, "");
  			        pos = this.__number.indexOf(",");
 					}
 				}
 				else {
 				    this.__number = this.__number.replace(/\./gi, "");
 				    pos = this.__number.indexOf(",");
 				}
 				 
 				if (pos == -1) pos = this.__number.length;
 				 
 				this.integers = this.__number.substring(0, pos);
 				this.decimals = this.__number.substr(pos +1, 2);
 
            this.integers = (isNaN(parseInt(this.integers))) ? "0" : parseInt(this.integers).toString();
            this.decimals = (isNaN(parseInt(this.decimals))) ? "0" : parseInt(this.decimals).toString();
 			 
 				if (this.decimals.length < 2)
 				{
 				   j = 2 - this.decimals.length;
 				   for (i=0; i<j; i++) {
 				        this.decimals += "0";
 				   }
 			    }
		   }

       Currency.prototype.toString = function() {
            return (this.integers + "," + this.decimals);
       }

       Currency.prototype.toNumber = function () {
            return parseFloat( this.integers.toString() + "." + this.decimals.toString() );
       }
