//Common
var hal = hal || {};
var ua = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var minVer = parseFloat(appVer);
var majVer = parseInt(minVer);
var isOpera = ua.indexOf("opera") != -1;
var isMac = ua.indexOf("mac") != -1;
var iePos = appVer.indexOf('msie');
if (iePos != -1) {
    minVer = parseFloat(appVer.substring(iePos + 5, appVer.indexOf(';', iePos)));
    majVer = parseInt(minVer)
}
var isSafari = ua.indexOf('safari') != -1;
var isFirefox = ua.indexOf('firefox/') != -1;
var isGecko = !isSafari && typeof navigator.product != 'undefined' && navigator.product.toLowerCase() == "gecko";
var isGver = isGecko ? navigator.productSub : 0;
var isIE = iePos != -1 && !isOpera && !isSafari;
var isIE6 = isIE && majVer == 6;
var isIE7up = isIE && minVer >= 7;
if (!Array.prototype.map) {
    Array.prototype.map = function (a) {
        var b = this.length;
        if (typeof a != 'function') return [];
        var c = new Array(b);
        var d = arguments[1];
        for (var i = 0; i < b; i++) if (i in this) c[i] = a.call(d, this[i], i, this);
        return c
    }
}
Array.prototype.inArray = function (a) {
    var b = this.length;
    for (var i = 0; i < b; i++) {
        if (this[i] === a) return true
    }
    return false
};
if (!String.prototype.trim) {
    String.prototype.trim = function () {
        return this.replace(/^\s+|\s+$/g, '')
    }
}
var Hal = {
    Cookie: function () {
        var f = this;
        this.setCookie = function (a, b, c) {
            if (!c) c = 30;
            var d = new Date();
            d.setTime(d.getTime() + (c * 24 * 60 * 60 * 1000));
            var e = '; expires=' + d.toGMTString();
            document.cookie = a + '=' + b + e + '; path=/'
        };
        this.getCookie = function (a) {
            var b = a + '=';
            var d = document.cookie.split(';');
            for (var i = 0; i < d.length; i++) {
                var c = d[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(b) == 0) return c.substring(b.length, c.length)
            }
            return null
        };
        this.deleteCookie = function (a) {
            f.setCookie(a, '', -1)
        }
    }
        /*
    Ajax: function (m, n, o) {
        var p = this;
        this.url = m;
        this.params = '';
        this.sendMethod = 'GET';
        this.callBackSuccess = n && typeof n == 'function' ?
        function (a) {
            n(a)
        } : function () {};
        this.callBackFailure = o && typeof o == 'function' ?
        function (a) {
            o(a)
        } : null;
        this.loadingHTML = '';
        this.loadingText = '';
        this.targetId = '';
        this.targetObject = null;
        this.timeout = null;
        this.proxyCache = 180000;
        this.getXmlHttp = function () {
            var a = false;
            if (window.XMLHttpRequest) a = new XMLHttpRequest();
            else if (window.ActiveXObject) {
                try {
                    a = new ActiveXObject('MSXML2.XMLHTTP')
                } catch(ex) {
                    try {
                        a = new ActiveXObject('Microsoft.XMLHTTP')
                    } catch(Ex) {
                        a = false
                    }
                }
            }
            return a
        };
        this._ao = new p.getXmlHttp();
        this.ajaxObject = p._ao;
        this.parseStyles = function (b) {
            var c = document.getElementsByTagName('head')[0];
            if (!c) return;
            var d = '<style[^>]*>([\u0001-\uFFFF]*?)</style>';
            var e = new RegExp(d, 'img');
            var f = new RegExp(d, 'im');
            var g = (b.match(e) || []).map(function (a) {
                return (a.match(f) || ['', ''])[1]
            });
            for (i = 0; i < g.length; i++) {
                var h = document.createElement('style');
                h.type = 'text/css';
                if (isIE) h.styleSheet.cssText = g[i];
                else {
                    var j = document.createTextNode(g[i]);
                    h.appendChild(j)
                }
                c.appendChild(h)
            }
        };
        this.sanitizeHtml = function (a) {
            var b = a;
            var c = b.match(new RegExp('<form[^>]+>', 'img'));
            if (c) b = b.substr(c.lastIndex);
            b = b.replace(new RegExp('<(script|style|iframe)[^>]*[\\S\\s]*?<\\/\\1>|<\\/(?:form|body|html)>', 'ig'), '');
            b = b.replace(/<input.*?(?=__EVENTTARGET)[^>]*>/i, '');
            b = b.replace(/<input.*?(?=__EVENTARGUMENT)[^>]*>/i, '');
            b = b.replace(/<input.*?(?=__VIEWSTATE)[^>]*>/i, '');
            b = b.replace(/<input.*?(?=__REQUESTDIGEST)[^>]*>/i, '');
            b = b.replace(/<input.*?(?=__EVENTVALIDATION)[^>]*>/i, '');
            if (document.getElementById('debugText')) document.getElementById('debugText').innerText = b;
            return b
        };
        this.parseScripts = function (b) {
            if (!b.match(/<script[^>]*>/ig)) return;
            var c = b;
            c = c.replace(/(?:\/\/<\!\[CDATA\[)|(?:\/\/\]\]>)|<\!\-\-|\/\/\-\->/ig, '');
            c = c.replace(/(?:<script.*\s*.*\s*)(?=var theForm)(?:[\s\S]*?)<\/script>/, '');
            c = c.replace(/(?:<script.*\s*.*\s*)(?=WebForm_OnSubmit)(?:[\s\S]*?)<\/script>/, '');
            c = c.replace(/(?:<script.*\s*.*\s*)(?=Sys\.WebForms)(?:[\s\S]*?)<\/script>/, '');
            var d = '<script[^>]*>([\u0001-\uFFFF]*?)<\/script>';
            var e = new RegExp(d, 'img');
            var f = new RegExp(d, 'im');
            var g = (c.match(e) || []).map(function (a) {
                return (a.match(f) || ['', ''])[1]
            });
            var h = g.join('\n');
            if (h.trim() == '') return;
            if (window.execScript) window.execScript(h);
            else window.eval(h)
        };
        this.getUrl = function (a) {
            a = a.toLowerCase();
            a += (a.indexOf('?') != -1 ? '&' : '?') + 't=' + (new Date()).getTime();
            if (a.indexOf('http') != 0) return a;
            if (a.indexOf((location.protocol + '//' + location.hostname).toLowerCase()) == 0) return a;
            return 'streamingproxy.axd?' + (p.proxyCache ? 'cache=' + p.proxyCache + '&' : '') + 'url=' + encodeURIComponent(a)
        };
        this.update = function (b, c, d, e, f, g) {
            var h = p.ajaxObject;
            if (h) {
                h.abort();
                if (p.timeout) var i = setTimeout(function () {
                    h.abort()
                },
                p.timeout);
                var j = null;
                if (c) {
                    if (typeof c == 'object') j = c;
                    else j = document.getElementById(c);
                    p.targetObject = j
                } else j = document.getElementById(p.targetId) || p.targetObject;
                h.onreadystatechange = function () {
                    if (h.readyState == 4) {
                        if (typeof i != 'undefined') clearTimeout(i);
                        if (h.status >= 200 && h.status < 300) {
                            var a = h.responseText;
                            p.parseStyles(a);
                            if (j) j.innerHTML = p.sanitizeHtml(a);
                            if (d && typeof d == 'function') d(a, j);
                            else p.callBackSuccess(a, j);
                            p.parseScripts(a)
                        } else {
                            if (e && typeof e == 'function') e(h.status, j);
                            else if (p.callBackFailure) p.callBackFailure(h.status, j);
                            else if (j) j.innerHTML = ''
                        }
                        delete h
                    } else if (j) j.innerHTML = p.loadingHTML != '' ? p.loadingHTML : '<div style="text-align:center;font-size:11px;color:#444444"><img src="' + (typeof _imagePath != 'undefined' ? _imagePath : '/images/') + 'ajax-loader.gif" alt="Loading..." /><br />' + (p.loadingText != '' ? p.loadingText : 'Loading...') + '</div>'
                };
                var k = b || p.url;
                if (k) p.url = k;
                k = p.getUrl(k);
                var l = g || p.params || '';
                if (!f) var f = p.sendMethod;
                h.open(f, k, true);
                if (f.toUpperCase() == 'POST') {
                    h.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                    h.send(l)
                } else h.send(null)
            }
        };
        this.submit = function (a, b, c, d) {
            p.sendMethod = 'POST';
            var e = document.forms[0].elements;
            var f;
            var g = '';
            for (var i = 0; i < e.length; i++) {
                f = e[i];
                if (f.name && f.name.length > 0 && f.name != '__VIEWSTATE' && f.name != '__EVENTVALIDATION') g += f.name + '=' + f.value + '&'
            }
            p.params = g.substr(0, g.length - 1);
            p.update(a, b, c, d)
        }
    }
        */
};
hal.getScrollTop = function () {
    return document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset || 0
};
hal.getScrollLeft = function () {
    return document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset || 0
};
hal.getWinHeight = function () {
    return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0
};
hal.getWinWidth = function () {
    return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0
};
hal.getScrollHeight = function () {
    return document.body.parentNode.scrollHeight
};
hal.getScrollWidth = function () {
    return document.body.parentNode.scrollWidth
};
hal.getObjDim = function (a) {
    var b = [];
    b[0] = a.offsetWidth;
    b[1] = a.offsetHeight;
    return b
};
hal.getObjPos = function (a) {
    var b = [],
        objLeft = 0,
        objTop = 0;
    while (a != null) {
        objLeft += a.offsetLeft;
        objTop += a.offsetTop;
        a = a.offsetParent
    }
    b[0] = objLeft;
    b[1] = objTop;
    return b
};
hal.getPlaceholder = function (a) {
    var d = document;
    var a = a || 'gPh';
    var b = d.getElementById(a);
    if (!b) {
        b = d.createElement('div');
        b.id = a;
        b.style.position = 'absolute';
        b.style.display = 'none';
        d.body.insertBefore(b, d.body.childNodes[0])
    }
    return b
};
hal.getIFrame = function (a) {
    if (!isIE6) return null;
    var d = document;
    var a = a || 'gIfm';
    var b = d.getElementById(a);
    if (!b) {
        var c = hal.getPlaceholder();
        b = d.createElement('iframe');
        if (window.location.protocol == 'https:') window.location.protocol+'//'+window.location.host+'/blank.html';
        c.parentNode.insertBefore(b, c);
        b.id = a;
        b.className = 'gIfm';
        b.frameBorder = '0';
        b.scrolling = 'no'
    }
    return b
};
hal.addEvent = function (a, b, c, d) {
    if (typeof a == 'string') var a = document.getElementById(a);
    if (a.addEventListener) {
        a.addEventListener(b, c, d || false);
        return true
    } else if (a.attachEvent) {
        var r = a.attachEvent('on' + b, c);
        return r
    } else a['on' + b] = c
};


