    function parseColor(color) {
      if (color.substring(0, 3) == 'rgb') {
        color = color.substring(4, color.length-1);
        color_arr = color.split(",");
        color_arr[0] = parseInt(color_arr[0], 10).toString(16); 
        color_arr[1] = parseInt(color_arr[1], 10).toString(16); 
        color_arr[2] = parseInt(color_arr[2], 10).toString(16); 
        if (color_arr[0].length < 2) color_arr[0] = "0"+color_arr[0];
        if (color_arr[1].length < 2) color_arr[1] = "0"+color_arr[1];
        if (color_arr[2].length < 2) color_arr[2] = "0"+color_arr[2];
        color = color_arr[0]+color_arr[1]+color_arr[2];
      } else 
      if (color.substring(0, 1) == '#') {
        color = color.substring(1);
      }
      return color;
    }

    function escapeStr(str) {
      var text = str;
      text = text.replace(/\%/g,'%25');
      text = text.replace(/\&/g,'%26');
      text = text.replace(/\$/g,'%24');
      text = text.replace(/\=/g,'%3D');
      text = text.replace(/\?/g,'%3F');
      text = text.replace(/\+/g,'%2B');
      return text;       	
    }
    
    function addBr(str) {
      var text = str;
      text = text.replace(/\n\r/g,'<br />');
      text = text.replace(/\r\n/g,'<br />');
      text = text.replace(/\r/g,'<br />');
      text = text.replace(/\n/g,'<br />');
      return text;       	
    }   
    
    function formatNumber(num, decimals, d_sprt, t_sprt) {
      var nStr = num.toFixed(decimals);
      nStr += '';
      x = nStr.split('.');
      x1 = x[0];
      x2 = x.length > 1 ? d_sprt + x[1] : '';
      var rgx = /(\d+)(\d{3})/;
      while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + t_sprt + '$2');
      }
      return x1 + x2;
    }
    
    
