﻿function doSecureLogin(el) {
    if(el && el.form && el.form.action) {
        var protocol = "https://";
        if(window.location.hostname.indexOf("localhost") == 0) protocol = "http://"
        el.form.action = protocol + window.location.hostname + "/store/DoLogin.aspx";
    }
    return false;
}

function getElementsByClassName(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    return retnode;
};

function purge(d) {
    var a = d.attributes, i, l, n;
    if (a) {        
        l = a.length;        
        for (i = 0; i < l; i += 1) {            
            n = a[i].name;            
            if (typeof d[n] === 'function') {                
                d[n] = null;            
            }        
        }
    }
    a = d.childNodes;
    if (a) {        
        l = a.length;        
        for (i = 0; i < l; i += 1) {            
            purge(d.childNodes[i]);        
        }
    }
}

function purgeAll(){
    purge(window);
}

document.getElementsByClassName = getElementsByClassName;
window.onunload = purgeAll;