/*yahoo*/
window.YAHOO = window.YAHOO || {};
YAHOO.namespace = function (ns) {
    if (!ns || !ns.length) {
        return null;
    }
    var levels = ns.split(".");
    var nsobj = YAHOO;
    for (var i = (levels[0] == "YAHOO") ? 1 : 0; i < levels.length; ++i) {
        nsobj[levels[i]] = nsobj[levels[i]] || {};
        nsobj = nsobj[levels[i]];
    }
    return nsobj;
};
YAHOO.log = function (sMsg, sCategory, sSource) {
    var l = YAHOO.widget.Logger;
    if (l && l.log) {
        return l.log(sMsg, sCategory, sSource);
    } else {
        return false;
    }
};
YAHOO.extend = function (subclass, superclass) {
    var f = function () {};
    f.prototype = superclass.prototype;
    subclass.prototype = new f();
    subclass.prototype.constructor = subclass;
    subclass.superclass = superclass.prototype;
    if (superclass.prototype.constructor == Object.prototype.constructor) {
        superclass.prototype.constructor = superclass;
    }
};
YAHOO.namespace("util");
YAHOO.namespace("widget");
YAHOO.namespace("example"); /*connection*/
YAHOO.util.Connect = {
    _msxml_progid: ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'],
    _http_header: {},
    _has_http_headers: false,
    _use_default_post_header: true,
    _default_post_header: 'application/x-www-form-urlencoded',
    _isFormSubmit: false,
    _isFileUpload: false,
    _formNode: null,
    _sFormData: null,
    _poll: {},
    _timeOut: {},
    _polling_interval: 50,
    _transaction_id: 0,
    setProgId: function (id) {
        this._msxml_progid.unshift(id);
    },
    setDefaultPostHeader: function (b) {
        this._use_default_post_header = b;
    },
    setPollingInterval: function (i) {
        if (typeof i == 'number' && isFinite(i)) {
            this._polling_interval = i;
        }
    },
    createXhrObject: function (transactionId) {
        var obj, http;
        try {
            http = new XMLHttpRequest();
            obj = {
                conn: http,
                tId: transactionId
            };
        } catch (e) {
            for (var i = 0; i < this._msxml_progid.length; ++i) {
                try {
                    http = new ActiveXObject(this._msxml_progid[i]);
                    obj = {
                        conn: http,
                        tId: transactionId
                    };
                    break;
                } catch (e) {}
            }
        } finally {
            return obj;
        }
    },
    getConnectionObject: function () {
        var o;
        var tId = this._transaction_id;
        try {
            o = this.createXhrObject(tId);
            if (o) {
                this._transaction_id++;
            }
        } catch (e) {} finally {
            return o;
        }
    },
    asyncRequest: function (method, uri, callback, postData) {
        var o = this.getConnectionObject();
        if (!o) {
            return null;
        }
        else {
            if (this._isFormSubmit) {
                if (this._isFileUpload) {
                    this.uploadFile(o.tId, callback, uri);
                    this.releaseObject(o);
                    return;
                }
                if (method == 'GET') {
                    uri += "?" + this._sFormData;
                } else if (method == 'POST') {
                    postData = (postData ? this._sFormData + "&" + postData : this._sFormData);
                }
                this._sFormData = '';
            }
            o.conn.open(method, uri, true);
            if (this._isFormSubmit || (postData && this._use_default_post_header)) {
                this.initHeader('Content-Type', this._default_post_header);
                if (this._isFormSubmit) {
                    this._isFormSubmit = false;
                }
            }
            if (this._has_http_headers) {
                this.setHeader(o);
            }
            this.handleReadyState(o, callback);
            o.conn.send(postData ? postData : null);
            return o;
        }
    },
    handleReadyState: function (o, callback) {
        var oConn = this;
        if (callback && callback.timeout) {
            this._timeOut[o.tId] = window.setTimeout(function () {
                oConn.abort(o, callback, true);
            }, callback.timeout);
        }
        this._poll[o.tId] = window.setInterval(function () {
            if (o.conn && o.conn.readyState == 4) {
                window.clearInterval(oConn._poll[o.tId]);
                delete oConn._poll[o.tId];
                if (callback && callback.timeout) {
                    delete oConn._timeOut[o.tId];
                }
                oConn.handleTransactionResponse(o, callback);
            }
        }, this._polling_interval);
    },
    handleTransactionResponse: function (o, callback, isAbort) {
        if (!callback) {
            this.releaseObject(o);
            return;
        }
        var httpStatus, responseObject;
        try {
            if (o.conn.status !== undefined && o.conn.status != 0) {
                httpStatus = o.conn.status;
            } else {
                httpStatus = 13030;
            }
        } catch (e) {
            httpStatus = 13030;
        }
        if (httpStatus >= 200 && httpStatus < 300) {
            try {
                responseObject = this.createResponseObject(o, callback.argument);
                if (callback.success) {
                    if (!callback.scope) {
                        callback.success(responseObject);
                    } else {
                        callback.success.apply(callback.scope, [responseObject]);
                    }
                }
            } catch (e) {}
        } else {
            try {
                switch (httpStatus) {
                case 12002:
                case 12029:
                case 12030:
                case 12031:
                case 12152:
                case 13030:
                    responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
                    if (callback.failure) {
                        if (!callback.scope) {
                            callback.failure(responseObject);
                        } else {
                            callback.failure.apply(callback.scope, [responseObject]);
                        }
                    }
                    break;
                default:
                    responseObject = this.createResponseObject(o, callback.argument);
                    if (callback.failure) {
                        if (!callback.scope) {
                            callback.failure(responseObject);
                        } else {
                            callback.failure.apply(callback.scope, [responseObject]);
                        }
                    }
                }
            } catch (e) {}
        }
        this.releaseObject(o);
        responseObject = null;
    },
    createResponseObject: function (o, callbackArg) {
        var obj = {};
        var headerObj = {};
        try {
            var headerStr = o.conn.getAllResponseHeaders();
            var header = headerStr.split('\n');
            for (var i = 0; i < header.length; i++) {
                var delimitPos = header[i].indexOf(':');
                if (delimitPos != -1) {
                    headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
                }
            }
        } catch (e) {}
        obj.tId = o.tId;
        obj.status = o.conn.status;
        obj.statusText = o.conn.statusText;
        obj.getResponseHeader = headerObj;
        obj.getAllResponseHeaders = headerStr;
        obj.responseText = o.conn.responseText;
        obj.responseXML = o.conn.responseXML;
        if (typeof callbackArg !== undefined) {
            obj.argument = callbackArg;
        }
        return obj;
    },
    createExceptionObject: function (tId, callbackArg, isAbort) {
        var COMM_CODE = 0;
        var COMM_ERROR = 'communication failure';
        var ABORT_CODE = -1;
        var ABORT_ERROR = 'transaction aborted';
        var obj = {};
        obj.tId = tId;
        if (isAbort) {
            obj.status = ABORT_CODE;
            obj.statusText = ABORT_ERROR;
        } else {
            obj.status = COMM_CODE;
            obj.statusText = COMM_ERROR;
        }
        if (callbackArg) {
            obj.argument = callbackArg;
        }
        return obj;
    },
    initHeader: function (label, value) {
        if (this._http_header[label] === undefined) {
            this._http_header[label] = value;
        } else {
            this._http_header[label] = value + "," + this._http_header[label];
        }
        this._has_http_headers = true;
    },
    setHeader: function (o) {
        for (var prop in this._http_header) {
            if (this._http_header.hasOwnProperty(prop)) {
                o.conn.setRequestHeader(prop, this._http_header[prop]);
            }
        }
        delete this._http_header;
        this._http_header = {};
        this._has_http_headers = false;
    },
    setForm: function (formId, isUpload, secureUri) {
        this._sFormData = '';
        if (typeof formId == 'string') {
            var oForm = (document.getElementById(formId) || document.forms[formId]);
        } else if (typeof formId == 'object') {
            var oForm = formId;
        } else {
            return;
        }
        if (isUpload) {
            this.createFrame(secureUri ? secureUri : null);
            this._isFormSubmit = true;
            this._isFileUpload = true;
            this._formNode = oForm;
            return;
        }
        var oElement, oName, oValue, oDisabled;
        var hasSubmit = false;
        for (var i = 0; i < oForm.elements.length; i++) {
            oElement = oForm.elements[i];
            oDisabled = oForm.elements[i].disabled;
            oName = oForm.elements[i].name;
            oValue = oForm.elements[i].value;
            if (!oDisabled && oName) {
                switch (oElement.type) {
                case 'select-one':
                case 'select-multiple':
                    for (var j = 0; j < oElement.options.length; j++) {
                        if (oElement.options[j].selected) {
                            if (window.ActiveXObject) {
                                this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].attributes['value'].specified ? oElement.options[j].value : oElement.options[j].text) + '&';
                            }
                            else {
                                this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].hasAttribute('value') ? oElement.options[j].value : oElement.options[j].text) + '&';
                            }
                        }
                    }
                    break;
                case 'radio':
                case 'checkbox':
                    if (oElement.checked) {
                        this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
                    }
                    break;
                case 'file':
                case undefined:
                case 'reset':
                case 'button':
                    break;
                case 'submit':
                    if (hasSubmit == false) {
                        this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
                        hasSubmit = true;
                    }
                    break;
                default:
                    this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
                    break;
                }
            }
        }
        this._isFormSubmit = true;
        this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
    },
    createFrame: function (secureUri) {
        var frameId = 'yuiIO' + this._transaction_id;
        if (window.ActiveXObject) {
            var io = document.createElement('<IFRAME id="' + frameId + '" name="' + frameId + '">');
            if (typeof secureUri == 'boolean') {
                io.src = 'javascript:false';
            } else {
                io.src = secureUri;
            }
        }
        else {
            var io = document.createElement('IFRAME');
            io.id = frameId;
            io.name = frameId;
        }
        io.style.position = 'absolute';
        io.style.top = '-1000px';
        io.style.left = '-1000px';
        document.body.appendChild(io);
    },
    uploadFile: function (id, callback, uri) {
        var frameId = 'yuiIO' + id;
        var io = document.getElementById(frameId);
        this._formNode.action = uri;
        this._formNode.enctype = 'multipart/form-data';
        this._formNode.method = 'POST';
        this._formNode.target = frameId;
        this._formNode.submit();
        this._formNode = null;
        this._isFileUpload = false;
        this._isFormSubmit = false;
        var uploadCallback = function () {
            var obj = {};
            obj.tId = id;
            obj.responseText = io.contentWindow.document.body ? io.contentWindow.document.body.innerHTML : null;
            obj.responseXML = io.contentWindow.document.XMLDocument ? io.contentWindow.document.XMLDocument : io.contentWindow.document;
            obj.argument = callback.argument;
            if (callback.upload) {
                if (!callback.scope) {
                    callback.upload(obj);
                } else {
                    callback.upload.apply(callback.scope, [obj]);
                }
            }
            if (YAHOO.util.Event) {
                YAHOO.util.Event.removeListener(io, "load", uploadCallback);
            } else if (window.ActiveXObject) {
                io.detachEvent('onload', uploadCallback);
            }
            else {
                io.removeEventListener('load', uploadCallback, false);
            }
            setTimeout(function () {
                document.body.removeChild(io);
            }, 100);
        };
        if (YAHOO.util.Event) {
            YAHOO.util.Event.addListener(io, "load", uploadCallback);
        } else if (window.ActiveXObject) {
            io.attachEvent('onload', uploadCallback);
        }
        else {
            io.addEventListener('load', uploadCallback, false);
        }
    },
    abort: function (o, callback, isTimeout) {
        if (this.isCallInProgress(o)) {
            o.conn.abort();
            window.clearInterval(this._poll[o.tId]);
            delete this._poll[o.tId];
            if (isTimeout) {
                delete this._timeOut[o.tId];
            }
            this.handleTransactionResponse(o, callback, true);
            return true;
        } else {
            return false;
        }
    },
    isCallInProgress: function (o) {
        if (o.conn) {
            return o.conn.readyState != 4 && o.conn.readyState != 0;
        }
        else {
            return false;
        }
    },
    releaseObject: function (o) {
        o.conn = null;
        o = null;
    }
}; /*event*/
YAHOO.util.CustomEvent = function (type, oScope, silent) {
    this.type = type;
    this.scope = oScope || window;
    this.silent = silent;
    this.subscribers = [];
    if (!this.silent) {}
};
YAHOO.util.CustomEvent.prototype = {
    subscribe: function (fn, obj, bOverride) {
        this.subscribers.push(new YAHOO.util.Subscriber(fn, obj, bOverride));
    },
    unsubscribe: function (fn, obj) {
        var found = false;
        for (var i = 0, len = this.subscribers.length; i < len; ++i) {
            var s = this.subscribers[i];
            if (s && s.contains(fn, obj)) {
                this._delete(i);
                found = true;
            }
        }
        return found;
    },
    fire: function () {
        var len = this.subscribers.length;
        if (!len && this.silent) {
            return;
        }
        var args = [];
        for (var i = 0; i < arguments.length; ++i) {
            args.push(arguments[i]);
        }
        if (!this.silent) {}
        for (i = 0; i < len; ++i) {
            var s = this.subscribers[i];
            if (s) {
                if (!this.silent) {}
                var scope = (s.override) ? s.obj : this.scope;
                s.fn.call(scope, this.type, args, s.obj);
            }
        }
    },
    unsubscribeAll: function () {
        for (var i = 0, len = this.subscribers.length; i < len; ++i) {
            this._delete(len - 1 - i);
        }
    },
    _delete: function (index) {
        var s = this.subscribers[index];
        if (s) {
            delete s.fn;
            delete s.obj;
        }
        this.subscribers.splice(index, 1);
    },
    toString: function () {
        return "CustomEvent: " + "'" + this.type + "', " + "scope: " + this.scope;
    }
};
YAHOO.util.Subscriber = function (fn, obj, bOverride) {
    this.fn = fn;
    this.obj = obj || null;
    this.override = (bOverride);
};
YAHOO.util.Subscriber.prototype.contains = function (fn, obj) {
    return (this.fn == fn && this.obj == obj);
};
YAHOO.util.Subscriber.prototype.toString = function () {
    return "Subscriber { obj: " + (this.obj || "") + ", override: " + (this.override || "no") + " }";
};
if (!YAHOO.util.Event) {
    YAHOO.util.Event = function () {
        var loadComplete = false;
        var listeners = [];
        var delayedListeners = [];
        var unloadListeners = [];
        var legacyEvents = [];
        var legacyHandlers = [];
        var retryCount = 0;
        var onAvailStack = [];
        var legacyMap = [];
        var counter = 0;
        return {
            POLL_RETRYS: 200,
            POLL_INTERVAL: 50,
            EL: 0,
            TYPE: 1,
            FN: 2,
            WFN: 3,
            SCOPE: 3,
            ADJ_SCOPE: 4,
            isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
            isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) && navigator.userAgent.match(/msie/gi)),
            addDelayedListener: function (el, sType, fn, oScope, bOverride) {
                delayedListeners[delayedListeners.length] = [el, sType, fn, oScope, bOverride];
                if (loadComplete) {
                    retryCount = this.POLL_RETRYS;
                    this.startTimeout(0);
                }
            },
            startTimeout: function (interval) {
                var i = (interval || interval === 0) ? interval : this.POLL_INTERVAL;
                var self = this;
                var callback = function () {
                    self._tryPreloadAttach();
                };
                this.timeout = setTimeout(callback, i);
            },
            onAvailable: function (p_id, p_fn, p_obj, p_override) {
                onAvailStack.push({
                    id: p_id,
                    fn: p_fn,
                    obj: p_obj,
                    override: p_override
                });
                retryCount = this.POLL_RETRYS;
                this.startTimeout(0);
            },
            addListener: function (el, sType, fn, oScope, bOverride) {
                if (!fn || !fn.call) {
                    return false;
                }
                if (this._isValidCollection(el)) {
                    var ok = true;
                    for (var i = 0, len = el.length; i < len; ++i) {
                        ok = (this.on(el[i], sType, fn, oScope, bOverride) && ok);
                    }
                    return ok;
                } else if (typeof el == "string") {
                    var oEl = this.getEl(el);
                    if (loadComplete && oEl) {
                        el = oEl;
                    } else {
                        this.addDelayedListener(el, sType, fn, oScope, bOverride);
                        return true;
                    }
                }
                if (!el) {
                    return false;
                }
                if ("unload" == sType && oScope !== this) {
                    unloadListeners[unloadListeners.length] = [el, sType, fn, oScope, bOverride];
                    return true;
                }
                var scope = (bOverride) ? oScope : el;
                var wrappedFn = function (e) {
                    return fn.call(scope, YAHOO.util.Event.getEvent(e), oScope);
                };
                var li = [el, sType, fn, wrappedFn, scope];
                var index = listeners.length;
                listeners[index] = li;
                if (this.useLegacyEvent(el, sType)) {
                    var legacyIndex = this.getLegacyIndex(el, sType);
                    if (legacyIndex == -1 || el != legacyEvents[legacyIndex][0]) {
                        legacyIndex = legacyEvents.length;
                        legacyMap[el.id + sType] = legacyIndex;
                        legacyEvents[legacyIndex] = [el, sType, el["on" + sType]];
                        legacyHandlers[legacyIndex] = [];
                        el["on" + sType] = function (e) {
                            YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e), legacyIndex);
                        };
                    }
                    legacyHandlers[legacyIndex].push(index);
                } else if (el.addEventListener) {
                    el.addEventListener(sType, wrappedFn, false);
                } else if (el.attachEvent) {
                    el.attachEvent("on" + sType, wrappedFn);
                }
                return true;
            },
            fireLegacyEvent: function (e, legacyIndex) {
                var ok = true;
                var le = legacyHandlers[legacyIndex];
                for (var i = 0, len = le.length; i < len; ++i) {
                    var index = le[i];
                    if (index) {
                        var li = listeners[index];
                        if (li && li[this.WFN]) {
                            var scope = li[this.ADJ_SCOPE];
                            var ret = li[this.WFN].call(scope, e);
                            ok = (ok && ret);
                        } else {
                            delete le[i];
                        }
                    }
                }
                return ok;
            },
            getLegacyIndex: function (el, sType) {
                var key = this.generateId(el) + sType;
                if (typeof legacyMap[key] == "undefined") {
                    return -1;
                } else {
                    return legacyMap[key];
                }
            },
            useLegacyEvent: function (el, sType) {
                if (!el.addEventListener && !el.attachEvent) {
                    return true;
                } else if (this.isSafari) {
                    if ("click" == sType || "dblclick" == sType) {
                        return true;
                    }
                }
                return false;
            },
            removeListener: function (el, sType, fn, index) {
                if (!fn || !fn.call) {
                    return false;
                }
                if (typeof el == "string") {
                    el = this.getEl(el);
                } else if (this._isValidCollection(el)) {
                    var ok = true;
                    for (var i = 0, len = el.length; i < len; ++i) {
                        ok = (this.removeListener(el[i], sType, fn) && ok);
                    }
                    return ok;
                }
                if ("unload" == sType) {
                    for (i = 0, len = unloadListeners.length; i < len; i++) {
                        var li = unloadListeners[i];
                        if (li && li[0] == el && li[1] == sType && li[2] == fn) {
                            unloadListeners.splice(i, 1);
                            return true;
                        }
                    }
                    return false;
                }
                var cacheItem = null;
                if ("undefined" == typeof index) {
                    index = this._getCacheIndex(el, sType, fn);
                }
                if (index >= 0) {
                    cacheItem = listeners[index];
                }
                if (!el || !cacheItem) {
                    return false;
                }
                if (el.removeEventListener) {
                    el.removeEventListener(sType, cacheItem[this.WFN], false);
                } else if (el.detachEvent) {
                    el.detachEvent("on" + sType, cacheItem[this.WFN]);
                }
                delete listeners[index][this.WFN];
                delete listeners[index][this.FN];
                listeners.splice(index, 1);
                return true;
            },
            getTarget: function (ev, resolveTextNode) {
                var t = ev.target || ev.srcElement;
                return this.resolveTextNode(t);
            },
            resolveTextNode: function (node) {
                if (node && node.nodeName && "#TEXT" == node.nodeName.toUpperCase()) {
                    return node.parentNode;
                } else {
                    return node;
                }
            },
            getPageX: function (ev) {
                var x = ev.pageX;
                if (!x && 0 !== x) {
                    x = ev.clientX || 0;
                    if (this.isIE) {
                        x += this._getScrollLeft();
                    }
                }
                return x;
            },
            getPageY: function (ev) {
                var y = ev.pageY;
                if (!y && 0 !== y) {
                    y = ev.clientY || 0;
                    if (this.isIE) {
                        y += this._getScrollTop();
                    }
                }
                return y;
            },
            getXY: function (ev) {
                return [this.getPageX(ev), this.getPageY(ev)];
            },
            getRelatedTarget: function (ev) {
                var t = ev.relatedTarget;
                if (!t) {
                    if (ev.type == "mouseout") {
                        t = ev.toElement;
                    } else if (ev.type == "mouseover") {
                        t = ev.fromElement;
                    }
                }
                return this.resolveTextNode(t);
            },
            getTime: function (ev) {
                if (!ev.time) {
                    var t = new Date().getTime();
                    try {
                        ev.time = t;
                    } catch (e) {
                        return t;
                    }
                }
                return ev.time;
            },
            stopEvent: function (ev) {
                this.stopPropagation(ev);
                this.preventDefault(ev);
            },
            stopPropagation: function (ev) {
                if (ev.stopPropagation) {
                    ev.stopPropagation();
                } else {
                    ev.cancelBubble = true;
                }
            },
            preventDefault: function (ev) {
                if (ev.preventDefault) {
                    ev.preventDefault();
                } else {
                    ev.returnValue = false;
                }
            },
            getEvent: function (e) {
                var ev = e || window.event;
                if (!ev) {
                    var c = this.getEvent.caller;
                    while (c) {
                        ev = c.arguments[0];
                        if (ev && Event == ev.constructor) {
                            break;
                        }
                        c = c.caller;
                    }
                }
                return ev;
            },
            getCharCode: function (ev) {
                return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0);
            },
            _getCacheIndex: function (el, sType, fn) {
                for (var i = 0, len = listeners.length; i < len; ++i) {
                    var li = listeners[i];
                    if (li && li[this.FN] == fn && li[this.EL] == el && li[this.TYPE] == sType) {
                        return i;
                    }
                }
                return -1;
            },
            generateId: function (el) {
                var id = el.id;
                if (!id) {
                    id = "yuievtautoid-" + counter;
                    ++counter;
                    el.id = id;
                }
                return id;
            },
            _isValidCollection: function (o) {
                return (o && o.length && typeof o != "string" && !o.tagName && !o.alert && typeof o[0] != "undefined");
            },
            elCache: {},
            getEl: function (id) {
                return document.getElementById(id);
            },
            clearCache: function () {},
            _load: function (e) {
                loadComplete = true;
            },
            _tryPreloadAttach: function () {
                if (this.locked) {
                    return false;
                }
                this.locked = true;
                var tryAgain = !loadComplete;
                if (!tryAgain) {
                    tryAgain = (retryCount > 0);
                }
                var stillDelayed = [];
                for (var i = 0, len = delayedListeners.length; i < len; ++i) {
                    var d = delayedListeners[i];
                    if (d) {
                        var el = this.getEl(d[this.EL]);
                        if (el) {
                            this.on(el, d[this.TYPE], d[this.FN], d[this.SCOPE], d[this.ADJ_SCOPE]);
                            delete delayedListeners[i];
                        } else {
                            stillDelayed.push(d);
                        }
                    }
                }
                delayedListeners = stillDelayed;
                var notAvail = [];
                for (i = 0, len = onAvailStack.length; i < len; ++i) {
                    var item = onAvailStack[i];
                    if (item) {
                        el = this.getEl(item.id);
                        if (el) {
                            var scope = (item.override) ? item.obj : el;
                            item.fn.call(scope, item.obj);
                            delete onAvailStack[i];
                        } else {
                            notAvail.push(item);
                        }
                    }
                }
                retryCount = (stillDelayed.length === 0 && notAvail.length === 0) ? 0 : retryCount - 1;
                if (tryAgain) {
                    this.startTimeout();
                }
                this.locked = false;
                return true;
            },
            purgeElement: function (el, recurse, sType) {
                var elListeners = this.getListeners(el, sType);
                if (elListeners) {
                    for (var i = 0, len = elListeners.length; i < len; ++i) {
                        var l = elListeners[i];
                        this.removeListener(el, l.type, l.fn);
                    }
                }
                if (recurse && el && el.childNodes) {
                    for (i = 0, len = el.childNodes.length; i < len; ++i) {
                        this.purgeElement(el.childNodes[i], recurse, sType);
                    }
                }
            },
            getListeners: function (el, sType) {
                var elListeners = [];
                if (listeners && listeners.length > 0) {
                    for (var i = 0, len = listeners.length; i < len; ++i) {
                        var l = listeners[i];
                        if (l && l[this.EL] === el && (!sType || sType === l[this.TYPE])) {
                            elListeners.push({
                                type: l[this.TYPE],
                                fn: l[this.FN],
                                obj: l[this.SCOPE],
                                adjust: l[this.ADJ_SCOPE],
                                index: i
                            });
                        }
                    }
                }
                return (elListeners.length) ? elListeners : null;
            },
            _unload: function (e, me) {
                for (var i = 0, len = unloadListeners.length; i < len; ++i) {
                    var l = unloadListeners[i];
                    if (l) {
                        var scope = (l[this.ADJ_SCOPE]) ? l[this.SCOPE] : window;
                        l[this.FN].call(scope, this.getEvent(e), l[this.SCOPE]);
                    }
                }
                if (listeners && listeners.length > 0) {
                    var j = listeners.length;
                    while (j) {
                        var index = j - 1;
                        l = listeners[index];
                        if (l) {
                            this.removeListener(l[this.EL], l[this.TYPE], l[this.FN], index);
                        }
                        j = j - 1;
                    }
                    this.clearCache();
                }
                for (i = 0, len = legacyEvents.length; i < len; ++i) {
                    delete legacyEvents[i][0];
                    delete legacyEvents[i];
                }
            },
            _getScrollLeft: function () {
                return this._getScroll()[1];
            },
            _getScrollTop: function () {
                return this._getScroll()[0];
            },
            _getScroll: function () {
                var dd = document.documentElement,
                    db = document.body;
                if (dd && dd.scrollTop) {
                    return [dd.scrollTop, dd.scrollLeft];
                } else if (db) {
                    return [db.scrollTop, db.scrollLeft];
                } else {
                    return [0, 0];
                }
            }
        };
    }();
    YAHOO.util.Event.on = YAHOO.util.Event.addListener;
    if (document && document.body) {
        YAHOO.util.Event._load();
    } else {
        YAHOO.util.Event.on(window, "load", YAHOO.util.Event._load, YAHOO.util.Event, true);
    }
    YAHOO.util.Event.on(window, "unload", YAHOO.util.Event._unload, YAHOO.util.Event, true);
    YAHOO.util.Event._tryPreloadAttach();
} /*dom*/
YAHOO.util.Dom = function () {
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') > -1);
    var isSafari = (ua.indexOf('safari') > -1);
    var isIE = (window.ActiveXObject);
    var id_counter = 0;
    var util = YAHOO.util;
    var property_cache = {};
    var toCamel = function (property) {
        var convert = function (prop) {
            var test = /(-[a-z])/i.exec(prop);
            return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
        };
        while (property.indexOf('-') > -1) {
            property = convert(property);
        }
        return property;
    };
    var toHyphen = function (property) {
        if (property.indexOf('-') > -1) {
            return property;
        }
        var converted = '';
        for (var i = 0, len = property.length; i < len; ++i) {
            if (property.charAt(i) == property.charAt(i).toUpperCase()) {
                converted = converted + '-' + property.charAt(i).toLowerCase();
            } else {
                converted = converted + property.charAt(i);
            }
        }
        return converted;
    };
    var cacheConvertedProperties = function (property) {
        property_cache[property] = {
            camel: toCamel(property),
            hyphen: toHyphen(property)
        };
    };
    return {
        get: function (el) {
            if (!el) {
                return null;
            }
            if (typeof el != 'string' && !(el instanceof Array)) {
                return el;
            }
            if (typeof el == 'string') {
                return document.getElementById(el);
            } else {
                var collection = [];
                for (var i = 0, len = el.length; i < len; ++i) {
                    collection[collection.length] = util.Dom.get(el[i]);
                }
                return collection;
            }
            return null;
        },
        getStyle: function (el, property) {
            var f = function (el) {
                var value = null;
                var dv = document.defaultView;
                if (!property_cache[property]) {
                    cacheConvertedProperties(property);
                }
                var camel = property_cache[property]['camel'];
                var hyphen = property_cache[property]['hyphen'];
                if (property == 'opacity' && el.filters) {
                    value = 1;
                    try {
                        value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
                    } catch (e) {
                        try {
                            value = el.filters.item('alpha').opacity / 100;
                        } catch (e) {}
                    }
                } else if (el.style[camel]) {
                    value = el.style[camel];
                } else if (isIE && el.currentStyle && el.currentStyle[camel]) {
                    value = el.currentStyle[camel];
                } else if (dv && dv.getComputedStyle) {
                    var computed = dv.getComputedStyle(el, '');
                    if (computed && computed.getPropertyValue(hyphen)) {
                        value = computed.getPropertyValue(hyphen);
                    }
                }
                return value;
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        setStyle: function (el, property, val) {
            if (!property_cache[property]) {
                cacheConvertedProperties(property);
            }
            var camel = property_cache[property]['camel'];
            var f = function (el) {
                switch (property) {
                case 'opacity':
                    if (isIE && typeof el.style.filter == 'string') {
                        el.style.filter = 'alpha(opacity=' + val * 100 + ')';
                        if (!el.currentStyle || !el.currentStyle.hasLayout) {
                            el.style.zoom = 1;
                        }
                    } else {
                        el.style.opacity = val;
                        el.style['-moz-opacity'] = val;
                        el.style['-khtml-opacity'] = val;
                    }
                    break;
                default:
                    el.style[camel] = val;
                }
            };
            util.Dom.batch(el, f, util.Dom, true);
        },
        getXY: function (el) {
            var f = function (el) {
                if (el.offsetParent === null || this.getStyle(el, 'display') == 'none') {
                    return false;
                }
                var parentNode = null;
                var pos = [];
                var box;
                if (el.getBoundingClientRect) {
                    box = el.getBoundingClientRect();
                    var doc = document;
                    if (!this.inDocument(el) && parent.document != document) {
                        doc = parent.document;
                        if (!this.isAncestor(doc.documentElement, el)) {
                            return false;
                        }
                    }
                    var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
                    var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
                    return [box.left + scrollLeft, box.top + scrollTop];
                } else {
                    pos = [el.offsetLeft, el.offsetTop];
                    parentNode = el.offsetParent;
                    if (parentNode != el) {
                        while (parentNode) {
                            pos[0] += parentNode.offsetLeft;
                            pos[1] += parentNode.offsetTop;
                            parentNode = parentNode.offsetParent;
                        }
                    }
                    if (isSafari && this.getStyle(el, 'position') == 'absolute') {
                        pos[0] -= document.body.offsetLeft;
                        pos[1] -= document.body.offsetTop;
                    }
                }
                if (el.parentNode) {
                    parentNode = el.parentNode;
                } else {
                    parentNode = null;
                }
                while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') {
                    if (util.Dom.getStyle(parentNode, 'display') != 'inline') {
                        pos[0] -= parentNode.scrollLeft;
                        pos[1] -= parentNode.scrollTop;
                    }
                    if (parentNode.parentNode) {
                        parentNode = parentNode.parentNode;
                    } else {
                        parentNode = null;
                    }
                }
                return pos;
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        getX: function (el) {
            var f = function (el) {
                return util.Dom.getXY(el)[0];
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        getY: function (el) {
            var f = function (el) {
                return util.Dom.getXY(el)[1];
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        setXY: function (el, pos, noRetry) {
            var f = function (el) {
                var style_pos = this.getStyle(el, 'position');
                if (style_pos == 'static') {
                    this.setStyle(el, 'position', 'relative');
                    style_pos = 'relative';
                }
                var pageXY = this.getXY(el);
                if (pageXY === false) {
                    return false;
                }
                var delta = [parseInt(this.getStyle(el, 'left'), 10), parseInt(this.getStyle(el, 'top'), 10)];
                if (isNaN(delta[0])) {
                    delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
                }
                if (isNaN(delta[1])) {
                    delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
                }
                if (pos[0] !== null) {
                    el.style.left = pos[0] - pageXY[0] + delta[0] + 'px';
                }
                if (pos[1] !== null) {
                    el.style.top = pos[1] - pageXY[1] + delta[1] + 'px';
                }
                var newXY = this.getXY(el);
                if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1])) {
                    this.setXY(el, pos, true);
                }
            };
            util.Dom.batch(el, f, util.Dom, true);
        },
        setX: function (el, x) {
            util.Dom.setXY(el, [x, null]);
        },
        setY: function (el, y) {
            util.Dom.setXY(el, [null, y]);
        },
        getRegion: function (el) {
            var f = function (el) {
                var region = new YAHOO.util.Region.getRegion(el);
                return region;
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        getClientWidth: function () {
            return util.Dom.getViewportWidth();
        },
        getClientHeight: function () {
            return util.Dom.getViewportHeight();
        },
        getElementsByClassName: function (className, tag, root) {
            var method = function (el) {
                return util.Dom.hasClass(el, className)
            };
            return util.Dom.getElementsBy(method, tag, root);
        },
        hasClass: function (el, className) {
            var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
            var f = function (el) {
                return re.test(el['className']);
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        addClass: function (el, className) {
            var f = function (el) {
                if (this.hasClass(el, className)) {
                    return;
                }
                el['className'] = [el['className'], className].join(' ');
            };
            util.Dom.batch(el, f, util.Dom, true);
        },
        removeClass: function (el, className) {
            var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
            var f = function (el) {
                if (!this.hasClass(el, className)) {
                    return;
                }
                var c = el['className'];
                el['className'] = c.replace(re, ' ');
                if (this.hasClass(el, className)) {
                    this.removeClass(el, className);
                }
            };
            util.Dom.batch(el, f, util.Dom, true);
        },
        replaceClass: function (el, oldClassName, newClassName) {
            if (oldClassName === newClassName) {
                return false;
            };
            var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
            var f = function (el) {
                if (!this.hasClass(el, oldClassName)) {
                    this.addClass(el, newClassName);
                    return;
                }
                el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
                if (this.hasClass(el, oldClassName)) {
                    this.replaceClass(el, oldClassName, newClassName);
                }
            };
            util.Dom.batch(el, f, util.Dom, true);
        },
        generateId: function (el, prefix) {
            prefix = prefix || 'yui-gen';
            el = el || {};
            var f = function (el) {
                if (el) {
                    el = util.Dom.get(el);
                } else {
                    el = {};
                }
                if (!el.id) {
                    el.id = prefix + id_counter++;
                }
                return el.id;
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        isAncestor: function (haystack, needle) {
            haystack = util.Dom.get(haystack);
            if (!haystack || !needle) {
                return false;
            }
            var f = function (needle) {
                if (haystack.contains && !isSafari) {
                    return haystack.contains(needle);
                } else if (haystack.compareDocumentPosition) {
                    return !!(haystack.compareDocumentPosition(needle) & 16);
                } else {
                    var parent = needle.parentNode;
                    while (parent) {
                        if (parent == haystack) {
                            return true;
                        } else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
                            return false;
                        }
                        parent = parent.parentNode;
                    }
                    return false;
                }
            };
            return util.Dom.batch(needle, f, util.Dom, true);
        },
        inDocument: function (el) {
            var f = function (el) {
                return this.isAncestor(document.documentElement, el);
            };
            return util.Dom.batch(el, f, util.Dom, true);
        },
        getElementsBy: function (method, tag, root) {
            tag = tag || '*';
            root = util.Dom.get(root) || document;
            var nodes = [];
            var elements = root.getElementsByTagName(tag);
            if (!elements.length && (tag == '*' && root.all)) {
                elements = root.all;
            }
            for (var i = 0, len = elements.length; i < len; ++i) {
                if (method(elements[i])) {
                    nodes[nodes.length] = elements[i];
                }
            }
            return nodes;
        },
        batch: function (el, method, o, override) {
            var id = el;
            el = util.Dom.get(el);
            var scope = (override) ? o : window;
            if (!el || el.tagName || !el.length) {
                if (!el) {
                    return false;
                }
                return method.call(scope, el, o);
            }
            var collection = [];
            for (var i = 0, len = el.length; i < len; ++i) {
                if (!el[i]) {
                    id = id[i];
                }
                collection[collection.length] = method.call(scope, el[i], o);
            }
            return collection;
        },
        getDocumentHeight: function () {
            var scrollHeight = -1,
                windowHeight = -1,
                bodyHeight = -1;
            var marginTop = parseInt(util.Dom.getStyle(document.body, 'marginTop'), 10);
            var marginBottom = parseInt(util.Dom.getStyle(document.body, 'marginBottom'), 10);
            var mode = document.compatMode;
            if ((mode || isIE) && !isOpera) {
                switch (mode) {
                case 'CSS1Compat':
                    scrollHeight = ((window.innerHeight && window.scrollMaxY) ? window.innerHeight + window.scrollMaxY : -1);
                    windowHeight = [document.documentElement.clientHeight, self.innerHeight || -1].sort(function (a, b) {
                        return (a - b);
                    })[1];
                    bodyHeight = document.body.offsetHeight + marginTop + marginBottom;
                    break;
                default:
                    scrollHeight = document.body.scrollHeight;
                    bodyHeight = document.body.clientHeight;
                }
            } else {
                scrollHeight = document.documentElement.scrollHeight;
                windowHeight = self.innerHeight;
                bodyHeight = document.documentElement.clientHeight;
            }
            var h = [scrollHeight, windowHeight, bodyHeight].sort(function (a, b) {
                return (a - b);
            });
            return h[2];
        },
        getDocumentWidth: function () {
            var docWidth = -1,
                bodyWidth = -1,
                winWidth = -1;
            var marginRight = parseInt(util.Dom.getStyle(document.body, 'marginRight'), 10);
            var marginLeft = parseInt(util.Dom.getStyle(document.body, 'marginLeft'), 10);
            var mode = document.compatMode;
            if (mode || isIE) {
                switch (mode) {
                case 'CSS1Compat':
                    docWidth = document.documentElement.clientWidth;
                    bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
                    break;
                default:
                    bodyWidth = document.body.clientWidth;
                    docWidth = document.body.scrollWidth;
                    break;
                }
            } else {
                docWidth = document.documentElement.clientWidth;
                bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
            }
            var w = Math.max(docWidth, bodyWidth);
            return w;
        },
        getViewportHeight: function () {
            var height = -1;
            var mode = document.compatMode;
            if ((mode || isIE) && !isOpera) {
                switch (mode) {
                case 'CSS1Compat':
                    height = document.documentElement.clientHeight;
                    break;
                default:
                    height = document.body.clientHeight;
                }
            } else {
                height = self.innerHeight;
            }
            return height;
        },
        getViewportWidth: function () {
            var width = -1;
            var mode = document.compatMode;
            if (mode || isIE) {
                switch (mode) {
                case 'CSS1Compat':
                    width = document.documentElement.clientWidth;
                    break;
                default:
                    width = document.body.clientWidth;
                }
            } else {
                width = self.innerWidth;
            }
            return width;
        }
    };
}();
YAHOO.util.Region = function (t, r, b, l) {
    this.top = t;
    this[1] = t;
    this.right = r;
    this.bottom = b;
    this.left = l;
    this[0] = l;
};
YAHOO.util.Region.prototype.contains = function (region) {
    return (region.left >= this.left && region.right <= this.right && region.top >= this.top && region.bottom <= this.bottom);
};
YAHOO.util.Region.prototype.getArea = function () {
    return ((this.bottom - this.top) * (this.right - this.left));
};
YAHOO.util.Region.prototype.intersect = function (region) {
    var t = Math.max(this.top, region.top);
    var r = Math.min(this.right, region.right);
    var b = Math.min(this.bottom, region.bottom);
    var l = Math.max(this.left, region.left);
    if (b >= t && r >= l) {
        return new YAHOO.util.Region(t, r, b, l);
    } else {
        return null;
    }
};
YAHOO.util.Region.prototype.union = function (region) {
    var t = Math.min(this.top, region.top);
    var r = Math.max(this.right, region.right);
    var b = Math.max(this.bottom, region.bottom);
    var l = Math.min(this.left, region.left);
    return new YAHOO.util.Region(t, r, b, l);
};
YAHOO.util.Region.prototype.toString = function () {
    return ("Region {" + "top: " + this.top + ", right: " + this.right + ", bottom: " + this.bottom + ", left: " + this.left + "}");
};
YAHOO.util.Region.getRegion = function (el) {
    var p = YAHOO.util.Dom.getXY(el);
    var t = p[1];
    var r = p[0] + el.offsetWidth;
    var b = p[1] + el.offsetHeight;
    var l = p[0];
    return new YAHOO.util.Region(t, r, b, l);
};
YAHOO.util.Point = function (x, y) {
    if (x instanceof Array) {
        y = x[1];
        x = x[0];
    }
    this.x = this.right = this.left = this[0] = x;
    this.y = this.top = this.bottom = this[1] = y;
};
YAHOO.util.Point.prototype = new YAHOO.util.Region(); /*autocomplete*/
YAHOO.widget.AutoComplete = function (inputEl, containerEl, oDataSource, oConfigs) {
    if (inputEl && containerEl && oDataSource) {
        if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) {
            this.dataSource = oDataSource;
        }
        else {
            return;
        }
        if (YAHOO.util.Dom.inDocument(inputEl)) {
            if (typeof inputEl == "string") {
                this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl;
                this._oTextbox = document.getElementById(inputEl);
            } else {
                this._sName = (inputEl.id) ? "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl.id : "instance" + YAHOO.widget.AutoComplete._nIndex;
                this._oTextbox = inputEl;
            }
        } else {
            return;
        }
        if (YAHOO.util.Dom.inDocument(containerEl)) {
            if (typeof containerEl == "string") {
                this._oContainer = document.getElementById(containerEl);
            }
            else {
                this._oContainer = containerEl;
            }
            if (this._oContainer.style.display == "none") {}
        } else {
            return;
        }
        if (typeof oConfigs == "object") {
            for (var sConfig in oConfigs) {
                if (sConfig) {
                    this[sConfig] = oConfigs[sConfig];
                }
            }
        }
        this._initContainer();
        this._initProps();
        this._initList();
        this._initContainerHelpers();
        var oSelf = this;
        var oTextbox = this._oTextbox;
        var oContent = this._oContainer._oContent;
        YAHOO.util.Event.addListener(oTextbox, "keyup", oSelf._onTextboxKeyUp, oSelf);
        YAHOO.util.Event.addListener(oTextbox, "keydown", oSelf._onTextboxKeyDown, oSelf);
        YAHOO.util.Event.addListener(oTextbox, "keypress", oSelf._onTextboxKeyPress, oSelf);
        YAHOO.util.Event.addListener(oTextbox, "focus", oSelf._onTextboxFocus, oSelf);
        YAHOO.util.Event.addListener(oTextbox, "blur", oSelf._onTextboxBlur, oSelf);
        YAHOO.util.Event.addListener(oContent, "mouseover", oSelf._onContainerMouseover, oSelf);
        YAHOO.util.Event.addListener(oContent, "mouseout", oSelf._onContainerMouseout, oSelf);
        YAHOO.util.Event.addListener(oContent, "scroll", oSelf._onContainerScroll, oSelf);
        YAHOO.util.Event.addListener(oContent, "resize", oSelf._onContainerResize, oSelf);
        if (oTextbox.form) {
            YAHOO.util.Event.addListener(oTextbox.form, "submit", oSelf._onFormSubmit, oSelf);
        }
        this.textboxFocusEvent = new YAHOO.util.CustomEvent("textboxFocus", this);
        this.textboxKeyEvent = new YAHOO.util.CustomEvent("textboxKey", this);
        this.dataRequestEvent = new YAHOO.util.CustomEvent("dataRequest", this);
        this.dataReturnEvent = new YAHOO.util.CustomEvent("dataReturn", this);
        this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
        this.containerExpandEvent = new YAHOO.util.CustomEvent("containerExpand", this);
        this.typeAheadEvent = new YAHOO.util.CustomEvent("typeAhead", this);
        this.itemMouseOverEvent = new YAHOO.util.CustomEvent("itemMouseOver", this);
        this.itemMouseOutEvent = new YAHOO.util.CustomEvent("itemMouseOut", this);
        this.itemArrowToEvent = new YAHOO.util.CustomEvent("itemArrowTo", this);
        this.itemArrowFromEvent = new YAHOO.util.CustomEvent("itemArrowFrom", this);
        this.itemSelectEvent = new YAHOO.util.CustomEvent("itemSelect", this);
        this.unmatchedItemSelectEvent = new YAHOO.util.CustomEvent("unmatchedItemSelect", this);
        this.selectionEnforceEvent = new YAHOO.util.CustomEvent("selectionEnforce", this);
        this.containerCollapseEvent = new YAHOO.util.CustomEvent("containerCollapse", this);
        this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
        oTextbox.setAttribute("autocomplete", "off");
        YAHOO.widget.AutoComplete._nIndex++;
    }
    else {}
};
YAHOO.widget.AutoComplete.prototype.dataSource = null;
YAHOO.widget.AutoComplete.prototype.minQueryLength = 2;
YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
YAHOO.widget.AutoComplete.prototype.delimChar = null;
YAHOO.widget.AutoComplete.prototype.autoHighlight = false;
YAHOO.widget.AutoComplete.prototype.typeAhead = false;
YAHOO.widget.AutoComplete.prototype.animHoriz = false;
YAHOO.widget.AutoComplete.prototype.animVert = false;
YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
YAHOO.widget.AutoComplete.prototype.forceSelection = false;
YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = false;
YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
YAHOO.widget.AutoComplete.prototype.useIFrame = false;
YAHOO.widget.AutoComplete.prototype.useShadow = false;
YAHOO.widget.AutoComplete.prototype.toString = function () {
    return "AutoComplete " + this._sName;
};
YAHOO.widget.AutoComplete.prototype.getListItems = function () {
    return this._aListItems;
};
YAHOO.widget.AutoComplete.prototype.getListItemData = function (oListItem) {
    if (oListItem._oResultData) {
        return oListItem._oResultData;
    } else {
        return false;
    }
};
YAHOO.widget.AutoComplete.prototype.setHeader = function (sHeader) {
    if (sHeader) {
        if (this._oContainer._oContent._oHeader) {
            this._oContainer._oContent._oHeader.innerHTML = sHeader;
            this._oContainer._oContent._oHeader.style.display = "block";
        }
    } else {
        this._oContainer._oContent._oHeader.innerHTML = "";
        this._oContainer._oContent._oHeader.style.display = "none";
    }
};
YAHOO.widget.AutoComplete.prototype.setFooter = function (sFooter) {
    if (sFooter) {
        if (this._oContainer._oContent._oFooter) {
            this._oContainer._oContent._oFooter.innerHTML = sFooter;
            this._oContainer._oContent._oFooter.style.display = "block";
        }
    } else {
        this._oContainer._oContent._oFooter.innerHTML = "";
        this._oContainer._oContent._oFooter.style.display = "none";
    }
};
YAHOO.widget.AutoComplete.prototype.setBody = function (sBody) {
    if (sBody) {
        if (this._oContainer._oContent._oBody) {
            this._oContainer._oContent._oBody.innerHTML = sBody;
            this._oContainer._oContent._oBody.style.display = "block";
            this._oContainer._oContent.style.display = "block";
        }
    } else {
        this._oContainer._oContent._oBody.innerHTML = "";
        this._oContainer._oContent.style.display = "none";
    }
    this._maxResultsDisplayed = 0;
};
YAHOO.widget.AutoComplete.prototype.formatResult = function (oResultItem, sQuery) {
    var sResult = oResultItem[0];
    if (sResult) {
        return sResult;
    } else {
        return "";
    }
};
YAHOO.widget.AutoComplete.prototype.sendQuery = function (sQuery) {
    if (sQuery) {
        this._sendQuery(sQuery);
    }
    else {
        return;
    }
};
YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
YAHOO.widget.AutoComplete._nIndex = 0;
YAHOO.widget.AutoComplete.prototype._sName = null;
YAHOO.widget.AutoComplete.prototype._oTextbox = null;
YAHOO.widget.AutoComplete.prototype._bFocused = true;
YAHOO.widget.AutoComplete.prototype._oAnim = null;
YAHOO.widget.AutoComplete.prototype._oContainer = null;
YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
YAHOO.widget.AutoComplete.prototype._aListItems = null;
YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
YAHOO.widget.AutoComplete.prototype._oCurItem = null;
YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
YAHOO.widget.AutoComplete.prototype._initProps = function () {
    var minQueryLength = this.minQueryLength;
    if (isNaN(minQueryLength) || (minQueryLength < 1)) {
        minQueryLength = 1;
    }
    var maxResultsDisplayed = this.maxResultsDisplayed;
    if (isNaN(this.maxResultsDisplayed) || (this.maxResultsDisplayed < 1)) {
        this.maxResultsDisplayed = 5;
    }
    var queryDelay = this.queryDelay;
    if (isNaN(this.queryDelay) || (this.queryDelay < 0)) {
        this.queryDelay = 0.5;
    }
    var aDelimChar = (this.delimChar) ? this.delimChar : null;
    if (aDelimChar) {
        if (typeof aDelimChar == "string") {
            this.delimChar = [aDelimChar];
        }
        else if (aDelimChar.constructor != Array) {
            this.delimChar = null;
        }
    }
    var animSpeed = this.animSpeed;
    if ((this.animHoriz || this.animVert) && YAHOO.util.Anim) {
        if (isNaN(animSpeed) || (animSpeed < 0)) {
            animSpeed = 0.3;
        }
        if (!this._oAnim) {
            oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
            this._oAnim = oAnim;
        } else {
            this._oAnim.duration = animSpeed;
        }
    }
    if (this.forceSelection && this.delimChar) {}
    if (this.alwaysShowContainer && (this.useShadow || this.useIFrame)) {}
    if (this.alwaysShowContainer) {
        this._bContainerOpen = true;
    }
};
YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function () {
    if (this.useShadow && !this._oContainer._oShadow) {
        var oShadow = document.createElement("div");
        oShadow.className = "yui-ac-shadow";
        this._oContainer._oShadow = this._oContainer.appendChild(oShadow);
    }
    if (this.useIFrame && !this._oContainer._oIFrame) {
        var oIFrame = document.createElement("iframe");
        oIFrame.src = this._iFrameSrc;
        oIFrame.frameBorder = 0;
        oIFrame.scrolling = "no";
        oIFrame.style.position = "absolute";
        oIFrame.style.width = "100%";
        oIFrame.style.height = "100%";
        this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame);
    }
};
YAHOO.widget.AutoComplete.prototype._initContainer = function () {
    if (!this._oContainer._oContent) {
        var oContent = document.createElement("div");
        oContent.className = "yui-ac-content";
        oContent.style.display = "none";
        this._oContainer._oContent = this._oContainer.appendChild(oContent);
        var oHeader = document.createElement("div");
        oHeader.className = "yui-ac-hd";
        oHeader.style.display = "none";
        this._oContainer._oContent._oHeader = this._oContainer._oContent.appendChild(oHeader);
        var oBody = document.createElement("div");
        oBody.className = "yui-ac-bd";
        this._oContainer._oContent._oBody = this._oContainer._oContent.appendChild(oBody);
        var oFooter = document.createElement("div");
        oFooter.className = "yui-ac-ft";
        oFooter.style.display = "none";
        this._oContainer._oContent._oFooter = this._oContainer._oContent.appendChild(oFooter);
    } else {}
};
YAHOO.widget.AutoComplete.prototype._initList = function () {
    this._aListItems = [];
    while (this._oContainer._oContent._oBody.hasChildNodes()) {
        var oldListItems = this.getListItems();
        if (oldListItems) {
            for (var oldi = oldListItems.length - 1; oldi >= 0; i--) {
                oldListItems[oldi] = null;
            }
        }
        this._oContainer._oContent._oBody.innerHTML = "";
    }
    var oList = document.createElement("ul");
    oList = this._oContainer._oContent._oBody.appendChild(oList);
    for (var i = 0; i < this.maxResultsDisplayed; i++) {
        var oItem = document.createElement("li");
        oItem = oList.appendChild(oItem);
        this._aListItems[i] = oItem;
        this._initListItem(oItem, i);
    }
    this._maxResultsDisplayed = this.maxResultsDisplayed;
};
YAHOO.widget.AutoComplete.prototype._initListItem = function (oItem, nItemIndex) {
    var oSelf = this;
    oItem.style.display = "none";
    oItem._nItemIndex = nItemIndex;
    oItem.mouseover = oItem.mouseout = oItem.onclick = null;
    YAHOO.util.Event.addListener(oItem, "mouseover", oSelf._onItemMouseover, oSelf);
    YAHOO.util.Event.addListener(oItem, "mouseout", oSelf._onItemMouseout, oSelf);
    YAHOO.util.Event.addListener(oItem, "click", oSelf._onItemMouseclick, oSelf);
};
YAHOO.widget.AutoComplete.prototype._onItemMouseover = function (v, oSelf) {
    if (oSelf.prehighlightClassName) {
        oSelf._togglePrehighlight(this, "mouseover");
    } else {
        oSelf._toggleHighlight(this, "to");
    }
    oSelf.itemMouseOverEvent.fire(oSelf, this);
};
YAHOO.widget.AutoComplete.prototype._onItemMouseout = function (v, oSelf) {
    if (oSelf.prehighlightClassName) {
        oSelf._togglePrehighlight(this, "mouseout");
    } else {
        oSelf._toggleHighlight(this, "from");
    }
    oSelf.itemMouseOutEvent.fire(oSelf, this);
};
YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function (v, oSelf) {
    oSelf._toggleHighlight(this, "to");
    oSelf._selectItem(this);
};
YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function (v, oSelf) {
    oSelf._bOverContainer = true;
};
YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function (v, oSelf) {
    oSelf._bOverContainer = false;
    if (oSelf._oCurItem) {
        oSelf._toggleHighlight(oSelf._oCurItem, "to");
    }
};
YAHOO.widget.AutoComplete.prototype._onContainerScroll = function (v, oSelf) {
    oSelf._oTextbox.focus();
};
YAHOO.widget.AutoComplete.prototype._onContainerResize = function (v, oSelf) {
    oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
};
YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function (v, oSelf) {
    var nKeyCode = v.keyCode;
    switch (nKeyCode) {
    case 9:
        if (oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
            if (oSelf._bContainerOpen) {
                YAHOO.util.Event.stopEvent(v);
            }
        }
        if (oSelf._oCurItem) {
            oSelf._selectItem(oSelf._oCurItem);
        } else {
            oSelf._clearList();
        }
        break;
    case 13:
        if (oSelf._nKeyCode != nKeyCode) {
            if (oSelf._bContainerOpen) {
                YAHOO.util.Event.stopEvent(v);
            }
        }
        if (oSelf._oCurItem) {
            oSelf._selectItem(oSelf._oCurItem);
        } else {
            oSelf._clearList();
        }
        break;
    case 27:
        oSelf._clearList();
        return;
    case 39:
        oSelf._jumpSelection();
        break;
    case 38:
        YAHOO.util.Event.stopEvent(v);
        oSelf._moveSelection(nKeyCode);
        break;
    case 40:
        YAHOO.util.Event.stopEvent(v);
        oSelf._moveSelection(nKeyCode);
        break;
    default:
        break;
    }
};
YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function (v, oSelf) {
    var nKeyCode = v.keyCode;
    switch (nKeyCode) {
    case 9:
    case 13:
        if ((oSelf._nKeyCode != nKeyCode)) {
            YAHOO.util.Event.stopEvent(v);
        }
        break;
    case 38:
    case 40:
        YAHOO.util.Event.stopEvent(v);
        break;
    default:
        break;
    }
};
YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function (v, oSelf) {
    oSelf._initProps();
    var nKeyCode = v.keyCode;
    oSelf._nKeyCode = nKeyCode;
    var sChar = String.fromCharCode(nKeyCode);
    var sText = this.value;
    if (oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
        return;
    } else {
        oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
    }
    if (oSelf.queryDelay > 0) {
        var nDelayID = setTimeout(function () {
            oSelf._sendQuery(sText);
        }, (oSelf.queryDelay * 1000));
        if (oSelf._nDelayID != -1) {
            clearTimeout(oSelf._nDelayID);
        }
        oSelf._nDelayID = nDelayID;
    } else {
        oSelf._sendQuery(sText);
    }
};
YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function (nKeyCode) {
    if ((nKeyCode == 9) || (nKeyCode == 13) || (nKeyCode == 16) || (nKeyCode == 17) || (nKeyCode >= 18 && nKeyCode <= 20) || (nKeyCode == 27) || (nKeyCode >= 33 && nKeyCode <= 35) || (nKeyCode >= 36 && nKeyCode <= 38) || (nKeyCode == 40) || (nKeyCode >= 44 && nKeyCode <= 45)) {
        return true;
    }
    return false;
};
YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v, oSelf) {
    oSelf._oTextbox.setAttribute("autocomplete", "off");
    oSelf._bFocused = true;
    oSelf.textboxFocusEvent.fire(oSelf);
};
YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v, oSelf) {
    if (!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
        if (!oSelf._bItemSelected) {
            if (!oSelf._bContainerOpen || (oSelf._bContainerOpen && !oSelf._textMatchesOption())) {
                if (oSelf.forceSelection) {
                    oSelf._clearSelection();
                } else {
                    oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
                }
            }
        }
        if (oSelf._bContainerOpen) {
            oSelf._clearList();
        }
        oSelf._bFocused = false;
        oSelf.textboxBlurEvent.fire(oSelf);
    }
};
YAHOO.widget.AutoComplete.prototype._onFormSubmit = function (v, oSelf) {
    if (oSelf.allowBrowserAutocomplete) {
        oSelf._oTextbox.setAttribute("autocomplete", "on");
    }
    else {
        oSelf._oTextbox.setAttribute("autocomplete", "off");
    }
};
YAHOO.widget.AutoComplete.prototype._sendQuery = function (sQuery) {
    if (sQuery.length <= 1 && sQuery != '') {
        return
    }
    var aDelimChar = (this.delimChar) ? this.delimChar : null;
    if (aDelimChar) {
        var nDelimIndex = -1;
        for (var i = aDelimChar.length - 1; i >= 0; i--) {
            var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
            if (nNewIndex > nDelimIndex) {
                nDelimIndex = nNewIndex;
            }
        }
        if (aDelimChar[i] == " ") {
            for (var j = aDelimChar.length - 1; j >= 0; j--) {
                if (sQuery[nDelimIndex - 1] == aDelimChar[j]) {
                    nDelimIndex--;
                    break;
                }
            }
        }
        if (nDelimIndex > -1) {
            var nQueryStart = nDelimIndex + 1;
            while (sQuery.charAt(nQueryStart) == " ") {
                nQueryStart += 1;
            }
            this._sSavedQuery = sQuery.substring(0, nQueryStart);
            sQuery = sQuery.substr(nQueryStart);
        } else if (sQuery.indexOf(this._sSavedQuery) < 0) {
            this._sSavedQuery = null;
        }
    }
    if (sQuery.length < this.minQueryLength) {
        if (this._nDelayID != -1) {
            clearTimeout(this._nDelayID);
        }
        this._clearList();
        return;
    }
    sQuery = encodeURIComponent(sQuery);
    this._nDelayID = -1;
    this.dataRequestEvent.fire(this, sQuery);
    this.dataSource.getResults(this._populateList, sQuery, this);
};
YAHOO.widget.AutoComplete.prototype._clearList = function () {
    this._oContainer._oContent.scrollTop = 0;
    var aItems = this._aListItems;
    if (aItems && (aItems.length > 0)) {
        for (var i = aItems.length - 1; i >= 0; i--) {
            aItems[i].style.display = "none";
        }
    }
    if (this._oCurItem) {
        this._toggleHighlight(this._oCurItem, "from");
    }
    this._oCurItem = null;
    this._nDisplayedItems = 0;
    this._sCurQuery = null;
    this._toggleContainer(false);
};
YAHOO.widget.AutoComplete.prototype._populateList = function (sQuery, aResults, oSelf) {
    if (aResults === null) {
        oSelf.dataErrorEvent.fire(oSelf, sQuery);
    }
    if (!oSelf._bFocused || !aResults) {
        return;
    }
    var isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
    var contentStyle = oSelf._oContainer._oContent.style;
    contentStyle.width = (!isOpera) ? null : "";
    contentStyle.height = (!isOpera) ? null : "";
    var sCurQuery = decodeURIComponent(sQuery);
    oSelf._sCurQuery = sCurQuery;
    oSelf._bItemSelected = false;
    if (oSelf._maxResultsDisplayed != oSelf.maxResultsDisplayed) {
        oSelf._initList();
    }
    var nItems = Math.min(aResults.length, oSelf.maxResultsDisplayed);
    oSelf._nDisplayedItems = nItems;
    if (nItems > 0) {
        oSelf._initContainerHelpers();
        var aItems = oSelf._aListItems;
        for (var i = nItems - 1; i >= 0; i--) {
            var oItemi = aItems[i];
            var oResultItemi = aResults[i];
            oItemi.innerHTML = oSelf.formatResult(oResultItemi, sCurQuery);
            var strobj = new String(oItemi.innerHTML);
            oItemi.innerHTML = strobj.replace("&gt;", "");
            oItemi.style.display = "list-item";
            oItemi._sResultKey = oResultItemi[0];
            oItemi._oResultData = oResultItemi;
        }
        for (var j = aItems.length - 1; j >= nItems; j--) {
            var oItemj = aItems[j];
            oItemj.innerHTML = null;
            oItemj.style.display = "none";
            oItemj._sResultKey = null;
            oItemj._oResultData = null;
        }
        if (oSelf.autoHighlight) {
            var oFirstItem = aItems[0];
            oSelf._toggleHighlight(oFirstItem, "to");
            oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
            oSelf._typeAhead(oFirstItem, sQuery);
        } else {
            oSelf._oCurItem = null;
        }
        oSelf._toggleContainer(true);
    } else {
        oSelf._clearList();
    }
    oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
};
YAHOO.widget.AutoComplete.prototype._clearSelection = function () {
    var sValue = this._oTextbox.value;
    var sChar = (this.delimChar) ? this.delimChar[0] : null;
    var nIndex = (sChar) ? sValue.lastIndexOf(sChar, sValue.length - 2) : -1;
    if (nIndex > -1) {
        this._oTextbox.value = sValue.substring(0, nIndex);
    }
    else {
        this._oTextbox.value = "";
    }
    this._sSavedQuery = this._oTextbox.value;
    this.selectionEnforceEvent.fire(this);
};
YAHOO.widget.AutoComplete.prototype._textMatchesOption = function () {
    var foundMatch = false;
    for (var i = this._nDisplayedItems - 1; i >= 0; i--) {
        var oItem = this._aListItems[i];
        var sMatch = oItem._sResultKey.toLowerCase();
        if (sMatch == this._sCurQuery.toLowerCase()) {
            foundMatch = true;
            break;
        }
    }
    return (foundMatch);
};
YAHOO.widget.AutoComplete.prototype._typeAhead = function (oItem, sQuery) {
    if (!this.typeAhead) {
        return;
    }
    var oTextbox = this._oTextbox;
    var sValue = this._oTextbox.value;
    if (!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
        return;
    }
    var nStart = sValue.length;
    this._updateValue(oItem);
    var nEnd = oTextbox.value.length;
    this._selectText(oTextbox, nStart, nEnd);
    var sPrefill = oTextbox.value.substr(nStart, nEnd);
    this.typeAheadEvent.fire(this, sQuery, sPrefill);
};
YAHOO.widget.AutoComplete.prototype._selectText = function (oTextbox, nStart, nEnd) {
    if (oTextbox.setSelectionRange) {
        oTextbox.setSelectionRange(nStart, nEnd);
    } else if (oTextbox.createTextRange) {
        var oTextRange = oTextbox.createTextRange();
        oTextRange.moveStart("character", nStart);
        oTextRange.moveEnd("character", nEnd - oTextbox.value.length);
        oTextRange.select();
    } else {
        oTextbox.select();
    }
};
YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function (bShow) {
    var bFireEvent = false;
    var width = this._oContainer._oContent.offsetWidth + "px";
    var height = this._oContainer._oContent.offsetHeight + "px";
    if (this.useIFrame && this._oContainer._oIFrame) {
        bFireEvent = true;
        if (this.alwaysShowContainer || bShow) {
            this._oContainer._oIFrame.style.width = width;
            this._oContainer._oIFrame.style.height = height;
        }
        else {
            this._oContainer._oIFrame.style.width = 0;
            this._oContainer._oIFrame.style.height = 0;
        }
    }
    if (this.useShadow && this._oContainer._oShadow) {
        bFireEvent = true;
        if (this.alwaysShowContainer || bShow) {
            this._oContainer._oShadow.style.width = width;
            this._oContainer._oShadow.style.height = height;
        } else {
            this._oContainer._oShadow.style.width = 0;
            this._oContainer._oShadow.style.height = 0;
        }
    }
};
YAHOO.widget.AutoComplete.prototype._toggleContainer = function (bShow) {
    if (this.alwaysShowContainer) {
        if (bShow) {
            this.containerExpandEvent.fire(this);
        }
        else {
            this.containerCollapseEvent.fire(this);
        }
        this._bContainerOpen = bShow;
        return;
    }
    var oContainer = this._oContainer;
    if (!bShow && !this._bContainerOpen) {
        oContainer._oContent.style.display = "none";
        return;
    }
    var oAnim = this._oAnim;
    if (oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
        if (!bShow) {
            this._toggleContainerHelpers(bShow);
        }
        if (oAnim.isAnimated()) {
            oAnim.stop();
        }
        var oClone = oContainer._oContent.cloneNode(true);
        oContainer.appendChild(oClone);
        oClone.style.top = "-9000px";
        oClone.style.display = "block";
        var wExp = oClone.offsetWidth;
        var hExp = oClone.offsetHeight;
        var wColl = (this.animHoriz) ? 0 : wExp;
        var hColl = (this.animVert) ? 0 : hExp;
        oAnim.attributes = (bShow) ? {
            width: {
                to: wExp
            },
            height: {
                to: hExp
            }
        } : {
            width: {
                to: wColl
            },
            height: {
                to: hColl
            }
        };
        if (bShow && !this._bContainerOpen) {
            oContainer._oContent.style.width = wColl + "px";
            oContainer._oContent.style.height = hColl + "px";
        } else {
            oContainer._oContent.style.width = wExp + "px";
            oContainer._oContent.style.height = hExp + "px";
        }
        oContainer.removeChild(oClone);
        oClone = null;
        var oSelf = this;
        var onAnimComplete = function () {
            oAnim.onComplete.unsubscribeAll();
            if (bShow) {
                oSelf.containerExpandEvent.fire(oSelf);
            } else {
                oContainer._oContent.style.display = "none";
                oSelf.containerCollapseEvent.fire(oSelf);
            }
            oSelf._toggleContainerHelpers(bShow);
        };
        oContainer._oContent.style.display = "block";
        oAnim.onComplete.subscribe(onAnimComplete);
        oAnim.animate();
        this._bContainerOpen = bShow;
    } else {
        if (bShow) {
            oContainer._oContent.style.display = "block";
            this.containerExpandEvent.fire(this);
        } else {
            oContainer._oContent.style.display = "none";
            this.containerCollapseEvent.fire(this);
        }
        this._toggleContainerHelpers(bShow);
        this._bContainerOpen = bShow;
    }
};
YAHOO.widget.AutoComplete.prototype._toggleHighlight = function (oNewItem, sType) {
    var sHighlight = this.highlightClassName;
    if (this._oCurItem) {
        YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
    }
    if ((sType == "to") && sHighlight) {
        YAHOO.util.Dom.addClass(oNewItem, sHighlight);
        this._oCurItem = oNewItem;
    }
};
YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function (oNewItem, sType) {
    if (oNewItem == this._oCurItem) {
        return;
    }
    var sPrehighlight = this.prehighlightClassName;
    if ((sType == "mouseover") && sPrehighlight) {
        YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
    }
    else {
        YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
    }
};
YAHOO.widget.AutoComplete.prototype._updateValue = function (oItem) {
    var oTextbox = this._oTextbox;
    var sDelimChar = (this.delimChar) ? this.delimChar[0] : null;
    var sSavedQuery = this._sSavedQuery;
    var sResultKey = oItem._sResultKey;
    var search_str1 = "<b>";
    var search_str2 = "</b>";
    sResultKey = sResultKey.replace(search_str1, "");
    sResultKey = sResultKey.replace(search_str2, "");
    oTextbox.focus();
    oTextbox.value = "";
    if (sDelimChar) {
        if (sSavedQuery) {
            oTextbox.value = sSavedQuery;
        }
        oTextbox.value += sResultKey + sDelimChar;
        if (sDelimChar != " ") {
            oTextbox.value += " ";
        }
    } else {
        oTextbox.value = sResultKey;
    }
    if (oTextbox.type == "textarea") {
        oTextbox.scrollTop = oTextbox.scrollHeight;
    }
    var end = oTextbox.value.length;
    this._selectText(oTextbox, end, end);
    this._oCurItem = oItem;
};
YAHOO.widget.AutoComplete.prototype._selectItem = function (oItem) {
    this._bItemSelected = true;
    this._updateValue(oItem);
    this.itemSelectEvent.fire(this, oItem, oItem._oResultData);
    this._clearList();
};
YAHOO.widget.AutoComplete.prototype._jumpSelection = function () {
    if (!this.typeAhead) {
        return;
    } else {
        this._clearList();
    }
};
YAHOO.widget.AutoComplete.prototype._moveSelection = function (nKeyCode) {
    if (this._bContainerOpen) {
        var oCurItem = this._oCurItem;
        var nCurItemIndex = -1;
        if (oCurItem) {
            nCurItemIndex = oCurItem._nItemIndex;
        }
        var nNewItemIndex = (nKeyCode == 40) ? (nCurItemIndex + 1) : (nCurItemIndex - 1);
        if (nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
            return;
        }
        if (oCurItem) {
            this._toggleHighlight(oCurItem, "from");
            this.itemArrowFromEvent.fire(this, oCurItem);
        }
        if (nNewItemIndex == -1) {
            if (this.delimChar && this._sSavedQuery) {
                if (!this._textMatchesOption()) {
                    this._oTextbox.value = this._sSavedQuery;
                } else {
                    this._oTextbox.value = this._sSavedQuery + this._sCurQuery;
                }
            } else {
                this._oTextbox.value = this._sCurQuery;
            }
            this._oCurItem = null;
            return;
        }
        if (nNewItemIndex == -2) {
            this._clearList();
            return;
        }
        var oNewItem = this._aListItems[nNewItemIndex];
        var oContent = this._oContainer._oContent;
        var scrollOn = ((YAHOO.util.Dom.getStyle(oContent, "overflow") == "auto") || (YAHOO.util.Dom.getStyle(oContent, "overflowY") == "auto"));
        if (scrollOn && (nNewItemIndex > -1) && (nNewItemIndex < this._nDisplayedItems)) {
            if (nKeyCode == 40) {
                if ((oNewItem.offsetTop + oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
                    oContent.scrollTop = (oNewItem.offsetTop + oNewItem.offsetHeight) - oContent.offsetHeight;
                }
                else if ((oNewItem.offsetTop + oNewItem.offsetHeight) < oContent.scrollTop) {
                    oContent.scrollTop = oNewItem.offsetTop;
                }
            } else {
                if (oNewItem.offsetTop < oContent.scrollTop) {
                    this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
                } else if (oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
                    this._oContainer._oContent.scrollTop = (oNewItem.offsetTop + oNewItem.offsetHeight) - oContent.offsetHeight;
                }
            }
        }
        this._toggleHighlight(oNewItem, "to");
        this.itemArrowToEvent.fire(this, oNewItem);
        if (this.typeAhead) {
            this._updateValue(oNewItem);
        }
    }
};
YAHOO.widget.DataSource = function () {};
YAHOO.widget.DataSource.prototype.ERROR_DATANULL = "Response data was null";
YAHOO.widget.DataSource.prototype.ERROR_DATAPARSE = "Response data could not be parsed";
YAHOO.widget.DataSource.prototype.maxCacheEntries = 0;
YAHOO.widget.DataSource.prototype.queryMatchContains = false;
YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
YAHOO.widget.DataSource.prototype.queryMatchCase = false;
YAHOO.widget.DataSource.prototype.getName = function () {
    return this._sName;
};
YAHOO.widget.DataSource.prototype.toString = function () {
    return "DataSource " + this._sName;
};
YAHOO.widget.DataSource.prototype.getResults = function (oCallbackFn, sQuery, oParent) {
    var aResults = this._doQueryCache(oCallbackFn, sQuery, oParent);
    if (aResults.length === 0) {
        this.queryEvent.fire(this, oParent, sQuery);
        this.doQuery(oCallbackFn, sQuery, oParent);
    }
};
YAHOO.widget.DataSource.prototype.doQuery = function (oCallbackFn, sQuery, oParent) {};
YAHOO.widget.DataSource.prototype.flushCache = function () {
    if (this._aCache) {
        this._aCache = [];
    }
    if (this._aCacheHelper) {
        this._aCacheHelper = [];
    }
    this.cacheFlushEvent.fire(this);
};
YAHOO.widget.DataSource.prototype.queryEvent = null;
YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
YAHOO.widget.DataSource.prototype.getResultsEvent = null;
YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
YAHOO.widget.DataSource._nIndex = 0;
YAHOO.widget.DataSource.prototype._sName = null;
YAHOO.widget.DataSource.prototype._aCache = null;
YAHOO.widget.DataSource.prototype._init = function () {
    var maxCacheEntries = this.maxCacheEntries;
    if (isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
        maxCacheEntries = 0;
    }
    if (maxCacheEntries > 0 && !this._aCache) {
        this._aCache = [];
    }
    this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
    YAHOO.widget.DataSource._nIndex++;
    this.queryEvent = new YAHOO.util.CustomEvent("query", this);
    this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
    this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
    this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
    this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
    this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
};
YAHOO.widget.DataSource.prototype._addCacheElem = function (resultObj) {
    var aCache = this._aCache;
    if (!aCache || !resultObj || !resultObj.query || !resultObj.results) {
        return;
    }
    if (aCache.length >= this.maxCacheEntries) {
        aCache.shift();
    }
    aCache.push(resultObj);
};
YAHOO.widget.DataSource.prototype._doQueryCache = function (oCallbackFn, sQuery, oParent) {
    var aResults = [];
    var bMatchFound = false;
    var aCache = this._aCache;
    var nCacheLength = (aCache) ? aCache.length : 0;
    var bMatchContains = this.queryMatchContains;
    if ((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
        this.cacheQueryEvent.fire(this, oParent, sQuery);
        if (!this.queryMatchCase) {
            var sOrigQuery = sQuery;
            sQuery = sQuery.toLowerCase();
        }
        for (var i = nCacheLength - 1; i >= 0; i--) {
            var resultObj = aCache[i];
            var aAllResultItems = resultObj.results;
            var matchKey = (!this.queryMatchCase) ? encodeURIComponent(resultObj.query.toLowerCase()) : encodeURIComponent(resultObj.query);
            if (matchKey == sQuery) {
                bMatchFound = true;
                aResults = aAllResultItems;
                if (i != nCacheLength - 1) {
                    aCache.splice(i, 1);
                    this._addCacheElem(resultObj);
                }
                break;
            }
            else if (this.queryMatchSubset) {
                for (var j = sQuery.length - 1; j >= 0; j--) {
                    var subQuery = sQuery.substr(0, j);
                    if (matchKey == subQuery) {
                        bMatchFound = true;
                        for (var k = aAllResultItems.length - 1; k >= 0; k--) {
                            var aRecord = aAllResultItems[k];
                            var sKeyIndex = (this.queryMatchCase) ? encodeURIComponent(aRecord[0]).indexOf(sQuery) : encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
                            if ((!bMatchContains && (sKeyIndex === 0)) || (bMatchContains && (sKeyIndex > -1))) {
                                aResults.unshift(aRecord);
                            }
                        }
                        resultObj = {};
                        resultObj.query = sQuery;
                        resultObj.results = aResults;
                        this._addCacheElem(resultObj);
                        break;
                    }
                }
                if (bMatchFound) {
                    break;
                }
            }
        }
        if (bMatchFound) {
            this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
            oCallbackFn(sOrigQuery, aResults, oParent);
        }
    }
    return aResults;
};
YAHOO.widget.DS_XHR = function (sScriptURI, aSchema, oConfigs) {
    if (typeof oConfigs == "object") {
        for (var sConfig in oConfigs) {
            this[sConfig] = oConfigs[sConfig];
        }
    }
    if (!aSchema || (aSchema.constructor != Array)) {
        return;
    }
    else {
        this.schema = aSchema;
    }
    this.scriptURI = sScriptURI;
    this._init();
};
YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
YAHOO.widget.DS_XHR.prototype.TYPE_JSON = 0;
YAHOO.widget.DS_XHR.prototype.TYPE_XML = 1;
YAHOO.widget.DS_XHR.prototype.TYPE_FLAT = 2;
YAHOO.widget.DS_XHR.prototype.ERROR_DATAXHR = "XHR response failed";
YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
YAHOO.widget.DS_XHR.prototype.scriptURI = null;
YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.prototype.TYPE_JSON;
YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n<!--";
YAHOO.widget.DS_XHR.prototype.doQuery = function (oCallbackFn, sQuery, oParent) {
    var isXML = (this.responseType == this.TYPE_XML);
    var sUri = this.scriptURI + "?" + this.scriptQueryParam + "=" + sQuery;
    if (this.scriptQueryAppend.length > 0) {
        sUri += "&" + this.scriptQueryAppend;
    }
    var oResponse = null;
    var oSelf = this;
    var responseSuccess = function (oResp) {
        if (!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
            return;
        }
        for (var foo in oResp) {}
        if (!isXML) {
            oResp = oResp.responseText;
        }
        else {
            oResp = oResp.responseXML;
        }
        if (oResp == '') {
            var exdate = new Date()
            exdate.setDate(exdate.getDate() + 1)
            document.cookie = "ntfk=" + escape(sQuery) + ";expires=" + exdate.toGMTString();
        }
        else {
            document.cookie = "ntfk=;"
        }
        if (oResp === null) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
            return;
        }
        var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
        var resultObj = {};
        resultObj.query = decodeURIComponent(sQuery);
        resultObj.results = aResults;
        if (aResults === null) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAPARSE);
            return;
        }
        else {
            oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
            oSelf._addCacheElem(resultObj);
            oCallbackFn(sQuery, aResults, oParent);
        }
    };
    var responseFailure = function (oResp) {
        oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAXHR);
        return;
    };
    var oCallback = {
        success: responseSuccess,
        failure: responseFailure
    };
    if (!isNaN(this.connTimeout) && this.connTimeout > 0) {
        oCallback.timeout = this.connTimeout;
    }
    if (this._oConn) {
        YAHOO.util.Connect.abort(this._oConn);
    }
    oSelf._oConn = YAHOO.util.Connect.asyncRequest("GET", sUri, oCallback, null);
};
YAHOO.widget.DS_XHR.prototype.parseResponse = function (sQuery, oResponse, oParent) {
    var aSchema = this.schema;
    var aResults = [];
    var bError = false;
    var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ? oResponse.indexOf(this.responseStripAfter) : -1;
    if (nEnd != -1) {
        oResponse = oResponse.substring(0, nEnd);
    }
    switch (this.responseType) {
    case this.TYPE_JSON:
        var jsonList;
        if (window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml') == -1)) {
            var jsonObjParsed = JSON.parse(oResponse);
            if (!jsonObjParsed) {
                bError = true;
                break;
            }
            else {
                jsonList = eval("jsonObjParsed." + aSchema[0]);
            }
        }
        else {
            try {
                while (oResponse.substring(0, 1) == " ") {
                    oResponse = oResponse.substring(1, oResponse.length);
                }
                if (oResponse.indexOf("{") < 0) {
                    bError = true;
                    break;
                }
                if (oResponse.indexOf("{}") === 0) {
                    break;
                }
                var jsonObjRaw = eval("(" + oResponse + ")");
                if (!jsonObjRaw) {
                    bError = true;
                    break;
                }
                jsonList = eval("(jsonObjRaw." + aSchema[0] + ")");
            }
            catch (e) {
                bError = true;
                break;
            }
        }
        if (!jsonList) {
            bError = true;
            break;
        }
        if (jsonList.constructor != Array) {
            jsonList = [jsonList];
        }
        for (var i = jsonList.length - 1; i >= 0; i--) {
            var aResultItem = [];
            var jsonResult = jsonList[i];
            for (var j = aSchema.length - 1; j >= 1; j--) {
                var dataFieldValue = jsonResult[aSchema[j]];
                if (!dataFieldValue) {
                    dataFieldValue = "";
                }
                aResultItem.unshift(dataFieldValue);
            }
            aResults.unshift(aResultItem);
        }
        break;
    case this.TYPE_XML:
        var xmlList = oResponse.getElementsByTagName(aSchema[0]);
        if (!xmlList) {
            bError = true;
            break;
        }
        for (var k = xmlList.length - 1; k >= 0; k--) {
            var result = xmlList.item(k);
            var aFieldSet = [];
            for (var m = aSchema.length - 1; m >= 1; m--) {
                var sValue = null;
                var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
                if (xmlAttr) {
                    sValue = xmlAttr.value;
                }
                else {
                    var xmlNode = result.getElementsByTagName(aSchema[m]);
                    if (xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
                        sValue = xmlNode.item(0).firstChild.nodeValue;
                    }
                    else {
                        sValue = "";
                    }
                }
                aFieldSet.unshift(sValue);
            }
            aResults.unshift(aFieldSet);
        }
        break;
    case this.TYPE_FLAT:
        if (oResponse.length > 0) {
            var newLength = oResponse.length - aSchema[0].length;
            if (oResponse.substr(newLength) == aSchema[0]) {
                oResponse = oResponse.substr(0, newLength);
            }
            var aRecords = oResponse.split(aSchema[0]);
            for (var n = aRecords.length - 1; n >= 0; n--) {
                aResults[n] = aRecords[n].split(aSchema[1]);
            }
        }
        break;
    default:
        break;
    }
    sQuery = null;
    oResponse = null;
    oParent = null;
    if (bError) {
        return null;
    }
    else {
        return aResults;
    }
};
YAHOO.widget.DS_XHR.prototype._oConn = null;
YAHOO.widget.DS_JSFunction = function (oFunction, oConfigs) {
    if (typeof oConfigs == "object") {
        for (var sConfig in oConfigs) {
            this[sConfig] = oConfigs[sConfig];
        }
    }
    if (!oFunction || (oFunction.constructor != Function)) {
        return;
    }
    else {
        this.dataFunction = oFunction;
        this._init();
    }
};
YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
YAHOO.widget.DS_JSFunction.prototype.doQuery = function (oCallbackFn, sQuery, oParent) {
    var oFunction = this.dataFunction;
    var aResults = [];
    aResults = oFunction(sQuery);
    if (aResults === null) {
        this.dataErrorEvent.fire(this, oParent, sQuery, this.ERROR_DATANULL);
        return;
    }
    var resultObj = {};
    resultObj.query = decodeURIComponent(sQuery);
    resultObj.results = aResults;
    this._addCacheElem(resultObj);
    this.getResultsEvent.fire(this, oParent, sQuery, aResults);
    oCallbackFn(sQuery, aResults, oParent);
    return;
};
YAHOO.widget.DS_JSArray = function (aData, oConfigs) {
    if (typeof oConfigs == "object") {
        for (var sConfig in oConfigs) {
            this[sConfig] = oConfigs[sConfig];
        }
    }
    if (!aData || (aData.constructor != Array)) {
        return;
    }
    else {
        this.data = aData;
        this._init();
    }
};
YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
YAHOO.widget.DS_JSArray.prototype.data = null;
YAHOO.widget.DS_JSArray.prototype.doQuery = function (oCallbackFn, sQuery, oParent) {
    var aData = this.data;
    var aResults = [];
    var bMatchFound = false;
    var bMatchContains = this.queryMatchContains;
    if (!this.queryMatchCase) {
        sQuery = sQuery.toLowerCase();
    }
    for (var i = aData.length - 1; i >= 0; i--) {
        var aDataset = [];
        if (aData[i]) {
            if (aData[i].constructor == String) {
                aDataset[0] = aData[i];
            }
            else if (aData[i].constructor == Array) {
                aDataset = aData[i];
            }
        }
        if (aDataset[0] && (aDataset[0].constructor == String)) {
            var sKeyIndex = (this.queryMatchCase) ? encodeURIComponent(aDataset[0]).indexOf(sQuery) : encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
            if ((!bMatchContains && (sKeyIndex === 0)) || (bMatchContains && (sKeyIndex > -1))) {
                aResults.unshift(aDataset);
            }
        }
    }
    this.getResultsEvent.fire(this, oParent, sQuery, aResults);
    oCallbackFn(sQuery, aResults, oParent);
}; /*sugk*/
YAHOO.example.ACFlatData = function () {
    var oACDS;
    var oAutoComp0, oAutoComp1, oAutoComp2;
    return {
        init: function () {
            oACDS = new YAHOO.widget.DS_XHR("autoc", ["\n", "\t"]);
            oACDS.responseType = YAHOO.widget.DS_XHR.prototype.TYPE_FLAT;
            oACDS.maxCacheEntries = 60;
            oACDS.queryMatchSubset = true;
            var myInput = document.getElementById('q');
            var myContainer = document.getElementById('ysearchcontainer0');
            oAutoComp0 = new YAHOO.widget.AutoComplete(myInput, myContainer, oACDS);
            oAutoComp0.delimChar = "";
            oAutoComp0.queryDelay = 0;
            oAutoComp0.formatResult = function (oResultItem, sQuery) {
                var sKey = oResultItem[0];
                var nQuantity = oResultItem[1];
                var sKeyQuery = sKey.substr(0, sQuery.length);
                var sKeyRemainder = sKey.substr(sQuery.length);
                var aMarkup = ["<div id='ysearchresult'  style='height:20px;text-align: left;'><div class='searchdiv'>", nQuantity, "</div>", sKeyQuery, "", sKeyRemainder, "</div>"];
                return (aMarkup.join(""));
            };
        },
        validateForm: function () {
            return false;
        }
    };
}();
YAHOO.util.Event.addListener(this, 'load', YAHOO.example.ACFlatData.init); /*fp*/
var Position = (function () {
    function resolveObject(s) {
        if (document.getElementById && document.getElementById(s) != null) {
            return document.getElementById(s);
        } else if (document.all && document.all[s] != null) {
            return document.all[s];
        } else if (document.anchors && document.anchors.length && document.anchors.length > 0 && document.anchors[0].x) {
            for (var i = 0; i < document.anchors.length; i++) {
                if (document.anchors[i].name == s) {
                    return document.anchors[i]
                }
            }
        }
    }
    var pos = {};
    pos.$VERSION = 1.0;
    pos.set = function (o, left, top) {
        if (typeof(o) == "string") {
            o = resolveObject(o);
        }
        if (o == null || !o.style) {
            return false;
        }
        if (typeof(left) == "object") {
            var pos = left;
            left = pos.left;
            top = pos.top;
        }
        o.style.left = left + "px";
        o.style.top = top + "px";
        return true;
    };
    pos.get = function (o) {
        var fixBrowserQuirks = true;
        if (typeof(o) == "string") {
            o = resolveObject(o);
        }
        if (o == null) {
            return null;
        }
        var left = 0;
        var top = 0;
        var width = 0;
        var height = 0;
        var parentNode = null;
        var offsetParent = null;
        offsetParent = o.offsetParent;
        var originalObject = o;
        var el = o;
        while (el.parentNode != null) {
            el = el.parentNode;
            if (el.offsetParent == null) {} else {
                var considerScroll = true;
                if (fixBrowserQuirks && window.opera) {
                    if (el == originalObject.parentNode || el.nodeName == "TR") {
                        considerScroll = false;
                    }
                }
                if (considerScroll) {
                    if (el.scrollTop && el.scrollTop > 0) {
                        top -= el.scrollTop;
                    }
                    if (el.scrollLeft && el.scrollLeft > 0) {
                        left -= el.scrollLeft;
                    }
                }
            }
            if (el == offsetParent) {
                left += o.offsetLeft;
                if (el.clientLeft && el.nodeName != "TABLE") {
                    left += el.clientLeft;
                }
                top += o.offsetTop;
                if (el.clientTop && el.nodeName != "TABLE") {
                    top += el.clientTop;
                }
                o = el;
                if (o.offsetParent == null) {
                    if (o.offsetLeft) {
                        left += o.offsetLeft;
                    }
                    if (o.offsetTop) {
                        top += o.offsetTop;
                    }
                }
                offsetParent = o.offsetParent;
            }
        }
        if (originalObject.offsetWidth) {
            width = originalObject.offsetWidth;
        }
        if (originalObject.offsetHeight) {
            height = originalObject.offsetHeight;
        }
        return {
            'left': left,
            'top': top,
            'width': width,
            'height': height
        };
    };
    pos.getCenter = function (o) {
        var c = this.get(o);
        if (c == null) {
            return null;
        }
        c.left = c.left + (c.width / 2);
        c.top = c.top + (c.height / 2);
        return c;
    };
    return pos;
})();

function _debug() {
    if (window['console']) {
        if (window['console'].debug) {
            var str = '';
            for (var i = 0; i < arguments.length; i++) {
                str += arguments[i].toString() + ',';
            }
            console.debug(str);
        }
    }
}

function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    }
    else {
        elm['on' + evType] = fn;
    }
}

