/**
 * http://kevin.vanzonneveld.net
 * +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 * + namespaced by: Michael White (http://getsprink.com)
 *      example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT');
 *      returns 1: '-=-=-=-=-=-Kevin van Zonneveld'
 *      example 2: str_pad('Kevin van Zonneveld', 30, '-', 'STR_PAD_BOTH');
 *      returns 2: '------Kevin van Zonneveld-----'
 *
 * @param string  input
 * @param int     pad_length
 * @param string  pad_string  default ''
 * @param string  pad_type   [STR_PAD_LEFT|STR_PAD_RIGHT|STR_PAD_BOTH], default STR_PAD_RIGHT
 * @return string
 */
function str_pad(input, pad_length, pad_string, pad_type) {
  var half = '', pad_to_go;

  var str_pad_repeater = function(s, len) {
    var collect = '';
    while(collect.length < len) {
      collect += s;
    }
    collect = collect.substr(0,len);
    return collect;
  };

  input += '';

  if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; }
  if ((pad_to_go = pad_length - input.length) > 0) {
    if (pad_type == 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; }
    else if (pad_type == 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); }
    else if (pad_type == 'STR_PAD_BOTH') {
      half = str_pad_repeater(pad_string, Math.ceil(pad_to_go/2));
      input = half + input + half;
      input = input.substr(0, pad_length);
    }
  }

  return input;
}

function writeEmail(contact, email, emailHost, overrideDisplay) {
  if (overrideDisplay == "") {
    document.write("<a href=" + "&#109a&#105l" + "&#116&#111:" + email + "@" + emailHost+ ">" + contact + "@" + emailHost+"</a>");
  }
  else {
    document.write("<a href=" + "&#109a&#105l" + "&#116&#111:" + email + "@" + emailHost+ ">" + overrideDisplay+"</a>");
  }
}

// http://kevin.vanzonneveld.net
// +   original by: Philip Peterson
// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// *     example 1: var test="Kevin+van+Zonneveld%21"; test.urldecode();
// *     returns 1: 'Kevin van Zonneveld!'
String.prototype.urldecode = function() {
  ret = this.replace(/\+/g, '%20');
  ret = decodeURIComponent(ret);
  ret = ret.toString();
  return ret;
}

// Simple Debug, written by Chris Klimas
// licensed under the GNU LGPL.
// http://www.gnu.org/licenses/lgpl.txt
//
// There are three functions defined here:
//
// log (message)
// Logs a message. Every second, all logged messages are displayed
// in an alert box. This saves you from having to hit Return a ton
// of times as your script executes.
//
// inspect (object)
// Logs the interesting properties an object possesses. Skips functions
// and anything in CAPS_AND_UNDERSCORES.
//
// inspectValues (object)
// Like inspect(), but displays values for the properties. The output
// for this can get very large -- for example, if you are inspecting
// a DOM element.
function log (message) { if (! _log_timeout) _log_timeout = window.setTimeout(dump_log, 1000); _log_messages.push(message);
function dump_log() { var message = ''; for (var i = 0; i < _log_messages.length; i++) message += _log_messages[i] + '\n'; alert(message); _log_timeout = null; delete _log_messages; _log_messages = new Array(); } }
function inspect (obj) { var message = 'Object possesses these properties:\n'; if (obj) { for (var i in obj) { if ((obj[i] instanceof Function) || (obj[i] == null) || (i.toUpperCase() == i)) continue; message += i + ', '; } message = message.substr(0, message.length - 2); } else message = 'Object is null'; log(message); }
function inspectValues (obj) { var message = ''; if (obj) for (var i in obj) { if ((obj[i] instanceof Function) || (obj[i] == null) || (i.toUpperCase() == i)) continue; message += i + ': ' + obj[i] + '\n'; } else message = 'Object is null'; log(message); } var _log_timeout; var _log_messages = new Array();
