	var engines = new Array();

var q = "";

/* CPM start */
/* var searchComplete = 0; */
/* CPM end */


var MooTools = {
    version: "1.11"
};

function reloadBottom()
{
/*document.getElementById("bottom").innerHTML = "<p>Watch free tv online</p>";*/

/*document.getElementById("bottom").innerHTML = new Ajax("/bottom.php", { method: 'get'});*/

 
 new Ajax("/bottom.php", {

                        method: 'get',

                        onSuccess: function (transport) {
							
						var response = transport.responseText || "no response text";
						
						document.getElementById("bottom").innerHTML = response;

                        }

                    }).request();
 
/*new Ajax.Request("/top.php", 
		{ 
		method: 'post', 
		postBody: 'name=john',
		onComplete: showResponse 
		});*/

/*new Ajax("/top.php", {
		method: 'post', 
		postBody: 'name=john',
		onComplete: showResponse 

                        }

                    }).request();*/
			

 
 /*new Ajax.Updater('bottom', '/bottom.php', { method: 'get' });*/
}

function showResponse(req){
	
				$('bottom').innerHTML = req.responseText;
			}

function $defined(B) {
    return (B != undefined)
}
function $type(D) {
    if (!$defined(D)) {
        return false
    }
    if (D.htmlElement) {
        return "element"
    }
    var C = typeof D;
    if (C == "object" && D.nodeName) {
        switch (D.nodeType) {
        case 1:
            return "element";
        case 3:
            return (/\S/).test(D.nodeValue) ? "textnode" : "whitespace"
        }
    }
    if (C == "object" || C == "function") {
        switch (D.constructor) {
        case Array:
            return "array";
        case RegExp:
            return "regexp";
        case Class:
            return "class"
        }
        if (typeof D.length == "number") {
            if (D.item) {
                return "collection"
            }
            if (D.callee) {
                return "arguments"
            }
        }
    }
    return C
}
function $merge() {
    var I = {};
    for (var J = 0; J < arguments.length; J++) {
        for (var G in arguments[J]) {
            var F = arguments[J][G];
            var H = I[G];
            if (H && $type(F) == "object" && $type(H) == "object") {
                I[G] = $merge(H, F)
            } else {
                I[G] = F
            }
        }
    }
    return I
}
var $extend = function () {
    var C = arguments;
    if (!C[1]) {
        C = [this, C[0]]
    }
    for (var D in C[1]) {
        C[0][D] = C[1][D]
    }
    return C[0]
};
var $native = function () {
    for (var D = 0, C = arguments.length; D < C; D++) {
        arguments[D].extend = function (B) {
            for (var A in B) {
                if (!this.prototype[A]) {
                    this.prototype[A] = B[A]
                }
                if (!this[A]) {
                    this[A] = $native.generic(A)
                }
            }
        }
    }
};
$native.generic = function (B) {
    return function (A) {
        return this.prototype[B].apply(A, Array.prototype.slice.call(arguments, 1))
    }
};
$native(Function, Array, String, Number);
function $chk(B) {
    return !! (B || B === 0)
}
function $pick(D, C) {
    return $defined(D) ? D : C
}
function $random(D, C) {
    return Math.floor(Math.random() * (C - D + 1) + D)
}
function $time() {
    return new Date().getTime()
}
function $clear(B) {
    clearTimeout(B);
    clearInterval(B);
    return null
}
var Abstract = function (B) {
    B = B || {};
    B.extend = $extend;
    return B
};
var Window = new Abstract(window);
var Document = new Abstract(document);
document.head = document.getElementsByTagName("head")[0];
window.xpath = !!(document.evaluate);
if (window.ActiveXObject) {
    window.ie = window[window.XMLHttpRequest ? "ie7" : "ie6"] = true
} else {
    if (document.childNodes && !document.all && !navigator.taintEnabled) {
        window.webkit = window[window.xpath ? "webkit420" : "webkit419"] = true
    } else {
        if (document.getBoxObjectFor != null) {
            window.gecko = true
        }
    }
}
window.khtml = window.webkit;
Object.extend = $extend;
if (typeof HTMLElement == "undefined") {
    var HTMLElement = function () {};
    if (window.webkit) {
        document.createElement("iframe")
    }
    HTMLElement.prototype = (window.webkit) ? window["[[DOMElement.prototype]]"] : {}
}
HTMLElement.prototype.htmlElement = function () {};
if (window.ie6) {
    try {
        document.execCommand("BackgroundImageCache", false, true)
    } catch(e) {}
}
var Class = function (D) {
    var C = function () {
        return (arguments[0] !== null && this.initialize && $type(this.initialize) == "function") ? this.initialize.apply(this, arguments) : this
    };
    $extend(C, this);
    C.prototype = D;
    C.constructor = Class;
    return C
};
Class.empty = function () {};
Class.prototype = {
    extend: function (H) {
        var G = new this(null);
        for (var F in H) {
            var E = G[F];
            G[F] = Class.Merge(E, H[F])
        }
        return new Class(G)
    },
    implement: function () {
        for (var D = 0, C = arguments.length; D < C; D++) {
            $extend(this.prototype, arguments[D])
        }
    }
};
Class.Merge = function (G, F) {
    if (G && G != F) {
        var H = $type(F);
        if (H != $type(G)) {
            return F
        }
        switch (H) {
        case "function":
            var E = function () {
                this.parent = arguments.callee.parent;
                return F.apply(this, arguments)
            };
            E.parent = G;
            return E;
        case "object":
            return $merge(G, F)
        }
    }
    return F
};
var Chain = new Class({
    chain: function (B) {
        this.chains = this.chains || [];
        this.chains.push(B);
        return this
    },
    callChain: function () {
        if (this.chains && this.chains.length) {
            this.chains.shift().delay(10, this)
        }
    },
    clearChain: function () {
        this.chains = []
    }
});
var Events = new Class({
    addEvent: function (D, C) {
        if (C != Class.empty) {
            this.$events = this.$events || {};
            this.$events[D] = this.$events[D] || [];
            this.$events[D].include(C)
        }
        return this
    },
    fireEvent: function (E, F, D) {
        if (this.$events && this.$events[E]) {
            this.$events[E].each(function (A) {
                A.create({
                    bind: this,
                    delay: D,
                    "arguments": F
                })()
            },
            this)
        }
        return this
    },
    removeEvent: function (D, C) {
        if (this.$events && this.$events[D]) {
            this.$events[D].remove(C)
        }
        return this
    }
});
var Options = new Class({
    setOptions: function () {
        this.options = $merge.apply(null, [this.options].extend(arguments));
        if (this.addEvent) {
            for (var B in this.options) {
                if ($type(this.options[B] == "function") && (/^on[A-Z]/).test(B)) {
                    this.addEvent(B, this.options[B])
                }
            }
        }
        return this
    }
});
Array.extend({
    forEach: function (G, F) {
        for (var H = 0, E = this.length; H < E; H++) {
            G.call(F, this[H], H, this)
        }
    },
    filter: function (H, G) {
        var I = [];
        for (var J = 0, F = this.length; J < F; J++) {
            if (H.call(G, this[J], J, this)) {
                I.push(this[J])
            }
        }
        return I
    },
    map: function (H, G) {
        var I = [];
        for (var J = 0, F = this.length; J < F; J++) {
            I[J] = H.call(G, this[J], J, this)
        }
        return I
    },
    every: function (G, F) {
        for (var H = 0, E = this.length; H < E; H++) {
            if (!G.call(F, this[H], H, this)) {
                return false
            }
        }
        return true
    },
    some: function (G, F) {
        for (var H = 0, E = this.length; H < E; H++) {
            if (G.call(F, this[H], H, this)) {
                return true
            }
        }
        return false
    },
    indexOf: function (G, F) {
        var E = this.length;
        for (var H = (F < 0) ? Math.max(0, E + F) : F || 0; H < E; H++) {
            if (this[H] === G) {
                return H
            }
        }
        return -1
    },
    copy: function (F, G) {
        F = F || 0;
        if (F < 0) {
            F = this.length + F
        }
        G = G || (this.length - F);
        var E = [];
        for (var H = 0; H < G; H++) {
            E[H] = this[F++]
        }
        return E
    },
    remove: function (E) {
        var F = 0;
        var D = this.length;
        while (F < D) {
            if (this[F] === E) {
                this.splice(F, 1);
                D--
            } else {
                F++
            }
        }
        return this
    },
    contains: function (C, D) {
        return this.indexOf(C, D) != -1
    },
    associate: function (G) {
        var F = {},
        H = Math.min(this.length, G.length);
        for (var E = 0; E < H; E++) {
            F[G[E]] = this[E]
        }
        return F
    },
    extend: function (E) {
        for (var F = 0, D = E.length; F < D; F++) {
            this.push(E[F])
        }
        return this
    },
    merge: function (E) {
        for (var F = 0, D = E.length; F < D; F++) {
            this.include(E[F])
        }
        return this
    },
    include: function (B) {
        if (!this.contains(B)) {
            this.push(B)
        }
        return this
    },
    getRandom: function () {
        return this[$random(0, this.length - 1)] || null
    },
    getLast: function () {
        return this[this.length - 1] || null
    }
});
Array.prototype.each = Array.prototype.forEach;
Array.each = Array.forEach;
function $A(B) {
    return Array.copy(B)
}
function $each(G, H, F) {
    if (G && typeof G.length == "number" && $type(G) != "object") {
        Array.forEach(G, H, F)
    } else {
        for (var E in G) {
            H.call(F || G, G[E], E)
        }
    }
}
Array.prototype.test = Array.prototype.contains;
String.extend({
    test: function (C, D) {
        return (($type(C) == "string") ? new RegExp(C, D) : C).test(this)
    },
    toInt: function () {
        return parseInt(this, 10)
    },
    toFloat: function () {
        return parseFloat(this)
    },
    camelCase: function () {
        return this.replace(/-\D/g, function (B) {
            return B.charAt(1).toUpperCase()
        })
    },
    hyphenate: function () {
        return this.replace(/\w[A-Z]/g, function (B) {
            return (B.charAt(0) + "-" + B.charAt(1).toLowerCase())
        })
    },
    capitalize: function () {
        return this.replace(/\b[a-z]/g, function (B) {
            return B.toUpperCase()
        })
    },
    trim: function () {
        return this.replace(/^\s+|\s+$/g, "")
    },
    clean: function () {
        return this.replace(/\s{2,}/g, " ").trim()
    },
    rgbToHex: function (D) {
        var C = this.match(/\d{1,3}/g);
        return (C) ? C.rgbToHex(D) : false
    },
    hexToRgb: function (D) {
        var C = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
        return (C) ? C.slice(1).hexToRgb(D) : false
    },
    contains: function (C, D) {
        return (D) ? (D + this + D).indexOf(D + C + D) > -1 : this.indexOf(C) > -1
    },
    escapeRegExp: function () {
        return this.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
    }
});
Array.extend({
    rgbToHex: function (F) {
        if (this.length < 3) {
            return false
        }
        if (this.length == 4 && this[3] == 0 && !F) {
            return "transparent"
        }
        var H = [];
        for (var E = 0; E < 3; E++) {
            var G = (this[E] - 0).toString(16);
            H.push((G.length == 1) ? "0" + G : G)
        }
        return F ? H : "#" + H.join("")
    },
    hexToRgb: function (E) {
        if (this.length != 3) {
            return false
        }
        var D = [];
        for (var F = 0; F < 3; F++) {
            D.push(parseInt((this[F].length == 1) ? this[F] + this[F] : this[F], 16))
        }
        return E ? D : "rgb(" + D.join(",") + ")"
    }
});
Function.extend({
    create: function (C) {
        var D = this;
        C = $merge({
            bind: D,
            event: false,
            "arguments": null,
            delay: false,
            periodical: false,
            attempt: false
        },
        C);
        if ($chk(C.arguments) && $type(C.arguments) != "array") {
            C.arguments = [C.arguments]
        }
        return function (B) {
            var H;
            if (C.event) {
                B = B || window.event;
                H = [(C.event === true) ? B : new C.event(B)];
                if (C.arguments) {
                    H.extend(C.arguments)
                }
            } else {
                H = C.arguments || arguments
            }
            var A = function () {
                return D.apply($pick(C.bind, D), H)
            };
            if (C.delay) {
                return setTimeout(A, C.delay)
            }
            if (C.periodical) {
                return setInterval(A, C.periodical)
            }
            if (C.attempt) {
                try {
                    return A()
                } catch(G) {
                    return false
                }
            }
            return A()
        }
    },
    pass: function (C, D) {
        return this.create({
            "arguments": C,
            bind: D
        })
    },
    attempt: function (C, D) {
        return this.create({
            "arguments": C,
            bind: D,
            attempt: true
        })()
    },
    bind: function (D, C) {
        return this.create({
            bind: D,
            "arguments": C
        })
    },
    bindAsEventListener: function (D, C) {
        return this.create({
            bind: D,
            event: true,
            "arguments": C
        })
    },
    delay: function (F, E, D) {
        return this.create({
            delay: F,
            bind: E,
            "arguments": D
        })()
    },
    periodical: function (D, E, F) {
        return this.create({
            periodical: D,
            bind: E,
            "arguments": F
        })()
    }
});
Number.extend({
    toInt: function () {
        return parseInt(this)
    },
    toFloat: function () {
        return parseFloat(this)
    },
    limit: function (D, C) {
        return Math.min(C, Math.max(D, this))
    },
    round: function (B) {
        B = Math.pow(10, B || 0);
        return Math.round(this * B) / B
    },
    times: function (D) {
        for (var C = 0; C < this; C++) {
            D(C)
        }
    }
});
var Element = new Class({
    initialize: function (F, G) {
        if ($type(F) == "string") {
            if (window.ie && G && (G.name || G.type)) {
                var E = (G.name) ? ' name="' + G.name + '"' : "";
                var H = (G.type) ? ' type="' + G.type + '"' : "";
                delete G.name;
                delete G.type;
                F = "<" + F + E + H + ">"
            }
            F = document.createElement(F)
        }
        F = $(F);
        return (!G || !F) ? F : F.set(G)
    }
});
var Elements = new Class({
    initialize: function (B) {
        return (B) ? $extend(B, this) : this
    }
});
Elements.extend = function (C) {
    for (var D in C) {
        this.prototype[D] = C[D];
        this[D] = $native.generic(D)
    }
};
function $(D) {
    if (!D) {
        return null
    }
    if (D.htmlElement) {
        return Garbage.collect(D)
    }
    if ([window, document].contains(D)) {
        return D
    }
    var C = $type(D);
    if (C == "string") {
        D = document.getElementById(D);
        C = (D) ? "element" : false
    }
    if (C != "element") {
        return null
    }
    if (D.htmlElement) {
        return Garbage.collect(D)
    }
    if (["object", "embed"].contains(D.tagName.toLowerCase())) {
        return D
    }
    $extend(D, Element.prototype);
    D.htmlElement = function () {};
    return Garbage.collect(D)
}
document.getElementsBySelector = document.getElementsByTagName;
function $$() {
    var F = [];
    for (var G = 0, H = arguments.length; G < H; G++) {
        var E = arguments[G];
        switch ($type(E)) {
        case "element":
            F.push(E);
        case "boolean":
            break;
        case false:
            break;
        case "string":
            E = document.getElementsBySelector(E, true);
        default:
            F.extend(E)
        }
    }
    return $$.unique(F)
}
$$.unique = function (I) {
    var L = [];
    for (var M = 0, H = I.length; M < H; M++) {
        if (I[M].$included) {
            continue
        }
        var N = $(I[M]);
        if (N && !N.$included) {
            N.$included = true;
            L.push(N)
        }
    }
    for (var J = 0, K = L.length; J < K; J++) {
        L[J].$included = null
    }
    return new Elements(L)
};
Elements.Multi = function (B) {
    return function () {
        var J = arguments;
        var L = [];
        var A = true;
        for (var I = 0, K = this.length, H; I < K; I++) {
            H = this[I][B].apply(this[I], J);
            if ($type(H) != "element") {
                A = false
            }
            L.push(H)
        }
        return (A) ? $$.unique(L) : L
    }
};
Element.extend = function (D) {
    for (var F in D) {
        HTMLElement.prototype[F] = D[F];
        Element.prototype[F] = D[F];
        Element[F] = $native.generic(F);
        var E = (Array.prototype[F]) ? F + "Elements" : F;
        Elements.prototype[E] = Elements.Multi(F)
    }
};
Element.extend({
    set: function (D) {
        for (var E in D) {
            var F = D[E];
            switch (E) {
            case "styles":
                this.setStyles(F);
                break;
            case "events":
                if (this.addEvents) {
                    this.addEvents(F)
                }
                break;
            case "properties":
                this.setProperties(F);
                break;
            default:
                this.setProperty(E, F)
            }
        }
        return this
    },
    inject: function (G, E) {
        G = $(G);
        switch (E) {
        case "before":
            G.parentNode.insertBefore(this, G);
            break;
        case "after":
            var H = G.getNext();
            if (!H) {
                G.parentNode.appendChild(this)
            } else {
                G.parentNode.insertBefore(this, H)
            }
            break;
        case "top":
            var F = G.firstChild;
            if (F) {
                G.insertBefore(this, F);
                break
            }
        default:
            G.appendChild(this)
        }
        return this
    },
    injectBefore: function (B) {
        return this.inject(B, "before")
    },
    injectAfter: function (B) {
        return this.inject(B, "after")
    },
    injectInside: function (B) {
        return this.inject(B, "bottom")
    },
    injectTop: function (B) {
        return this.inject(B, "top")
    },
    adopt: function () {
        var B = [];
        $each(arguments, function (A) {
            B = B.concat(A)
        });
        $$(B).inject(this);
        return this
    },
    remove: function () {
        return this.parentNode.removeChild(this)
    },
    clone: function (E) {
        var F = $(this.cloneNode(E !== false));
        if (!F.$events) {
            return F
        }
        F.$events = {};
        for (var D in this.$events) {
            F.$events[D] = {
                keys: $A(this.$events[D].keys),
                values: $A(this.$events[D].values)
            }
        }
        return F.removeEvents()
    },
    replaceWith: function (B) {
        B = $(B);
        this.parentNode.replaceChild(B, this);
        return B
    },
    appendText: function (B) {
        this.appendChild(document.createTextNode(B));
        return this
    },
    hasClass: function (B) {
        return this.className.contains(B, " ")
    },
    addClass: function (B) {
        if (!this.hasClass(B)) {
            this.className = (this.className + " " + B).clean()
        }
        return this
    },
    removeClass: function (B) {
        this.className = this.className.replace(new RegExp("(^|\\s)" + B + "(?:\\s|$)"), "$1").clean();
        return this
    },
    toggleClass: function (B) {
        return this.hasClass(B) ? this.removeClass(B) : this.addClass(B)
    },
    setStyle: function (D, C) {
        switch (D) {
        case "opacity":
            return this.setOpacity(parseFloat(C));
        case "float":
            D = (window.ie) ? "styleFloat" : "cssFloat"
        }
        D = D.camelCase();
        switch ($type(C)) {
        case "number":
            if (! ["zIndex", "zoom"].contains(D)) {
                C += "px"
            }
            break;
        case "array":
            C = "rgb(" + C.join(",") + ")"
        }
        this.style[D] = C;
        return this
    },
    setStyles: function (B) {
        switch ($type(B)) {
        case "object":
            Element.setMany(this, "setStyle", B);
            break;
        case "string":
            this.style.cssText = B
        }
        return this
    },
    setOpacity: function (B) {
        if (B == 0) {
            if (this.style.visibility != "hidden") {
                this.style.visibility = "hidden"
            }
        } else {
            if (this.style.visibility != "visible") {
                this.style.visibility = "visible"
            }
        }
        if (!this.currentStyle || !this.currentStyle.hasLayout) {
            this.style.zoom = 1
        }
        if (window.ie) {
            this.style.filter = (B == 1) ? "" : "alpha(opacity=" + B * 100 + ")"
        }
        this.style.opacity = this.$tmp.opacity = B;
        return this
    },
    getStyle: function (G) {
        G = G.camelCase();
        var E = this.style[G];
        if (!$chk(E)) {
            if (G == "opacity") {
                return this.$tmp.opacity
            }
            E = [];
            for (var H in Element.Styles) {
                if (G == H) {
                    Element.Styles[H].each(function (A) {
                        var B = this.getStyle(A);
                        E.push(parseInt(B) ? B : "0px")
                    },
                    this);
                    if (G == "border") {
                        var F = E.every(function (A) {
                            return (A == E[0])
                        });
                        return (F) ? E[0] : false
                    }
                    return E.join(" ")
                }
            }
            if (G.contains("border")) {
                if (Element.Styles.border.contains(G)) {
                    return ["Width", "Style", "Color"].map(function (A) {
                        return this.getStyle(G + A)
                    },
                    this).join(" ")
                } else {
                    if (Element.borderShort.contains(G)) {
                        return ["Top", "Right", "Bottom", "Left"].map(function (A) {
                            return this.getStyle("border" + A + G.replace("border", ""))
                        },
                        this).join(" ")
                    }
                }
            }
            if (document.defaultView) {
                E = document.defaultView.getComputedStyle(this, null).getPropertyValue(G.hyphenate())
            } else {
                if (this.currentStyle) {
                    E = this.currentStyle[G]
                }
            }
        }
        if (window.ie) {
            E = Element.fixStyle(G, E, this)
        }
        if (E && G.test(/color/i) && E.contains("rgb")) {
            return E.split("rgb").splice(1, 4).map(function (A) {
                return A.rgbToHex()
            }).join(" ")
        }
        return E
    },
    getStyles: function () {
        return Element.getMany(this, "getStyle", arguments)
    },
    walk: function (D, E) {
        D += "Sibling";
        var F = (E) ? this[E] : this[D];
        while (F && $type(F) != "element") {
            F = F[D]
        }
        return $(F)
    },
    getPrevious: function () {
        return this.walk("previous")
    },
    getNext: function () {
        return this.walk("next")
    },
    getFirst: function () {
        return this.walk("next", "firstChild")
    },
    getLast: function () {
        return this.walk("previous", "lastChild")
    },
    getParent: function () {
        return $(this.parentNode)
    },
    getChildren: function () {
        return $$(this.childNodes)
    },
    hasChild: function (B) {
        return !! $A(this.getElementsByTagName("*")).contains(B)
    },
    getProperty: function (F) {
        var H = Element.Properties[F];
        if (H) {
            return this[H]
        }
        var E = Element.PropertiesIFlag[F] || 0;
        if (!window.ie || E) {
            return this.getAttribute(F, E)
        }
        var G = this.attributes[F];
        return (G) ? G.nodeValue : null
    },
    removeProperty: function (D) {
        var C = Element.Properties[D];
        if (C) {
            this[C] = ""
        } else {
            this.removeAttribute(D)
        }
        return this
    },
    getProperties: function () {
        return Element.getMany(this, "getProperty", arguments)
    },
    setProperty: function (E, F) {
        var D = Element.Properties[E];
        if (D) {
            this[D] = F
        } else {
            this.setAttribute(E, F)
        }
        return this
    },
    setProperties: function (B) {
        return Element.setMany(this, "setProperty", B)
    },
    setHTML: function () {
        this.innerHTML = $A(arguments).join("");
        return this
    },
    setText: function (D) {
        var C = this.getTag();
        if (["style", "script"].contains(C)) {
            if (window.ie) {
                if (C == "style") {
                    this.styleSheet.cssText = D
                } else {
                    if (C == "script") {
                        this.setProperty("text", D)
                    }
                }
                return this
            } else {
                this.removeChild(this.firstChild);
                return this.appendText(D)
            }
        }
        this[$defined(this.innerText) ? "innerText" : "textContent"] = D;
        return this
    },
    getText: function () {
        var B = this.getTag();
        if (["style", "script"].contains(B)) {
            if (window.ie) {
                if (B == "style") {
                    return this.styleSheet.cssText
                } else {
                    if (B == "script") {
                        return this.getProperty("text")
                    }
                }
            } else {
                return this.innerHTML
            }
        }
        return ($pick(this.innerText, this.textContent))
    },
    getTag: function () {
        return this.tagName.toLowerCase()
    },
    empty: function () {
        Garbage.trash(this.getElementsByTagName("*"));
        return this.setHTML("")
    }
});
Element.fixStyle = function (G, F, H) {
    if ($chk(parseInt(F))) {
        return F
    }
    if (["height", "width"].contains(G)) {
        var J = (G == "width") ? ["left", "right"] : ["top", "bottom"];
        var I = 0;
        J.each(function (A) {
            I += H.getStyle("border-" + A + "-width").toInt() + H.getStyle("padding-" + A).toInt()
        });
        return H["offset" + G.capitalize()] - I + "px"
    } else {
        if (G.test(/border(.+)Width|margin|padding/)) {
            return "0px"
        }
    }
    return F
};
Element.Styles = {
    border: [],
    padding: [],
    margin: []
};
["Top", "Right", "Bottom", "Left"].each(function (D) {
    for (var C in Element.Styles) {
        Element.Styles[C].push(C + D)
    }
});
Element.borderShort = ["borderWidth", "borderStyle", "borderColor"];
Element.getMany = function (H, F, G) {
    var E = {};
    $each(G, function (A) {
        E[A] = H[F](A)
    });
    return E
};
Element.setMany = function (H, F, G) {
    for (var E in G) {
        H[F](E, G[E])
    }
    return H
};
Element.Properties = new Abstract({
    "class": "className",
    "for": "htmlFor",
    colspan: "colSpan",
    rowspan: "rowSpan",
    accesskey: "accessKey",
    tabindex: "tabIndex",
    maxlength: "maxLength",
    readonly: "readOnly",
    frameborder: "frameBorder",
    value: "value",
    disabled: "disabled",
    checked: "checked",
    multiple: "multiple",
    selected: "selected"
});
Element.PropertiesIFlag = {
    href: 2,
    src: 2
};
Element.Methods = {
    Listeners: {
        addListener: function (D, C) {
            if (this.addEventListener) {
                this.addEventListener(D, C, false)
            } else {
                this.attachEvent("on" + D, C)
            }
            return this
        },
        removeListener: function (D, C) {
            if (this.removeEventListener) {
                this.removeEventListener(D, C, false)
            } else {
                this.detachEvent("on" + D, C)
            }
            return this
        }
    }
};
window.extend(Element.Methods.Listeners);
document.extend(Element.Methods.Listeners);
Element.extend(Element.Methods.Listeners);
var Garbage = {
    elements: [],
    collect: function (B) {
        if (!B.$tmp) {
            Garbage.elements.push(B);
            B.$tmp = {
                opacity: 1
            }
        }
        return B
    },
    trash: function (J) {
        for (var L = 0, G = J.length, K; L < G; L++) {
            if (! (K = J[L]) || !K.$tmp) {
                continue
            }
            if (K.$events) {
                K.fireEvent("trash").removeEvents()
            }
            for (var I in K.$tmp) {
                K.$tmp[I] = null
            }
            for (var H in Element.prototype) {
                K[H] = null
            }
            Garbage.elements[Garbage.elements.indexOf(K)] = null;
            K.htmlElement = K.$tmp = K = null
        }
        Garbage.elements.remove(null)
    },
    empty: function () {
        Garbage.collect(window);
        Garbage.collect(document);
        Garbage.trash(Garbage.elements)
    }
};
window.addListener("beforeunload", function () {
    window.addListener("unload", Garbage.empty);
    if (window.ie) {
        window.addListener("unload", CollectGarbage)
    }
});
var Event = new Class({
    initialize: function (E) {
        if (E && E.$extended) {
            return E
        }
        this.$extended = true;
        E = E || window.event;
        this.event = E;
        this.type = E.type;
        this.target = E.target || E.srcElement;
        if (this.target.nodeType == 3) {
            this.target = this.target.parentNode
        }
        this.shift = E.shiftKey;
        this.control = E.ctrlKey;
        this.alt = E.altKey;
        this.meta = E.metaKey;
        if (["DOMMouseScroll", "mousewheel"].contains(this.type)) {
            this.wheel = (E.wheelDelta) ? E.wheelDelta / 120 : -(E.detail || 0) / 3
        } else {
            if (this.type.contains("key")) {
                this.code = E.which || E.keyCode;
                for (var F in Event.keys) {
                    if (Event.keys[F] == this.code) {
                        this.key = F;
                        break
                    }
                }
                if (this.type == "keydown") {
                    var D = this.code - 111;
                    if (D > 0 && D < 13) {
                        this.key = "f" + D
                    }
                }
                this.key = this.key || String.fromCharCode(this.code).toLowerCase()
            } else {
                if (this.type.test(/(click|mouse|menu)/)) {
                    this.page = {
                        x: E.pageX || E.clientX + document.documentElement.scrollLeft,
                        y: E.pageY || E.clientY + document.documentElement.scrollTop
                    };
                    this.client = {
                        x: E.pageX ? E.pageX - window.pageXOffset : E.clientX,
                        y: E.pageY ? E.pageY - window.pageYOffset : E.clientY
                    };
                    this.rightClick = (E.which == 3) || (E.button == 2);
                    switch (this.type) {
                    case "mouseover":
                        this.relatedTarget = E.relatedTarget || E.fromElement;
                        break;
                    case "mouseout":
                        this.relatedTarget = E.relatedTarget || E.toElement
                    }
                    this.fixRelatedTarget()
                }
            }
        }
        return this
    },
    stop: function () {
        return this.stopPropagation().preventDefault()
    },
    stopPropagation: function () {
        if (this.event.stopPropagation) {
            this.event.stopPropagation()
        } else {
            this.event.cancelBubble = true
        }
        return this
    },
    preventDefault: function () {
        if (this.event.preventDefault) {
            this.event.preventDefault()
        } else {
            this.event.returnValue = false
        }
        return this
    }
});
Event.fix = {
    relatedTarget: function () {
        if (this.relatedTarget && this.relatedTarget.nodeType == 3) {
            this.relatedTarget = this.relatedTarget.parentNode
        }
    },
    relatedTargetGecko: function () {
        try {
            Event.fix.relatedTarget.call(this)
        } catch(B) {
            this.relatedTarget = this.target
        }
    }
};
Event.prototype.fixRelatedTarget = (window.gecko) ? Event.fix.relatedTargetGecko : Event.fix.relatedTarget;
Event.keys = new Abstract({
    enter: 13,
    up: 38,
    down: 40,
    left: 37,
    right: 39,
    esc: 27,
    space: 32,
    backspace: 8,
    tab: 9,
    "delete": 46
});
Element.Methods.Events = {
    addEvent: function (G, H) {
        this.$events = this.$events || {};
        this.$events[G] = this.$events[G] || {
            keys: [],
            values: []
        };
        if (this.$events[G].keys.contains(H)) {
            return this
        }
        this.$events[G].keys.push(H);
        var E = G;
        var F = Element.Events[G];
        if (F) {
            if (F.add) {
                F.add.call(this, H)
            }
            if (F.map) {
                H = F.map
            }
            if (F.type) {
                E = F.type
            }
        }
        if (!this.addEventListener) {
            H = H.create({
                bind: this,
                event: true
            })
        }
        this.$events[G].values.push(H);
        return (Element.NativeEvents.contains(E)) ? this.addListener(E, H) : this
    },
    removeEvent: function (K, L) {
        if (!this.$events || !this.$events[K]) {
            return this
        }
        var H = this.$events[K].keys.indexOf(L);
        if (H == -1) {
            return this
        }
        var G = this.$events[K].keys.splice(H, 1)[0];
        var I = this.$events[K].values.splice(H, 1)[0];
        var J = Element.Events[K];
        if (J) {
            if (J.remove) {
                J.remove.call(this, L)
            }
            if (J.type) {
                K = J.type
            }
        }
        return (Element.NativeEvents.contains(K)) ? this.removeListener(K, I) : this
    },
    addEvents: function (B) {
        return Element.setMany(this, "addEvent", B)
    },
    removeEvents: function (C) {
        if (!this.$events) {
            return this
        }
        if (!C) {
            for (var D in this.$events) {
                this.removeEvents(D)
            }
            this.$events = null
        } else {
            if (this.$events[C]) {
                this.$events[C].keys.each(function (A) {
                    this.removeEvent(C, A)
                },
                this);
                this.$events[C] = null
            }
        }
        return this
    },
    fireEvent: function (E, F, D) {
        if (this.$events && this.$events[E]) {
            this.$events[E].keys.each(function (A) {
                A.create({
                    bind: this,
                    delay: D,
                    "arguments": F
                })()
            },
            this)
        }
        return this
    },
    cloneEvents: function (E, D) {
        if (!E.$events) {
            return this
        }
        if (!D) {
            for (var F in E.$events) {
                this.cloneEvents(E, F)
            }
        } else {
            if (E.$events[D]) {
                E.$events[D].keys.each(function (A) {
                    this.addEvent(D, A)
                },
                this)
            }
        }
        return this
    }
};
window.extend(Element.Methods.Events);
document.extend(Element.Methods.Events);
Element.extend(Element.Methods.Events);
Element.Events = new Abstract({
    mouseenter: {
        type: "mouseover",
        map: function (B) {
            B = new Event(B);
            if (B.relatedTarget != this && !this.hasChild(B.relatedTarget)) {
                this.fireEvent("mouseenter", B)
            }
        }
    },
    mouseleave: {
        type: "mouseout",
        map: function (B) {
            B = new Event(B);
            if (B.relatedTarget != this && !this.hasChild(B.relatedTarget)) {
                this.fireEvent("mouseleave", B)
            }
        }
    },
    mousewheel: {
        type: (window.gecko) ? "DOMMouseScroll" : "mousewheel"
    }
});
Element.NativeEvents = ["click", "dblclick", "mouseup", "mousedown", "mousewheel", "DOMMouseScroll", "mouseover", "mouseout", "mousemove", "keydown", "keypress", "keyup", "load", "unload", "beforeunload", "resize", "move", "focus", "blur", "change", "submit", "reset", "select", "error", "abort", "contextmenu", "scroll"];
Function.extend({
    bindWithEvent: function (D, C) {
        return this.create({
            bind: D,
            "arguments": C,
            event: Event
        })
    }
});
Elements.extend({
    filterByTag: function (B) {
        return new Elements(this.filter(function (A) {
            return (Element.getTag(A) == B)
        }))
    },
    filterByClass: function (D, E) {
        var F = this.filter(function (A) {
            return (A.className && A.className.contains(D, " "))
        });
        return (E) ? F : new Elements(F)
    },
    filterById: function (E, F) {
        var D = this.filter(function (A) {
            return (A.id == E)
        });
        return (F) ? D : new Elements(D)
    },
    filterByAttribute: function (J, F, H, G) {
        var I = this.filter(function (B) {
            var A = Element.getProperty(B, J);
            if (!A) {
                return false
            }
            if (!F) {
                return true
            }
            switch (F) {
            case "=":
                return (A == H);
            case "*=":
                return (A.contains(H));
            case "^=":
                return (A.substr(0, H.length) == H);
            case "$=":
                return (A.substr(A.length - H.length) == H);
            case "!=":
                return (A != H);
            case "~=":
                return A.contains(H, " ")
            }
            return false
        });
        return (G) ? I : new Elements(I)
    }
});
function $E(C, D) {
    return ($(D) || document).getElement(C)
}
function $ES(C, D) {
    return ($(D) || document).getElementsBySelector(C)
}
$$.shared = {
    regexp: /^(\w*|\*)(?:#([\w-]+)|\.([\w-]+))?(?:\[(\w+)(?:([!*^$]?=)["']?([^"'\]]*)["']?)?])?$/,
    xpath: {
        getParam: function (J, H, G, I) {
            var F = [H.namespaceURI ? "xhtml:" : "", G[1]];
            if (G[2]) {
                F.push('[@id="', G[2], '"]')
            }
            if (G[3]) {
                F.push('[contains(concat(" ", @class, " "), " ', G[3], ' ")]')
            }
            if (G[4]) {
                if (G[5] && G[6]) {
                    switch (G[5]) {
                    case "*=":
                        F.push("[contains(@", G[4], ', "', G[6], '")]');
                        break;
                    case "^=":
                        F.push("[starts-with(@", G[4], ', "', G[6], '")]');
                        break;
                    case "$=":
                        F.push("[substring(@", G[4], ", string-length(@", G[4], ") - ", G[6].length, ' + 1) = "', G[6], '"]');
                        break;
                    case "=":
                        F.push("[@", G[4], '="', G[6], '"]');
                        break;
                    case "!=":
                        F.push("[@", G[4], '!="', G[6], '"]')
                    }
                } else {
                    F.push("[@", G[4], "]")
                }
            }
            J.push(F.join(""));
            return J
        },
        getItems: function (N, K, I) {
            var J = [];
            var H = document.evaluate(".//" + N.join("//"), K, $$.shared.resolver, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
            for (var L = 0, M = H.snapshotLength; L < M; L++) {
                J.push(H.snapshotItem(L))
            }
            return (I) ? J : new Elements(J.map($))
        }
    },
    normal: {
        getParam: function (F, I, G, J) {
            if (J == 0) {
                if (G[2]) {
                    var H = I.getElementById(G[2]);
                    if (!H || ((G[1] != "*") && (Element.getTag(H) != G[1]))) {
                        return false
                    }
                    F = [H]
                } else {
                    F = $A(I.getElementsByTagName(G[1]))
                }
            } else {
                F = $$.shared.getElementsByTagName(F, G[1]);
                if (G[2]) {
                    F = Elements.filterById(F, G[2], true)
                }
            }
            if (G[3]) {
                F = Elements.filterByClass(F, G[3], true)
            }
            if (G[4]) {
                F = Elements.filterByAttribute(F, G[4], G[5], G[6], true)
            }
            return F
        },
        getItems: function (D, F, E) {
            return (E) ? D : $$.unique(D)
        }
    },
    resolver: function (B) {
        return (B == "xhtml") ? "http://www.w3.org/1999/xhtml" : false
    },
    getElementsByTagName: function (H, I) {
        var G = [];
        for (var J = 0, F = H.length; J < F; J++) {
            G.extend(H[J].getElementsByTagName(I))
        }
        return G
    }
};
$$.shared.method = (window.xpath) ? "xpath" : "normal";
Element.Methods.Dom = {
    getElements: function (I, J) {
        var O = [];
        I = I.trim().split(" ");
        for (var M = 0, N = I.length; M < N; M++) {
            var L = I[M];
            var K = L.match($$.shared.regexp);
            if (!K) {
                break
            }
            K[1] = K[1] || "*";
            var P = $$.shared[$$.shared.method].getParam(O, this, K, M);
            if (!P) {
                break
            }
            O = P
        }
        return $$.shared[$$.shared.method].getItems(O, this, J)
    },
    getElement: function (B) {
        return $(this.getElements(B, true)[0] || false)
    },
    getElementsBySelector: function (F, G) {
        var H = [];
        F = F.split(",");
        for (var I = 0, J = F.length; I < J; I++) {
            H = H.concat(this.getElements(F[I], true))
        }
        return (G) ? H : $$.unique(H)
    }
};
Element.extend({
    getElementById: function (E) {
        var F = document.getElementById(E);
        if (!F) {
            return false
        }
        for (var D = F.parentNode; D != this; D = D.parentNode) {
            if (!D) {
                return false
            }
        }
        return F
    },
    getElementsByClassName: function (B) {
        return this.getElements("." + B)
    }
});
document.extend(Element.Methods.Dom);
Element.extend(Element.Methods.Dom);
Element.extend({
    getValue: function () {
        switch (this.getTag()) {
        case "select":
            var B = [];
            $each(this.options, function (A) {
                if (A.selected) {
                    B.push($pick(A.value, A.text))
                }
            });
            return (this.multiple) ? B : B[0];
        case "input":
            if (! (this.checked && ["checkbox", "radio"].contains(this.type)) && !["hidden", "text", "password"].contains(this.type)) {
                break
            }
        case "textarea":
            return this.value
        }
        return false
    },
    getFormElements: function () {
        return $$(this.getElementsByTagName("input"), this.getElementsByTagName("select"), this.getElementsByTagName("textarea"))
    },
    toQueryString: function () {
        var B = [];
        this.getFormElements().each(function (F) {
            var G = F.name;
            var A = F.getValue();
            if (A === false || !G || F.disabled) {
                return
            }
            var H = function (C) {
                B.push(G + "=" + encodeURIComponent(C))
            };
            if ($type(A) == "array") {
                A.each(H)
            } else {
                H(A)
            }
        });
        return B.join("&")
    }
});
Element.extend({
    scrollTo: function (C, D) {
        this.scrollLeft = C;
        this.scrollTop = D
    },
    getSize: function () {
        return {
            scroll: {
                x: this.scrollLeft,
                y: this.scrollTop
            },
            size: {
                x: this.offsetWidth,
                y: this.offsetHeight
            },
            scrollSize: {
                x: this.scrollWidth,
                y: this.scrollHeight
            }
        }
    },
    getPosition: function (E) {
        E = E || [];
        var H = this,
        F = 0,
        G = 0;
        do {
            F += H.offsetLeft || 0;
            G += H.offsetTop || 0;
            H = H.offsetParent
        } while (H);
        E.each(function (A) {
            F -= A.scrollLeft || 0;
            G -= A.scrollTop || 0
        });
        return {
            x: F,
            y: G
        }
    },
    getTop: function (B) {
        return this.getPosition(B).y
    },
    getLeft: function (B) {
        return this.getPosition(B).x
    },
    getCoordinates: function (F) {
        var D = this.getPosition(F);
        var E = {
            width: this.offsetWidth,
            height: this.offsetHeight,
            left: D.x,
            top: D.y
        };
        E.right = E.left + E.width;
        E.bottom = E.top + E.height;
        return E
    }
});
Element.Events.domready = {
    add: function (F) {
        if (window.loaded) {
            F.call(this);
            return
        }
        var D = function () {
            if (window.loaded) {
                return
            }
            window.loaded = true;
            window.timer = $clear(window.timer);
            this.fireEvent("domready")
        }.bind(this);
        if (document.readyState && window.webkit) {
            window.timer = function () {
                if (["loaded", "complete"].contains(document.readyState)) {
                    D()
                }
            }.periodical(50)
        } else {
            if (document.readyState && window.ie) {
                if (!$("ie_ready")) {
                    var E = (window.location.protocol == "https:") ? "://0" : "javascript:void(0)";
                    document.write('<script id="ie_ready" defer src="' + E + '"><\/script>');
                    $("ie_ready").onreadystatechange = function () {
                        if (this.readyState == "complete") {
                            D()
                        }
                    }
                }
            } else {
                window.addListener("load", D);
                document.addListener("DOMContentLoaded", D)
            }
        }
    }
};
window.onDomReady = function (B) {
    return this.addEvent("domready", B)
};
window.extend({
    getWidth: function () {
        if (this.webkit419) {
            return this.innerWidth
        }
        if (this.opera) {
            return document.body.clientWidth
        }
        return document.documentElement.clientWidth
    },
    getHeight: function () {
        if (this.webkit419) {
            return this.innerHeight
        }
        if (this.opera) {
            return document.body.clientHeight
        }
        return document.documentElement.clientHeight
    },
    getScrollWidth: function () {
        if (this.ie) {
            return Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth)
        }
        if (this.webkit) {
            return document.body.scrollWidth
        }
        return document.documentElement.scrollWidth
    },
    getScrollHeight: function () {
        if (this.ie) {
            return Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight)
        }
        if (this.webkit) {
            return document.body.scrollHeight
        }
        return document.documentElement.scrollHeight
    },
    getScrollLeft: function () {
        return this.pageXOffset || document.documentElement.scrollLeft
    },
    getScrollTop: function () {
        return this.pageYOffset || document.documentElement.scrollTop
    },
    getSize: function () {
        return {
            size: {
                x: this.getWidth(),
                y: this.getHeight()
            },
            scrollSize: {
                x: this.getScrollWidth(),
                y: this.getScrollHeight()
            },
            scroll: {
                x: this.getScrollLeft(),
                y: this.getScrollTop()
            }
        }
    },
    getPosition: function () {
        return {
            x: 0,
            y: 0
        }
    }
});
var Fx = {};
Fx.Base = new Class({
    options: {
        onStart: Class.empty,
        onComplete: Class.empty,
        onCancel: Class.empty,
        transition: function (B) {
            return - (Math.cos(Math.PI * B) - 1) / 2
        },
        duration: 500,
        unit: "px",
        wait: true,
        fps: 50
    },
    initialize: function (B) {
        this.element = this.element || null;
        this.setOptions(B);
        if (this.options.initialize) {
            this.options.initialize.call(this)
        }
    },
    step: function () {
        var B = $time();
        if (B < this.time + this.options.duration) {
            this.delta = this.options.transition((B - this.time) / this.options.duration);
            this.setNow();
            this.increase()
        } else {
            this.stop(true);
            this.set(this.to);
            this.fireEvent("onComplete", this.element, 10);
            this.callChain()
        }
    },
    set: function (B) {
        this.now = B;
        this.increase();
        return this
    },
    setNow: function () {
        this.now = this.compute(this.from, this.to)
    },
    compute: function (D, C) {
        return (C - D) * this.delta + D
    },
    start: function (D, C) {
        if (!this.options.wait) {
            this.stop()
        } else {
            if (this.timer) {
                return this
            }
        }
        this.from = D;
        this.to = C;
        this.change = this.to - this.from;
        this.time = $time();
        this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
        this.fireEvent("onStart", this.element);
        return this
    },
    stop: function (B) {
        if (!this.timer) {
            return this
        }
        this.timer = $clear(this.timer);
        if (!B) {
            this.fireEvent("onCancel", this.element)
        }
        return this


    },
    custom: function (D, C) {
        return this.start(D, C)
    },
    clearTimer: function (B) {
        return this.stop(B)
    }
});
Fx.Base.implement(new Chain, new Events, new Options);
Fx.CSS = {
    select: function (F, E) {
        if (F.test(/color/i)) {
            return this.Color
        }
        var D = $type(E);
        if ((D == "array") || (D == "string" && E.contains(" "))) {
            return this.Multi
        }
        return this.Single
    },
    parse: function (K, J, G) {
        if (!G.push) {
            G = [G]
        }
        var H = G[0],
        I = G[1];
        if (!$chk(I)) {
            I = H;
            H = K.getStyle(J)
        }
        var L = this.select(J, I);
        return {
            from: L.parse(H),
            to: L.parse(I),
            css: L
        }
    }
};
Fx.CSS.Single = {
    parse: function (B) {
        return parseFloat(B)
    },
    getNow: function (E, F, D) {
        return D.compute(E, F)
    },
    getValue: function (E, D, F) {
        if (D == "px" && F != "opacity") {
            E = Math.round(E)
        }
        return E + D
    }
};
Fx.CSS.Multi = {
    parse: function (B) {
        return B.push ? B : B.split(" ").map(function (A) {
            return parseFloat(A)
        })
    },
    getNow: function (G, H, I) {
        var F = [];
        for (var J = 0; J < G.length; J++) {
            F[J] = I.compute(G[J], H[J])
        }
        return F
    },
    getValue: function (E, D, F) {
        if (D == "px" && F != "opacity") {
            E = E.map(Math.round)
        }
        return E.join(D + " ") + D
    }
};
Fx.CSS.Color = {
    parse: function (B) {
        return B.push ? B : B.hexToRgb(true)
    },
    getNow: function (G, H, I) {
        var F = [];
        for (var J = 0; J < G.length; J++) {
            F[J] = Math.round(I.compute(G[J], H[J]))
        }
        return F
    },
    getValue: function (B) {
        return "rgb(" + B.join(",") + ")"
    }
};
Fx.Style = Fx.Base.extend({
    initialize: function (F, E, D) {
        this.element = $(F);
        this.property = E;
        this.parent(D)
    },
    hide: function () {
        return this.set(0)
    },
    setNow: function () {
        this.now = this.css.getNow(this.from, this.to, this)
    },
    set: function (B) {
        this.css = Fx.CSS.select(this.property, B);
        return this.parent(this.css.parse(B))
    },
    start: function (E, F) {
        if (this.timer && this.options.wait) {
            return this
        }
        var D = Fx.CSS.parse(this.element, this.property, [E, F]);
        this.css = D.css;
        return this.parent(D.from, D.to)
    },
    increase: function () {
        this.element.setStyle(this.property, this.css.getValue(this.now, this.options.unit, this.property))
    }
});
Element.extend({
    effect: function (D, C) {
        return new Fx.Style(this, D, C)
    }
});
Fx.Styles = Fx.Base.extend({
    initialize: function (D, C) {
        this.element = $(D);
        this.parent(C)
    },
    setNow: function () {
        for (var B in this.from) {
            this.now[B] = this.css[B].getNow(this.from[B], this.to[B], this)
        }
    },
    set: function (E) {
        var D = {};
        this.css = {};
        for (var F in E) {
            this.css[F] = Fx.CSS.select(F, E[F]);
            D[F] = this.css[F].parse(E[F])
        }
        return this.parent(D)
    },
    start: function (I) {
        if (this.timer && this.options.wait) {
            return this
        }
        this.now = {};
        this.css = {};
        var G = {},
        H = {};
        for (var J in I) {
            var F = Fx.CSS.parse(this.element, J, I[J]);
            G[J] = F.from;
            H[J] = F.to;
            this.css[J] = F.css
        }
        return this.parent(G, H)
    },
    increase: function () {
        for (var B in this.now) {
            this.element.setStyle(B, this.css[B].getValue(this.now[B], this.options.unit, B))
        }
    }
});
Element.extend({
    effects: function (B) {
        return new Fx.Styles(this, B)
    }
});
Fx.Elements = Fx.Base.extend({
    initialize: function (D, C) {
        this.elements = $$(D);
        this.parent(C)
    },
    setNow: function () {
        for (var K in this.from) {
            var H = this.from[K],
            I = this.to[K],
            L = this.css[K],
            G = this.now[K] = {};
            for (var J in H) {
                G[J] = L[J].getNow(H[J], I[J], this)
            }
        }
    },
    set: function (I) {
        var N = {};
        this.css = {};
        for (var L in I) {
            var J = I[L],
            M = this.css[L] = {},
            H = N[L] = {};
            for (var K in J) {
                M[K] = Fx.CSS.select(K, J[K]);
                H[K] = M[K].parse(J[K])
            }
        }
        return this.parent(N)
    },
    start: function (K) {
        if (this.timer && this.options.wait) {
            return this
        }
        this.now = {};
        this.css = {};
        var P = {},
        O = {};
        for (var T in K) {
            var R = K[T],
            N = P[T] = {},
            Q = O[T] = {},
            L = this.css[T] = {};
            for (var M in R) {
                var S = Fx.CSS.parse(this.elements[T], M, R[M]);
                N[M] = S.from;
                Q[M] = S.to;
                L[M] = S.css
            }
        }
        return this.parent(P, O)
    },
    increase: function () {
        for (var G in this.now) {
            var E = this.now[G],
            H = this.css[G];
            for (var F in E) {
                this.elements[G].setStyle(F, H[F].getValue(E[F], this.options.unit, F))
            }
        }
    }
});
Fx.Scroll = Fx.Base.extend({
    options: {
        overflown: [],
        offset: {
            x: 0,
            y: 0
        },
        wheelStops: true
    },
    initialize: function (D, C) {
        this.now = [];
        this.element = $(D);
        this.bound = {
            stop: this.stop.bind(this, false)
        };
        this.parent(C);
        if (this.options.wheelStops) {
            this.addEvent("onStart", function () {
                document.addEvent("mousewheel", this.bound.stop)
            }.bind(this));
            this.addEvent("onComplete", function () {
                document.removeEvent("mousewheel", this.bound.stop)
            }.bind(this))
        }
    },
    setNow: function () {
        for (var B = 0; B < 2; B++) {
            this.now[B] = this.compute(this.from[B], this.to[B])
        }
    },
    scrollTo: function (L, H) {
        if (this.timer && this.options.wait) {
            return this
        }
        var J = this.element.getSize();
        var K = {
            x: L,
            y: H
        };
        for (var I in J.size) {
            var G = J.scrollSize[I] - J.size[I];
            if ($chk(K[I])) {
                K[I] = ($type(K[I]) == "number") ? K[I].limit(0, G) : G
            } else {
                K[I] = J.scroll[I]
            }
            K[I] += this.options.offset[I]
        }
        return this.start([J.scroll.x, J.scroll.y], [K.x, K.y])
    },
    toTop: function () {
        return this.scrollTo(false, 0)
    },
    toBottom: function () {
        return this.scrollTo(false, "full")
    },
    toLeft: function () {
        return this.scrollTo(0, false)
    },
    toRight: function () {
        return this.scrollTo("full", false)
    },
    toElement: function (F) {
        var D = this.element.getPosition(this.options.overflown);
        var E = $(F).getPosition(this.options.overflown);
        return this.scrollTo(E.x - D.x, E.y - D.y)
    },
    increase: function () {
        this.element.scrollTo(this.now[0], this.now[1])
    }
});
Fx.Slide = Fx.Base.extend({
    options: {
        mode: "vertical"
    },
    initialize: function (D, C) {
        this.element = $(D);
        this.wrapper = new Element("div", {
            styles: $extend(this.element.getStyles("margin"), {
                overflow: "hidden"
            })
        }).injectAfter(this.element).adopt(this.element);
        this.element.setStyle("margin", 0);
        this.setOptions(C);
        this.now = [];
        this.parent(this.options);
        this.open = true;
        this.addEvent("onComplete", function () {
            this.open = (this.now[0] === 0)
        });
        if (window.webkit419) {
            this.addEvent("onComplete", function () {
                if (this.open) {
                    this.element.remove().inject(this.wrapper)
                }
            })
        }
    },
    setNow: function () {
        for (var B = 0; B < 2; B++) {
            this.now[B] = this.compute(this.from[B], this.to[B])
        }
    },
    vertical: function () {
        this.margin = "margin-top";
        this.layout = "height";
        this.offset = this.element.offsetHeight
    },
    horizontal: function () {
        this.margin = "margin-left";
        this.layout = "width";
        this.offset = this.element.offsetWidth
    },
    slideIn: function (B) {
        this[B || this.options.mode]();
        return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [0, this.offset])
    },
    slideOut: function (B) {
        this[B || this.options.mode]();
        return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [-this.offset, 0])
    },
    hide: function (B) {
        this[B || this.options.mode]();
        this.open = false;
        return this.set([-this.offset, 0])
    },
    show: function (B) {
        this[B || this.options.mode]();
        this.open = true;
        return this.set([0, this.offset])
    },
    toggle: function (B) {
        if (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) {
            return this.slideIn(B)
        }
        return this.slideOut(B)
    },
    increase: function () {
        this.element.setStyle(this.margin, this.now[0] + this.options.unit);
        this.wrapper.setStyle(this.layout, this.now[1] + this.options.unit)
    }
});
Fx.Transition = function (D, C) {
    C = C || [];
    if ($type(C) != "array") {
        C = [C]
    }
    return $extend(D, {
        easeIn: function (A) {
            return D(A, C)
        },
        easeOut: function (A) {
            return 1 - D(1 - A, C)
        },
        easeInOut: function (A) {
            return (A <= 0.5) ? D(2 * A, C) / 2 : (2 - D(2 * (1 - A), C)) / 2
        }
    })
};
Fx.Transitions = new Abstract({
    linear: function (B) {
        return B
    }
});
Fx.Transitions.extend = function (C) {
    for (var D in C) {
        Fx.Transitions[D] = new Fx.Transition(C[D]);
        Fx.Transitions.compat(D)
    }
};
Fx.Transitions.compat = function (B) {
    ["In", "Out", "InOut"].each(function (A) {
        Fx.Transitions[B.toLowerCase() + A] = Fx.Transitions[B]["ease" + A]
    })
};
Fx.Transitions.extend({
    Pow: function (D, C) {
        return Math.pow(D, C[0] || 6)
    },
    Expo: function (B) {
        return Math.pow(2, 8 * (B - 1))
    },
    Circ: function (B) {
        return 1 - Math.sin(Math.acos(B))
    },
    Sine: function (B) {
        return 1 - Math.sin((1 - B) * Math.PI / 2)
    },
    Back: function (D, C) {
        C = C[0] || 1.618;
        return Math.pow(D, 2) * ((C + 1) * D - C)
    },
    Bounce: function (F) {
        var G;
        for (var H = 0, E = 1; 1; H += E, E /= 2) {
            if (F >= (7 - 4 * H) / 11) {
                G = -Math.pow((11 - 6 * H - 11 * F) / 4, 2) + E * E;
                break
            }
        }
        return G
    },
    Elastic: function (D, C) {
        return Math.pow(2, 10 * --D) * Math.cos(20 * D * Math.PI * (C[0] || 1) / 3)
    }
});
["Quad", "Cubic", "Quart", "Quint"].each(function (D, C) {
    Fx.Transitions[D] = new Fx.Transition(function (A) {
        return Math.pow(A, [C + 2])
    });
    Fx.Transitions.compat(D)
});
var Drag = {};
Drag.Base = new Class({
    options: {
        handle: false,
        unit: "px",
        onStart: Class.empty,
        onBeforeStart: Class.empty,
        onComplete: Class.empty,
        onSnap: Class.empty,
        onDrag: Class.empty,
        limit: false,
        modifiers: {
            x: "left",
            y: "top"
        },
        grid: false,
        snap: 6
    },
    initialize: function (D, C) {
        this.setOptions(C);
        this.element = $(D);
        this.handle = $(this.options.handle) || this.element;
        this.mouse = {
            now: {},
            pos: {}
        };
        this.value = {
            start: {},
            now: {}
        };
        this.bound = {
            start: this.start.bindWithEvent(this),
            check: this.check.bindWithEvent(this),
            drag: this.drag.bindWithEvent(this),
            stop: this.stop.bind(this)
        };
        this.attach();
        if (this.options.initialize) {
            this.options.initialize.call(this)
        }
    },
    attach: function () {
        this.handle.addEvent("mousedown", this.bound.start);
        return this
    },
    detach: function () {
        this.handle.removeEvent("mousedown", this.bound.start);
        return this
    },
    start: function (G) {
        this.fireEvent("onBeforeStart", this.element);
        this.mouse.start = G.page;
        var E = this.options.limit;
        this.limit = {
            x: [],
            y: []
        };
        for (var F in this.options.modifiers) {
            if (!this.options.modifiers[F]) {
                continue
            }
            this.value.now[F] = this.element.getStyle(this.options.modifiers[F]).toInt();
            this.mouse.pos[F] = G.page[F] - this.value.now[F];
            if (E && E[F]) {
                for (var H = 0; H < 2; H++) {
                    if ($chk(E[F][H])) {
                        this.limit[F][H] = ($type(E[F][H]) == "function") ? E[F][H]() : E[F][H]
                    }
                }
            }
        }
        if ($type(this.options.grid) == "number") {
            this.options.grid = {
                x: this.options.grid,
                y: this.options.grid
            }
        }
        document.addListener("mousemove", this.bound.check);
        document.addListener("mouseup", this.bound.stop);
        this.fireEvent("onStart", this.element);
        G.stop()
    },
    check: function (C) {
        var D = Math.round(Math.sqrt(Math.pow(C.page.x - this.mouse.start.x, 2) + Math.pow(C.page.y - this.mouse.start.y, 2)));
        if (D > this.options.snap) {
            document.removeListener("mousemove", this.bound.check);
            document.addListener("mousemove", this.bound.drag);
            this.drag(C);
            this.fireEvent("onSnap", this.element)
        }
        C.stop()
    },
    drag: function (C) {
        this.out = false;
        this.mouse.now = C.page;
        for (var D in this.options.modifiers) {
            if (!this.options.modifiers[D]) {
                continue
            }
            this.value.now[D] = this.mouse.now[D] - this.mouse.pos[D];
            if (this.limit[D]) {
                if ($chk(this.limit[D][1]) && (this.value.now[D] > this.limit[D][1])) {
                    this.value.now[D] = this.limit[D][1];
                    this.out = true
                } else {
                    if ($chk(this.limit[D][0]) && (this.value.now[D] < this.limit[D][0])) {
                        this.value.now[D] = this.limit[D][0];
                        this.out = true
                    }
                }
            }
            if (this.options.grid[D]) {
                this.value.now[D] -= (this.value.now[D] % this.options.grid[D])
            }
            this.element.setStyle(this.options.modifiers[D], this.value.now[D] + this.options.unit)
        }
        this.fireEvent("onDrag", this.element);
        C.stop()
    },
    stop: function () {
        document.removeListener("mousemove", this.bound.check);
        document.removeListener("mousemove", this.bound.drag);
        document.removeListener("mouseup", this.bound.stop);
        this.fireEvent("onComplete", this.element)
    }
});
Drag.Base.implement(new Events, new Options);
Element.extend({
    makeResizable: function (B) {
        return new Drag.Base(this, $merge({
            modifiers: {
                x: "width",
                y: "height"
            }
        },
        B))
    }
});
Drag.Move = Drag.Base.extend({
    options: {
        droppables: [],
        container: false,
        overflown: []
    },
    initialize: function (H, E) {
        this.setOptions(E);
        this.element = $(H);
        this.droppables = $$(this.options.droppables);
        this.container = $(this.options.container);
        this.position = {
            element: this.element.getStyle("position"),
            container: false
        };
        if (this.container) {
            this.position.container = this.container.getStyle("position")
        }
        if (! ["relative", "absolute", "fixed"].contains(this.position.element)) {
            this.position.element = "absolute"
        }
        var F = this.element.getStyle("top").toInt();
        var G = this.element.getStyle("left").toInt();
        if (this.position.element == "absolute" && !["relative", "absolute", "fixed"].contains(this.position.container)) {
            F = $chk(F) ? F : this.element.getTop(this.options.overflown);
            G = $chk(G) ? G : this.element.getLeft(this.options.overflown)
        } else {
            F = $chk(F) ? F : 0;
            G = $chk(G) ? G : 0
        }
        this.element.setStyles({
            top: F,
            left: G,
            position: this.position.element
        });
        this.parent(this.element)
    },
    start: function (E) {
        this.overed = null;
        if (this.container) {
            var D = this.container.getCoordinates();
            var F = this.element.getCoordinates();
            if (this.position.element == "absolute" && !["relative", "absolute", "fixed"].contains(this.position.container)) {
                this.options.limit = {
                    x: [D.left, D.right - F.width],
                    y: [D.top, D.bottom - F.height]
                }
            } else {
                this.options.limit = {
                    y: [0, D.height - F.height],
                    x: [0, D.width - F.width]
                }
            }
        }
        this.parent(E)
    },
    drag: function (C) {
        this.parent(C);
        var D = this.out ? false : this.droppables.filter(this.checkAgainst, this).getLast();
        if (this.overed != D) {
            if (this.overed) {
                this.overed.fireEvent("leave", [this.element, this])
            }
            this.overed = D ? D.fireEvent("over", [this.element, this]) : null
        }
        return this
    },
    checkAgainst: function (D) {
        D = D.getCoordinates(this.options.overflown);
        var C = this.mouse.now;
        return (C.x > D.left && C.x < D.right && C.y < D.bottom && C.y > D.top)
    },
    stop: function () {
        if (this.overed && !this.out) {
            this.overed.fireEvent("drop", [this.element, this])
        } else {
            this.element.fireEvent("emptydrop", this)
        }
        this.parent();
        return this
    }
});
Element.extend({
    makeDraggable: function (B) {
        return new Drag.Move(this, B)
    }
});
var XHR = new Class({
    options: {
        method: "post",
        async: true,
        onRequest: Class.empty,
        onSuccess: Class.empty,
        onFailure: Class.empty,
        urlEncoded: true,
        encoding: "utf-8",
        autoCancel: false,
        headers: {}
    },
    setTransport: function () {
        this.transport = (window.XMLHttpRequest) ? new XMLHttpRequest() : (window.ie ? new ActiveXObject("Microsoft.XMLHTTP") : false);
        return this
    },
    initialize: function (C) {
        this.setTransport().setOptions(C);
        this.options.isSuccess = this.options.isSuccess || this.isSuccess;
        this.headers = {};
        if (this.options.urlEncoded && this.options.method == "post") {
            var D = (this.options.encoding) ? "; charset=" + this.options.encoding : "";
            this.setHeader("Content-type", "application/x-www-form-urlencoded" + D)
        }
        if (this.options.initialize) {
            this.options.initialize.call(this)
        }
    },
    onStateChange: function () {
        if (this.transport.readyState != 4 || !this.running) {
            return
        }
        this.running = false;
        var C = 0;
        try {
            C = this.transport.status
        } catch(D) {}
        if (this.options.isSuccess.call(this, C)) {
            this.onSuccess()
        } else {
            this.onFailure()
        }
        this.transport.onreadystatechange = Class.empty
    },
    isSuccess: function (B) {
        return ((B >= 200) && (B < 300))
    },
    onSuccess: function () {
        this.response = {
            text: this.transport.responseText,
            xml: this.transport.responseXML
        };
        this.fireEvent("onSuccess", [this.response.text, this.response.xml]);
        this.callChain()
    },
    onFailure: function () {
        this.fireEvent("onFailure", this.transport)
    },
    setHeader: function (C, D) {
        this.headers[C] = D;
        return this
    },
    send: function (E, G) {
        if (this.options.autoCancel) {
            this.cancel()
        } else {
            if (this.running) {
                return this
            }
        }
        this.running = true;
        if (G && this.options.method == "get") {
            E = E + (E.contains("?") ? "&" : "?") + G;
            G = null
        }
        this.transport.open(this.options.method.toUpperCase(), E, this.options.async);
        this.transport.onreadystatechange = this.onStateChange.bind(this);
        if ((this.options.method == "post") && this.transport.overrideMimeType) {
            this.setHeader("Connection", "close")
        }
        $extend(this.headers, this.options.headers);
        for (var H in this.headers) {
            try {
                this.transport.setRequestHeader(H, this.headers[H])
            } catch(F) {}
        }
        this.fireEvent("onRequest");
        this.transport.send($pick(G, null));
        return this
    },
    cancel: function () {
        if (!this.running) {
            return this
        }
        this.running = false;
        this.transport.abort();
        this.transport.onreadystatechange = Class.empty;
        this.setTransport();
        this.fireEvent("onCancel");
        return this
    }
});
XHR.implement(new Chain, new Events, new Options);
var Ajax = XHR.extend({
    options: {
        data: null,
        update: null,
        onComplete: Class.empty,
        evalScripts: false,
        evalResponse: false
    },
    initialize: function (D, C) {
        this.addEvent("onSuccess", this.onComplete);
        this.setOptions(C);
        this.options.data = this.options.data || this.options.postBody;
        if (! ["post", "get"].contains(this.options.method)) {
            this._method = "_method=" + this.options.method;
            this.options.method = "post"
        }
        this.parent();
        this.setHeader("X-Requested-With", "XMLHttpRequest");
        this.setHeader("Accept", "text/javascript, text/html, application/xml, text/xml, */*");
        this.url = D
    },
    onComplete: function () {
        if (this.options.update) {
            $(this.options.update).empty().setHTML(this.response.text)
        }
        if (this.options.evalScripts || this.options.evalResponse) {
            this.evalScripts()
        }
        this.fireEvent("onComplete", [this.response.text, this.response.xml], 20)
    },
    request: function (B) {
        B = B || this.options.data;
        switch ($type(B)) {
        case "element":
            B = $(B).toQueryString();
            break;
        case "object":
            B = Object.toQueryString(B)
        }
        if (this._method) {
            B = (B) ? [this._method, B].join("&") : this._method
        }
        return this.send(this.url, B)
    },
    evalScripts: function () {
        var F, D;
        if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader("Content-type"))) {
            D = this.response.text
        } else {
            D = [];
            var E = /<script[^>]*>([\s\S]*?)<\/script>/gi;
            while ((F = E.exec(this.response.text))) {
                D.push(F[1])
            }
            D = D.join("\n")
        }
        if (D) {
            (window.execScript) ? window.execScript(D) : window.setTimeout(D, 0)
        }
    },
    getHeader: function (C) {
        try {
            return this.transport.getResponseHeader(C)
        } catch(D) {}
        return null
    }
});
Object.toQueryString = function (F) {
    var E = [];
    for (var D in F) {
        E.push(encodeURIComponent(D) + "=" + encodeURIComponent(F[D]))
    }
    return E.join("&")
};
Element.extend({
    send: function (B) {
        return new Ajax(this.getProperty("action"), $merge({
            data: this.toQueryString()
        },
        B, {
            method: "post"
        })).request()
    }
});
var Cookie = new Abstract({
    options: {
        domain: false,
        path: false,
        duration: false,
        secure: false
    },
    set: function (G, F, H) {
        H = $merge(this.options, H);
        F = encodeURIComponent(F);
        if (H.domain) {
            F += "; domain=" + H.domain
        }
        if (H.path) {
            F += "; path=" + H.path
        }
        if (H.duration) {
            var E = new Date();
            E.setTime(E.getTime() + H.duration * 24 * 60 * 60 * 1000);
            F += "; expires=" + E.toGMTString()
        }
        if (H.secure) {
            F += "; secure"
        }
        document.cookie = G + "=" + F;
        return $extend(H, {
            key: G,
            value: F
        })
    },
    get: function (C) {
        var D = document.cookie.match("(?:^|;)\\s*" + C.escapeRegExp() + "=([^;]*)");
        return D ? decodeURIComponent(D[1]) : false
    },
    remove: function (D, C) {
        if ($type(D) == "object") {
            this.set(D.key, "", $merge(D, {
                duration: -1
            }))
        } else {
            this.set(D, "", $merge(C, {
                duration: -1
            }))
        }
    }
});
var Json = {
    toString: function (E) {
        switch ($type(E)) {
        case "string":
            return '"' + E.replace(/(["\\])/g, "\\$1") + '"';
        case "array":
            return "[" + E.map(Json.toString).join(",") + "]";
        case "object":
            var D = [];
            for (var F in E) {
                D.push(Json.toString(F) + ":" + Json.toString(E[F]))
            }
            return "{" + D.join(",") + "}";
        case "number":
            if (isFinite(E)) {
                break
            }
        case false:
            return "null"
        }
        return String(E)
    },
    evaluate: function (str, secure) {
        return (($type(str) != "string") || (secure && !str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/))) ? null : eval("(" + str + ")")
    }
};
Json.Remote = XHR.extend({
    initialize: function (D, C) {
        this.url = D;
        this.addEvent("onSuccess", this.onComplete);
        this.parent(C);
        this.setHeader("X-Request", "JSON")
    },
    send: function (B) {
        return this.parent(this.url, "json=" + Json.toString(B))
    },
    onComplete: function () {
        this.fireEvent("onComplete", [Json.evaluate(this.response.text, this.options.secure)])
    }
});
var Asset = new Abstract({
    javascript: function (E, F) {
        F = $merge({
            onload: Class.empty
        },
        F);
        var D = new Element("script", {
            src: E
        }).addEvents({
            load: F.onload,
            readystatechange: function () {
                if (this.readyState == "complete") {
                    this.fireEvent("load")
                }
            }
        });
        delete F.onload;
        return D.setProperties(F).inject(document.head)
    },
    css: function (D, C) {
        return new Element("link", $merge({
            rel: "stylesheet",
            media: "screen",
            type: "text/css",
            href: D
        },
        C)).inject(document.head)
    },
    image: function (G, H) {
        H = $merge({
            onload: Class.empty,
            onabort: Class.empty,
            onerror: Class.empty
        },
        H);
        var F = new Image();
        F.src = G;
        var E = new Element("img", {
            src: G
        });
        ["load", "abort", "error"].each(function (B) {
            var A = H["on" + B];
            delete H["on" + B];
            E.addEvent(B, function () {
                this.removeEvent(B, arguments.callee);
                A.call(this)
            })
        });
        if (F.width && F.height) {
            E.fireEvent("load", E, 1)
        }
        return E.setProperties(H)
    },
    images: function (F, G) {
        G = $merge({
            onComplete: Class.empty,
            onProgress: Class.empty
        },
        G);
        if (!F.push) {
            F = [F]
        }
        var E = [];
        var H = 0;
        F.each(function (A) {
            var B = new Asset.image(A, {
                onload: function () {
                    G.onProgress.call(this, H);
                    H++;
                    if (H == F.length) {
                        G.onComplete()
                    }
                }
            });
            E.push(B)
        });
        return new Elements(E)
    }
});
var Hash = new Class({
    length: 0,
    initialize: function (B) {
        this.obj = B || {};
        this.setLength()
    },
    get: function (B) {
        return (this.hasKey(B)) ? this.obj[B] : null
    },
    hasKey: function (B) {
        return (B in this.obj)
    },
    set: function (C, D) {
        if (!this.hasKey(C)) {
            this.length++
        }
        this.obj[C] = D;
        return this
    },
    setLength: function () {
        this.length = 0;
        for (var B in this.obj) {
            this.length++
        }
        return this
    },
    remove: function (B) {
        if (this.hasKey(B)) {
            delete this.obj[B];
            this.length--
        }
        return this
    },
    each: function (C, D) {
        $each(this.obj, C, D)
    },
    extend: function (B) {
        $extend(this.obj, B);
        return this.setLength()
    },
    merge: function () {
        this.obj = $merge.apply(null, [this.obj].extend(arguments));
        return this.setLength()
    },
    empty: function () {
        this.obj = {};
        this.length = 0;
        return this
    },
    keys: function () {
        var C = [];
        for (var D in this.obj) {
            C.push(D)
        }
        return C
    },
    values: function () {
        var C = [];
        for (var D in this.obj) {
            C.push(this.obj[D])
        }
        return C
    }
});
function $H(B) {
    return new Hash(B)
}
Hash.Cookie = Hash.extend({
    initialize: function (D, C) {
        this.name = D;
        this.options = $extend({
            autoSave: true
        },
        C || {});
        this.load()
    },
    save: function () {

        if (this.length == 0) {
            Cookie.remove(this.name, this.options);
            return true
        }
        var B = Json.toString(this.obj);
        if (B.length > 4096) {
            return false
        }
        Cookie.set(this.name, B, this.options);
        return true
    },
    load: function () {
        this.obj = Json.evaluate(Cookie.get(this.name), true) || {};
        this.setLength()
    }
});
Hash.Cookie.Methods = {};
["extend", "set", "merge", "empty", "remove"].each(function (B) {
    Hash.Cookie.Methods[B] = function () {
        Hash.prototype[B].apply(this, arguments);
        if (this.options.autoSave) {
            this.save()
        }
        return this
    }
});
Hash.Cookie.implement(Hash.Cookie.Methods);
var Scroller = new Class({
    options: {
        area: 20,
        velocity: 1,
        onChange: function (C, D) {
            this.element.scrollTo(C, D)
        }
    },
    initialize: function (D, C) {
        this.setOptions(C);
        this.element = $(D);
        this.mousemover = ([window, document].contains(D)) ? $(document.body) : this.element
    },
    start: function () {
        this.coord = this.getCoords.bindWithEvent(this);
        this.mousemover.addListener("mousemove", this.coord)
    },
    stop: function () {
        this.mousemover.removeListener("mousemove", this.coord);
        this.timer = $clear(this.timer)
    },
    getCoords: function (B) {
        this.page = (this.element == window) ? B.client : B.page;
        if (!this.timer) {
            this.timer = this.scroll.periodical(50, this)
        }
    },
    scroll: function () {
        var E = this.element.getSize();
        var F = this.element.getPosition();
        var G = {
            x: 0,
            y: 0
        };
        for (var H in this.page) {
            if (this.page[H] < (this.options.area + F[H]) && E.scroll[H] != 0) {
                G[H] = (this.page[H] - this.options.area - F[H]) * this.options.velocity
            } else {
                if (this.page[H] + this.options.area > (E.size[H] + F[H]) && E.scroll[H] + E.size[H] != E.scrollSize[H]) {
                    G[H] = (this.page[H] - E.size[H] + this.options.area - F[H]) * this.options.velocity
                }
            }
        }
        if (G.y || G.x) {
            this.fireEvent("onChange", [E.scroll.x + G.x, E.scroll.y + G.y])
        }
    }
});
Scroller.implement(new Events, new Options);
var Slider = new Class({
    options: {
        onChange: Class.empty,
        onComplete: Class.empty,
        onTick: function (B) {
            this.knob.setStyle(this.p, B)
        },
        mode: "horizontal",
        steps: 100,
        offset: 0
    },
    initialize: function (J, G, L) {
        this.element = $(J);
        this.knob = $(G);
        this.setOptions(L);
        this.previousChange = -1;
        this.previousEnd = -1;
        this.step = -1;
        this.element.addEvent("mousedown", this.clickedElement.bindWithEvent(this));
        var K, H;
        switch (this.options.mode) {
        case "horizontal":
            this.z = "x";
            this.p = "left";
            K = {
                x: "left",
                y: false
            };
            H = "offsetWidth";
            break;
        case "vertical":
            this.z = "y";
            this.p = "top";
            K = {
                x: false,
                y: "top"
            };
            H = "offsetHeight"
        }
        this.max = this.element[H] - this.knob[H] + (this.options.offset * 2);
        this.half = this.knob[H] / 2;
        this.getPos = this.element["get" + this.p.capitalize()].bind(this.element);
        this.knob.setStyle("position", "relative").setStyle(this.p, -this.options.offset);
        var I = {};
        I[this.z] = [-this.options.offset, this.max - this.options.offset];
        this.drag = new Drag.Base(this.knob, {
            limit: I,
            modifiers: K,
            snap: 0,
            onStart: function () {
                this.draggedKnob()
            }.bind(this),
            onDrag: function () {
                this.draggedKnob()
            }.bind(this),
            onComplete: function () {
                this.draggedKnob();
                this.end()
            }.bind(this)
        });
        if (this.options.initialize) {
            this.options.initialize.call(this)
        }
    },
    set: function (B) {
        this.step = B.limit(0, this.options.steps);
        this.checkStep();
        this.end();
        this.fireEvent("onTick", this.toPosition(this.step));
        return this
    },
    clickedElement: function (D) {
        var C = D.page[this.z] - this.getPos() - this.half;
        C = C.limit(-this.options.offset, this.max - this.options.offset);
        this.step = this.toStep(C);
        this.checkStep();
        this.end();
        this.fireEvent("onTick", C)
    },
    draggedKnob: function () {
        this.step = this.toStep(this.drag.value.now[this.z]);
        this.checkStep()
    },
    checkStep: function () {
        if (this.previousChange != this.step) {
            this.previousChange = this.step;
            this.fireEvent("onChange", this.step)
        }
    },
    end: function () {
        if (this.previousEnd !== this.step) {
            this.previousEnd = this.step;
            this.fireEvent("onComplete", this.step + "")
        }
    },
    toStep: function (B) {
        return Math.round((B + this.options.offset) / this.max * this.options.steps)
    },
    toPosition: function (B) {
        return this.max * B / this.options.steps
    }
});
Slider.implement(new Events);
Slider.implement(new Options);
var SmoothScroll = Fx.Scroll.extend({
    initialize: function (D) {
        this.parent(window, D);
        this.links = (this.options.links) ? $$(this.options.links) : $$(document.links);
        var C = window.location.href.match(/^[^#]*/)[0] + "#";
        this.links.each(function (A) {
            if (A.href.indexOf(C) != 0) {
                return
            }
            var B = A.href.substr(C.length);
            if (B && $(B)) {
                this.useLink(A, B)
            }
        },
        this);
        if (!window.webkit419) {
            this.addEvent("onComplete", function () {
                window.location.hash = this.anchor
            })
        }
    },
    useLink: function (D, C) {
        D.addEvent("click", function (A) {
            this.anchor = C;
            this.toElement(C);
            A.stop()
        }.bindWithEvent(this))
    }
});
var Tips = new Class({
    options: {
        onShow: function (B) {
            B.setStyle("visibility", "visible")
        },
        onHide: function (B) {
            B.setStyle("visibility", "hidden")
        },
        maxTitleChars: 30,
        showDelay: 100,
        hideDelay: 100,
        className: "tool",
        offsets: {
            x: 16,
            y: 16
        },
        fixed: false
    },
    initialize: function (D, C) {
        this.setOptions(C);
        this.toolTip = new Element("div", {
            "class": this.options.className + "-tip",
            styles: {
                position: "absolute",
                top: "0",
                left: "0",
                visibility: "hidden"
            }
        }).inject(document.body);
        this.wrapper = new Element("div").inject(this.toolTip);
        $$(D).each(this.build, this);
        if (this.options.initialize) {
            this.options.initialize.call(this)
        }
    },
    build: function (F) {
        F.$tmp.myTitle = (F.href && F.getTag() == "a") ? F.href.replace("http://", "") : (F.rel || false);
        if (F.title) {
            var E = F.title.split("::");
            if (E.length > 1) {
                F.$tmp.myTitle = E[0].trim();
                F.$tmp.myText = E[1].trim()
            } else {
                F.$tmp.myText = F.title
            }
            F.removeAttribute("title")
        } else {
            F.$tmp.myText = false
        }
        if (F.$tmp.myTitle && F.$tmp.myTitle.length > this.options.maxTitleChars) {
            F.$tmp.myTitle = F.$tmp.myTitle.substr(0, this.options.maxTitleChars - 1) + "&hellip;"
        }
        F.addEvent("mouseenter", function (A) {
            this.start(F);
            if (!this.options.fixed) {
                this.locate(A)
            } else {
                this.position(F)
            }
        }.bind(this));
        if (!this.options.fixed) {
            F.addEvent("mousemove", this.locate.bindWithEvent(this))
        }
        var D = this.end.bind(this);
        F.addEvent("mouseleave", D);
        F.addEvent("trash", D)
    },
    start: function (B) {
        this.wrapper.empty();
        if (B.$tmp.myTitle) {
            this.title = new Element("span").inject(new Element("div", {
                "class": this.options.className + "-title"
            }).inject(this.wrapper)).setHTML(B.$tmp.myTitle)
        }
        if (B.$tmp.myText) {
            this.text = new Element("span").inject(new Element("div", {
                "class": this.options.className + "-text"
            }).inject(this.wrapper)).setHTML(B.$tmp.myText)
        }
        $clear(this.timer);
        this.timer = this.show.delay(this.options.showDelay, this)
    },
    end: function (B) {
        $clear(this.timer);
        this.timer = this.hide.delay(this.options.hideDelay, this)
    },
    position: function (C) {
        var D = C.getPosition();
        this.toolTip.setStyles({
            left: D.x + this.options.offsets.x,
            top: D.y + this.options.offsets.y
        })
    },
    locate: function (N) {
        var L = {
            x: window.getWidth(),
            y: window.getHeight()
        };
        var H = {
            x: window.getScrollLeft(),
            y: window.getScrollTop()
        };
        var M = {
            x: this.toolTip.offsetWidth,
            y: this.toolTip.offsetHeight
        };
        var I = {
            x: "left",
            y: "top"
        };
        for (var K in I) {
            var J = N.page[K] + this.options.offsets[K];
            if ((J + M[K] - H[K]) > L[K]) {
                J = N.page[K] - this.options.offsets[K] - M[K]
            }
            this.toolTip.setStyle(I[K], J)
        }
    },
    show: function () {
        if (this.options.timeout) {
            this.timer = this.hide.delay(this.options.timeout, this)
        }
        this.fireEvent("onShow", [this.toolTip])
    },
    hide: function () {
        this.fireEvent("onHide", [this.toolTip])
    }
});
Tips.implement(new Events, new Options);
var Group = new Class({
    initialize: function () {
        this.instances = $A(arguments);
        this.events = {};
        this.checker = {}
    },
    addEvent: function (D, C) {
        this.checker[D] = this.checker[D] || {};
        this.events[D] = this.events[D] || [];
        if (this.events[D].contains(C)) {
            return false
        } else {
            this.events[D].push(C)
        }
        this.instances.each(function (B, A) {
            B.addEvent(D, this.check.bind(this, [D, B, A]))
        },
        this);
        return this
    },
    check: function (G, E, H) {
        this.checker[G][H] = true;
        var F = this.instances.every(function (A, B) {
            return this.checker[G][B] || false
        },
        this);
        if (!F) {
            return
        }
        this.checker[G] = {};
        this.events[G].each(function (A) {
            A.call(this, this.instances, E)
        },
        this)
    }
});
var Accordion = Fx.Elements.extend({
    options: {
        onActive: Class.empty,
        onBackground: Class.empty,
        display: 0,
        show: false,
        height: true,
        width: false,
        opacity: true,
        fixedHeight: false,
        fixedWidth: false,
        wait: false,
        alwaysHide: false
    },
    initialize: function () {
        var K, I, H, L;
        $each(arguments, function (A, B) {
            switch ($type(A)) {
            case "object":
                K = A;
                break;
            case "element":
                L = $(A);
                break;
            default:
                var C = $$(A);
                if (!I) {
                    I = C
                } else {
                    H = C
                }
            }
        });
        this.togglers = I || [];
        this.elements = H || [];
        this.container = $(L);
        this.setOptions(K);
        this.previous = -1;
        if (this.options.alwaysHide) {
            this.options.wait = true
        }
        if ($chk(this.options.show)) {
            this.options.display = false;
            this.previous = this.options.show
        }
        if (this.options.start) {
            this.options.display = false;
            this.options.show = false
        }
        this.effects = {};
        if (this.options.opacity) {
            this.effects.opacity = "fullOpacity"
        }
        if (this.options.width) {
            this.effects.width = this.options.fixedWidth ? "fullWidth" : "offsetWidth"
        }
        if (this.options.height) {
            this.effects.height = this.options.fixedHeight ? "fullHeight" : "scrollHeight"
        }
        for (var J = 0, G = this.togglers.length; J < G; J++) {
            this.addSection(this.togglers[J], this.elements[J])
        }
        this.elements.each(function (B, C) {
            if (this.options.show === C) {
                this.fireEvent("onActive", [this.togglers[C], B])
            } else {
                for (var A in this.effects) {
                    B.setStyle(A, 0)
                }
            }
        },
        this);
        this.parent(this.elements);
        if ($chk(this.options.display)) {
            this.display(this.options.display)
        }
    },
    addSection: function (K, M, I) {
        K = $(K);
        M = $(M);
        var J = this.togglers.contains(K);
        var N = this.togglers.length;
        this.togglers.include(K);
        this.elements.include(M);
        if (N && (!J || I)) {
            I = $pick(I, N - 1);
            K.injectBefore(this.togglers[I]);
            M.injectAfter(K)
        } else {
            if (this.container && !J) {
                K.inject(this.container);
                M.inject(this.container)
            }
        }
        var H = this.togglers.indexOf(K);
        K.addEvent("click", this.display.bind(this, H));
        if (this.options.height) {
            M.setStyles({
                "padding-top": 0,
                "border-top": "none",
                "padding-bottom": 0,
                "border-bottom": "none"
            })
        }
        if (this.options.width) {
            M.setStyles({
                "padding-left": 0,
                "border-left": "none",
                "padding-right": 0,
                "border-right": "none"
            })
        }
        M.fullOpacity = 1;
        if (this.options.fixedWidth) {
            M.fullWidth = this.options.fixedWidth
        }
        if (this.options.fixedHeight) {
            M.fullHeight = this.options.fixedHeight
        }
        M.setStyle("overflow", "hidden");
        if (!J) {
            for (var L in this.effects) {
                M.setStyle(L, 0)
            }
        }
        return this
    },
    display: function (C) {
        C = ($type(C) == "element") ? this.elements.indexOf(C) : C;
        if ((this.timer && this.options.wait) || (C === this.previous && !this.options.alwaysHide)) {
            return this
        }
        this.previous = C;
        var D = {};
        this.elements.each(function (B, G) {
            D[G] = {};
            var H = (G != C) || (this.options.alwaysHide && (B.offsetHeight > 0));
            this.fireEvent(H ? "onBackground" : "onActive", [this.togglers[G], B]);
            for (var A in this.effects) {
                D[G][A] = H ? 0 : B[this.effects[A]]
            }
        },
        this);
        return this.start(D)
    },
    showThisHideOpen: function (B) {
        return this.display(B)
    }
});
Fx.Accordion = Accordion;
var SortingTable = new Class({
    initialize: function (B, A) {
        this.options = $merge({
            zebra: true,
            details: false,
            paginator: false
        },
        A);
        this.table = $(B);
        this.tbody = $(this.table.getElementsByTagName("tbody")[0]);
        if (this.options.zebra) {
            SortingTable.stripe_table(this.tbody.getElementsByTagName("tr"))
        }
        this.headers = new Hash;
        var C = $(this.table.getElementsByTagName("thead")[0]);
        $each(C.getElementsByTagName("tr")[0].getElementsByTagName("th"), function (E, D) {
            var E = $(E);
            this.headers.set(E.getText(), {
                column: D,
                element: E
            });
	    /*
	     * Summary: When the result table header is clicked, the page changed, so we need to reload the ads.
	     * Author : Zhiyan
	     */
	    E.addEvent('mousedown', load_ads);

            E.addEvent("mousedown", function (F) {
                var F = new Event(F);
                this.sort_by_header(F.target.getText());
                if (this.options.paginator) {
                    this.options.paginator.to_page(1)
                }
            }.bind(this))
        }.bind(this));
        this.load_conversions()
    },
    sort_by_header: function (D) {
        this.rows = new Array;
        var A = this.tbody.getElementsBySelector("tr, span");
        while (row = A.shift()) {
            row = {
                row: row.remove()
            };
            if (this.options.details) {
                row.detail = A.shift().remove()
            }
            this.rows.unshift(row)
        }
        var C = this.headers.get(D);
        if (this.sort_column >= 0 && this.sort_column == C.column) {
            if (C.element.hasClass("reverseSort")) {
                C.element.removeClass("reverseSort");
                C.element.addClass("forwardSort")
            } else {
                C.element.removeClass("forwardSort");
                C.element.addClass("reverseSort")
            }
        } else {
            this.headers.each(function (E) {
                E.element.removeClass("forwardSort");
                E.element.removeClass("reverseSort")
            });
            this.sort_column = C.column;
            if (C.conversion_function) {
                this.conversion_matcher = C.conversion_matcher;
                this.conversion_function = C.conversion_function
            } else {
                this.conversion_function = false;
                this.rows.some(function (F) {
                    var E = $(F.row.getElementsByTagName("td")[this.sort_column]).getText();
                    if (E == "") {
                        return false
                    }
                    this.conversions.some(function (G) {
                        if (G.matcher.test(E)) {
                            this.conversion_matcher = G.matcher;
                            this.conversion_function = G.conversion_function;
                            return true
                        }
                        return false
                    }.bind(this));
                    if (this.conversion_function) {
                        return true
                    }
                    return false
                }.bind(this));
                C.conversion_function = this.conversion_function.bind(this);
                C.conversion_matcher = this.conversion_matcher;
                this.headers.set(D, C)
            }
            C.element.addClass("forwardSort");
            this.rows.each(function (E) {
                E.compare_value = this.conversion_function(E);
                E.toString = function () {
                    return this.compare_value
                }
            }.bind(this));
	    // TODO : Sort numbers
	    this.rows.sort();
        }
        var B = 0;
        while (row = this.rows.shift()) {
            row.row.injectInside(this.tbody);
            if (row.detail) {
                row.detail.injectInside(this.tbody)
            }
            if (row.row.getTag() == "tr") {
                if (this.options.zebra) {
                    row.row.className = row.row.className.replace(this.removeAltClassRe, "$1").clean();
                    if (row.detail) {
                        row.detail.className = row.detail.className.replace(this.removeAltClassRe, "$1").clean()
                    }
                    if ((B % 2) == 0) {
                        row.row.addClass("alt");
                        if (row.detail) {
                            row.detail.addClass("alt")
                        }
                    }
                }
                B++
            }
        }
        this.rows = false
    },
    load_conversions: function () {
        this.conversions = $A([{
			/* <size sort zhiyan */
            matcher: /([0-9.]{1,8}).*([KiMGT]{1})B/,
            conversion_function: function (C) {
                var A = $(C.row.getElementsByTagName("td")[this.sort_column]).getText();
                A = this.conversion_matcher.exec(A);
                if (!A) {
                    return "0"
                }
                if (A[2] == "M") {
                    sort_val = "1"
                } else {
                    if (A[2] == "G") {
                        sort_val = "2"
                    } else {
                        if (A[2] == "T") {
                            sort_val = "3"
                        } else {
			    if(A[2] == 'i'){
			    	sort_val = "0";
			    }else{
                            	sort_val = "0"
			    }
                        }
                    }
                }
                var B = A[1].indexOf(".");
                if (B == -1) {
                    post = "00"
                } else {
                    var D = A[1].split(".");
                    A[1] = D[0];
                    post = D[1].concat("00".substr(0, 2 - D[1].length))
                }
                return sort_val.concat("00000000".substr(0, 8 - A[1].length).concat(A[1])).concat(post);
            }
			/* size sort zhiyan> */
        },
        {
			/* <date sort zhiyan */
            matcher: /(\d{1,2}) (.{3,6}) ago/,
            conversion_function: function (C) {
                var A = $(C.row.getElementsByTagName("td")[this.sort_column]).getText();
                A = this.conversion_matcher.exec(A);
                if (!A) {
                    return "0"
                }
                var B;

		if(A[2].indexOf("year") != -1)
		{	B = "4";	}
		if(A[2].indexOf("month") != -1)
		{	B = "3";	}
		if(A[2].indexOf("day") != -1)
		{	B = "2";	}
		if(A[2].indexOf("hour") != -1)
		{	B = "1";	}
		if(A[2].indexOf("minute") != -1)
		{	B = "0";	}
		/*
                if (A[2].indexOf("month") != -1) {
                    B = "1"
                } else {
                    if (A[2].indexOf("year") != -1) {
                        B = "2"
                    } else {
			    if(A[2].indexOf("day") != -1){
				    B = "";
			    }
                        B = "0"
                    }
                }
		*/
                return B.concat("00".substr(0, 2 - A[1].length).concat(A[1]))
            }
			/* date sort zhiyan> */
        },
        {
            matcher: /^\d+$/,
            conversion_function: function (B) {
                var A = $(B.row.getElementsByTagName("td")[this.sort_column]).getText();
                return "00000000000000000000000000000000".substr(0, 32 - A.length).concat(A)
            }
        },
        {
            matcher: /.*/,
            conversion_function: function (A) {
                return $(A.row.getElementsByTagName("td")[this.sort_column]).getText()
            }
        }])
    }
});
SortingTable.removeAltClassRe = new RegExp("(^|\\s)alt(?:\\s|$)");
SortingTable.implement({
    removeAltClassRe: SortingTable.removeAltClassRe
});
SortingTable.stripe_table = function (B) {
    var A = 0;
    $$(B).each(function (C) {
        A++;
        C.className = C.className.replace(this.removeAltClassRe, "$1").clean();
        if (! ((A % 2) == 0)) {
            C.addClass("alt")
        }
    }.bind(this))
};
var PaginatingTable = new Class({
    initialize: function (C, B, A) {
        this.options = $merge({
            per_page: 10,
            current_page: 1,
            offset_el: false,
            cutoff_el: false
        },
        A);
        this.table = $(C);
        this.tbody = this.table.getElementsByTagName("tbody")[0];
        if (this.options.offset_el) {
            this.options.offset_el = $(this.options.offset_el)
        }
        if (this.options.cutoff_el) {
            this.options.cutoff_el = $(this.options.cutoff_el)
        }
		// FLUXTAH
        // this.paginators = $A();
		this.paginators = new Array(); // end FLUXTAH

        if ($type(B) == "array") {
            $each(B, function (D) {
                this.paginators.push($(D))
            }.bind(this))
        } else {
            this.paginators.push($(B))
        }
        this.update_pages()
    },
    update_pages: function () {
        this.pages = Math.ceil(this.tbody.getElementsByTagName("tr").length / this.options.per_page);
        this.create_pagination();
        this.to_page(1)
    },
    to_page: function (C) {
		/* CPM start */
		/*if (searchComplete == 1) {reloadBottom();}*/
		/* CPM end */
        C = parseInt(C);
        if (C > this.pages || C < 1) {
            return
        }
        this.current_page = C;
        this.low_limit = this.options.per_page * (this.current_page - 1);
        this.high_limit = this.options.per_page * this.current_page;
        var A = this.tbody.getElementsByTagName("tr");
        if (A.length < this.high_limit) {
            this.high_limit = A.length
        }
        for (var B = 0; B < A.length; B++) {
            if (this.low_limit <= B && this.high_limit > B) {
                A[B].style.display = ""
            } else {
                A[B].style.display = "none"
            }
        }
        this.paginators.each(function (F) {
            var D = F.getElementsByTagName("a");
            for (var E = 0; E < D.length; E++) {
                if (E == this.current_page) {
                    D[E].addClass("currentPage")
                } else {
                    D[E].removeClass("currentPage")
                }
            }
        }.bind(this));
        if (this.options.offset_el) {
            this.options.offset_el.setText(this.low_limit + 1)
        }
        if (this.options.cutoff_el) {
            this.options.cutoff_el.setText(this.high_limit)
        }
    },
    to_next_page: function () {
        this.to_page(this.current_page + 1)
    },
    to_prev_page: function () {
        this.to_page(this.current_page - 1)
    },
    create_pagination: function () {
        this.paginators.each(function (B) {
            B.empty();
            this.create_pagination_node("&#171;", function (C) {
                var C = new Event(C);
                this.to_prev_page();
		/* Prev link clicked, load ads, by Zhiyan */
		load_ads(); /* CPM */
                C.stop();
                return false
            }).injectInside(B);
            for (var A = 1; A <= this.pages; A++) {
                this.create_pagination_node(A, function (C) {
                    var C = new Event(C);
                    this.to_page(C.target.getText());
		/* Page number clicked, load ads, by Zhiyan */
			load_ads(); /* CPM */
                    C.stop();
                    return false
                }).injectInside(B)
            }
            this.create_pagination_node("&#187;", function (C) {
                var C = new Event(C);
                this.to_next_page();
		/* Next link clicked, load ads, by Zhiyan */
		load_ads(); /* CPM */
                C.stop();
                return false
            }).injectInside(B)
        }.bind(this))
    },
    create_pagination_node: function (E, C) {
        var D = new Element("span").setHTML(E);
        if (E == "&#171;") {
            var B = new Element("a", {
                href: "#",
                "class": "previous-page"
            }).addEvent("click", C.bind(this))
        } else {
            if (E == "&#187;") {
                var B = new Element("a", {
                    href: "#",
                    "class": "next-page"
                }).addEvent("click", C.bind(this))
            } else {
                var B = new Element("a", {
                    href: "#"
                }).addEvent("click", C.bind(this))
            }
        }
        var A = new Element("li");
        D.injectInside(B.injectInside(A));
        return A
    }
});
var TsTable = new Class({
    initialize: function (B, A) {
        this.options = $merge({
            max_title_length: 52,
            end_sort_timeout: 5000,
            seed_limit: 10000000
        },
        A);
        this.average_number_of_seeds;
        this.total_number_of_seeds = 0;
        this.element_stockpile = {
            a: new Element("a"),
            td: new Element("td"),
            tr: new Element("tr")
        };
        this.torrents_chain = new Chain();
        this.killing_chain = false;
        this.table = $(B);
        this.tbody = this.table.getElementsByTagName("tbody")[0];
        this.timer = this.run_torrent_chain.periodical(1, this)
    },
    run_torrent_chain: function () {
        if (!this.torrents_chain.chains) {
            return
        }
        this.torrents_chain.callChain();
        if (this.torrents_chain.chains.length == 0) {
            if (!this.killing_chain) {
                this.stop_chain.delay(10000, this);
                this.killing_chain = true
            }
        } else {
            this.killing_chain = false
        }
    },
    stop_chain: function () {
        if (this.killing_chain) {
            this.run_torrent_chain = $clear(this.timer)
        }
    },
    first_torrent_to_tr: function (A) {
        A.element.injectInside(this.tbody)
    },
    add_torrent_to_tr: function (D, B) {
        var C = this.tbody.getElements("tr")[B] || this.tbody.getElements("tr").getLast();
        if (parseInt(C.getElementsByTagName("td")[3].getText()) <= D.seeds) {
            while (C.getPrevious() && D.seeds > parseInt(C.getPrevious().getElementsByTagName("td")[3].getText())) {
                C = C.getPrevious();
                B--
            }
            if (B >= 30) {
                D.element.style.display = "none"
            }
            D.element.injectBefore(C)
        } else {
            while (C.getNext() && D.seeds <= parseInt(C.getNext().getElementsByTagName("td")[3].getText())) {
                C = C.getNext();
                B++
            }
            if (B >= 30) {
                D.element.style.display = "none"
            }
            D.element.injectAfter(C)
        }
        if (D.element.style.display != "none") {
            var A = this.tbody.getElements("tr");
            if (B < 30 && A[30]) {
                A[30].style.display = "none"
            }
            SortingTable.stripe_table(A.slice(0, 29))
        }
    },
    prep_torrent: function (E) {
        window.rCount++;
        var fullName = E.anchor;
        var G = E.anchor.substring(0, this.options.max_title_length);
        if (G != E.anchor) {
            G += "..."
        }
        G = G.replace("@", "");
        switch (E.engine) {
        case "tpb":
            var S = "thepiratebay.org";  
            break;
        case "min":
            var S = "mininova.org"; 
            break;
        case "bit":
            var S = "bittorrent.com"; 
            break;
        case "ish":
            var S = "isohunt.com"; 
            break;
        case "sep":
            var S = "seedpeer.com"; 
            break;
        case "mon":
            var S = "monova.org";
            break;
        case "trz":
            var S = "torrentz.com";
            break;
		case "tfu":
			var S = "torrentfunk.com";
			break;
		case "tor":
			var S = "torlock.com";
			break;
		case "ybt":
			var S = "yourbittorrent.com";
			break;
		case "t2d":
			var S = "torrentstodownload";
			break;
        case "tre":
            var S = "torrentreactor.to"; 
            break;
		case "ide":
            var S = "idealtorrent.com";
            break;
	    case "sum":
            var S = "sumotorrent.com"; 
            break;
		case "tdl":
            var S = "torrentdownloads.net";
            break;
		case "tr7":
            var S = "torrent7.com";
            break;
		case "nts":
            var S = "newtorrents.info"; 
            break;
		case "btm":
            var S = "btmon.com";
            break;
		case "fdl":
            var S = "fulldls.com";
            break;
		case "ext":
            var S = "extratorrent.com"; 
            break;
		case "pod":
            var S = "podtropolis.com"; 
            break;
		case "btj":
            var S = "btjunkie.org"; 
            break;
		case "tpl":
            var S = "torrentportal.com"; 
            break;
		case "vrt":
            var S = "vertor.com";
            break;
		case "dmd":
            var S = "demonoid.com"; 
            break;
		case "ena":
            var S = "extremenova.org";
            break;
		case "thb":
            var S = "torrenthub.org";
            break; 
		case "tzp":
            var S = "torrentzap.com"; 
            break;
		case "trr":
            var S = "torrent.ws";
            break;
		case "mbt":
            var S = "mybittorrent.com"; 
            break;
		case "lgi":
            var S = "legittorrents.info"; 
            break;
		case "ilc": 
            var S = "ilcorsaronero.info"; 
            break;
		case "trt":
            var S = "torrentreactor.net";
            break;
		case "tvg":
            var S = "tntvillage.org"; 
            break;
		case "tdz":
            var S = "torrentdownloadz.com";
            break;
		case "ols":
            var S = "onlytorrents.com";
            break;
		case "box":
            var S = "torrentbox.com"; 
            break;
		case "fen":
            var S = "fenopy.com";
            break;
		case "bts":
            var S = "btscene.com"; 
            break;
		case "rtz":
            var S = "realtorrentz.com"; 
            break;
		case "dts":
            var S = "downloadtorrents.net"; 
            break;
		case "kik":
            var S = "kickasstorrents.com"; 
            break;
		case "h33":
            var S = "h33t.com"; 
            break;
		case "spu":
            var S = "superfundo.org"; 
            break;
		case "bam":
            var S = "bittorrent.am"; 
            break;
		case "alv":
            var S = "alivetorrents.com"; 
            break;
		case "twl":
            var S = "torrentsworld.net"; 
            break;
		case "tnl":
            var S = "torrentbit.net"; 
            break;
		case "vee":
            var S = "torrentfactory.org"; 
            break;
		case "t2c":
            var S = "torrent2crazy.com"; 
            break;
		default:
            var S = "Unknown";
            break;
        }
        if (!isNaN(E.date)) {
            var U = new Date();
            var L = new Date();
            L.setTime(E.date * 1000);
            var P = Math.round((U.getTime() - L.getTime()) / 1000);
            var C;
            if (P <= 0) {
                C = "1 hour ago"
            } else {
                if (P < 60) {
                    C = P + " seconds ago"
                } else {
                    if (P >= 60 && P < 3600) {
                        var N = Math.floor(P / 60);
                        if (N == 1) {
                            C = "1 minute ago"
                        } else {
                            C = N + " minutes ago"
                        }
                    } else {
                        if (P >= 3600 && P < 86400) {
                            var O = Math.floor(P / 3600);
                            if (O == 1) {
                                C = "1 hour ago"
                            } else {
                                C = O + " hours ago"
                            }
                        } else {
                            if (P >= 86400 && P < 2629744) {
                                var F = Math.floor(P / 86400);
                                if (F == 1) {
                                    C = "1 day ago"
                                } else {
                                    C = F + " days ago"
                                }
                            } else {
                                if (P >= 2629744 && P < 31556926) {
                                    var H = Math.round(P / 2629744);
                                    if (H == 1) {
                                        C = "1 month ago"
                                    } else {
                                        C = H + " months ago"
                                    }
                                } else {
                                    if (P >= 31556926) {
                                        var M = Math.round(P / 31556926);
                                        if (M == 1) {
                                            C = "1 year ago"
                                        } else {
                                            C = M + " years ago"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if (!E.date) {
                C = "Unknown"
            } else {
                C = E.date
            }
        }
        if ($type(E.seeds) != "number") {
            E.seeds = 0
        }
        if ($type(E.peers) != "number") {
            E.peers = 0
        }
        this.total_number_of_seeds = this.total_number_of_seeds + E.seeds;
        this.average_number_of_seeds = Math.round(this.total_number_of_seeds / window.rCount);
        if (E.engine == "vze") {
            if (E.avgseeds > this.average_number_of_seeds) {
                E.seeds = Math.round((E.seeds / E.avgseeds) * this.average_number_of_seeds);
                E.peers = Math.round((E.peers / E.avgseeds) * this.average_number_of_seeds)
            }
        }
        if (E.engine == "bit") {
            var J = Math.random();
            E.seeds = Math.round(J * this.average_number_of_seeds);
            E.peers = Math.round(J * (1 + Math.random()) * this.average_number_of_seeds)
        }
        E.element = $(this.element_stockpile.tr.cloneNode(false));
        var D = $(this.element_stockpile.td.cloneNode(false));
        D.innerHTML = C;
        D.className = "date";
        E.element.appendChild(D);
        var K = $(this.element_stockpile.td.cloneNode(false));
        K.className = "title";
        var R = $(this.element_stockpile.a.cloneNode(false));
        R.innerHTML = G;
        R.setProperty('title', fullName);
        R.id = "l_" + id;
        R.href = E.href;
        if (E.verified) {
            var I = $(this.element_stockpile.a.cloneNode(false));
            I.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            I.title = "This torrent has been verified and is safe to download";
            I.className = "verified";
            K.appendChild(I)
        }
		/*R.addEvent("mouseup", function () {						  	
            window.open(E.href);
			_gaq.push(['_trackEvent', 'TorrentsSiteOut', E.engine+'-title', R.title]);
        });*/
        K.appendChild(R);
        E.element.appendChild(K);
        var Q = $(this.element_stockpile.td.cloneNode(false));
        Q.innerHTML = E.size;
        Q.className = "size";
        Q.addEvent("click", function () {						  	
            window.open(E.href);
			_gaq.push(['_trackEvent', 'TorrentsSiteOut', E.engine+'-size', R.title]);
        });
        E.element.appendChild(Q);
        var B = $(this.element_stockpile.td.cloneNode(false));
        B.innerHTML = E.seeds;
        B.id = "s_" + id;
        B.className = "seeds";
        B.addEvent("click", function () {
            window.open(E.href);
			_gaq.push(['_trackEvent', 'TorrentsSiteOut', E.engine+'-seeds', R.title]);
        });
        E.element.appendChild(B);
        var T = $(this.element_stockpile.td.cloneNode(false));
        T.innerHTML = E.peers;
        T.className = "peers";
        T.addEvent("click", function () {
            window.open(E.href);
			_gaq.push(['_trackEvent', 'TorrentsSiteOut', E.engine+'-peers', R.title]);
        });
        E.element.appendChild(T);
        var A = $(this.element_stockpile.td.cloneNode(false));
        A.className = E.engine + " engine";
        A.innerHTML = S;
        A.addEvent("click", function () {
            window.open(E.href);
			_gaq.push(['_trackEvent', 'TorrentsSiteOut', E.engine+'-engine', R.title]);
        });
        E.element.appendChild(A);
        return E
    },
    add_torrents_to_table: function (B, F) {
        if ($type(B) != "array") {
            this.torrents_chain.chain(F);
            return
        }
        // FLUXTAH
        // var D = $A();;
		var D = new Array(); // end FLUXTAH
        var E;
        while (E = B.shift()) {
			/// changed E.seeds > 1000000 to E.seeds > 40000
			/// added E.peers > 40000
            if (!E.anchor || !E.seeds || !E.peers || E.seeds > 40000 || E.peers > 40000 || E.size == "0 MB") {
                continue
            }
            E = this.prep_torrent(E);
            if (E && E.element) {
                D.unshift(E)
            }
        }
        if (D.length > 0) {
            D.sort(function (H, G) {
                return G.seeds - H.seeds
            });
            var A = this.tbody.getElements("tr");
            if (A.length == 0) {
                this.first_torrent_to_tr(D.shift());
                A = this.tbody.getElements("tr")
            }
            if (D.length > 0) {
                for (var C = 0; C < A.length; C++) {
                    if (parseInt(A[C].getElementsByTagName("td")[3].getText()) <= D[0].seeds) {
                        this.torrents_chain.chain(this.add_torrent_to_tr.pass([D.shift(), C], this));
                        C = C - 1;
                        if (D.length == 0) {
                            break
                        }
                    }
                }
                if (D.length > 0) {
                    this.torrents_chain.chain(this.add_torrent_to_tr.pass([D[0], A.length], this));
                    if (D.length > 1) {
                        for (var C = 1; C < D.length; C++) {
                            this.torrents_chain.chain(this.add_torrent_to_tr.pass([D[C], A.length + C], this))
                        }
                    }
                }
            }
        }
        this.torrents_chain.chain(F);
        A = false
    }
});
function focusQuery() {
    document.searchform.q.focus()
}
Json.Remote = Json.Remote.extend({
    send: function () {
        if (this.options.timeout) {
            this.timeoutTimer = window.setTimeout(this.callTimeout.bindAsEventListener(this), this.options.timeout);
            this.addEvent("onComplete", this.removeTimer)
        }
        this.parent()
    },
    callTimeout: function () {
        this.transport.abort();
        this.onFailure();
        if (this.options.onTimeout) {
            this.options.onTimeout()
        }
    },
    removeTimer: function () {
        window.clearTimeout(this.timeoutTimer)
    }
});
function sortCompleteCallback(A) {
    tablePaginater.showPage(A)
} (function () {
    //parent.window.clickout = function (A, B) {
	self.window.clickout = function (A, B) {
        A.href = A.href;
        A.onmousedown = "";
        return true
    }
})();
function numOrdA(B, A) {
    return (B - A)
}
function numOrdD(B, A) {
    return (A - B)
}
function sortFileSize(B, A) {
   return fdTableSort.sortNumeric(B, A)
}
function sortFileSizePrepareData(D, C) {
    var A = /(kb|mb|gb)/i;
    var B = C.search(A) != -1 ? C.match(A)[0] : "";
    switch (B.toLowerCase()) {
    case "kb":
        mult = 1024;
        break;
    case "mb":
        mult = 1048576;
        break;
    case "gb":
        mult = 1073741824;
        break;
    default:
        mult = 1
    }
    C = parseFloat(C.replace(/[^0-9\.\-]/g, ""));
    return isNaN(C) ? "" : C * mult
}
function sortEnglishLonghandDateFormat(B, A) {
    var C = B[fdTableSort.pos];
    var D = A[fdTableSort.pos];
    return C - D
}
function toggleHashGroup(B) {
    var D = this.id.replace("e", "");
    var C = $(D).className;
    var A = $$("tr." + C);
    if (this.src.toString().match("plus")) {
        this.src = "/i/minus.gif";
        A.removeClass("collapsed")
    } else {
        if (this.src.toString().match("minus")) {
            this.src = "/i/plus.gif";
            A.addClass("collapsed");
            $(D).removeClass("collapsed")
        }
    }
}
function sortEnglishLonghandDateFormatPrepareData(C, D) {
    var A = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
    var E = D.toLowerCase();
    for (var B = 0; B < 12; B++) {
        E = E.replace(A[B], B + 1).replace(A[B].substring(0, 3), B + 1)
    }
    if (E.search(/a-z/) != -1) {
        return -1
    }
    E = E.replace(/\s+/g, " ").replace(/[^\d\s]/g, "");
    if (E.replace(" ", "") == "") {
        return -1
    }
    E = E.split(" ");
    if (E.length < 2) {
        return -1
    }
    if (E.length == 2) {
        E[2] = String(new Date().getFullYear())
    }
    if (E[0].length < 2) {
        E[0] = "0" + String(E[0])
    }
    if (E[1].length < 2) {
        E[1] = "0" + String(E[1])
    }
    if (E[2].length != 4) {
        E[2] = (parseInt(E[2]) < 50) ? "20" + E[2] : "19" + E[2]
    }
    return E[2] + String(E[1]) + E[0]
}
function sortDaysAgo(B, A) {
    return fdTableSort.sortNumeric(B, A)
}
function sortDaysAgoPrepareData(F, D) {
    var C, E, B;
    C = /minute/i;
    B = D.search(C);
    if (B != -1) {
        E = 60
    }
    C = /hour/i;
    B = D.search(C);
    if (B != -1) {
        E = 3600
    }
    C = /day/i;
    B = D.search(C);
    if (B != -1) {
        E = 86400
    }
    C = /month/i;
    B = D.search(C);
    if (B != -1) {
        E = 2629743
    }
    C = /year/i;
    B = D.search(C);
    if (B != -1) {
        E = 31556926
    }
    var A = D.split(" ");
    D = A[0];
    D = D * E;
    return isNaN(D) ? 1000000000000 : D
}
function txtFocus(A, B) {
    if (A.value == B) {
        A.value = ""
    }
    A.style.color = "#000"
}
function txtBlur(A, B) {
    if (A.value == "") {
        A.value = B
    }
    A.style.color = "#AAA"
}
function searchFocus(A, B) {
    if (A.value == B) {
        A.value = ""
    }
}
function searchBlur(A, B) {
    if (A.value == "") {
        A.value = B
    }
}
var e = 0;
var jsonObj = new Array();
var eCount = 0;
var enCount = 0;
var rCount = 0;
var sCount = 0;
var fCount = -1;
var id = 0;
var resultsPerPage = 30;
var maxNumPages = 30;
var maxTitleLength = 52;
var endSortTimeout = 2000;
var seedLimit = 10000000;
var avgSeedNum = 0;
var totSeedNum = 0;
var maxSeedNum = 0;
var results, periodical, timer;
var engineImages = new Array();
var ida = new Array();
var idb = new Array();
/* CPM start */
/* searchComplete = 0; */
/* CPM end */

var SiteConfig = {
	advert_type : 'bottom'
};

/*
 * Summary: This is the function call to load ads dynamically from the server and fill the response into the .bottom div.
 */
var load_ads = function(){

	var stamp = new Date();
		
	/* <load ads zhiyan */
	/*
	 * advert system : Use the SiteConfig global var to determin what kind of ads to fetch.
	*/
	new XHR({method: 'get', onSuccess: function(req){
			$$('.bottom').each(function(div, i){
				div.innerHTML = req;
			});
		}}).send('/load_ads.php', 'type='+SiteConfig.advert_type+'&pos=bottom&timestamp='+stamp.getTime());
	/* load ads */
   };
function runScripts(e) { /* this function is not used any more, zhiyan */
	if (e.nodeType != 1) return; //if it's not an element node, return
 
	if (e.tagName.toLowerCase() == 'script') {
		eval(e.text); //run the script
	}
	else {
		var n = e.firstChild;
		while ( n ) {
			if ( n.nodeType == 1 ) runScripts( n ); //if it's an element node, recurse
			n = n.nextSibling;
		}
	}
}   


var addTorrents = function (B, A) {
    $("loading").setStyles("display: none; opacity: 1");
    window.rtable_paginator = window.rtable_paginator || new PaginatingTable("rtable", ["rtable-tablePaginater", "rtable-tablePaginaterClone"], {
        per_page: 30,
        offset_el: "pagination_offset",
        cutoff_el: "pagetotal"
    });
    if ($type(B) == "string") {
        B = Json.evaluate(B, true)
    }
    $("loading").style.display = "none";
    window.torrentsniff.add_torrents_to_table(B, function () {
        $("loader-" + A).src = "/css/images/complete.gif";
        eCount++;
        $("searchstatus").setHTML("Searching " + (eCount + 1) + " of " + engines.length + ' engines&nbsp;&nbsp;<img src="/css/images/loader-engines.gif" />');
        if (eCount >= engines.length) {
            startSearch = $clear(periodical);
            $("searchstatus").setHTML("Search Complete&nbsp;&nbsp;");
			/* CPM start */
			/* setTimeout('searchComplete = 1;', 2000) */
			/* CPM end */
            setTimeout(function () {
                window.rtable_paginator.update_pages();
                new SortingTable("rtable", {
                    paginator: window.rtable_paginator
                })
            },
            100)
        } else {
            window.rtable_paginator.update_pages()
        }
    })
};
window.addEvent("domready", function (B) {
    focusQuery();
    window.torrentsniff = new TsTable("rtable");
    results = $("results");
    $("searchstatus").setHTML("Searching " + (eCount + 1) + " of " + engines.length + ' engines&nbsp;&nbsp;<img src="/css/images/loader-engines.gif" />');
    var A = function () {
        if (jsonObj[enCount] == null || jsonObj[enCount] == "") {
            if (enCount <= engines.length) {
                var C = engines[enCount];
                var D = new Json.Remote("/search.php?e=" + engines[enCount] + "&q=" + q, {
                    method: "get",
                    timeout: 9000,
                    onFailure: function () {
                        addTorrents(null, C)
                    },
                    onTimeout: function () {
                        addTorrents(null, C)
                    },
                    onSuccess: function (E) {
                        addTorrents(E, C);
                        E = null
                    }
                }).send()
            }
        } else {
            addTorrents(jsonObj[enCount], engines[enCount])
        }
        enCount++;
        if (enCount >= engines.length) {
            A = $clear(periodical)
        }
    };
    periodical = A.periodical(100)
});
function filter(A) {
    if (window.filter_changed == true) {
        $clear(window.delayed_filter)
    }
    window.filter_changed = true;
    window.delayed_filter = (function (C) {
        var D = 0,
        B = 0;
        if (C.value == null || C.value == "") {
            $("rtable").getElement("tbody").getElementsBySelector("tr, span").each(function (E) {
                if (E.getTag() != "tr") {
                    E.replaceWith(new Element("tr").adopt(E.getChildren()))
                }
            })
        } else {
            $("rtable").getElement("tbody").getElementsBySelector("tr, span").each(function (E) {
                if (E.getText().toLowerCase().indexOf(C.value.toLowerCase()) == -1) {
                    if (E.getTag() != "span") {
                        E.replaceWith(new Element("span").adopt(E.getChildren()))
                    }
                    B--
                } else {
                    if (E.getTag() != "tr") {
                        E.replaceWith(new Element("tr").adopt(E.getChildren()))
                    }
                    D++
                }
            });
            B = 0;
            D = 0
        }
        window.rtable_paginator.update_pages();
        SortingTable.stripe_table($$("table#rtable tbody tr"));
        window.filter_changed = false
    }).delay(350, this, A)
};

var Site = {

    start: function () {

        var mengines = $$('.engine');

        mengines.each(function (engine, i) {

            engine.addEvent('mouseover', function (event) {

                var disengine = engine.getElements('.disengine');

                disengine.setStyle('display', 'inline');

            });

            engine.addEvent('mouseout', function (event) {

                engine.getElements('.disengine').setStyle('display', 'none');

            });

        });

        var dislinks = $$('.disengine');

        dislinks.each(function (engine, i) {

            engine.addEvent('click', function (event) {

                var alt = engine.getProperty('alt');

                var disable = engine.getProperty('dis');

                if (disable) {

                    new Ajax("/settings.php?e=" + alt, {

                        method: 'get',

                        onSuccess: function (e) {

                            engine.removeProperty('dis');

                            // parent
                            $$("." + alt).removeClass('disabled');

                            engine.innerHTML = 'torrents';

                        }

                    }).request();

                }

                else

                {

                    new Ajax("/settings.php?e=" + alt + "&disable", {

                        method: 'get',

                        onSuccess: function (e) {

                            engine.setProperty('dis', 'true');

                            $$("." + alt).addClass('disabled');

                            engine.innerHTML = 'torrents';

                        }

                    }).request();

                }

            });

        });

    }

};

window.addEvent('load', Site.start);