function halert(c, a) {
    var b = hal.spl;
    if (a) {
        if (typeof a == 'object') b.oTf = a;
        else b.oTf = document.getElementById(a)
    }
    if (!b.alertPanel) b.alertPanel = new Hal.StagePanel('alertPnl');
    var d = b.alertPanel;
    d.innerHTML = c;
    d.apply();
    d.open();
    if (d.okButton && d.okButton.focus) d.okButton.focus();
    return
}
function hconfirm(c, a, b) {
    var d = null;
    if (typeof a == 'object') {
        d = a;
        var a = d.OnClientOk;
        if (typeof a == 'string') d.onClientOk = function () {
            eval(a)
        };
        else if (typeof a == 'function') d.onClientOk = function () {
            a()
        };
        var b = d.OnClientCancel;
        if (typeof b == 'string') d.onClientCancel = function () {
            eval(b)
        };
        else if (typeof b == 'function') d.onClientCancel = function () {
            b()
        }
    } else {
        if (!hal.spl.confirmPanel) hal.spl.confirmPanel = new Hal.StagePanel('confirmPnl');
        d = hal.spl.confirmPanel;
        if (a) {
            if (typeof a == 'string') d.onClientOk = function () {
                eval(a)
            };
            else if (typeof a == 'function') d.onClientOk = function () {
                a()
            }
        }
        if (b) {
            if (typeof b == 'string') d.onClientCancel = function () {
                eval(b)
            };
            else if (typeof b == 'function') d.onClientCancel = function () {
                b()
            }
        }
    }
    d.innerHTML = c;
    d.apply();
    d.open();
    if (d.okButton && d.okButton.focus) d.okButton.focus();
    return
}
//Calendar2
hal.cal = {
    cHd: 300,
    gMx: 365,
    tC: '',
    gCO: {},
    cMt: new Date().getMonth() + 1,
    cDt: new Date().getDate(),
    cYr: new Date().getFullYear(),
    cDi: new Date().getTime(),
    c_mOvr: function (a) {
        hal.cal.tC = a.className;
        if (hal.cal.tC != 'ddIv' && hal.cal.tC != 'ddNn') a.className = hal.cal.tC + ' cOvr'
    },
    c_mOut: function (a) {
        a.className = hal.cal.tC
    },
    fYr: function (a) {
        var b = a.getYear();
        var d = b % 100;
        d += d < 38 ? 2000 : 1900;
        return d
    },
    aDy: function (a, b) {
        var d = new Date(2000, 1, 1),
            f = new Date(2000, 1, 1);
        if (d.setDate(128) > f.valueOf()) {
            b.setDate(b.getDate() + a);
            return b
        }
        for (var c = 96; a > c; a -= c) b.setDate(b.getDate() + c);
        b.setDate(b.getDate() + a);
        return b
    },
    hide: function () {
        var a = document.getElementById('calPnl');
        if (a) a.style.display = 'none';
        var b = document.getElementById('calIfm');
        if (b) b.style.display = 'none'
    },
    clrC: function () {
        var a = document.getElementById('calPnl');
        if (a) a.innerHTML = '';
        hal.cal.hide()
    },
    cEv: function (a) {
        if (!a) var a = window.event;
        a.cancelBubble = true;
        if (a.stopPropagation) a.stopPropagation()
    },
    gLDi: function (a) {
        return (isNaN(a) || a < hal.cal.cDi) ? hal.cal.cDi : a
    },
    gDsfi: function (a) {
        return hal.cal.gDsfo(new Date(a))
    },
    gDsfo: function (a) {
        return (a.getMonth() + 1) + '/' + a.getDate() + '/' + hal.cal.fYr(a)
    }
};
Hal.Calendar = function (k, g, l, callback) {
    var B = document.getElementById(k);
    if (!B) return;
    var o = hal.cal;
    var r = this;
    var G = B;
    g = g || k;
    if (typeof o.gCO[g] == 'undefined') o.gCO[g] = {};
    var w = o.gCO[g];
    if (typeof w.cOa == 'undefined') w.cOa = [];
    if (typeof w.cIa == 'undefined') w.cIa = [];
    if (!w.cOa.inArray(k)) {
        w.cOa.push(k);
        w.cIa.push(o.cDi)
    }
    this.id = k;
    this.groupName = g;
    this.title = l;
    this.textBox = G;
    this.groupObj = w;
    this.cOa = w.cOa;
    this.cIa = w.cIa;
    this.panel = document.getElementById('calPnl');
    this.iFrame = hal.getIFrame('calIfm');
    this.stagePanel = null;
    this.register = function () {
        var m = r.textBox;
        m.onfocus = function (a) {
            r.open(a);
            if (this.select) this.select()
        };
        m.onclick = function (a) {
            r.open(a)
        };
        m.onblur = function (a) {
            var b = r.textBox;
            var d = Date.parse(b.value);
            if (isNaN(d)) d = o.cDi;
            var f = new Date(d);
            var c = new Date(o.fYr(f), f.getMonth(), f.getDate());
            d = c.getTime();
            var e = new Date(o.cDi);
            e = o.aDy(o.gMx, e);
            var n = e.getTime();
            if (d < o.cDi) d = o.cDi;
            else if (d > n) d = n;
            c.setTime(d);
            b.value = o.gDsfo(c);
            r.setText(d);
         	if (typeof callback == 'function') {
         		setTimeout(callback, 500);
         	}
       };
        m.onkeydown = function (a) {
            if (!a) var a = window.event;
            var b = a.preventDefault ? a.which : a.keyCode;
            if (b == 9) o.hide()
        };
        if (m.value.trim().length == 0) m.value = o.gDsfo(new Date())
    };
    this.register();
};
Hal.Calendar.prototype.init = function () {
    var a = this;
    var b = hal.cal;
    var d = a.cOa;
    var f = a.cIa;
    if (d.length != f.length) return;
    var c, e;
    for (var n = 0; n < d.length; n++) {
        c = document.getElementById(d[n]);
        e = b.gLDi(Date.parse(c.value));
        f[n] = e;
        c.value = b.gDsfi(e)
    }
};
Hal.Calendar.prototype.load = function (b, d) {
    var f = this;
    var c = hal.cal;
    var e = f.cOa;
    var n = f.cIa;
    var m = f.cHt;
    var k = f.textBox;
    c.clrC();
    var g = document;
    var l = new Date();
    l.setTime(d);
    var B = l.getFullYear();
    var o = l.getMonth() + 1;
    var r = l.getDate();
    var G = e.length == 2;
    var w = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    var Q = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var S = 'table';
    var E = 'tr';
    var O = 'th';
    var M = 'td';
    var P = 'tbody';
    var A = g.createElement(S);
    A.border = 0;
    A.cellPadding = 0;
    A.cellSpacing = 0;
    A.className = 'gTb';
    if (G) {
        var T = g.createElement('thead');
        A.appendChild(T);
        var V = g.createElement(E);
        T.appendChild(V);
        var C = g.createElement(O);
        C.colSpan = 2;
        C.className = 'gTh ' + (k == g.getElementById(e[0]) ? 'gTh0' : 'gTh1');
        var bh;
        C.innerHTML = k == g.getElementById(e[0]) ? f.title || 'Arrival Date' : f.title || 'Departure Date';
        V.appendChild(C)
    }
    var F = g.createElement(P);
    A.appendChild(F);
    var D = g.createElement(E);
    F.appendChild(D);
    var H = g.createElement(M);
    H.colSpan = 2;
    D.appendChild(H);
    var t = g.createElement(S);
    t.border = 0;
    t.cellPadding = 0;
    t.cellSpacing = 0;
    t.className = 'mTb';
    H.appendChild(t);
    var h = g.createElement(P);
    var j, z, q, u, y, v;
    t.appendChild(h);
    var bd = c.cYr;
    var N = c.cMt;
    var bi = c.cDt;
    for (var be = 0; be < 2; be++) {
        q = g.createElement(E);
        h.appendChild(q);
        for (var bf = 0; bf < 6; bf++) {
            if (N > 12) {
                N = 1;
                bd += 1
            }
            l.setTime(Date.parse(N + '/1/' + bd));
            u = g.createElement(M);
            q.appendChild(u);
            u.className = (N == o || N == (o + 1 > 12 ? 1 : o + 1) ? 'mTds' : 'mTd');
            u.id = l.getTime() + 'mm';
            u.innerHTML = w[N - 1].substr(0, 3);
            u.onclick = function (a) {
                c.cEv(a);
                f.load(a, parseInt(this.id))
            };
            N++
        }
    }
    var W = g.createElement(E);
    W.style.verticalAlign = 'top';
    F.appendChild(W);
    var R = B,
        I = o,
        bj = r,
        J = false,
        bk = true,
        X = false,
        U = 1;
    var Y = new Date(c.cDi);
    Y = c.aDy(c.gMx, Y);
    for (p = 0; p < 2; p++) {
        var K = new Date(R, I - 1, 1);
        K.od = K.getDay() + 1;
        var Z = new Date();
        var bg = (R == Z.getFullYear() && I == Z.getMonth() + 1) ? Z.getDate() : 0;
        Q[1] = (((K.getFullYear() % 100 != 0) && (K.getFullYear() % 4 == 0)) || (K.getFullYear() % 400 == 0)) ? 29 : 28;
        u = g.createElement(M);
        W.appendChild(u);
        u.className = 'dTbC';
        j = g.createElement(S);
        u.appendChild(j);
        j.border = 0;
        j.cellPadding = 0;
        j.cellSpacing = 0;
        j.className = 'dTb';
        z = g.createElement(P);
        j.appendChild(z);
        q = g.createElement(E);
        z.appendChild(q);
        y = g.createElement(O);
        q.appendChild(y);
        y.className = 'mNm';
        y.colSpan = 7;
        y.innerHTML = w[I - 1] + ' ' + R;
        q = g.createElement(E);
        z.appendChild(q);
        for (s = 0; s < 7; s++) {
            y = g.createElement(O);
            q.appendChild(y);
            y.className = 'dOw';
            y.innerHTML = 'SMTWTFS'.substr(s, 1)
        }
        q = g.createElement(E);
        z.appendChild(q);
        q.className = 'dtRw';
        for (i = 1; i <= 42; i++) {
            u = g.createElement(M);
            q.appendChild(u);
            v = '';
            x = ((i - K.od >= 0) && (i - K.od < Q[I - 1])) ? i - K.od + 1 : '&nbsp;';
            J = !isNaN(x);
            if (i == 36 && !J) {
                z.removeChild(q);
                break
            }
            var ba = J ? new Date(R, I - 1, x) : null;
            var L = J ? ba.getTime() : null;
            if (X) {
                v = 'sDts'
            } else if (x == bg) {
//                v = 'ddTy' // today should be unavailable
                v = 'ddIv';
                J = false
            } else if (!J) {
                v = 'ddNn'
            } else if ((x < bg || (J && ba && ba > Y)) && x < 32) {
                v = 'ddIv';
                J = false
            } else {
                v = 'ddNm'
            }
            if (J) {
                if (G) {
                    var bb = n[0];
                    var bc = n[1];
                    if (L == bb && L == bc) {
                        v = 'sDtb'
                    } else if (L == bb) {
                        v = 'sDt0';
                        X = true
                    } else if (L == bc) {
                        v = 'sDt1';
                        X = false
                    } else if (L > bb && L < bc) {
                        v = 'sDts'
                    }
                } else {
                    if (L == Date.parse(k.value)) v = 'sDt'
                }
                if (U == 1 || U == 7) {
                    v += ' ddWe'
                }
                u.id = L + 'dd';
                u.onclick = function (a) {
                    f.sTT(a, this)
                }
            }
            u.onmouseover = function () {
                c.c_mOvr(this)
            };
            u.onmouseout = function () {
                c.c_mOut(this)
            };
            u.className = v;
            u.innerHTML = u.textContent = x;
            U++;
            if (i % 7 == 0 && i < 36) {
                q = g.createElement(E);
                z.appendChild(q);
                U = 1
            }
        }
        I += 1;
        if (I > 12) {
            I = 1;
            R += 1
        }
    }
    f.loadPlaceholder();
    f.panel.appendChild(f.container(A));
    f.show(b, G)
};
Hal.Calendar.prototype.loadPlaceholder = function () {
    var b = this;
    var d = hal.cal;
    var f = document,
        c = 'calPnl';
    var e = b.panel;
    if (!e) {
        e = hal.getPlaceholder(c);
        e.onmouseover = function (a) {};
        e.onmouseout = function (a) {};
        e.onclick = function (a) {
            d.cEv(a)
        };
        b.panel = e
    }
    e.innerHTML = ''
};
Hal.Calendar.prototype.show = function () {
    var a = this;
    var b = a.getPos();
    var d = b[0] + 'px';
    var f = b[1] + 'px';
    if (a.panel) {
        var c = a.panel;
        c.style.left = d;
        c.style.top = f;
        c.style.zIndex = 500000;
        c.style.display = 'block';
        if (a.iFrame) {
            var e = a.iFrame;
            e.style.width = c.offsetWidth;
            e.style.height = c.offsetHeight;
            e.style.left = d;
            e.style.top = f;
            e.style.zIndex = 999;
            e.style.display = 'block'
        }
    }
};
Hal.Calendar.prototype.sTT = function (a, b) {
    var d = this;
    var f = hal.cal;
    var c = parseInt(b.id);
    var e = new Date(c);
    d.textBox.value = f.gDsfo(e);
    d.setText(c);
    d.focusNext(a, c)
};
Hal.Calendar.prototype.focusNext = function (a, b) {
    var d = this,
        f = document,
        c = hal.cal,
        e = d.textBox,
        n = d.cOa,
        m = d.cIa,
        k, g = n.length,
        l;
    for (i = 0; i < g; i++) {
        l = i + 1;
        if (e == f.getElementById(n[i])) {
            if (l == g) {
                if (g == 2) {
                    d.load(a, b);
                    setTimeout('hal.cal.hide()', c.cHd);
                    return
                }
                c.hide();
                return
            } else if (l > g) return;
            k = f.getElementById(n[l]);
            break
        }
    }
    var B = k.parentNode;
    if (B && (B.style.display == 'none' || B.style.visibility == 'hidden')) {
        k.value = e.value;
        c.hide();
        return
    }
    if (k.focus && k.select) {
        k.focus();
        k.select()
    }
};
Hal.Calendar.prototype.open = function (a) {
    var b = this;
    var d = hal.cal;
    d.cEv(a);
    var f = b.textBox;
    b.init();
    var c = d.cDi;
    if (!isNaN(Date.parse(f.value))) {
        var e = new Date();
        e.setTime(Date.parse(f.value));
        if (e.getTime() >= d.cDi) c = e.getTime()
    }
    b.setText(c);
    b.load(a, c)
};
Hal.Calendar.prototype.m_onClick = function (a, b) {
    hal.cal.cEv(a);
    this.load(a, parseInt(b.id))
};
Hal.Calendar.prototype.setText = function (a) {
    var b = this,
        d = b.textBox,
        f = b.cOa,
        c = b.cIa;
    if (!f || !c) return;
    var e, n, m, k = f.length,
        g = false;
    for (var l = 0; l < k; l++) {
        e = document.getElementById(f[l]);
        n = e.value;
        m = Date.parse(n);
        if (d == e) g = true;
        if (g) {
            if (isNaN(m) || m < a) e.value = d.value
        } else {
            if (isNaN(m) || m > a) e.value = d.value
        }
        c[l] = Date.parse(e.value)
    }
};
Hal.Calendar.prototype.getPos = function () {
    var a = this;
    var b = a.textBox;
    var d = [];
    var f = 0;
    var c = 0;
    var e = b.offsetHeight;
    var n = hal.getScrollTop();
    var m = 235;
    while (b != null) {
        f += b.offsetLeft;
        c += b.offsetTop;
        b = b.offsetParent
    }
    if (c - m >= n && c + e + m > hal.getWinHeight() + n) c -= (m + 2);
    else c += e;
    d[0] = f - 5;
    d[1] = c;
    return d
};
Hal.Calendar.prototype.container = function (a) {
    var b = document;
    var d = 'relative';
    var f = 'table';
    var c = 'div';
    var e = 'tbody';
    var n = 'tr';
    var m = 'td';
    var k = 'img';
    var g = 'button';
    var l = _imagePath || '/images/';
    var B = 'spacer';
    var o = 'px';
    var r = 'Module';
    var G = 'Content';
    var w = 'Top';
    var Q = w.toLowerCase();
    var S = 'Row';
    var E = 'Table';
    var O = 'Main';
    var M = 'Left';
    var P = 'Right';
    var A = 'Bottom';
    var T = A.toLowerCase();
    var V = 'Cell';
    var C = '.gif';
    var bh = 'Title';
    var F = '100%';
    var D = b.createElement(f);
    D.border = 0;
    D.cellPadding = 0;
    D.cellSpacing = 0;
    D.style.width = F;
    D.style.height = F;
    var H = b.createElement(e);
    D.appendChild(H);
    var t = b.createElement(n);
    H.appendChild(t);
    t.style.verticalAlign = T;
    var h = b.createElement(m);
    t.appendChild(h);
    h.className = r + w + M;
    var j = b.createElement(k);
    h.appendChild(j);
    j.src = l + r + '_tl' + C;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + w;
    //h.style.width = F;
    j = b.createElement(k);
    h.appendChild(j);
    j.src = l + B + C;
    j.style.width = '290px'; //(isSafari ? 200 : 1) + o;
    j.style.height = 1 + o;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + w + P;
    j = b.createElement(k);
    h.appendChild(j);
    j.src = l + r + '_tr' + C;
    t = b.createElement(n);
    H.appendChild(t);
    t.style.verticalAlign = Q;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + O;
    h.colSpan = 3;
    h.style.width = F;
    var z = b.createElement(c);
    h.appendChild(z);
    z.className = r + O + G;
    z.style.position = d;
    if (!isIE) {
        j = b.createElement(k);
        z.appendChild(j);
        j.src = l + 'GradWhite.png';
        j.className = r + 'GradientImg';
        j.style.zIndex = 1
    }
    var q = b.createElement(c);
    z.appendChild(q);
    q.className = r + G;
    q.style.padding = 7 + o;
    q.style.position = d;
    var u = b.createElement(c);
    q.appendChild(u);
    u.appendChild(a);
    var y = b.createElement(c);
    q.appendChild(y);
    y.style.textAlign = 'center';
    y.style.marginTop = '7px';
    var v = b.createElement('a');
    y.appendChild(v);
    v.className = 'cLnk';
    v.href = 'javascript:void(0)';
    v.innerHTML = 'Close';
    v.onclick = function () {
        hal.cal.hide();
        return false
    };
    t = b.createElement(n);
    H.appendChild(t);
    t.style.verticalAlign = Q;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + A + M;
    j = b.createElement(k);
    h.appendChild(j);
    j.src = l + r + '_bl' + C;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + A;
    h.style.width = F;
    j = b.createElement(k);
    h.appendChild(j);
    j.src = l + B + C;
    h = b.createElement(m);
    t.appendChild(h);
    h.className = r + A + P;
    j = b.createElement(k);
    h.appendChild(j);
    j.src = l + r + '_br' + C;
    return D
};
if (window.addEventListener) document.addEventListener('click', hal.cal.hide, false);
else if (window.attachEvent) document.attachEvent('onclick', hal.cal.hide);
else if (document.getElementById) document.onclick = hal.cal.hide();
