﻿String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.ByteCount = function() {
    txt = this.replace(/([\u0391-\uFFE5])/ig, '11');
    var count = txt.length;
    return count;
}
String.prototype.RepHTML = function() {
    return this.replace(/<[^>].*?>/g, "");
}
function getAbsoluteLeft(ob) {
    var mendingLeft = ob.offsetLeft;
    while (ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY") {
        mendingLeft += ob.offsetParent.offsetLeft;
        ob = ob.offsetParent;
    }
    return mendingLeft;
}
function getAbsoluteTop(ob) {
    var mendingTop = ob.offsetTop;
    while (ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY") {
        mendingTop += ob.offsetParent.offsetTop;
        ob = ob.offsetParent;
    }
    return mendingTop;
}
function chkInteger(NUM) {
    var pattern = /^-?([1-9]\d*|0)$/;
    if (NUM.length == 0) {
        return false;
    } else {
        return pattern.test(NUM);
    }
}

function DataRequest(url, strdata, callback) {
    var ajax = null;
    if (window.XMLHttpRequest) {
        ajax = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (url.indexOf("?") > 0) {
        url += "&rndnum=" + Math.random();
    }
    else {
        url += "?rndnum=" + Math.random();
    }
    ajax.open("post", url, true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    ajax.send(strdata);
    ajax.onreadystatechange = function() {
        if (ajax.readyState == 4 && ajax.status == 200) {
            callback(ajax);
        }
    }

}

function win_open(htmlurl, win_width, win_heihgt, win_left, win_top) {
    var newwin = window.open(htmlurl, "newWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=" + win_top + ",left=" + win_left + ",width=" + win_width + ",height=" + win_heihgt);
    if (newwin) { newwin.focus(); }
    return false;
}

