﻿//-------------字符串去除空格方法-------------------//
String.prototype.Trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function(){
    return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function(){
    return this.replace(/(\s*$)/g, "");
}
String.prototype.startsWith = function(s){
    return this.substring(0, s.length) == s;
}
String.prototype.endsWith = function (s) {
    var start = this.length - s.length;
    return this.substring(start) == s;
};
//-------------字符串去除空格方法-------------------//

//获得地址栏参数
function getQueryString(param)
{
    var query = window.location.search;
    var iLen = param.length;
    var iStart = query.indexOf(param);
    if (iStart == -1)
    return "";
    iStart += iLen + 1;
    var iEnd = query.indexOf("&", iStart);
    if (iEnd == -1)
    return query.substring(iStart);

    return query.substring(iStart, iEnd);
}

function   CheckDate(str){   
    var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);     
    if(r == null) return false;     
    var d = new Date(r[1], r[3]-1,r[4]);     
    return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);   
}

function CheckInteger(str){
    var r = str.match(/^\d*$/);
    if (r == null) return false;
    return true;
}

function CheckMoney(str){
    var r = str.match(/^(-)?(\d)*(\.(\d){2})?$/);
    if (r == null) return false;
    return true;
}

//删除提示
function DeleteConfirm(category,str){
    return confirm('确实要删除'+category+'【'+str+'】吗?\r\n点击确定删除,点击取消撤销操作.');
}

//删除提示
function DeleteConfirmMessage(message){
    return confirm(message);
}

//删除提示，来源是Select
function DeleteConfirmBySelect(category,select){
    if (select.selectedIndex<0)
        return false;
    return confirm('确实要删除'+category+'【'+select.options[select.selectedIndex].text+'】吗?\r\n点击确定删除,点击取消撤销操作.');
}

//验证是否为空值
function ValidateEmpty(source,errObj){
    if (source.value.Trim()==""){
        errObj.style.display="";
        return false;
    }
    else{
        errObj.style.display="none";
        return true;
    }
}

////日期格式化
//Date.prototype.format   =   function(format)   
//{   
//  var   o   =   {   
//      "M+"   :   this.getMonth()+1,   //month   
//      "d+"   :   this.getDate(),         //day   
//      "h+"   :   this.getHours(),       //hour   
//      "m+"   :   this.getMinutes(),   //minute   
//      "s+"   :   this.getSeconds(),   //second   
//      "q+"   :   Math.floor((this.getMonth()+3)/3),     //quarter   
//      "S"   :   this.getMilliseconds()   //millisecond   
//  }   
//  if(/(y+)/.test(format))   format=format.replace(RegExp.$1,   
//      (this.getFullYear()+"").substr(4   -   RegExp.$1.length));   
//  for(var   k   in   o)if(new   RegExp("("+   k   +")").test(format))   
//      format   =   format.replace(RegExp.$1,   
//          RegExp.$1.length==1   ?   o[k]   :     
//              ("00"+   o[k]).substr((""+   o[k]).length));   
//  return   format;   
//};  