﻿Date.prototype.IsInThePass = function(str) {
    var valid = true;
    var reg = new RegExp("(\\d{1,2})\/(\\d{1,2})\/(\\d{4})");   
    var result = reg.exec(str);
    if (result != null) {
        var date = new Date(Number(result[3]), Number(result[2]) - 1, Number(result[1]), 0, 0, 0, 0);
        valid = (date < this.ToDate());
    } 

    return valid;
}

Date.prototype.AddDays = function (n) {
    var date = new Date(this.getTime() + (n * 24 * 60 * 60 * 1000));
    return date;
}

Date.prototype.ToDate = function() {
    return new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0, 0);
}

Date.prototype.ToDateString = function() {
    var year = this.getFullYear();
    var month = "0" + (this.getMonth() + 1);
    month = (month.length > 2) ? month.substring(1, month.length) : month;
    var day = "0" + this.getDate();
    day = (day.length > 2) ? day.substring(1, day.length) : day;
    
    return year + "-" + month + "-" + day;
}

function openPopup(lnk,name,w,h) {
    w = (typeof(w) == "undefined") ? 610 : w;
    h = (typeof(h) == "undefined") ? 480 : h;
    var t = (screen.height - h) / 2;
    var l = (screen.width - w) / 2;
    name = (typeof(name) == "undefined") ? "newWindow" : name;
    
    var url = $(lnk).attr("href");
    var feature = "scrollbars=yes,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",resizable=no,location=no,menubar=yes";
    var newWindow = window.open(url, name, feature);
    newWindow.focus();
}