﻿var Behaviour = { list: new Array, register: function(sheet) { Behaviour.list.push(sheet); }, start: function() { Behaviour.addLoadEvent(function() { Behaviour.apply(); }); }, apply: function() {
    for (h = 0; sheet = Behaviour.list[h]; h++) {
        for (selector in sheet) {
            list = document.getElementsBySelector(selector); if (!list) { continue; }
            for (i = 0; element = list[i]; i++) { sheet[selector](element); } 
        } 
    } 
}, addLoadEvent: function(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } 
}
Behaviour.start(); function getAllChildren(e) { return e.all ? e.all : e.getElementsByTagName('*'); }
document.getElementsBySelector = function(selector) {
    if (!document.getElementsByTagName) { return new Array(); }
    var tokens = selector.split(' '); var currentContext = new Array(document); for (var i = 0; i < tokens.length; i++) {
        token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, ''); ; if (token.indexOf('#') > -1) {
            var bits = token.split('#'); var tagName = bits[0]; var id = bits[1]; var element = document.getElementById(id); if (tagName && element.nodeName.toLowerCase() != tagName) { return new Array(); }
            currentContext = new Array(element); continue;
        }
        if (token.indexOf('.') > -1) {
            var bits = token.split('.'); var tagName = bits[0]; var className = bits[1]; if (!tagName) { tagName = '*'; }
            var found = new Array; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) {
                var elements; if (tagName == '*') { elements = getAllChildren(currentContext[h]); } else { elements = currentContext[h].getElementsByTagName(tagName); }
                for (var j = 0; j < elements.length; j++) { found[foundCount++] = elements[j]; } 
            }
            currentContext = new Array; var currentContextIndex = 0; for (var k = 0; k < found.length; k++) { if (found[k].className && found[k].className.match(new RegExp('\\b' + className + '\\b'))) { currentContext[currentContextIndex++] = found[k]; } }
            continue;
        }
        if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
            var tagName = RegExp.$1; var attrName = RegExp.$2; var attrOperator = RegExp.$3; var attrValue = RegExp.$4; if (!tagName) { tagName = '*'; }
            var found = new Array; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) {
                var elements; if (tagName == '*') { elements = getAllChildren(currentContext[h]); } else { elements = currentContext[h].getElementsByTagName(tagName); }
                for (var j = 0; j < elements.length; j++) { found[foundCount++] = elements[j]; } 
            }
            currentContext = new Array; var currentContextIndex = 0; var checkFunction; switch (attrOperator) { case '=': checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); }; break; case '~': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b'))); }; break; case '|': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?'))); }; break; case '^': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); }; break; case '$': checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); }; break; case '*': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); }; break; default: checkFunction = function(e) { return e.getAttribute(attrName); }; }
            currentContext = new Array; var currentContextIndex = 0; for (var k = 0; k < found.length; k++) { if (checkFunction(found[k])) { currentContext[currentContextIndex++] = found[k]; } }
            continue;
        }
        if (!currentContext[0]) { return; }
        tagName = token; var found = new Array; var foundCount = 0; for (var h = 0; h < currentContext.length; h++) { var elements = currentContext[h].getElementsByTagName(tagName); for (var j = 0; j < elements.length; j++) { found[foundCount++] = elements[j]; } }
        currentContext = found;
    }
    return currentContext;
}
function monorail_formhelper_numberonly(e, exceptions, forbidalso) {
    exceptions = exceptions.concat([8, 9, 13, 38, 39, 40, 46]); var code = e.charCode; if (!code) code = e.keyCode; if ((e.ctrlKey && code == 118) || (e.ctrlKey && code == 122))
    { return false; }
    if (e.ctrlKey || e.altKey) return true; for (var i = 0; i < forbidalso.length; i++) if (forbidalso[i] == code) return false; for (var i = 0; i < exceptions.length; i++) if (exceptions[i] == code) return true; if (code <= 47 || code > 57) return false; return true;
}
function monorail_formhelper_getkeycode(e) {
    if (typeof (e.keyCode) == 'number')
    { return e.keyCode; }
    else if (typeof (e.which) == 'number')
    { return e.which; }
    else if (typeof (e.charCode) == 'number')
    { return e.charCode; }
    else
    { return null; } 
}
function monorail_formhelper_getevent(e) {
    if (!e) {
        if (window.event)
        { return window.event; }
        else
        { return null; } 
    }
    else
    { return e; } 
}
function monorail_formhelper_mask(e, elem, loc, delim) {
    e = monorail_formhelper_getevent(e); var keycode = monorail_formhelper_getkeycode(e); var locs = loc.split(','); var str = elem.value; for (var i = 0; i <= locs.length; i++) {
        for (var k = 0; k <= str.length; k++) {
            if (k == locs[i]) {
                if (str.substring(k, k + 1) != delim) {
                    if (keycode != 8)
                    { str = str.substring(0, k) + delim + str.substring(k, str.length); } 
                } 
            } 
        } 
    }
    elem.value = str
}
var Validator = Class.create(); Validator.prototype = { initialize: function(className, error, test, options) {
    if (typeof test == 'function') { this.options = $H(options); this._test = test; } else { this.options = $H(test); this._test = function() { return true }; }
    this.error = error || 'Validation failed.'; this.className = className;
}, test: function(v, elm) { return (this._test(v, elm) && this.options.all(function(p) { return Validator.methods[p.key] ? Validator.methods[p.key](v, elm, p.value) : true; })); } 
}
Validator.methods = { pattern: function(v, elm, opt) { return Validation.get('IsEmpty').test(v) || opt.test(v) }, minLength: function(v, elm, opt) { return Validation.get('IsEmpty').test(v) || v.length >= opt }, maxLength: function(v, elm, opt) { return Validation.get('IsEmpty').test(v) || v.length <= opt }, min: function(v, elm, opt) { return Validation.get('IsEmpty').test(v) || v >= parseFloat(opt) }, max: function(v, elm, opt) { return Validation.get('IsEmpty').test(v) || v <= parseFloat(opt) }, notOneOf: function(v, elm, opt) { return $A(opt).all(function(value) { return v != value; }) }, oneOf: function(v, elm, opt) { return $A(opt).any(function(value) { return v == value; }) }, is: function(v, elm, opt) { return v == opt }, isNot: function(v, elm, opt) { return v != opt }, equalToField: function(v, elm, opt) { return v == $F(opt) }, notEqualToField: function(v, elm, opt) { return v != $F(opt) }, include: function(v, elm, opt) { return $A(opt).all(function(value) { return Validation.get(value).test(v, elm); }) } }
var Validation = Class.create(); Validation.prototype = { initialize: function(form, options) { this.options = Object.extend({ onSubmit: true, stopOnFirst: false, immediate: false, focusOnError: true, useTitles: false, onFormValidate: function(result, form) { }, onElementValidate: function(result, elm) { } }, options || {}); this.form = $(form); if (this.options.onSubmit) Event.observe(this.form, 'submit', this.onSubmit.bind(this), false); if (this.options.immediate) { var useTitles = this.options.useTitles; var callback = this.options.onElementValidate; Form.getElements(this.form).each(function(input) { Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev), { useTitle: useTitles, onElementValidate: callback }); }); }); } }, onSubmit: function(ev) { if (!this.validate()) Event.stop(ev); }, validate: function() {
    var result = false; var useTitles = this.options.useTitles; var callback = this.options.onElementValidate; if (this.options.stopOnFirst) { result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm, { useTitle: useTitles, onElementValidate: callback }); }); } else { result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm, { useTitle: useTitles, onElementValidate: callback }); }).all(); }
    if (!result && this.options.focusOnError) { Form.getElements(this.form).findAll(function(elm) { return $(elm).hasClassName('validation-failed') }).first().focus() }
    this.options.onFormValidate(result, this.form); return result;
}, reset: function() { Form.getElements(this.form).each(Validation.reset); } 
}
Object.extend(Validation, { validate: function(elm, options) { options = Object.extend({ useTitle: false, onElementValidate: function(result, elm) { } }, options || {}); elm = $(elm); var cn = elm.classNames(); return result = cn.all(function(value) { var test = Validation.test(value, elm, options.useTitle); options.onElementValidate(test, elm); return test; }); }, test: function(name, elm, useTitle) {
    var v = Validation.get(name); var prop = '__advice' + name.camelize(); try {
        if (Validation.isVisible(elm) && !v.test($F(elm), elm)) {
            if (!elm[prop]) {
                var advice = Validation.getAdvice(name, elm); if (advice == null) {
                    var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error; advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) + '" style="display:none">' + errorMsg + '</div>'
                    switch (elm.type.toLowerCase()) {
                        case 'checkbox': case 'radio': var p = elm.parentNode; if (p) { new Insertion.Bottom(p, advice); } else { new Insertion.After(elm, advice); }
                            break; default: new Insertion.After(elm, advice);
                    }
                    advice = Validation.getAdvice(name, elm);
                }
                if (typeof Effect == 'undefined') { advice.style.display = 'block'; } else { new Effect.Appear(advice, { duration: 1 }); } 
            }
            elm[prop] = true; elm.removeClassName('validation-passed'); elm.addClassName('validation-failed'); return false;
        } else { var advice = Validation.getAdvice(name, elm); if (advice != null) advice.hide(); elm[prop] = ''; elm.removeClassName('validation-failed'); elm.addClassName('validation-passed'); return true; } 
    } catch (e) { throw (e) } 
}, isVisible: function(elm) {
    while (elm.tagName != 'BODY') { if (!$(elm).visible()) return false; elm = elm.parentNode; }
    return true;
}, getAdvice: function(name, elm) { return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm)); }, getElmID: function(elm) { return elm.id ? elm.id : elm.name; }, reset: function(elm) {
    elm = $(elm); var cn = elm.classNames(); cn.each(function(value) {
        var prop = '__advice' + value.camelize(); if (elm[prop]) { var advice = Validation.getAdvice(value, elm); advice.hide(); elm[prop] = ''; }
        elm.removeClassName('validation-failed'); elm.removeClassName('validation-passed');
    });
}, add: function(className, error, test, options) { var nv = {}; nv[className] = new Validator(className, error, test, options); Object.extend(Validation.methods, nv); }, addAllThese: function(validators) { var nv = {}; $A(validators).each(function(value) { nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {})); }); Object.extend(Validation.methods, nv); }, get: function(name) { return Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_']; }, methods: { '_LikeNoIDIEverSaw_': new Validator('_LikeNoIDIEverSaw_', '', {})}
}); Validation.add('IsEmpty', '', function(v) { return ((v == null) || (v.length == 0)); }); Validation.addAllThese([['required', 'This is a required field.', function(v) { return !Validation.get('IsEmpty').test(v); } ], ['validate-number', 'Please enter a valid number in this field.', function(v) { return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v)); } ], ['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) { return Validation.get('IsEmpty').test(v) || !/[^\d]/.test(v); } ], ['validate-alpha', 'Please use letters only (a-z) in this field.', function(v) { return Validation.get('IsEmpty').test(v) || /^[a-zA-Z]+$/.test(v) } ], ['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) { return Validation.get('IsEmpty').test(v) || !/\W/.test(v) } ], ['validate-date', 'Please enter a valid date.', function(v) { var test = new Date(v); return Validation.get('IsEmpty').test(v) || !isNaN(test); } ], ['validate-email', 'Please enter a valid email address. For example fred@domain.com .', function(v) { return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v) } ], ['validate-url', 'Please enter a valid URL.', function(v) { return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v) } ], ['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) { if (Validation.get('IsEmpty').test(v)) return true; var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/; if (!regex.test(v)) return false; var d = new Date(v.replace(regex, '$2/$1/$3')); return (parseInt(RegExp.$2, 10) == (1 + d.getMonth())) && (parseInt(RegExp.$1, 10) == d.getDate()) && (parseInt(RegExp.$3, 10) == d.getFullYear()); } ], ['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) { return Validation.get('IsEmpty').test(v) || /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v) } ], ['validate-selection', 'Please make a selection', function(v, elm) { return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v); } ], ['validate-one-required', 'Please select one of the above options.', function(v, elm) { var p = elm.parentNode; var options = p.getElementsByTagName('INPUT'); return $A(options).any(function(elm) { return $F(elm); }); } ]]); Object.extend = function(dest, source, replace) {
    for (var prop in source) {
        if (replace == false && dest[prop] != null) { continue; }
        dest[prop] = source[prop];
    }
    return dest;
}; Object.extend(Function.prototype, { apply: function(o, a) {
    var r, x = "__fapply"; if (typeof o != "object") { o = {}; }
    o[x] = this; var s = "r = o." + x + "("; for (var i = 0; i < a.length; i++) {
        if (i > 0) { s += ","; }
        s += "a[" + i + "]";
    }
    s += ");"; eval(s); delete o[x]; return r;
}, bind: function(o) {
    if (!Function.__objs) { Function.__objs = []; Function.__funcs = []; }
    var objId = o.__oid; if (!objId) { Function.__objs[objId = o.__oid = Function.__objs.length] = o; }
    var me = this; var funcId = me.__fid; if (!funcId) { Function.__funcs[funcId = me.__fid = Function.__funcs.length] = me; }
    if (!o.__closures) { o.__closures = []; }
    var closure = o.__closures[funcId]; if (closure) { return closure; }
    o = null; me = null; return Function.__objs[objId].__closures[funcId] = function() { return Function.__funcs[funcId].apply(Function.__objs[objId], arguments); };
} 
}, false); Object.extend(Array.prototype, { push: function(o) { this[this.length] = o; }, addRange: function(items) { if (items.length > 0) { for (var i = 0; i < items.length; i++) { this.push(items[i]); } } }, clear: function() { this.length = 0; return this; }, shift: function() {
    if (this.length == 0) { return null; }
    var o = this[0]; for (var i = 0; i < this.length - 1; i++) { this[i] = this[i + 1]; }
    this.length--; return o;
} 
}, false); Object.extend(String.prototype, { trimLeft: function() { return this.replace(/^\s*/, ""); }, trimRight: function() { return this.replace(/\s*$/, ""); }, trim: function() { return this.trimRight().trimLeft(); }, endsWith: function(s) {
    if (this.length == 0 || this.length < s.length) { return false; }
    return (this.substr(this.length - s.length) == s);
}, startsWith: function(s) {
    if (this.length == 0 || this.length < s.length) { return false; }
    return (this.substr(0, s.length) == s);
}, split: function(c) {
    var a = []; if (this.length == 0) return a; var p = 0; for (var i = 0; i < this.length; i++) { if (this.charAt(i) == c) { a.push(this.substring(p, i)); p = ++i; } }
    a.push(s.substr(p)); return a;
} 
}, false); Object.extend(String, { format: function(s) {
    for (var i = 1; i < arguments.length; i++) { s = s.replace("{" + (i - 1) + "}", arguments[i]); }
    return s;
}, isNullOrEmpty: function(s) {
    if (s == null || s.length == 0) { return true; }
    return false;
} 
}, false); if (typeof addEvent == "undefined")
    addEvent = function(o, evType, f, capture) {
        if (o == null) { return false; }
        if (o.addEventListener) { o.addEventListener(evType, f, capture); return true; } else if (o.attachEvent) { var r = o.attachEvent("on" + evType, f); return r; } else { try { o["on" + evType] = f; } catch (e) { } } 
    }; if (typeof removeEvent == "undefined")
    removeEvent = function(o, evType, f, capture) {
        if (o == null) { return false; }
        if (o.removeEventListener) { o.removeEventListener(evType, f, capture); return true; } else if (o.detachEvent) { o.detachEvent("on" + evType, f); } else { try { o["on" + evType] = function() { }; } catch (e) { } } 
    }; Object.extend(Function.prototype, { getArguments: function() {
        var args = []; for (var i = 0; i < this.arguments.length; i++) { args.push(this.arguments[i]); }
        return args;
    } 
    }, false); var MS = { "Browser": {} }; Object.extend(MS.Browser, { isIE: navigator.userAgent.indexOf('MSIE') != -1, isFirefox: navigator.userAgent.indexOf('Firefox') != -1, isOpera: window.opera != null }, false); var BlocAjax = {}; BlocAjax.IFrameXmlHttp = function() { }; BlocAjax.IFrameXmlHttp.prototype = { onreadystatechange: null, headers: [], method: "POST", url: null, async: true, iframe: null, status: 0, readyState: 0, responseText: null, abort: function() { }, readystatechanged: function() {
        var doc = this.iframe.contentDocument || this.iframe.document; if (doc != null && doc.readyState == "complete" && doc.body != null && doc.body.res != null) { this.status = 200; this.statusText = "OK"; this.readyState = 4; this.responseText = doc.body.res; this.onreadystatechange(); return; }
        setTimeout(this.readystatechanged.bind(this), 10);
    }, open: function(method, url, async) {
        if (async == false) { alert("Synchronous call using IFrameXMLHttp is not supported."); return; }
        if (this.iframe == null) {
            var iframeID = "hans"; if (document.createElement && document.documentElement && (window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1))
            { var ifr = document.createElement('iframe'); ifr.setAttribute('id', iframeID); ifr.style.visibility = 'hidden'; ifr.style.position = 'absolute'; ifr.style.width = ifr.style.height = ifr.borderWidth = '0px'; this.iframe = document.getElementsByTagName('body')[0].appendChild(ifr); }
            else if (document.body && document.body.insertAdjacentHTML)
            { document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID + '" id="' + iframeID + '" style="border:1px solid black;display:none"></iframe>'); }
            if (window.frames && window.frames[iframeID]) { this.iframe = window.frames[iframeID]; }
            this.iframe.name = iframeID; this.iframe.document.open(); this.iframe.document.write("<" + "html><" + "body></" + "body></" + "html>"); this.iframe.document.close();
        }
        this.method = method; this.url = url; this.async = async;
    }, setRequestHeader: function(name, value) {
        for (var i = 0; i < this.headers.length; i++) { if (this.headers[i].name == name) { this.headers[i].value = value; return; } }
        this.headers.push({ "name": name, "value": value });
    }, getResponseHeader: function(name, value) { return null; }, addInput: function(doc, form, name, value) {
        var ele; var tag = "input"; if (value.indexOf("\n") >= 0) { tag = "textarea"; }
        if (doc.all) { ele = doc.createElement("<" + tag + " name=\"" + name + "\" />"); } else { ele = doc.createElement(tag); ele.setAttribute("name", name); }
        ele.setAttribute("value", value); form.appendChild(ele); ele = null;
    }, send: function(data) {
        if (this.iframe == null) { return; }
        var doc = this.iframe.contentDocument || this.iframe.document; var form = doc.createElement("form"); doc.body.appendChild(form); form.setAttribute("action", this.url); form.setAttribute("method", this.method); form.setAttribute("enctype", "application/x-www-form-urlencoded"); for (var i = 0; i < this.headers.length; i++) { switch (this.headers[i].name.toLowerCase()) { case "content-length": case "accept-encoding": case "content-type": break; default: this.addInput(doc, form, this.headers[i].name, this.headers[i].value); } }
        this.addInput(doc, form, "data", data); form.submit(); setTimeout(this.readystatechanged.bind(this), 0);
    } 
    }; var progids = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]; var progid = null; if (typeof ActiveXObject != "undefined") {
    var ie7xmlhttp = false; if (typeof XMLHttpRequest == "object") { try { var o = new XMLHttpRequest(); ie7xmlhttp = true; } catch (e) { } }
    if (typeof XMLHttpRequest == "undefined" || !ie7xmlhttp) {
        XMLHttpRequest = function() {
            var xmlHttp = null; if (!BlocAjax.noActiveX) {
                if (progid != null) { return new ActiveXObject(progid); }
                for (var i = 0; i < progids.length && xmlHttp == null; i++) { try { xmlHttp = new ActiveXObject(progids[i]); progid = progids[i]; } catch (e) { } } 
            }
            if (xmlHttp == null && MS.Browser.isIE) { return new BlocAjax.IFrameXmlHttp(); }
            return xmlHttp;
        };
    } 
}
Object.extend(BlocAjax, { noOperation: function() { }, onLoading: function() { }, onError: function() { }, onTimeout: function() { return true; }, onStateChanged: function() { }, cryptProvider: null, queue: null, token: "", version: "7.4.24.1", ID: "BlocAjax", noActiveX: false, timeoutPeriod: 120 * 1000, queue: null, noUtcTime: false, m: { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }, toJSON: function(o) {
    if (o == null) { return "null"; }
    var v = []; var i; var c = o.constructor; if (c == Number) { return isFinite(o) ? o.toString() : BlocAjax.toJSON(null); } else if (c == Boolean) { return o.toString(); } else if (c == String) {
        if (/["\\\x00-\x1f]/.test(o)) {
            o = o.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                var c = BlocAjax.m[b]; if (c) { return c; }
                c = b.charCodeAt(); return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
            });
        }
        return '"' + o + '"';
    } else if (c == Array) {
        for (i = 0; i < o.length; i++) { v.push(BlocAjax.toJSON(o[i])); }
        return "[" + v.join(",") + "]";
    } else if (c == Date) {
        var d = {}; d.__type = "System.DateTime"; if (BlocAjax.noUtcTime == true) { d.Year = o.getFullYear(); d.Month = o.getMonth() + 1; d.Day = o.getDate(); d.Hour = o.getHours(); d.Minute = o.getMinutes(); d.Second = o.getSeconds(); d.Millisecond = o.getMilliseconds(); } else { d.Year = o.getUTCFullYear(); d.Month = o.getUTCMonth() + 1; d.Day = o.getUTCDate(); d.Hour = o.getUTCHours(); d.Minute = o.getUTCMinutes(); d.Second = o.getUTCSeconds(); d.Millisecond = o.getUTCMilliseconds(); }
        return BlocAjax.toJSON(d);
    }
    if (typeof o.toJSON == "function") { return o.toJSON(); }
    if (typeof o == "object") {
        for (var attr in o) { if (typeof o[attr] != "function") { v.push('"' + attr + '":' + BlocAjax.toJSON(o[attr])); } }
        if (v.length > 0) { return "{" + v.join(",") + "}"; }
        return "{}";
    }
    return o.toString();
}, dispose: function() { if (BlocAjax.queue != null) { BlocAjax.queue.dispose(); } } 
}, false); addEvent(window, "unload", BlocAjax.dispose); BlocAjax.Request = function(url) { this.url = url; this.xmlHttp = null; }; BlocAjax.Request.prototype = { url: null, callback: null, onLoading: null, onError: null, onTimeout: null, onStateChanged: null, args: null, context: null, isRunning: false, abort: function() {
    if (this.timeoutTimer != null) { clearTimeout(this.timeoutTimer); }
    if (this.xmlHttp) { this.xmlHttp.onreadystatechange = BlocAjax.noOperation; this.xmlHttp.abort(); }
    if (this.isRunning) { this.isRunning = false; this.onLoading(false); } 
}, dispose: function() { this.abort(); }, getEmptyRes: function() { return { error: null, value: null, request: { method: this.method, args: this.args }, context: this.context, duration: this.duration }; }, endRequest: function(res) {
    this.abort(); if (res.error != null) { this.onError(res.error, this); }
    if (typeof this.callback == "function") { this.callback(res, this); } 
}, mozerror: function() {
    if (this.timeoutTimer != null) { clearTimeout(this.timeoutTimer); }
    var res = this.getEmptyRes(); res.error = { Message: "Unknown", Type: "ConnectFailure", Status: 0 }; this.endRequest(res);
}, doStateChange: function() {
    this.onStateChanged(this.xmlHttp.readyState, this); if (this.xmlHttp.readyState != 4 || !this.isRunning) { return; }
    this.duration = new Date().getTime() - this.__start; if (this.timeoutTimer != null) { clearTimeout(this.timeoutTimer); }
    var res = this.getEmptyRes(); if (this.xmlHttp.status == 200 && this.xmlHttp.statusText == "OK") { res = this.createResponse(res); } else { res = this.createResponse(res, true); res.error = { Message: this.xmlHttp.statusText, Type: "ConnectFailure", Status: this.xmlHttp.status }; }
    this.endRequest(res);
}, createResponse: function(r, noContent) {
    if (!noContent) {
        var responseText = "" + this.xmlHttp.responseText; if (BlocAjax.cryptProvider != null && typeof BlocAjax.cryptProvider.decrypt == "function") { responseText = BlocAjax.cryptProvider.decrypt(responseText); }
        if (this.xmlHttp.getResponseHeader("Content-Type") == "text/xml") { r.value = this.xmlHttp.responseXML; } else { if (responseText != null && responseText.trim().length > 0) { r.json = responseText; var v = null; eval("v = " + responseText + ";"); if (v != null) { if (typeof v.value != "undefined") r.value = v.value; else if (typeof v.error != "undefined") r.error = v.error; } } } 
    }
    return r;
}, timeout: function() {
    try
{ this.duration = new Date().getTime() - this.__start; var r = this.onTimeout(this.duration, this); if (typeof r == "undefined" || r != false) { this.abort(); } else { this.timeoutTimer = setTimeout(this.timeout.bind(this), BlocAjax.timeoutPeriod); } } catch (error)
{ } finally
{ ; } 
}, invoke: function(method, args, callback, context) {
    this.__start = new Date().getTime(); this.xmlHttp = new XMLHttpRequest(); this.isRunning = true; this.method = method; this.args = args; this.callback = callback; this.context = context; var async = typeof (callback) == "function" && callback != BlocAjax.noOperation; if (async) {
        if (MS.Browser.isIE) { this.xmlHttp.onreadystatechange = this.doStateChange.bind(this); } else { this.xmlHttp.onload = this.doStateChange.bind(this); this.xmlHttp.onerror = this.mozerror.bind(this); }
        this.onLoading(true);
    }
    var json = BlocAjax.toJSON(args) + ""; if (BlocAjax.cryptProvider != null && typeof BlocAjax.cryptProvider.encrypt == "function") { json = BlocAjax.cryptProvider.encrypt(json); }
    this.xmlHttp.open("POST", this.url, async); this.xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8"); this.xmlHttp.setRequestHeader("X-" + BlocAjax.ID + "-Method", method); if (BlocAjax.token != null && BlocAjax.token.length > 0) { this.xmlHttp.setRequestHeader("X-" + BlocAjax.ID + "-Token", BlocAjax.token); }
    this.timeoutTimer = setTimeout(this.timeout.bind(this), BlocAjax.timeoutPeriod); try { this.xmlHttp.send(json); } catch (e) { }
    if (!async) { return this.createResponse({ error: null, value: null }); }
    return true;
} 
}; BlocAjax.RequestQueue = function(conc) {
    this.queue = []; this.requests = []; this.timer = null; if (isNaN(conc)) { conc = 2; }
    for (var i = 0; i < conc; i++) { this.requests[i] = new BlocAjax.Request(); this.requests[i].callback = function(res) { var r = res.context; res.context = r[3][1]; r[3][0](res, this); }; this.requests[i].callbackHandle = this.requests[i].callback.bind(this.requests[i]); } 
}; BlocAjax.RequestQueue.prototype = { process: function() {
    this.timer = null; if (this.queue.length == 0) { return; }
    for (var i = 0; i < this.requests.length && this.queue.length > 0; i++) { if (this.requests[i].isRunning == false) { var r = this.queue.shift(); this.requests[i].url = r[0]; this.requests[i].onLoading = r[3].length > 2 && r[3][2] != null && typeof r[3][2] == "function" ? r[3][2] : BlocAjax.onLoading; this.requests[i].onError = r[3].length > 3 && r[3][3] != null && typeof r[3][3] == "function" ? r[3][3] : BlocAjax.onError; this.requests[i].onTimeout = r[3].length > 4 && r[3][4] != null && typeof r[3][4] == "function" ? r[3][4] : BlocAjax.onTimeout; this.requests[i].onStateChanged = r[3].length > 5 && r[3][5] != null && typeof r[3][5] == "function" ? r[3][5] : BlocAjax.onStateChanged; this.requests[i].invoke(r[1], r[2], this.requests[i].callbackHandle, r); r = null; } }
    if (this.queue.length > 0 && this.timer == null) { this.timer = setTimeout(this.process.bind(this), 0); } 
}, add: function(url, method, args, e) { this.queue.push([url, method, args, e]); if (this.timer == null) { this.timer = setTimeout(this.process.bind(this), 0); } }, abort: function() {
    this.queue.length = 0; if (this.timer != null) { clearTimeout(this.timer); }
    this.timer = null; for (var i = 0; i < this.requests.length; i++) { if (this.requests[i].isRunning == true) { this.requests[i].abort(); } } 
}, dispose: function() {
    for (var i = 0; i < this.requests.length; i++) { var r = this.requests[i]; r.dispose(); }
    this.requests.clear();
} 
}; BlocAjax.queue = new BlocAjax.RequestQueue(2); BlocAjax.AjaxClass = function(url) { this.url = url; }; BlocAjax.AjaxClass.prototype = { invoke: function(method, args, e) {
    if (e != null) {
        if (e.length != 6) { for (; e.length < 6; ) { e.push(null); } }
        if (e[0] != null && typeof (e[0]) == "function") { return BlocAjax.queue.add(this.url, method, args, e); } 
    }
    var r = new BlocAjax.Request(); r.url = this.url; return r.invoke(method, args);
} 
}; function subOptions(obj)
{ obj.options.length = 0; }
function addOption(obj, value, text) {
    var optionP = document.createElement('option'); optionP.text = text; optionP.value = value; try
{ obj.add(optionP, null); }
    catch (ex)
{ obj.add(optionP); } 
}
function txtboxgotfocus(myitem, gtext) { if (myitem.value == gtext) { myitem.value = ''; myitem.style.color = 'black'; } }
function txtboxlostfocus(myitem, gtext) { if (myitem.value == '') { myitem.value = gtext; myitem.style.color = '#666'; } }
function findPosX(obj) {
    var curleft = 0; if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft; if (!obj.offsetParent)
            break; obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x; return curleft;
}
function findPosY(obj) {
    var curtop = 0; if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop; if (!obj.offsetParent)
            break; obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y; return curtop;
}
function ShowPopup(sender, target, x, y) {
    var orgin = document.getElementById(sender); var popup = document.getElementById(target); popup.style.left = (findPosX(orgin) + x) + "px"; popup.style.top = (findPosY(orgin) + y) + "px"; var orgimage = document.getElementById('orgimageurl').value; var bigimage = document.getElementById('bigimage'); var popimage = document.getElementById('popimage'); popimage.src = '/Content/gfx/ajax-loader-small.gif'; bigimage.src = orgimage; if (popup.style.display == "none") { popup.style.display = "block"; }
    else { popup.style.display = "none"; }
}
function showtopopup(obj) {
    var popimage = document.getElementById('popimage');popimage.src = obj.src;
}
function ShowPopupForBubble(sender, target, x, y, id) { var orgin = document.getElementById(sender); var popup = document.getElementById(target); popup.style.left = (findPosX(orgin) + x) + "px"; popup.style.top = (findPosY(orgin) + y) + "px"; popup.style.display = "block"; $('hidebubbleid').value = id; }
function isDate(p_Expression) { return !isNaN(new Date(p_Expression)); }
function dateAdd(p_Interval, p_Number, p_Date) {
    if (!isDate(p_Date)) { return "invalid date: '" + p_Date + "'"; }
    if (isNaN(p_Number)) { return "invalid number: '" + p_Number + "'"; }
    p_Number = new Number(p_Number); var dt = new Date(p_Date); switch (p_Interval.toLowerCase()) {
        case "yyyy": { dt.setFullYear(dt.getFullYear() + p_Number); break; }
        case "q": { dt.setMonth(dt.getMonth() + (p_Number * 3)); break; }
        case "m": { dt.setMonth(dt.getMonth() + p_Number); break; }
        case "y": case "d": case "w": { dt.setDate(dt.getDate() + p_Number); break; }
        case "ww": { dt.setDate(dt.getDate() + (p_Number * 7)); break; }
        case "h": { dt.setHours(dt.getHours() + p_Number); break; }
        case "n": { dt.setMinutes(dt.getMinutes() + p_Number); break; }
        case "s": { dt.setSeconds(dt.getSeconds() + p_Number); break; }
        case "ms": { dt.setMilliseconds(dt.getMilliseconds() + p_Number); break; }
        default: { return "invalid interval: '" + p_Interval + "'"; } 
    }
    return dt;
}
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear) {
    if (!isDate(p_Date1)) { return "invalid date: '" + p_Date1 + "'"; }
    if (!isDate(p_Date2)) { return "invalid date: '" + p_Date2 + "'"; }
    var dt1 = new Date(p_Date1); var dt2 = new Date(p_Date2); var iDiffMS = dt2.valueOf() - dt1.valueOf(); var dtDiff = new Date(iDiffMS); var nYears = dt2.getUTCFullYear() - dt1.getUTCFullYear(); var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears != 0 ? nYears * 12 : 0); var nQuarters = parseInt(nMonths / 3); var nMilliseconds = iDiffMS; var nSeconds = parseInt(iDiffMS / 1000); var nMinutes = parseInt(nSeconds / 60); var nHours = parseInt(nMinutes / 60); var nDays = parseInt(nHours / 24); var nWeeks = parseInt(nDays / 7); var iDiff = 0; switch (p_Interval.toLowerCase()) { case "yyyy": return nYears; case "q": return nQuarters; case "m": return nMonths; case "y": case "d": return nDays; case "w": return nDays; case "ww": return nWeeks; case "h": return nHours; case "n": return nMinutes; case "s": return nSeconds; case "ms": return nMilliseconds; default: return "invalid interval: '" + p_Interval + "'"; } 
}
function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear) {
    if (!isDate(p_Date)) { return "invalid date: '" + p_Date + "'"; }
    var dtPart = new Date(p_Date); switch (p_Interval.toLowerCase()) { case "yyyy": return dtPart.getFullYear(); case "q": return parseInt(dtPart.getMonth() / 3) + 1; case "m": return dtPart.getMonth() + 1; case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart); case "d": return dtPart.getDate(); case "w": return dtPart.getDay(); case "ww": return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart); case "h": return dtPart.getHours(); case "n": return dtPart.getMinutes(); case "s": return dtPart.getSeconds(); case "ms": return dtPart.getMilliseconds(); default: return "invalid interval: '" + p_Interval + "'"; } 
}
function weekdayName(p_Date, p_abbreviate) {
    if (!isDate(p_Date)) { return "invalid date: '" + p_Date + "'"; }
    var dt = new Date(p_Date); var retVal = dt.toString().split(' ')[0]; var retVal = Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')[dt.getUTCDay()]; if (p_abbreviate == true) { retVal = retVal.substring(0, 3) }
    return retVal;
}
function monthName(p_Date, p_abbreviate) {
    if (!isDate(p_Date)) { return "invalid date: '" + p_Date + "'"; }
    var dt = new Date(p_Date); var retVal = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')[dt.getUTCMonth()]; if (p_abbreviate == true) { retVal = retVal.substring(0, 3) }
    return retVal;
}
function IsDate(p_Expression) { return isDate(p_Expression); }
function DateAdd(p_Interval, p_Number, p_Date) { return dateAdd(p_Interval, p_Number, p_Date); }
function DateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear) { return dateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear); }
function DatePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear) { return datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear); }
function WeekdayName(p_Date) { return weekdayName(p_Date); }
function MonthName(p_Date) { return monthName(p_Date); }
function getExpDate(days, hours, minutes) { var expDate = new Date(); if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") { expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString(); } }
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) { endstr = document.cookie.length; }
    return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name) {
    var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) {
        var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); }
        i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break;
    }
    return "";
}
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    } 
}
function ForDight(Dight, How)
{ Dight = Math.round(Dight * Math.pow(10, How)) / Math.pow(10, How); return Dight; }
function HtmlDecode(s) {
    var out = ""; if (s == null) return; var l = s.length; for (var i = 0; i < l; i++) {
        var ch = s.charAt(i); if (ch == '&') {
            var semicolonIndex = s.indexOf(';', i + 1); if (semicolonIndex > 0) {
                var entity = s.substring(i + 1, semicolonIndex); if (entity.length > 1 && entity.charAt(0) == '#') {
                    if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
                        ch = String.fromCharCode(eval('0' + entity.substring(1))); else
                        ch = String.fromCharCode(eval(entity.substring(1)));
                }
                else {
                    switch (entity)
                    { case 'quot': ch = String.fromCharCode(0x0022); break; case 'amp': ch = String.fromCharCode(0x0026); break; case 'lt': ch = String.fromCharCode(0x003c); break; case 'gt': ch = String.fromCharCode(0x003e); break; case 'nbsp': ch = String.fromCharCode(0x00a0); break; case 'iexcl': ch = String.fromCharCode(0x00a1); break; case 'cent': ch = String.fromCharCode(0x00a2); break; case 'pound': ch = String.fromCharCode(0x00a3); break; case 'curren': ch = String.fromCharCode(0x00a4); break; case 'yen': ch = String.fromCharCode(0x00a5); break; case 'brvbar': ch = String.fromCharCode(0x00a6); break; case 'sect': ch = String.fromCharCode(0x00a7); break; case 'uml': ch = String.fromCharCode(0x00a8); break; case 'copy': ch = String.fromCharCode(0x00a9); break; case 'ordf': ch = String.fromCharCode(0x00aa); break; case 'laquo': ch = String.fromCharCode(0x00ab); break; case 'not': ch = String.fromCharCode(0x00ac); break; case 'shy': ch = String.fromCharCode(0x00ad); break; case 'reg': ch = String.fromCharCode(0x00ae); break; case 'macr': ch = String.fromCharCode(0x00af); break; case 'deg': ch = String.fromCharCode(0x00b0); break; case 'plusmn': ch = String.fromCharCode(0x00b1); break; case 'sup2': ch = String.fromCharCode(0x00b2); break; case 'sup3': ch = String.fromCharCode(0x00b3); break; case 'acute': ch = String.fromCharCode(0x00b4); break; case 'micro': ch = String.fromCharCode(0x00b5); break; case 'para': ch = String.fromCharCode(0x00b6); break; case 'middot': ch = String.fromCharCode(0x00b7); break; case 'cedil': ch = String.fromCharCode(0x00b8); break; case 'sup1': ch = String.fromCharCode(0x00b9); break; case 'ordm': ch = String.fromCharCode(0x00ba); break; case 'raquo': ch = String.fromCharCode(0x00bb); break; case 'frac14': ch = String.fromCharCode(0x00bc); break; case 'frac12': ch = String.fromCharCode(0x00bd); break; case 'frac34': ch = String.fromCharCode(0x00be); break; case 'iquest': ch = String.fromCharCode(0x00bf); break; case 'Agrave': ch = String.fromCharCode(0x00c0); break; case 'Aacute': ch = String.fromCharCode(0x00c1); break; case 'Acirc': ch = String.fromCharCode(0x00c2); break; case 'Atilde': ch = String.fromCharCode(0x00c3); break; case 'Auml': ch = String.fromCharCode(0x00c4); break; case 'Aring': ch = String.fromCharCode(0x00c5); break; case 'AElig': ch = String.fromCharCode(0x00c6); break; case 'Ccedil': ch = String.fromCharCode(0x00c7); break; case 'Egrave': ch = String.fromCharCode(0x00c8); break; case 'Eacute': ch = String.fromCharCode(0x00c9); break; case 'Ecirc': ch = String.fromCharCode(0x00ca); break; case 'Euml': ch = String.fromCharCode(0x00cb); break; case 'Igrave': ch = String.fromCharCode(0x00cc); break; case 'Iacute': ch = String.fromCharCode(0x00cd); break; case 'Icirc': ch = String.fromCharCode(0x00ce); break; case 'Iuml': ch = String.fromCharCode(0x00cf); break; case 'ETH': ch = String.fromCharCode(0x00d0); break; case 'Ntilde': ch = String.fromCharCode(0x00d1); break; case 'Ograve': ch = String.fromCharCode(0x00d2); break; case 'Oacute': ch = String.fromCharCode(0x00d3); break; case 'Ocirc': ch = String.fromCharCode(0x00d4); break; case 'Otilde': ch = String.fromCharCode(0x00d5); break; case 'Ouml': ch = String.fromCharCode(0x00d6); break; case 'times': ch = String.fromCharCode(0x00d7); break; case 'Oslash': ch = String.fromCharCode(0x00d8); break; case 'Ugrave': ch = String.fromCharCode(0x00d9); break; case 'Uacute': ch = String.fromCharCode(0x00da); break; case 'Ucirc': ch = String.fromCharCode(0x00db); break; case 'Uuml': ch = String.fromCharCode(0x00dc); break; case 'Yacute': ch = String.fromCharCode(0x00dd); break; case 'THORN': ch = String.fromCharCode(0x00de); break; case 'szlig': ch = String.fromCharCode(0x00df); break; case 'agrave': ch = String.fromCharCode(0x00e0); break; case 'aacute': ch = String.fromCharCode(0x00e1); break; case 'acirc': ch = String.fromCharCode(0x00e2); break; case 'atilde': ch = String.fromCharCode(0x00e3); break; case 'auml': ch = String.fromCharCode(0x00e4); break; case 'aring': ch = String.fromCharCode(0x00e5); break; case 'aelig': ch = String.fromCharCode(0x00e6); break; case 'ccedil': ch = String.fromCharCode(0x00e7); break; case 'egrave': ch = String.fromCharCode(0x00e8); break; case 'eacute': ch = String.fromCharCode(0x00e9); break; case 'ecirc': ch = String.fromCharCode(0x00ea); break; case 'euml': ch = String.fromCharCode(0x00eb); break; case 'igrave': ch = String.fromCharCode(0x00ec); break; case 'iacute': ch = String.fromCharCode(0x00ed); break; case 'icirc': ch = String.fromCharCode(0x00ee); break; case 'iuml': ch = String.fromCharCode(0x00ef); break; case 'eth': ch = String.fromCharCode(0x00f0); break; case 'ntilde': ch = String.fromCharCode(0x00f1); break; case 'ograve': ch = String.fromCharCode(0x00f2); break; case 'oacute': ch = String.fromCharCode(0x00f3); break; case 'ocirc': ch = String.fromCharCode(0x00f4); break; case 'otilde': ch = String.fromCharCode(0x00f5); break; case 'ouml': ch = String.fromCharCode(0x00f6); break; case 'divide': ch = String.fromCharCode(0x00f7); break; case 'oslash': ch = String.fromCharCode(0x00f8); break; case 'ugrave': ch = String.fromCharCode(0x00f9); break; case 'uacute': ch = String.fromCharCode(0x00fa); break; case 'ucirc': ch = String.fromCharCode(0x00fb); break; case 'uuml': ch = String.fromCharCode(0x00fc); break; case 'yacute': ch = String.fromCharCode(0x00fd); break; case 'thorn': ch = String.fromCharCode(0x00fe); break; case 'yuml': ch = String.fromCharCode(0x00ff); break; case 'OElig': ch = String.fromCharCode(0x0152); break; case 'oelig': ch = String.fromCharCode(0x0153); break; case 'Scaron': ch = String.fromCharCode(0x0160); break; case 'scaron': ch = String.fromCharCode(0x0161); break; case 'Yuml': ch = String.fromCharCode(0x0178); break; case 'fnof': ch = String.fromCharCode(0x0192); break; case 'circ': ch = String.fromCharCode(0x02c6); break; case 'tilde': ch = String.fromCharCode(0x02dc); break; case 'Alpha': ch = String.fromCharCode(0x0391); break; case 'Beta': ch = String.fromCharCode(0x0392); break; case 'Gamma': ch = String.fromCharCode(0x0393); break; case 'Delta': ch = String.fromCharCode(0x0394); break; case 'Epsilon': ch = String.fromCharCode(0x0395); break; case 'Zeta': ch = String.fromCharCode(0x0396); break; case 'Eta': ch = String.fromCharCode(0x0397); break; case 'Theta': ch = String.fromCharCode(0x0398); break; case 'Iota': ch = String.fromCharCode(0x0399); break; case 'Kappa': ch = String.fromCharCode(0x039a); break; case 'Lambda': ch = String.fromCharCode(0x039b); break; case 'Mu': ch = String.fromCharCode(0x039c); break; case 'Nu': ch = String.fromCharCode(0x039d); break; case 'Xi': ch = String.fromCharCode(0x039e); break; case 'Omicron': ch = String.fromCharCode(0x039f); break; case 'Pi': ch = String.fromCharCode(0x03a0); break; case ' Rho ': ch = String.fromCharCode(0x03a1); break; case 'Sigma': ch = String.fromCharCode(0x03a3); break; case 'Tau': ch = String.fromCharCode(0x03a4); break; case 'Upsilon': ch = String.fromCharCode(0x03a5); break; case 'Phi': ch = String.fromCharCode(0x03a6); break; case 'Chi': ch = String.fromCharCode(0x03a7); break; case 'Psi': ch = String.fromCharCode(0x03a8); break; case 'Omega': ch = String.fromCharCode(0x03a9); break; case 'alpha': ch = String.fromCharCode(0x03b1); break; case 'beta': ch = String.fromCharCode(0x03b2); break; case 'gamma': ch = String.fromCharCode(0x03b3); break; case 'delta': ch = String.fromCharCode(0x03b4); break; case 'epsilon': ch = String.fromCharCode(0x03b5); break; case 'zeta': ch = String.fromCharCode(0x03b6); break; case 'eta': ch = String.fromCharCode(0x03b7); break; case 'theta': ch = String.fromCharCode(0x03b8); break; case 'iota': ch = String.fromCharCode(0x03b9); break; case 'kappa': ch = String.fromCharCode(0x03ba); break; case 'lambda': ch = String.fromCharCode(0x03bb); break; case 'mu': ch = String.fromCharCode(0x03bc); break; case 'nu': ch = String.fromCharCode(0x03bd); break; case 'xi': ch = String.fromCharCode(0x03be); break; case 'omicron': ch = String.fromCharCode(0x03bf); break; case 'pi': ch = String.fromCharCode(0x03c0); break; case 'rho': ch = String.fromCharCode(0x03c1); break; case 'sigmaf': ch = String.fromCharCode(0x03c2); break; case 'sigma': ch = String.fromCharCode(0x03c3); break; case 'tau': ch = String.fromCharCode(0x03c4); break; case 'upsilon': ch = String.fromCharCode(0x03c5); break; case 'phi': ch = String.fromCharCode(0x03c6); break; case 'chi': ch = String.fromCharCode(0x03c7); break; case 'psi': ch = String.fromCharCode(0x03c8); break; case 'omega': ch = String.fromCharCode(0x03c9); break; case 'thetasym': ch = String.fromCharCode(0x03d1); break; case 'upsih': ch = String.fromCharCode(0x03d2); break; case 'piv': ch = String.fromCharCode(0x03d6); break; case 'ensp': ch = String.fromCharCode(0x2002); break; case 'emsp': ch = String.fromCharCode(0x2003); break; case 'thinsp': ch = String.fromCharCode(0x2009); break; case 'zwnj': ch = String.fromCharCode(0x200c); break; case 'zwj': ch = String.fromCharCode(0x200d); break; case 'lrm': ch = String.fromCharCode(0x200e); break; case 'rlm': ch = String.fromCharCode(0x200f); break; case 'ndash': ch = String.fromCharCode(0x2013); break; case 'mdash': ch = String.fromCharCode(0x2014); break; case 'lsquo': ch = String.fromCharCode(0x2018); break; case 'rsquo': ch = String.fromCharCode(0x2019); break; case 'sbquo': ch = String.fromCharCode(0x201a); break; case 'ldquo': ch = String.fromCharCode(0x201c); break; case 'rdquo': ch = String.fromCharCode(0x201d); break; case 'bdquo': ch = String.fromCharCode(0x201e); break; case 'dagger': ch = String.fromCharCode(0x2020); break; case 'Dagger': ch = String.fromCharCode(0x2021); break; case 'bull': ch = String.fromCharCode(0x2022); break; case 'hellip': ch = String.fromCharCode(0x2026); break; case 'permil': ch = String.fromCharCode(0x2030); break; case 'prime': ch = String.fromCharCode(0x2032); break; case 'Prime': ch = String.fromCharCode(0x2033); break; case 'lsaquo': ch = String.fromCharCode(0x2039); break; case 'rsaquo': ch = String.fromCharCode(0x203a); break; case 'oline': ch = String.fromCharCode(0x203e); break; case 'frasl': ch = String.fromCharCode(0x2044); break; case 'euro': ch = String.fromCharCode(0x20ac); break; case 'image': ch = String.fromCharCode(0x2111); break; case 'weierp': ch = String.fromCharCode(0x2118); break; case 'real': ch = String.fromCharCode(0x211c); break; case 'trade': ch = String.fromCharCode(0x2122); break; case 'alefsym': ch = String.fromCharCode(0x2135); break; case 'larr': ch = String.fromCharCode(0x2190); break; case 'uarr': ch = String.fromCharCode(0x2191); break; case 'rarr': ch = String.fromCharCode(0x2192); break; case 'darr': ch = String.fromCharCode(0x2193); break; case 'harr': ch = String.fromCharCode(0x2194); break; case 'crarr': ch = String.fromCharCode(0x21b5); break; case 'lArr': ch = String.fromCharCode(0x21d0); break; case 'uArr': ch = String.fromCharCode(0x21d1); break; case 'rArr': ch = String.fromCharCode(0x21d2); break; case 'dArr': ch = String.fromCharCode(0x21d3); break; case 'hArr': ch = String.fromCharCode(0x21d4); break; case 'forall': ch = String.fromCharCode(0x2200); break; case 'part': ch = String.fromCharCode(0x2202); break; case 'exist': ch = String.fromCharCode(0x2203); break; case 'empty': ch = String.fromCharCode(0x2205); break; case 'nabla': ch = String.fromCharCode(0x2207); break; case 'isin': ch = String.fromCharCode(0x2208); break; case 'notin': ch = String.fromCharCode(0x2209); break; case 'ni': ch = String.fromCharCode(0x220b); break; case 'prod': ch = String.fromCharCode(0x220f); break; case 'sum': ch = String.fromCharCode(0x2211); break; case 'minus': ch = String.fromCharCode(0x2212); break; case 'lowast': ch = String.fromCharCode(0x2217); break; case 'radic': ch = String.fromCharCode(0x221a); break; case 'prop': ch = String.fromCharCode(0x221d); break; case 'infin': ch = String.fromCharCode(0x221e); break; case 'ang': ch = String.fromCharCode(0x2220); break; case 'and': ch = String.fromCharCode(0x2227); break; case 'or': ch = String.fromCharCode(0x2228); break; case 'cap': ch = String.fromCharCode(0x2229); break; case 'cup': ch = String.fromCharCode(0x222a); break; case 'int': ch = String.fromCharCode(0x222b); break; case 'there4': ch = String.fromCharCode(0x2234); break; case 'sim': ch = String.fromCharCode(0x223c); break; case 'cong': ch = String.fromCharCode(0x2245); break; case 'asymp': ch = String.fromCharCode(0x2248); break; case 'ne': ch = String.fromCharCode(0x2260); break; case 'equiv': ch = String.fromCharCode(0x2261); break; case 'le': ch = String.fromCharCode(0x2264); break; case 'ge': ch = String.fromCharCode(0x2265); break; case 'sub': ch = String.fromCharCode(0x2282); break; case 'sup': ch = String.fromCharCode(0x2283); break; case 'nsub': ch = String.fromCharCode(0x2284); break; case 'sube': ch = String.fromCharCode(0x2286); break; case 'supe': ch = String.fromCharCode(0x2287); break; case 'oplus': ch = String.fromCharCode(0x2295); break; case 'otimes': ch = String.fromCharCode(0x2297); break; case 'perp': ch = String.fromCharCode(0x22a5); break; case 'sdot': ch = String.fromCharCode(0x22c5); break; case 'lceil': ch = String.fromCharCode(0x2308); break; case 'rceil': ch = String.fromCharCode(0x2309); break; case 'lfloor': ch = String.fromCharCode(0x230a); break; case 'rfloor': ch = String.fromCharCode(0x230b); break; case 'lang': ch = String.fromCharCode(0x2329); break; case 'rang': ch = String.fromCharCode(0x232a); break; case 'loz': ch = String.fromCharCode(0x25ca); break; case 'spades': ch = String.fromCharCode(0x2660); break; case 'clubs': ch = String.fromCharCode(0x2663); break; case 'hearts': ch = String.fromCharCode(0x2665); break; case 'diams': ch = String.fromCharCode(0x2666); break; default: ch = ''; break; } 
                }
                i = semicolonIndex;
            } 
        }
        out += ch;
    }
    return out;
}
var Facebox = Class.create({
    initialize: function(extra_set) {
        this.settings = {
            loading_image: '/javascript/facebox/loading.gif',
            close_image: '/javascript/facebox/closebox.png',
            image_types: new RegExp('\.' + ['png', 'jpg', 'jpeg', 'gif'].join('|') + '$', 'i'),
            inited: true,
            facebox_html: '\
 <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    <img src="/javascript/facebox/closebox.png" title="close" class="close_image" /> \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
        };
        if (extra_set) Object.extend(this.settings, extra_set);
        $(document.body).insert({ bottom: this.settings.facebox_html });

        this.preload = [new Image(), new Image()];
        this.preload[0].src = this.settings.close_image;
        this.preload[1].src = this.settings.loading_image;

        f = this;
        $$('#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr').each(function(elem) {
            f.preload.push(new Image());
            f.preload.slice(-1).src = elem.getStyle('background-image').replace(/url\((.+)\)/, '$1');
        });

        this.facebox = $('facebox');
        this.keyPressListener = this.watchKeyPress.bindAsEventListener(this);

        this.watchClickEvents();
        fb = this;
        Event.observe($$('#facebox .close').first(), 'click', function(e) {
            Event.stop(e);
            fb.close()
        });
        Event.observe($$('#facebox .close_image').first(), 'click', function(e) {
            Event.stop(e);
            fb.close()
        });
    },

    watchKeyPress: function(e) {
        // Close if espace is pressed or if there's a click outside of the facebox
        if (e.keyCode == 27 || !Event.element(e).descendantOf(this.facebox)) this.close();
    },

    watchClickEvents: function(e) {
        var f = this;
        $$('a[rel=facebox]').each(function(elem, i) {
            Event.observe(elem, 'click', function(e) {
                Event.stop(e);
                f.click_handler(elem, e);
            });
        });
    },

    loading: function() {
        if ($$('#facebox .loading').length == 1) return true;

        contentWrapper = $$('#facebox .content').first();
        contentWrapper.childElements().each(function(elem, i) {
            elem.remove();
        });
        contentWrapper.insert({ bottom: '<div class="loading"><img src="' + this.settings.loading_image + '"/><br class="clear" /></div>' });

        var pageScroll = document.viewport.getScrollOffsets();
        this.facebox.setStyle({
            'top': pageScroll.top + (document.viewport.getHeight() / 10) + 'px',
            'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
        });

        Event.observe(document, 'keypress', this.keyPressListener);
        Event.observe(document, 'click', this.keyPressListener);
    },

    reveal: function(data, klass) {
        this.loading();
        load = $$('#facebox .loading').first();
        if (load) load.remove();

        contentWrapper = $$('#facebox .content').first();
        if (klass) contentWrapper.addClassName(klass);
        contentWrapper.insert({ bottom: data });

        $$('#facebox .body').first().childElements().each(function(elem, i) {
            elem.show();
        });

        if (!this.facebox.visible()) new Effect.Appear(this.facebox, { duration: .3 });
        this.facebox.setStyle({
            'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
        });

        Event.observe(document, 'keypress', this.keyPressListener);
        Event.observe(document, 'click', this.keyPressListener);
    },

    close: function() {
        new Effect.Fade('facebox', { duration: .3 });
    },

    click_handler: function(elem, e) {
        this.loading();
        Event.stop(e);

        // support for rel="facebox[.inline_popup]" syntax, to add a class
        var klass = elem.rel.match(/facebox\[\.(\w+)\]/);
        if (klass) klass = klass[1];

        new Effect.Appear(this.facebox, { duration: .3 });

        if (elem.href.match(/#/)) {
            var url = window.location.href.split('#')[0];
            var target = elem.href.replace(url + '#', '');
            // var data      = $$(target).first();
            var d = $(target);
            // create a new element so as to not delete the original on close()
            var data = new Element(d.tagName);
            data.innerHTML = d.innerHTML;
            this.reveal(data, klass);
        } else if (elem.href.match(this.settings.image_types)) {
            var image = new Image();
            fb = this;
            image.onload = function() {
                fb.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
            }
            image.src = elem.href;
        } else {
            var fb = this;
            var url = elem.href;
            new Ajax.Request(url, {
                method: 'get',
                onFailure: function(transport) {
                    fb.reveal(transport.responseText, klass);
                },
                onSuccess: function(transport) {
                    fb.reveal(transport.responseText, klass);
                }
            });

        }
    }
});

var facebox;
document.observe('dom:loaded', function() {
    facebox = new Facebox();
});
 var addNamespace = function(ns) {
    var nsParts = ns.split("."); var root = window; for (var i = 0; i < nsParts.length; i++) {
        if (typeof root[nsParts[i]] == "undefined") { root[nsParts[i]] = {}; }
        root = root[nsParts[i]];
    } 
}; Object.extend(window, { $: function() {
    var elements = []; for (var i = 0; i < arguments.length; i++) {
        var e = arguments[i]; if (typeof e == 'string') { e = document.getElementById(e); }
        if (arguments.length == 1) { return e; }
        elements.push(e);
    }
    return elements;
}, Class: { create: function() { return function() { if (typeof this.initialize == "function") { this.initialize.apply(this, arguments); } }; } }
}, false); addNamespace("MS.Debug"); MS.Debug = {}; addNamespace("MS.Position"); Object.extend(MS.Position, { getLocation: function(ele) {
    var x = 0; var y = 0; var p; for (p = ele; p; p = p.offsetParent) { if (p.offsetLeft && p.offsetTop) { x += p.offsetLeft; y += p.offsetTop; } }
    return { left: x, top: y };
}, getBounds: function(ele) { var offset = MS.Position.getLocation(ele); var width = ele.offsetWidth; var height = ele.offsetHeight; return { left: offset.left, top: offset.top, width: width, height: height }; }, setLocation: function(ele, loc) { ele.style.position = "absolute"; ele.style.left = loc.left + "px"; ele.style.top = loc.top + "px"; }, setBounds: function(ele, rect) {
    if (rect.left && rect.top) { MS.Position.setLocation(ele, rect); }
    ele.style.width = rect.width + "px"; ele.style.height = rect.height + "px";
} 
}, false); addNamespace("MS.Keys"); Object.extend(MS.Keys, { TAB: 9, ESC: 27, KEYUP: 38, KEYDOWN: 40, KEYLEFT: 37, KEYRIGHT: 39, SHIFT: 16, CTRL: 17, ALT: 18, ENTER: 13, getCode: function(e) {
    e = MS.getEvent(e); if (e != null) { return e.keyCode; }
    return -1;
} 
}, false); Object.extend(MS, { setText: function(ele, text) {
    if (ele == null) { return; }
    if (document.all) { ele.innerText = text; } else { ele.textContent = text; } 
}, setHtml: function(ele, html) {
    if (ele == null) { return; }
    ele.innerHTML = html;
}, cancelEvent: function(e) { e = MS.getEvent(e); if (window.event) { e.returnValue = false; } else if (e) { e.preventDefault(); e.stopPropagation(); } }, getEvent: function(e) {
    if (window.event) { return window.event; }
    if (e) { return e; }
    return null;
}, getTarget: function(e) {
    e = MS.getEvent(e); if (window.event) { return e.srcElement; }
    if (e) { return e.target; } 
} 
}, false); var StringBuilder = function() { this.v = []; }; Object.extend(StringBuilder.prototype, { append: function(s) { this.v.push(s); }, appendLine: function(s) { this.v.push(s + "\r\n"); }, clear: function() { this.v.clear(); }, toString: function() { return this.v.join(""); } }, true); function getreturnurl() { $('returnurl').value = $('relurl').value; return true; }

function OnFouceOnEmail(obj) { if ($('divemail1').innerHTML == "E-Mail" || $('divemail1').innerHTML == "E-post" || $('divemail1').innerHTML == "电子邮件") { $('divemail1').innerHTML = "&nbsp;"; } } function BlurEmail(obj) { if (obj.value == "") $('divemail1').innerHTML = "E-Mail"; } function BlurPassword(obj) { if (obj.value == "") { obj.style.display = "none"; document.getElementById('inppwdplace').style.display = ""; } } function OnFouceOnPassword(obj) { document.getElementById('head_password').style.display = ''; obj.style.display = 'none'; document.getElementById('head_password').focus(); }

function changesite() { var url = "http://" + $('selsite').value + "/profile/changesite.rails"; if ($('currentuid') != null && $("key") != null) url += "?uid=" + $F('currentuid') + "&guid=" + $F("key") + "&autologin=1&rtn=" + location.pathname + escape(location.search); window.location = url; }  //window.location = url; }

function postshout() { var shout = $('facebox').getElementsBySelector('input#txtshout')[0].value; var siteid = $('siteid').value; var userid = $F('currentuid'); var Key = $F("key"); if (shout.trim() != '') { if (Bloc.ObjectModel.Profile.AddShout(userid, Key, shout, siteid).value) { window.location.href = window.location.href; } } };

function checkemailontopmenu() { if ($("topemail")!=null) if ($('topemail').value != "") $('divemail1').innerHTML = "&nbsp;"; }
Event.observe(window, 'load', checkemailontopmenu, false);
