/**
 *  General Purpose Javascript Library
 *
 *  Copyright (c) 2009 Stanislav Filippov <stas@stas.us>
 * 
 *  COPYING AND UNLICENSED USAGE STRICTLY PROHIBITED
 * 
 **/

function clone(o)
{
  function c(o)
  {
    for (var i in o)
      this[i] = o[i];
  }
  return new c(o);
};


// http://sajjadhossain.com/2008/10/31/javascript-string-trimming-and-padding/

String.prototype.lpad = function(padString, length) {
	var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
}



// https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent

function URLencode( str ) 
{
  return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
                                 replace(/\)/g, '%29').replace(/\*/g, '%2A');
}



function array_size( obj )
{
  var len = 0;
  for ( var i in obj )
    len++;
  return len;
}


/**
 *
 *  Auxilary functions
 *
 */

function classExists(c) {
    return eval("typeof " + c + " == 'function'");
}


var ob_write_buffer = '';
function ob_init()
{
  ob_write_buffer = '';
}
function ob_write(s)
{
  //alert(s);
  ob_write_buffer += s;
}
function ob_writeln(s)
{
  //alert(s);
  ob_write_buffer += s+"\r";
}

//////
