﻿function addBookmarkForBrowser() {
    var sTitle = document.title; //"完整版全国列车时刻表、航班、手机号码段数据库下载";
    var sUrl = parent.location.href; //"http://train.myds.cn/";
    if (window.sidebar) { window.sidebar.addPanel(sTitle, sUrl, ""); } else if (document.all) { window.external.AddFavorite(sUrl, sTitle); } else if (window.opera && window.print) { alert("浏览器不支持收藏脚本，请自己添加"); return true; }
    /*
    if (window.sidebar) {
        addBookmarkForBrowser = function(sTitle, sUrl) {
            window.sidebar.addPanel(sTitle, sUrl, "");
        }
    }
    else if (window.external) {
        addBookmarkForBrowser = function(sTitle, sUrl) {
            window.external.AddFavorite(sUrl, sTitle);
        }
    }
    else {
        addBookmarkForBrowser = function() {
            alert("浏览器不支持收藏脚本，请自己添加");
        }
    }
    return addBookmarkForBrowser(sTitle, sUrl);
    */
}

//JS 判断中文
function isChinese(temp) {
    var reg = /.*[\u4e00-\u9fa5]+.*$/;
    return reg.test(temp);
} 

//JS StringBuilder
function StringBuilder(value) {
    this.strings = new Array("");
    this.Append(value);
}
// Appends the given value to the end of this instance. 
StringBuilder.prototype.Append = function(value) {
    if (value) {
        this.strings.push(value);
    }
}
// Clears the string buffer 
StringBuilder.prototype.Clear = function() {
    this.strings.length = 1;
}
// Converts this instance to a String. 
StringBuilder.prototype.toString = function() {
    return this.strings.join("");
}

//JS Trim() , Ltrim() , RTrim()
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, "");
}

function windowClose() {
    parent.window.opener = null;
    parent.window.open("", "_self");
    parent.window.close();
}
