/*
 * strExtensions - String extensions
 * http://www.karalamalar.net/
 *
 * Copyright (c) 2009 İzzet Emre Erkan
 * Licensed under Creative Commons Attribution-Share Alike 3.0 Unported License
 * http://creativecommons.org/licenses/by-sa/3.0/
 *
 * Date: 2009-10-08 17:43:34 +0300 (Thu, 08 Oct 2009)
 * Revision: 2
 */
String.prototype.trimLeft =
  function(c) {
    c = c || ' ';
    return this.replace(new RegExp('^'+c+'+'),"");
  };
String.prototype.trimRight =
  function(c) {
    c = c || ' ';
    return this.replace(new RegExp(''+c+'+$'),"");
  };
String.prototype.trim =
  function(c) {
    return this.trimLeft(c).trimRight(c);
  };
String.prototype.padLeft =
  function(l, c) {
    c = c || ' ';
    var s = this.toString();
    while (s.length < l) s = c + s;
    return s;
  }
String.prototype.padRight =
  function(l, c) {
    c = c || ' ';
    var s = this.toString();
    while (s.length < l) s = s + c;
    return s;
  }
String.prototype.valiDate =
  function() {
    if(/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}$/.test(this)) {
      var v = this.replace(/[- /]/g,'.').split('.');
      var d=parseInt(v[0],10), m=parseInt(v[1],10), y=parseInt(v[2],10);
      var o = new Date(y, m - 1, d);
      return o.getDate() == d && o.getMonth() + 1 == m && o.getFullYear() == y;
    }
    else
      return false;
  }