michaelkappel.com
Michael Kappel, MCTS     ASP.net C# Application Development     Microsoft Certified Professional     and     Microsoft Certified Technology Specialist
MICHAELKAPPEL.COM

MICHAELKAPPEL.COM


Michael Kappel's Links
ASP.NET Code Samples
Acronym Search/Filter
Photo Search/Filter
Send Mike a Message
MJK.tel facebook.com LinkedIn.com m-i-k-e.myplaxo.com MySpace.com flickr.com BrightFuse.com
ToolKit.js
Files in "JS" Directory:
> Click Here to Download ToolKit.js <
// JScript File

// ToolKit.Web.UI.Javascript Support Functions
function setOpacity(obj, opacity) {
        try { obj.style.filter = "alpha(opacity=" + opacity + ")"; } catch (ex) { }
        try { obj.style.filters.alpha.opacity = opacity; } catch (ex) { }
        try {obj.style.opacity = (opacity / 100); } catch (ex) { }
        try { obj.style.MozOpacity = (opacity / 100); } catch (ex) { }
        try {obj.style.KhtmlOpacity = (opacity / 100); } catch (ex) { }
}
function OpacityOnOver(obj, out, over) {
    obj.opacityOver = over;
    obj.opacityOut = out;
    var oldonmouseover = obj.onmouseover;
    obj.onmouseover = function() {
        setOpacity(obj, obj.opacityOver);
        if (oldonmouseover) {
            oldonmouseover();
        }
    }
    var oldonmouseout = obj.onmouseout;
    obj.onmouseout = function() {
        setOpacity(obj, obj.opacityOut);
        if (oldonmouseout) {
            oldonmouseout();
        }
    }
    setOpacity(obj, obj.opacityOut);
}
function ObjectVar(clientId) {
    if (document.getElementById(clientId) != undefined) {
        return document.getElementById(clientId);
    } else {
        return null;
    }
}
function ValidatorVar(clientId) {
    if (eval("typeof " + clientId + " == 'object'")) {
        return eval(clientId);
    } else {
        return null;
    }
}
function onPageLoadComplete() {

}
function addLoadEvent(func) {
    if (func == 'Clear') {
        onPageLoadComplete = function() {
        }
    } else {
        var oldonload = onPageLoadComplete;
        onPageLoadComplete = function() {
            if (oldonload) {
                oldonload();
            }
            func();
            //document.write(func); 
        }
    }
}
// General DOM Functions
function ParentElement(obj, arg) {
    if (obj == null ||
        (obj.parentNode == null && obj.tagName.toLowerCase != arg.toLowerCase)
       ) return null;
    var result;
    if (obj.tagName.toLowerCase != arg.toLowerCase) {
        result = TableTop(obj.parentNode);
    } else {
        result = obj;
    }
    return result;
}
function FindElement(objArr, arg) {
    var result = '';
    for (var i = 0; i < objArr.length; i++) {
        if (objArr[i].id.indexOf(arg) >= 0) {
            result = objArr[i];
            break;
        }
    }
    return result;
}

function zBox(BoxId, Content) {
    this.content = Content;
    this.id = BoxId;
    this.table = document.createElement('table');
    this.tbody = document.createElement('tbody');
    this.row = document.createElement('tr');
    this.cell = document.createElement('td');
    this.div = document.createElement('div');
    this.open = function() {
        if (this.table.id) {
            this.table.style.display = 'block';
            this.div.innerHTML = this.content;
        } else {
            var pageBody = document.getElementsByTagName('body')[0];
            this.table.id = 'tbl' + this.id;
            this.table.style.display = 'block';
            this.table.style.position = 'fixed';
            this.table.style.width = '100%';
            this.table.style.height = '100%';
            this.table.style.zIndex = '9100';
            this.table.style.top = '0px';
            this.table.style.right = '0px';
            this.table.style.bottom = '0px';
            this.table.style.left = '0px';
            this.table.setAttribute("width", "100%");
            this.table.style.backgroundColor = 'transparent';
            pageBody.appendChild(this.table);
            this.table.appendChild(this.tbody);
            this.tbody.appendChild(this.row);
            this.row.appendChild(this.cell);
            this.cell.appendChild(this.div);
            this.cell.vAlign = 'middle';
            this.cell.align = 'center';
            this.cell.style.textAlign = 'center';
            this.cell.style.verticalAlign = 'middle';
            this.div.innerHTML = this.content;
            this.div.style.minWidth = '120px';
            this.div.style.minHeight = '80px';
            this.div.style.border = '1px solid green';
            this.div.style.backgroundColor = '#ffffff';
            this.div.style.color = '#000000';
            ToolKit.cover.open();
        }
    }
    this.show = function(arg) {
        this.content = arg;
        this.open();
    }
    this.close = function() {
        this.table.style.display = 'none';
        ToolKit.cover.close();
    }
}

