	function LTrim(str)
	{
	        var whitespace = new String(" \t\n\r ");
	        var s = new String(str);
	        if (whitespace.indexOf(s.charAt(0)) != -1) {
	            var j=0, i = s.length;
	            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	                j++;
	            s = s.substring(j, i);
	        }
	        return s;
	}

	function RTrim(str)
	{
	        var whitespace = new String(" \t\n\r ");
	        var s = new String(str);
	        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	            var i = s.length - 1;
	            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
	                i--;
	            s = s.substring(0, i+1);
	        }
	        return s;
	}
	                                                                                                                        
	function Trim(str)
	{
	        return RTrim(LTrim(str));
	}

	function ConvertNull(str) 
	{
		if (str == null)
		{
			return " ";
		}
		else {
			return str;
		}
	}
	
	function formatCurrency(num) 
	{
		if (num == null) 
		{
			return "$0.00";
		}

		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	}


	function Replace(sString, sReplaceThis, sWithThis) 
	{ 
		if (sReplaceThis != "" && sReplaceThis != sWithThis) 
		{ 
			var counter = 0; 
			var start = 0; 
			var before = ""; 
			var after = ""; 
			while (counter<sString.length) 
			{ 
				start = sString.indexOf(sReplaceThis, counter); 
				if (start == -1) 
				{ 
					break; 
				} 
				else 
				{ 
					before = sString.substr(0, start); 
					after = sString.substr(start + sReplaceThis.length, sString.length); 
					sString = before + sWithThis + after; 
					counter = before.length + sWithThis.length; 
				} 
			} 
		} 
		return sString; 
	} 
	
	function nullOptions(aMenu)
	{
		var tot = aMenu.options.length;
		for (i=0; i<tot; i++)
		{
			aMenu.options[i]=null;
		}
		aMenu.options.length=0;
	}


	//FUNCTION: ConvertDiscountRateToPercentageText(discountRate)
	//
	//This method returns the discount rate as percentage text string 
	//for display.
	//
	//PARAMETERS:
	//discountRate: Decimal discount rate
	//
	//RETURNS: Discount rate in percentage string format (for display)
	function ConvertDiscountRateToPercentageText(discountRate)
	{
		var discountRatePercentage = 0.0;
		var discountRatePercentageText = "";
		
		discountRatePercentage = (discountRate*100);	
		//alert(String(discountRatePercentage.toFixed() + "%"));
		return(discountRatePercentage.toFixed() + "%");
	}	


	//FUNCTION:SetCostText(cost, zeroCostText)
	//
	//This method sets cost to a dollar format or the zero cost string specified
	//for display.
	//
	//PARAMETERS:
	//cost: The cost to be formatted to a dollar amount or set to the zero cost string
	//
	//RETURNS: String containing dollar amount or the zero cost string
	function SetCostText(cost, zeroCostText)
	{
		var costText = "";
		if(Number(cost) == 0)
			costText = zeroCostText;
		else
			costText = formatCurrency(cost);

		return(costText);
	}
	
	function SetPriceText(regPrice, discount, rebateAmt)
	{	    	    
	    
	    var priceText = "";
	    
	    if(regPrice != 0)
	    {
	        priceText = formatCurrency(regPrice) + " regular price<br />";
	    }
	    
	    if(discount != 0)
	    {
            priceText += "-" + formatCurrency(discount) + " discount<br />";
	    }
	    
		if(rebateAmt > 0) 
		{
		    priceText += "- " + formatCurrency(rebateAmt) + " mail-in rebate";
		}
	    return(priceText);	
	}