//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * @package Starweb Webshop System
 * @version See version-file
 * @copyright Copyright (c) 2000 - 2007, Ehandelslogik i Lund AB
 * 
 * @author Ehandelslogik i Lund AB, org.no 556696-9019  (Starweb)
 *  Country: Sweden
 *  Homepage: www.starweb.se
 *  E-mail: support@starweb.se
 * 
 * License:
 * This program is not "free" software and restrictions apply!
 * This file as well as all other files containing the code to our software may ONLY be used and/or redistributed with written permission from us.
 * You'll find information regarding our conditions and pricing on our homepage. Contact us immediately if any of these conditions are not clear.
 */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * @name Function: Round Cost No
 * @access public
 *
 * @param float fCostNo
 */
function RoundCostNo(fCostNo)
{
   if(fCostNo == '')
   { return '-'; }
   else
   {
      fCostNo = fCostNo - 0; // Force number
      iCurrDecNo = iCurrDecNo - 0; // Force number
      var fFloatVar = Math.pow(10, iCurrDecNo);
      
      //fCostNo += Math.pow(10, - (iCurrDecNo + 1));
      fCostNo = Math.round(fCostNo * fFloatVar) / fFloatVar;
      
      fCostNo += Math.pow(10, - (iCurrDecNo + 1));
      fCostNo += ""; // Force string
      fCostNoFormatted = (iCurrDecNo == 0)
         ? fCostNo.substring(0, fCostNo.indexOf('.'))
         : fCostNo.substring(0, fCostNo.indexOf('.') + (iCurrDecNo + 10));


      return number_format(fCostNoFormatted, iCurrDecNo, ",", " ");
   }
}






/**
 * @name Function: Number Format
 * @access private
 *
 * @desc Made by Mathias Bynens <http://mathiasbynens.be/>
 *
 * @param float a
 * @param int b
 * @param string c
 * @param string d
 */
function number_format(a, b, c, d)
{
   a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
   e = a + '';
   f = e.split('.');
   
   if(!f[0])
   { f[0] = '0'; }

   if (!f[1])
   { f[1] = ""; }
   
   if (f[1].length < b)
   {
      g = f[1];
      
      for(i=f[1].length+1; i<=b; i++)
      { g += '0'; }
      
      f[1] = g;
   }
   
   if(d != '' && f[0].length > 3)
   {
      h = f[0];
      f[0] = "";
      for(j = 3; j < h.length; j+=3)
      {
         i = h.slice(h.length - j, h.length - j + 3);
         f[0] = d + i +   f[0] + '';
      }
      
      j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
      f[0] = j + f[0];
   }
   
   c = (b <= 0) ? '' : c;
   
   
   return f[0] + c + f[1];
}