//window.alert = function(arg) {
//    ToolKit.box.show(arg);
//}
function CoverAll(CoverId, color, opacity) {
    this.id = CoverId;
    this.table = document.createElement('table');
    this.tbody = document.createElement('tbody');
    this.row = document.createElement('tr');
    this.cell = document.createElement('td');
    this.cellText = document.createTextNode(' ');
    this.open = function() {
        if (this.table.id) {
            this.table.style.display = 'block';
        } else {
            var pageBody = document.getElementsByTagName('body')[0];
            this.table.id = 'tbl' + this.id;
            this.table.style.display = 'block';
            this.table.style.position = 'fixed';
            this.table.style.width = '100%';
            this.table.style.height = '100%';
            this.table.style.zIndex = '9000';
            this.table.style.top = '0px';
            this.table.style.right = '0px';
            this.table.style.bottom = '0px';
            this.table.style.left = '0px';
            this.table.setAttribute("width", "100%");
            this.table.style.backgroundColor = color;
            setOpacity(this.table, opacity);
            pageBody.appendChild(this.table);
            this.table.appendChild(this.tbody);
            this.tbody.appendChild(this.row);
            this.row.appendChild(this.cell);
            this.cell.appendChild(this.cellText);
        }
    }
    this.close = function() {
        this.table.style.display = 'none';
    }
}
// General String Functions
function ToolKitJS() {
    this.exists = function(objName) {
        if (eval("typeof(" + objName + ")!=='undefined' && " + objName + " != null")) {
            return true;
        } else {
            return false;
        }
    }
    this.number = function(arg) {
        return arg.replace(/[^0-9\-]/g, '');
    }
    this.decimal = function(arg) {
        return arg.replace(/[^0-9\-.]/g, '');
    }
    this.PhoneUs = function(arg) {
        return arg.replace(/[^0-9\-()\s]/g, '');
    }
    this.DateUs = function(arg) {
        return arg.replace(/[^0-9\/]/g, '');
    }
    this.Alphanumeric = function(arg) {
    return arg.replace(/[^0-9a-zA-Z\-\/]/g, '');
    }
    this.currency = function(arg) {
        var minus = '';
        if (arg < 0) { minus = '-'; }
        arg = arg + '';
        arg = arg.replace(/[^\d.]/g, '') - 0;
        var i = parseFloat(arg);
        if (isNaN(i)) { i = 0.00; }
        i = Math.abs(i);
        i = parseInt((i + .005) * 100);
        i = i / 100; 1
        s = new String(i);
        if (s.indexOf('.') < 0) { s += '.00'; }
        if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
        arg = minus + s;
        var delimiter = ","; // replace comma if desired
        var a = arg.split('.', 2)
        var d = a[1];
        var i = parseInt(a[0]);
        if (isNaN(i)) { return ''; }
        i = Math.abs(i);
        var n = new String(i);
        var a = [];
        while (n.length > 3) {
            var nn = n.substr(n.length - 3);
            a.unshift(nn);
            n = n.substr(0, n.length - 3);
        }
        if (n.length > 0) { a.unshift(n); }
        n = a.join(delimiter);
        if (d.length < 1) { arg = n; }
        else { arg = n + '.' + d; }
        arg = minus + arg;
        return '$' + arg;
    }
    this.validationClear = function() {
        for (v in Page_Validators) {
            Page_Validators[v].style.display = 'none';
        }
    }
    this.onError = function(ex) {
        alert('onError');
    }
    this.onTimeout = function(ex) {
        alert('onTimeout');
    }
    this.cover = new CoverAll('Cover', '#000000', 50);
    this.box = new zBox('Box', '');
    this.errors = function(ex, method, func) {
        try {
            var message = ex.message;
            var name = ex.name;
            var lineNumber = (ex.lineNumber || '0');
            var fileName = (ex.fileName || document.URLUnencoded);
            var stack = escape(ex.stack || '');
            var toError = setTimeout("wsErrors.ErrorHandler('" + message + "','" + method + "','" + name + "','" + lineNumber + "','" + fileName + "','" + stack + "'," + func + "," + this.onTimeout + "," + this.onError + ");", 0);
        } catch (ex) {
            var toError = setTimeout("wsErrors.ErrorHandler('Error in Error Handler','errors','Error in Error Handler','0','ToolKit.js','',null," + this.onTimeout + "," + this.onError + ");", 0);
        }
    }
}
var ToolKit = new ToolKitJS();
[MICHAELKAPPEL.COM Main] [Login] [My Photos] [My Links] [Contact Me] [Asp.net Code Samples] [Web Services] [Acronyms] [Characters]
[Mike's Flickr.com] [Fermi National Accelerator Laboratory] [Argonne National Laboratory] [Graffiti of the world] [Pictures Taken By People]
Microsoft Certified Technology Specialist