/* var pollingUriPath = window.location.pathname;
if (!pollingUriPath || pollingUriPath == "/") {
    var pollingUriName = "index.cgx"
} else {
    var pollingUriName = pollingUriPath.substr(pollingUriPath.lastIndexOf("/") + 1, pollingUriPath.lastIndexOf(".") - pollingUriPath.lastIndexOf("/")) + "cgx"
} */
if(document.URL.match(/^(http:\/\/|https:\/\/)?[a-z0-9]+:[a-z0-9]+@[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/g)) {
    window.location.href = window.location.href;
}

var pollingTimerHandler = null;
var pollingTimerInterval = 0;
var editLastValue = null;


var arrIMG = [];
var ts = 0;

function AddPreCacheImage(a, b) {
    if (a == "?") {
        a = "EVO_STA_IMG_" + arrIMG.length
    }
    arrIMG.push({
        id: a,
        src: b
    });
    return a
}
var tmrChkImg = null;
var docIMGelement = null;
var imageIdx = 0;

function SerializeImageLoading() {
    if (imageIdx >= arrIMG.length) {
        ThrowPageLoadingOverlay();
        periodicUpdate();
        return
    }
    if (arrIMG[imageIdx].id != "") {
        docIMGelement = document.getElementById(arrIMG[imageIdx].id)
    } else {
        docIMGelement = new Image()
    }
    docIMGelement.src = arrIMG[imageIdx].src;
    tmrChkImg = setTimeout("goToNextImage();", 10)
}

function pauseJS(c) {
    var b = new Date();
    var a = null;
    do {
        a = new Date()
    } while (a - b < c)
}

function goToNextImage() {
    if (docIMGelement.complete) {
        pauseJS(1);
        imageIdx += 1;
        SerializeImageLoading()
    } else {
        tmrChkImg = setTimeout("goToNextImage();", 5)
    }
}

function EVO_Image(c, d, b, a, e) { }

function EVO_CheckBox(e, c, a, d) { }

function EVO_Select(e, b, d, c) { }

function EVO_Radio(e, b, d, a, c) { }

function EVO_Button(e, b, d, a, c) { }

function EVO_Text(d, i, g, a, b, c, f) { }

function EVO_DivImgMap(e, g, b, c, a, h) { }

function EVO_ImgMap(j, g, a, d, e, c) { }

function EVO_HtmlItem(c, a, b) { }

var Base64 = {
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
    encode: function (c) {
        var a = "";
        var k, h, f, j, g, e, d;
        var b = 0;
        while (b < c.length) {
            k = c[b++];
            h = c[b++];
            f = c[b++];
            j = k >> 2;
            g = ((k & 3) << 4) | (h >> 4);
            e = ((h & 15) << 2) | (f >> 6);
            d = f & 63;
            if (isNaN(h)) {
                e = d = 64
            } else {
                if (isNaN(f)) {
                    d = 64
                }
            }
            a += this._keyStr.charAt(j) + this._keyStr.charAt(g) + this._keyStr.charAt(e) + this._keyStr.charAt(d)
        }
        return a
    }
};

function setCookie(b, d, a) {
    var e = new Date();
    e.setTime(e.getTime() + (a * 60 * 60 * 1000));
    var c = escape(d) + ((a == null) ? "" : "; expires=" + e.toUTCString());
    document.cookie = b + "=" + c
}

function getCookie(b) {
    var c, a, e, d = document.cookie.split(";");
    for (c = 0; c < d.length; c++) {
        a = d[c].substr(0, d[c].indexOf("="));
        e = d[c].substr(d[c].indexOf("=") + 1);
        a = a.replace(/^\s+|\s+$/g, "");
        if (a == b) {
            return unescape(e)
        }
    }
}

function EncodePassword(b) {
    if (!b) {
        return ""
    }
    var a = [];
    for (var c = 0; c < b.length; c++) {
        a.push((((b.charCodeAt(c) ^ 231) + 169) % 256) ^ 139)
    }
    return Base64.encode(a)
}

function EVO_CheckPassword(a, b) {
    if (!a) {
        return true
    }
    var c = getCookie(location.pathname);
    if (c && EncodePassword(c) == a) {
        return true
    }
    c = prompt("Please enter password :", "");
    if (!c) {
        history.back();
        return false
    }
    if (EncodePassword(c) == a) {
        if (b) {
            setCookie(location.pathname, c, b)
        }
        return true
    } else {
        alert("Wrong password entered !\n ");
        history.back();
        return false
    }
};