﻿function getQuerystring(key, default_)
{
    if (default_==null) default_=""; 
    key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if(qs == null)
        return default_;
    else
        return qs[1];
}

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}

function async(fn) {
    window.setTimeout(fn, 20);
}


function getNowDate() {
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1;
    if (month < 10) {
        month = "0" + month;
    }    
    var day = currentTime.getDate();
    if (day < 10) {
        day = "0" + day;
    }   
    var year = currentTime.getFullYear();
    var hours = currentTime.getHours();
    if (hours < 10) {
        hours = "0" + hours;
    }
    var minutes = currentTime.getMinutes();
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    var seconds = currentTime.getSeconds();
    if (seconds < 10) {
        seconds = "0" + seconds;
    }
    var strRet = year + "/" + month + "/" + day + " " + hours + ":" + minutes + ":" + seconds;
    return strRet;
}


function escapeChars(str) {
    return str.replace('"', '\'')
}
