﻿function isNull(obj) {
    if (obj == null || typeof (obj) == 'undefined' || (!obj))
        return true;
    else
        return false;
}
var Class = {
    create: function() {
        return function() {
            this.initialize.apply(this, arguments);
        }
    }
}
Object.extend = function(destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
    return destination;
}
function addEventHandler(oTarget, sEventType, fnHandler) {
    if (!isNull(oTarget)) {
        if (oTarget.addEventListener) {
            oTarget.addEventListener(sEventType, fnHandler, false);
        } else if (oTarget.attachEvent) {
            oTarget.attachEvent("on" + sEventType, fnHandler);
        } else {
            oTarget["on" + sEventType] = fnHandler;
        }
    }
}

function removeEventHandler(oTarget, sEventType, fnHandler) {
    if (!isNull(oTarget)) {
        if (oTarget.detachEvent) {
            oTarget.detachEvent("on" + sEventType, fnHandler);
        } else if (oTarget.removeEventListener) {
            oTarget.removeEventListener(sEventType, fnHandler, false);
        } else {
            oTarget["on" + sEventType] = null;
        }
    }
}
function getDocumentRect() {
    var l, t, w, h;
    if (typeof (window.pageYOffset) != 'undefined') {
        l = window.pageXOffset;
        t = window.pageYOffset;
        w = window.innerWidth;
        h = window.innerHeight;
    }
    else if (typeof (document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
        l = document.documentElement.scrollLeft;
        t = document.documentElement.scrollTop;
        w = document.documentElement.clientWidth;
        h = document.documentElement.clientHeight;
    }
    else if (typeof (document.body) != 'undefined') {
        l = document.body.scrollLeft;
        t = document.body.scrollTop;
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    return { left: l, top: t, width: w, height: h };
}
function getElementRect(e) {
    var l = e.offsetLeft;
    var t = e.offsetTop;
    var w = e.offsetWidth;
    var h = e.offsetHeight;

    while (e = e.offsetParent) {
        l += e.offsetLeft;
        t += e.offsetTop;

        if (e.tagName.toLowerCase() == 'body') {
            break;
        }
    }
    return { left: l, top: t, width: w, height: h };
}
function getScroll() {
    var x, y;
    if (document.body.scrollTop) {
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    }
    else {
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    return { x: x, y: y };
}
function getQueryString() {
    var params = new Object();
    var query = location.search.substring(1); //获取查询串   
    var pairs = query.split("&"); //在逗号处断开   
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('='); //查找name=value   
        if (pos == -1) continue; //如果没有找到就跳过   
        var argName = pairs[i].substring(0, pos); //提取name   
        var argValue = pairs[i].substring(pos + 1); //提取value
        params[argName] = unescape(argValue); //存为属性   
    }
    return params; //返回对象
}
function getQueryString() {
    var params = new Object();
    var query = location.search.substring(1); //获取查询串   
    var pairs = query.split("&"); //在逗号处断开   
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('='); //查找name=value   
        if (pos == -1) continue; //如果没有找到就跳过   
        var argName = pairs[i].substring(0, pos); //提取name   
        var argValue = pairs[i].substring(pos + 1); //提取value
        params[argName] = unescape(argValue); //存为属性   
    }
    return params; //返回对象   
} 
