﻿GlobalClass = function(document, window) {
    this._document = document;
    this._window = window;
    this._navigator = this._window.navigator;
    this._userAgent = this._navigator.userAgent;


    this.isMSIE = function() {
        return (this._userAgent.indexOf("MSIE") >= 0);
    }

    this.isMSIE6 = function() {
        return (this._userAgent.indexOf("MSIE 6.") >= 0);
    }

    this.isSafari = function() {
        return (this._userAgent.indexOf("Safari") >= 0);
    }

    this.isMozilla = function() {
        return (this._userAgent.indexOf("Firefox") >= 0);
    }

    this.isNull = function(item) {
        return (typeof (item) == 'undefined' || item == null)
    }

    this.toInt = function(item) {
        var result = 0;
        if (!this.isNull(item)) result = isNaN(parseInt(item)) ? 0 : parseInt(item);
        return result;
    }

    this.addHandler = function(obj, eventName, handler) {
        if (obj.attachEvent) {
            obj.attachEvent("on" + eventName, handler);
            return;
        }
        if (obj.addEventListener) {
            obj.addEventListener(eventName, handler, false);
            return;
        }
    }

    this.removeHandler = function(obj, eventName, handler) {
        if (obj.detachEvent) {
            obj.detachEvent("on" + eventName, handler);
            return;
        }
        if (obj.removeEventListener) {
            obj.removeEventListener(eventName, handler, false);
            return;
        }
    }

    this.disableSelection = function (target) {
        if (typeof target.onselectstart != "undefined") //IE route
            target.onselectstart = function() { return false }
        else if (typeof target.style.MozUserSelect != "undefined") //Firefox route
            target.style.MozUserSelect = "none"
        else //All other route (ie: Opera)
            target.onmousedown = function() { return false }
        target.style.cursor = "default"
    }
}
Global = new GlobalClass(document, window); 
