// This file combines the following JS calls into one call:
// http://www.logitech.com/javascript/v2/popup.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/events/jquery.ontextresize.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/events/jquery.onmousewheel.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/jquery.cookie.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/jquery.easing.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/jquery.flash.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/third-party/jquery.pngfix.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/schematic/jquery.sifr.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/schematic/jquery.formulate.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/schematic/jquery.shadow.js
// http://www.logitech.com/javascript/v2/cmn/lib/plugins/schematic/jquery.vmlcorners.js
// http://www.logitech.com/javascript/v2/cmn/global.js
function fieldClear(obj) {
    if (obj.Val) {
        if (obj.value == '') {
            obj.value = obj.Val;
            obj.Val = null;
            obj.first = null;
        }
        else {
            obj.Val = null;
        }
    } else if (!obj.first) {
        obj.Val = obj.value;
        obj.value = '';
        obj.first = 'true';
    }
}
function winpopup(url) {
    var newwindow = window.open(url, '3dspinner', 'height=500,width=650');
    if (window.focus) {
        newwindow.focus()
    }
}
function popUp(argURL, argWIDTH, argHEIGHT) {
    var winArg, popWin;
    if (!argWIDTH) argWIDTH = '500';
    if (!argHEIGHT) argHEIGHT = '500';
    winArgs = 'width=' + argWIDTH + ',height=' + argHEIGHT + ',titlebar=0,toolbar=0,location=0,menubar=0,';
    winArgs += 'scrollbars=0,resizable=1,channelmode=0,directories=0,status=0,screenX=20,screenY=20,top=20,left=20';
    popWin = window.open(argURL, '', winArgs, true);
}
function popOpen(id) {
    var topOffset = 1;
    setSize(topOffset);
    var overShade = document.getElementById(id);
    var topPad = pos + topOffset;
    overShade.style.height = (ph - topPad) + 'px';
    overShade.style.width = pw + 'px';
    overShade.style.paddingTop = topPad + 'px';
    overShade.style.display = 'block';
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        coverSelects(overShade);
    }
}
function popClose(id) {
    var fObj = document.getElementById(id);
    fObj.style.display = "";
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        document.getElementById("popup-cover").outerHTML = "";
    }
}
function popOpenFlash(id) {
    var topOffset = 1;
    setSize(topOffset);
    var overShade = document.getElementById(id);
    var topPad = pos + topOffset;
    overShade.style.height = (ph - topPad) + 'px';
    overShade.style.width = pw + 'px';
    overShade.style.paddingTop = topPad + 'px';
    overShade.style.display = 'block';
    fo.write(tempID);
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        coverSelects(overShade);
    }
}
function popCloseFlash(id) {
    var flashObj = document.getElementById(id);
    fooo.write(tempID);
    flashObj.style.display = "";
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        document.getElementById("popup-cover").outerHTML = "";
    }
}
function popOpenFlashHowto(id, flashid) {
    var topOffset = 1;
    setSize(topOffset);
    var overShade = document.getElementById(id);
    var topPad = pos + topOffset;
    overShade.style.height = (ph - topPad) + 'px';
    overShade.style.width = pw + 'px';
    overShade.style.paddingTop = topPad + 'px';
    overShade.style.display = 'block';
    window[flashid].write(flashid);
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        coverSelects(overShade);
    }
}
function popCloseFlashHowto(id, flashidd) {
    var flashObj = document.getElementById(id);
    fooo.write(flashidd);
    flashObj.style.display = "";
    if (document.all && !navigator.appVersion.match(/MSIE 7.0/) && !navigator.userAgent.match('Opera')) {
        document.getElementById("popup-cover").outerHTML = "";
    }
}
function setSize(topOffset) {
    if (window.pageYOffset != null) {
        pos = window.pageYOffset;
        ph = document.documentElement.scrollHeight;
        pw = document.documentElement.scrollWidth;
        if (document.body.scrollHeight > document.documentElement.scrollHeight) {
            ph = document.body.scrollHeight;
            pw = document.body.scrollWidth;
        }
    } else if (document.documentElement.scrollTop > document.body.scrollTop) {
        pos = document.documentElement.scrollTop;
        ph = document.documentElement.scrollHeight;
        pw = document.documentElement.scrollWidth;
        if (document.documentElement.clientHeight > document.documentElement.scrollHeight) {
            ph = document.documentElement.clientHeight;
        }
    } else if (document.body != null) {
        pos = document.body.scrollTop;
        ph = document.body.scrollHeight;
        pw = document.body.scrollWidth;
        if (document.documentElement.scrollHeight > document.body.scrollHeight) {
            ph = document.documentElement.scrollHeight;
        }
        ph = ph + pos + topOffset;
    }
}
function coverSelects(par) {
    var covHeight = document.body.scrollHeight + "px";
    var coverFrame = "<IFRAME id='popup-cover' style='";
    coverFrame = coverFrame + "height:" + covHeight + ";' ";
    coverFrame = coverFrame + "src='javascript:false;' frameBorder='0' scrolling='no'></IFRAME>";
    par.insertAdjacentHTML("afterEnd", coverFrame);
}

jQuery.onTextResize = (function ($) {
    $(document).ready(function () {
        var frame = $("<iframe src='#' />").attr("id", "frame-onTextResize" + Date.parse(new Date)).attr("frameborder", "0").css({
            width: "100em",
            height: "10px",
            position: "absolute",
            borderWidth: 0,
            top: "-5000px",
            left: "-5000px"
        }).appendTo("body");
        if ($.browser.msie) {
            frame.bind("resize", function () {
                $.onTextResize.trigger(frame[0].offsetWidth / 100);
            });
            $.onTextResize.emValue = (frame[0].offsetWidth / 100);
        } else {
            var doc = frame[0].contentWindow || frame[0].contentDocument || frame[0].document;
            doc = doc.document || doc;
            doc.open();
            doc.write('<div id="em" style="width:100em;height:10px;"></div>');
            doc.write('<script>window.onload = function(){var em = document.getElementById("em");var onTextResize = parent.jQuery.onTextResize;window.onresize = function(){if(onTextResize){onTextResize.trigger(em.offsetWidth / 100);}};parent.jQuery.onTextResize.emValue = (em.offsetWidth / 100);};</script>');
            doc.close();
        }
    });
    return {
        trigger: function (em) {
            if (this.emTimeout) {
                clearTimeout(this.emTimeout);
            }
            var oldValue = this.emValue;
            this.emValue = em;
            if (!oldValue || (oldValue == em)) {
                return;
            }
            var trigger = function () {
                $(document).trigger("textresize", [em]);
            };
            if ($.browser.safari) {
                trigger();
            } else {
                this.emTimeout = setTimeout(trigger, 350);
            }
        }
    };
})(jQuery);

(function ($) {
    $.fn.wheel = function (fn) {
        return this[fn ? "bind" : "trigger"]("wheel", fn);
    };
    $.event.special.wheel = {
        setup: function () {
            $.event.add(this, wheelEvents, wheelHandler, {});
        },
        teardown: function () {
            $.event.remove(this, wheelEvents, wheelHandler);
        }
    };
    var wheelEvents = !$.browser.mozilla ? "mousewheel" : "DOMMouseScroll" + ($.browser.version < "1.9" ? " mousemove" : "");
    var wheelHandler = function (event) {
        switch (event.type) {
        case "mousemove":
            return $.extend(event.data, {
                clientX: event.clientX,
                clientY: event.clientY,
                pageX: event.pageX,
                pageY: event.pageY
            });
        case "DOMMouseScroll":
            $.extend(event, event.data);
            event.delta = -event.detail / 3;
            break;
        case "mousewheel":
            event.delta = event.wheelDelta / 120;
            if ($.browser.opera) {
                event.delta *= -1;
            }
            break;
        }
        event.type = "wheel";
        return $.event.handle.call(this, event, event.delta);
    };
})(jQuery);

jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
    def: 'easeInOutQuad',
    swing: function (x, t, b, c, d) {
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t + b;
        }
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t * t * t * t + b;
        }
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t === 0) {
            return b;
        }
        if (t == d) {
            return b + c;
        }
        if ((t /= d / 2) < 1) {
            return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        }
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInRegular: function (x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutRegular: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutRegular: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t + b;
        }
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    }
});

(function ($) {
    var $self;
    var REPLACE_COUNT = 0;
    $self = jQuery.fn.flash = function (htmlOptions, pluginOptions, replace, update) {
        var block = replace || $self.replace;
        pluginOptions = $self.copy($self.pluginOptions, pluginOptions);
        if (!$self.hasFlash(pluginOptions.version)) {
            if (pluginOptions.expressInstall && $self.hasFlash(6, 0, 65)) {
                var expressInstallOptions = {
                    flashvars: {
                        MMredirectURL: location,
                        MMplayerType: 'PlugIn',
                        MMdoctitle: jQuery('title').text()
                    }
                };
            } else if (pluginOptions.update) {
                block = update || $self.update;
            } else {
                return this;
            }
        }
        htmlOptions = $self.copy($self.htmlOptions, expressInstallOptions, htmlOptions);
        return this.each(function () {
            block.call(this, $self.copy(htmlOptions));
        });
    };
    $self.copy = function () {
        var options = {},
        flashvars = {};
        for (var i = 0; i < arguments.length; i++) {
            var arg = arguments[i];
            if (arg == undefined) {
                continue;
            }
            jQuery.extend(options, arg);
            if (arg.flashvars == undefined) {
                continue;
            }
            jQuery.extend(flashvars, arg.flashvars);
        }
        options.flashvars = flashvars;
        return options;
    };
    $self.hasFlash = function () {
        if ((/hasFlash\=true/).test(location)) {
            return true;
        }
        if ((/hasFlash\=false/).test(location)) {
            return false;
        }
        var pv = $self.hasFlash.playerVersion().match(/\d+/g);
        var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($self.pluginOptions.version).match(/\d+/g);
        for (var i = 0; i < 3; i++) {
            pv[i] = parseInt(pv[i] || 0);
            rv[i] = parseInt(rv[i] || 0);
            if (pv[i] < rv[i]) {
                return false;
            }
            if (pv[i] > rv[i]) {
                return true;
            }
        }
        return true;
    };
    $self.hasFlash.playerVersion = function () {
        if (window.ActiveXObject) {
            try {
                var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
                try {
                    axo.AllowScriptAccess = 'always';
                } catch(e) {
                    return '6,0,0';
                }
                return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
            } catch(e) {}
        } else if (navigator.mimeTypes) {
            try {
                if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
                    return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
                }
            } catch(e) {}
        }
        return '0,0,0';
    };
    $self.htmlOptions = {
        height: 240,
        flashvars: {},
        pluginspage: 'http://www.adobe.com/go/getflashplayer',
        src: '#',
        type: 'application/x-shockwave-flash',
        width: 320
    };
    $self.pluginOptions = {
        expressInstall: false,
        update: true,
        version: '6.0.65'
    };
    $self.replace = function (htmlOptions) {
        var replaced = '<div class="alt">' + this.innerHTML + '</div>';
        if ($.browser.msie) {
            var spanToReplace = jQuery(this).addClass('flash-replaced').html('<span class="replace-me"></span>' + replaced).find(".replace-me")[0];
            if (spanToReplace) {
                spanToReplace.outerHTML = $self.transform(htmlOptions);
            }
        } else {
            this.innerHTML = replaced;
            jQuery(this).addClass('flash-replaced').prepend($self.transform(htmlOptions));
        }
    };
    $self.update = function (htmlOptions) {
        return;
        var url = String(location).split('?');
        url.splice(1, 0, '?hasFlash=true&');
        url = url.join('');
        var msg = '<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="' + url + '">Click here.</a></p>';
        this.innerHTML = '<span class="alt">' + this.innerHTML + '</span>';
        jQuery(this).addClass('flash-update').prepend(msg);
    };
    function toAttributeString() {
        var s = '';
        for (var key in this) {
            if (typeof this[key] != 'function') {
                s += key + '="' + this[key] + '" ';
            }
        }
        return s;
    }
    function toFlashvarsString() {
        var s = '';
        for (var key in this) {
            if (typeof this[key] != 'function') {
                s += key + '=' + encodeURIComponent(this[key]) + '&';
            }
        }
        return s.replace(/&$/, '');
    }
    $self.transform = function (htmlOptions) {
        htmlOptions.toString = toAttributeString;
        if (htmlOptions.flashvars) {
            htmlOptions.flashvars.toString = toFlashvarsString;
        }
        if ($.browser.msie) {
            var params = ieOptions(htmlOptions);
            var attrs = params.shift();
            var params = params[0];
            var attrStrings = [];
            for (var key in attrs) {
                attrStrings.push(key + '="' + attrs[key] + '"');
            }
            var obj = '<object ' + attrStrings.join(" ") + '>';
            var paramsStrings = [];
            for (var key in params) {
                paramsStrings.push('<param name="' + key + '" value="' + params[key] + '" />');
            }
            obj += paramsStrings.join(" ") + '</object>';
            return obj;
        } else {
            return '<embed ' + String(htmlOptions) + '/>';
        }
    };
    function ieOptions(options) {
        $.extend(options, {
            classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
        });
        var attrNames = ["width", "height", "id", "name", "class", "classid"];
        var ignore = ["pluginspage", "type", "toString"];
        var attrs = {};
        var params = {};
        for (var key in options) {
            if ($.inArray(key, ignore) == -1) {
                if ($.inArray(key, attrNames) > -1) {
                    attrs[key] = options[key];
                } else {
                    var realkey = key === "src" ? "movie" : key;
                    params[realkey] = options[key];
                }
            }
        }
        if (!attrs.id) {
            attrs.id = "jquery-flash-" + REPLACE_COUNT++;
        }
        return[attrs, params];
    };
    if (window.attachEvent) {
        window.attachEvent("onbeforeunload", function () {
            __flash__removeCallback = function (instance, name) {
                if (instance && name) {
                    instance[name] = null;
                }
            };
            __flash_unloadHandler = function () {};
            __flash_savedUnloadHandler = function () {};
        });
    }
})(jQuery);

(function ($) {
    $.fn.pngfix = function (options) {
        var elements = this;
        options = options || {};
        var settings = $.extend({
            imageFixSrc: false,
            sizingMethod: false,
            force: false
        },
        options);
        if (!$.browser.msie || ($.browser.version == 7 && !options.force)) {
            return elements;
        }
        function setFilter(el, path, mode) {
            var fs = el.attr("filters");
            var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";
            if (fs[alpha]) {
                fs[alpha].enabled = true;
                fs[alpha].src = path;
                fs[alpha].sizingMethod = mode;
            } else {
                el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');
            }
        }
        var body = $(document.body);
        return elements.filter(function () {
            return !$(this).hasClass("pnghide");
        }).each(function () {
            var el = $(this);
            if (/\.png/.test(el.attr("src"))) {
                el.wrap('<span class="pngfixed"></span>');
                var par = $('<span></span>').appendTo(el.parent());
                par.css({
                    "margin-top": el.css("margin-top"),
                    "margin-left": el.css("margin-left"),
                    "margin-bottom": el.css("margin-bottom"),
                    "margin-right": el.css("margin-right"),
                    height: el.height(),
                    width: el.width(),
                    display: "inline-block"
                });
                setFilter(par, el.attr("src"), "scale");
                el.addClass("pnghide");
            }
        });
    };
})(jQuery);

(function ($) {
    var WIN = $(window),
    DOC = $(document),
    BODY = $("body");
    var sIFR = (function () {
        var self = $.sIFR = {},
        ClassNames, PREFETCH_COOKIE, util, ua;
        ClassNames = {
            ACTIVE: "sIFR-active",
            REPLACED: "sIFR-replaced",
            IGNORE: "sIFR-ignore",
            ALT: "sIFR-alternate",
            CLASS: "sIFR-class",
            LAYOUT: "sIFR-layout",
            WRAP: "sIFR-flash-wrap",
            FLASH: "sIFR-flash",
            FIX_FOCUS: "sIFR-fixfocus",
            DUMMY: "sIFR-dummy"
        };
        ClassNames.IGNORE_CLASSES = [ClassNames.REPLACED, ClassNames.IGNORE, ClassNames.ALT];
        self.ClassNames = ClassNames;
        self.MIN_FLASH = "8.0.0";
        self.MIN_SIZE = 6;
        self.MAX_SIZE = 126;
        self.PADDING_BOTTOM = 5;
        self.VERSION = "436";
        self.isActive = false;
        self.isEnabled = true;
        self.fixHover = true;
        self.domains = [];
        self.forceWidth = true;
        self.fitExactly = false;
        self.forceTransform = true;
        self.replacements = {};
        self.elementCount = 0;
        self.isInitialized = false;
        function Util(sIFR) {
            function capitalize(str) {
                return str.toLocaleUpperCase();
            }
            this.textTransform = function (type, str) {
                switch (type) {
                case "uppercase":
                    return str.toLocaleUpperCase();
                case "lowercase":
                    return str.toLocaleLowerCase();
                case "capitalize":
                    return str.replace(/^\w|\s\w/g, capitalize);
                default:
                    return;
                }
                return str;
            };
            this.getCSS = function (css, property, remove, selector) {
                var value = null;
                selector = selector || ".sIFR-root";
                if (css && css[selector] && css[selector][property]) {
                    value = css[selector][property];
                    if (remove) {
                        delete css[selector][property];
                    }
                }
                return value;
            };
            this.toString = function (arg) {
                var css = [];
                for (var selector in arg) {
                    var rule = arg[selector];
                    if (rule == Object.prototype[selector]) {
                        continue;
                    }
                    css.push(selector, "{");
                    for (var property in rule) {
                        if (rule[property] == Object.prototype[property]) {
                            continue;
                        }
                        var value = rule[property];
                        if (Util.REMOVE[property]) {
                            value = parseInt(value, 10);
                        }
                        css.push(property, ":", value, ";");
                    }
                    css.push("}");
                }
                return css.join("");
            };
            this.getTypography = function (el, parent) {
                var typo = (parent || el).data("sIFR-typography");
                var node = (parent) ? el[0] : typo.node,
                fontSize = typo.fontSize,
                pixelFont = typo.pixelFont,
                ratios = typo.ratios,
                tuneHeight = typo.tuneHeight,
                leading = typo.leading,
                forceWidth = typo.forceWidth;
                var size, lines;
                var width = el.width();
                var forcedWidth = forceWidth ? width : "100%";
                if (!fontSize) {
                    var calculation = sIFR.calculate(node);
                    size = Math.min(sIFR.MAX_SIZE, Math.max(sIFR.MIN_SIZE, calculation.fontSize));
                    if (pixelFont) {
                        size = Math.max(8, 8 * Math.round(size / 8));
                    }
                    lines = calculation.lines;
                } else {
                    size = fontSize;
                    lines = 1;
                }
                var renderHeight = Math.round(lines * sIFR.getRatio(size, ratios) * size) + sIFR.PADDING_BOTTOM + tuneHeight;
                if (lines > 1 && leading) {
                    renderHeight += Math.round((lines - 1) * leading);
                }
                return {
                    size: size,
                    lines: lines,
                    renderHeight: renderHeight,
                    width: width,
                    forcedWidth: forcedWidth
                };
            };
            this.escape = function (str) {
                return escape(str).replace(/\+/g, "%2B");
            };
            this.domain = function () {
                var domain = "";
                try {
                    domain = document.domain;
                } catch(e) {}
                return domain;
            };
            this.domainMatches = function (domain, match) {
                if (match == "*" || match == domain) {
                    return true;
                }
                var wildcard = match.lastIndexOf("*");
                if (wildcard > -1) {
                    match = match.substr(wildcard + 1);
                    var matchPosition = domain.lastIndexOf(match);
                    if (matchPosition > -1 && (matchPosition + match.length) == domain.length) {
                        return true;
                    }
                }
                return false;
            };
            this.getComputedStyle = function (node, property) {
                var result;
                if (document.defaultView && document.defaultView.getComputedStyle) {
                    var style = document.defaultView.getComputedStyle(node, null);
                    result = style ? style[property] : null;
                } else { if (node.currentStyle) {
                        result = node.currentStyle[property];
                    }
                }
                return result || '';
            };
            this.parseVersion = function (version) {
                return version.replace(/\,/g, ".").replace(/(^|\D)(\d+)(?=\D|$)/g, function (version, nonDigit, digits) {
                    version = nonDigit;
                    for (var i = 4 - digits.length; i >= 0; i--) {
                        version += '0';
                    }
                    return version + digits;
                });
            };
        }
        Util.REMOVE = {
            leading: true,
            "margin-left": true,
            "margin-right": true,
            "text-indent": true
        };
        Util.SINGLE_WHITESPACE = " ";
        util = self.util = new Util(self);
        self.activate = function () {
            if (!this.isEnabled || this.isActive || !isValidDomain() || isFile()) {
                return;
            }
            this.isActive = true;
            this.setFlashClass();
            self.isInitialized = true;
        };
        self.setFlashClass = function () {
            if (this.hasFlashClassSet) {
                return;
            }
            BODY.addClass(ClassNames.ACTIVE);
            this.hasFlashClassSet = true;
        };
        function isValidDomain() {
            if (self.domains.length === 0) {
                return true;
            }
            var domain = util.domain();
            for (var i = 0; i < self.domains.length; i++) {
                if (util.domainMatches(domain, self.domains[i])) {
                    return true;
                }
            }
            return false;
        }
        function isFile() {
            if (document.location.protocol == 'file:') {
                return true;
            }
            return false;
        }
        function getRatio(size, ratios) {
            for (var i = 0; i < ratios.length; i += 2) {
                if (size <= ratios[i]) {
                    return ratios[i + 1];
                }
            }
            return ratios[ratios.length - 1] || 1;
        }
        self.getRatio = getRatio;
        function getNewDimensions(element, parent) {
            element.removeClass(ClassNames.ALT);
            parent.removeClass(ClassNames.REPLACED);
            var typo = util.getTypography(element, parent),
            height = typo.renderHeight,
            width = typo.width;
            element.addClass(ClassNames.ALT);
            parent.addClass(ClassNames.REPLACED);
            return {
                width: width,
                height: height
            };
        }
        function calculate(node) {
            var el = $(node);
            var fontSize = sIFR.util.getComputedStyle(node, "fontSize");
            var deduce = fontSize.indexOf('px') == -1;
            var html = el.html();
            if (deduce) {
                el.html("X");
            }
            var props = ["padding-top", "padding-bottom", "border-top", "border-bottom", "line-height", "display"];
            $.each(props, function (e, prop) {
                if (prop != "line-height" && prop != "display") {
                    el.css(prop, 0);
                }
            });
            el.css("line-height", "2em");
            el.css("display", "block");
            fontSize = deduce ? node.offsetHeight / 2 : parseInt(fontSize, 10);
            if (deduce) {
                el.html(html);
            }
            var lines = Math.round(node.offsetHeight / (2 * fontSize));
            $.each(props, function (e, prop) {
                el.css(prop, "");
            });
            if (isNaN(lines) || !isFinite(lines) || lines === 0) {
                lines = 1;
            }
            return {
                fontSize: fontSize,
                lines: lines
            };
        }
        self.calculate = calculate;
        function parseContent(source, textTransform) {
            var node = $(source),
            link = node.find("a"),
            primaryLink = {},
            clone,
            html;
            if (link.eq(0)) {
                link = link.eq(0);
                primaryLink = {
                    href: link.attr("href"),
                    target: link.attr("target")
                };
            }
            clone = node.clone();
            clone.find(":not(a)").each(function () {
                var not = $(this);
                not.replaceWith(not.text());
            });
            html = clone.html();
            clone.remove();
            return {
                text: html,
                primaryLink: primaryLink
            };
        }
        self.parseContent = parseContent;
        return self;
    })();
    jQuery.fn.sifr = function (kwargs) {
        if (!sIFR.isInitialized) {
            sIFR.activate();
        }
        var flash = $.fn.flash;
        var parse = sIFR.util.parseVersion;
        if (!flash || (parse(flash.hasFlash.playerVersion()) < parse(sIFR.MIN_FLASH))) {
            return this;
        }
        return this.each(function () {
            var node = this,
            currKW = kwargs,
            el = $(node),
            cache = el.data("kwargs"),
            ClassNames = sIFR.ClassNames,
            getCSS = sIFR.util.getCSS,
            src,
            ratios = [];
            if (node == document) {
                if (currKW && currKW.defaultFont) {
                    sIFR.defaultFont = currKW.defaultFont;
                }
                if (!currKW) {
                    var func = (currKW === false) ? "unsifr" : "sifr";
                    var replacements = sIFR.replacements,
                    backup = {},
                    key;
                    for (key in replacements) {
                        backup[key] = replacements[key];
                        replacements[key].element[func]();
                    }
                    sIFR.replacements = backup;
                }
                return;
            }
            if (currKW === false) {
                if (el.hasClass(ClassNames.REPLACED)) {
                    var removeID = el.find("." + ClassNames.FLASH).attr("id");
                    sIFR.replacements[removeID] = null;
                    delete sIFR.replacements[removeID];
                    el.removeClass(ClassNames.REPLACED).html(el.find("." + ClassNames.ALT).html()).css("min-height", "");
                }
                return;
            }
            if (el.hasClass(ClassNames.REPLACED)) {
                return;
            } else if (!currKW && cache) {
                currKW = cache;
            } else if (!cache) {
                el.data("kwargs", currKW);
            }
            if (sIFR.onReplacementStart) {
                sIFR.onReplacementStart(currKW);
            }
            currKW = currKW || {};
            if (!currKW.font) {
                if (sIFR.defaultFont) {
                    currKW.font = sIFR.defaultFont;
                } else {
                    return;
                }
            }
            if (typeof currKW.font === "string") {
                src = currKW.font;
            } else if (typeof currKW.font === "object") {
                src = currKW.font.src;
                ratios = currKW.font.ratios || [];
            }
            var css = currKW.css,
            cssText = sIFR.util.toString(css),
            forceSingleLine = (currKW.forceSingleLine === true),
            preventWrap = (currKW.preventWrap === true) && !forceSingleLine,
            fitExactly = forceSingleLine || (currKW.fitExactly === null ? sIFR.fitExactly : currKW.fitExactly) === true,
            forceWidth = fitExactly || (currKW.forceWidth === null ? sIFR.forceWidth : currKW.forceWidth) === true,
            pixelFont = currKW.pixelFont === true,
            tuneHeight = parseInt(currKW.tuneHeight) || 0,
            events = !!currKW.onRelease || !!currKW.onRollOver || !!currKW.onRollOut,
            fixFlash = $.browser.ie && (flash.hasFlash.playerVersion() < parse("9.0.115")),
            fontSize = getCSS(css, "font-size", true) || "0",
            backgroundColor = getCSS(css, "background-color", true) || "#FFFFFF",
            kerning = getCSS(css, "kerning", true) || "",
            opacity = getCSS(css, "opacity", true) || "100",
            cursor = getCSS(css, "cursor", true) || "default",
            leading = parseInt(getCSS(css, "leading")) || 0,
            gridFitType = currKW.gridFitType || (getCSS(css, "text-align") == "right") ? "subpixel" : "pixel",
            textTransform = (sIFR.forceTransform === false) ? "none" : getCSS(css, "text-transform", true) || "none",
            wmode = currKW.wmode || 'transparent';
            if (fitExactly) {
                getCSS(css, "text-align", true);
            }
            fontSize = /^\d+(px)?$/.test(fontSize) ? parseInt(fontSize) : 0;
            opacity = (parseFloat(opacity) < 1) ? (100 * parseFloat(opacity)) : opacity;
            el.data("sIFR-typography", {
                node: node,
                fontSize: fontSize,
                pixelFont: pixelFont,
                ratios: ratios,
                tuneHeight: tuneHeight,
                leading: leading,
                forceWidth: forceWidth
            });
            var props = sIFR.util.getTypography(el),
            size = props.size,
            lines = props.lines,
            renderHeight = props.renderHeight,
            width = props.width,
            forcedWidth = props.forcedWidth,
            content = sIFR.parseContent(node, textTransform),
            id = "sIFR_replacement_" + (sIFR.elementCount++),
            flashvars,
            alternate,
            dummy;
            flashvars = {
                "id": id,
                "content": sIFR.util.escape(content.text),
                "width": width,
                "renderheight": renderHeight,
                "link": sIFR.util.escape(content.primaryLink.href || ""),
                "target": sIFR.util.escape(content.primaryLink.target || ""),
                "size": size,
                "css": sIFR.util.escape(cssText),
                "cursor": cursor,
                "tunewidth": (currKW.tuneWidth || 0),
                "tuneheight": tuneHeight,
                "offsetleft": (currKW.offsetLeft || ""),
                "offsettop": (currKW.offsetTop || ""),
                "fitexactly": fitExactly,
                "preventwrap": preventWrap,
                "forcesingleline": forceSingleLine,
                "antialiastype": (currKW.antiAliasType || ""),
                "thickness": (currKW.thickness || ""),
                "sharpness": (currKW.sharpness || ""),
                "kerning": kerning,
                "gridfittype": gridFitType,
                "opacity": opacity,
                "blendmode": (currKW.blendMode || ""),
                "selectable": true,
                "fixhover": (sIFR.fixHover === true),
                "events": events,
                "delayrun": fixFlash,
                "version": sIFR.VERSION
            };
            alternate = $('<span></span>').addClass(ClassNames.ALT).html(el.html());
            el.html(alternate.attr("id", id + "_alternate")).addClass(ClassNames.REPLACED);
            el.css("min-height", renderHeight);
            dummy = $('<span></span>').prependTo(el);
            dummy.flash({
                "name": id,
                "flashvars": flashvars,
                "id": id,
                "class": "sIFR-flash",
                "src": src,
                "width": forcedWidth,
                "height": renderHeight,
                "wmode": wmode,
                "allowScriptAccess": "always"
            }).addClass(ClassNames.WRAP);
            sIFR.replacements[id] = sIFR.replacements[id] || {
                element: el,
                alternate: alternate,
                flash: document.getElementById(id)
            };
        });
    };
    jQuery.fn.unsifr = function () {
        return this.sifr(false);
    };
})(jQuery);

(function ($) {
    var $settings, $prefix = "ui-formulate",
    $hover = $prefix + "-hover",
    $active = $prefix + "-active",
    $redraw = $prefix + "-redraw",
    $current = $prefix + "-current",
    $scroller = $prefix + "-scroller",
    $selected = $prefix + "-selected",
    $disabled = $prefix + "-disabled",
    $listwrap = $prefix + "-list-wrap",
    $scrollable = $prefix + "-scrollable",
    $noformulate = $prefix + "-ignore",
    $previousEvent, $winHeight, $winTop, $customWrapper, $keyDownElement, $keyDownTarget, $winLeft;
    var HTML = {
        WRAPPER: '<div class="' + $prefix + '"><div class="' + $prefix + '-wrap"></div></div>',
        SUBMIT: '<span class="' + $prefix + '-value"></span>',
        LIST: {
            WRAP: '<div class="' + $listwrap + '"><ul></ul></div>',
            ITEM: '<li><a href="#"></a></li>',
            VALUE: '<span class="' + $current + '"></span>'
        },
        SCROLL: {
            UP: '<span class="' + $scroller + ' ' + $prefix + '-up" rel="up"></span>',
            DOWN: '<span class="' + $scroller + ' ' + $prefix + '-down" rel="down"></span>'
        }
    };
    var CACHE = [];
    var WIN = $(window),
    DOC = $(document);
    var parseNum = window.parseFloat;
    var isIE6 = (function () {
        return $.browser.msie && $.browser.version <= 6;
    })();
    var inlineBlock = (function () {
        if (typeof $.support.inlineBlock !== "undefined") {
            return $.support.inlineBlock;
        }
        var dummy = $('<div></div>').css("display", "inline-block");
        $.extend($.support, {
            inlineBlock: (dummy.css("display") === "inline-block")
        });
        dummy.remove();
        return $.support.inlineBlock;
    })();
    var textOverflow = (function () {
        if (typeof $.support.textOverflow !== "undefined") {
            return $.support.textOverflow;
        }
        var dummy = $('<div></div>').css("text-overflow", "ellipsis");
        $.extend($.support, {
            textOverflow: (dummy.css("text-overflow") === "ellipsis") && !$.browser.msie
        });
        dummy.remove();
        return $.support.textOverflow;
    })();
    var overrideChecked = (function () {
        $.extend($.expr[":"], {
            checked: function (elem) {
                var el = $(elem);
                var value = (elem.checked === true);
                return !el.data("eventTriggered") ? value : !value;
            }
        });
    })();
    var triggeredEventFix = function (e) {
        e.stopPropagation();
        var el = $(this);
        el.data("eventTriggered", !e.originalEvent);
        if (el.is(":radio") && (this.checked === true)) {
            el.data("eventTriggered", !el.data("eventTriggered"));
        }
        window.setTimeout(function () {
            el.removeData("eventTriggered");
        },
        10);
    };
    var fadeOut = function (el, timer, callback) {
        if ($.browser.msie) {
            callback();
        } else {
            el.fadeOut(timer, callback);
        }
    };
    var scrollIntoView = function (el, list) {
        var posTop = el.position().top,
        ul = list.find("ul"),
        ulTop = parseNum(ul.css("top")),
        offsetTop = (posTop + ulTop),
        trueHeight = list.height() - ($settings.windowPadding * 6);
        if (offsetTop < 0) {
            list.trigger("wheel", "down", offsetTop);
        } else if (trueHeight < offsetTop) {
            list.trigger("wheel", "up", el.height());
        }
    };
    var selectOption = function (parent, selected, callback) {
        window.setTimeout(function () {
            selected.addClass($prefix + "-interstitial");
            window.setTimeout(function () {
                selected.removeClass($prefix + "-interstitial");
                fadeOut(parent, $settings.fadeOutTimer, callback);
            },
            70);
        },
        70);
    };
    var repositionList = function (items, selected, list, height) {
        var i = items.index(list.find("." + $selected));
        list.css("top", -(i * height));
    };
    var expandList = function (dir, list, ul) {
        var target = list;
        if ($customWrapper) {
            target = list.find("." + $listwrap);
        }
        var el = $(this),
        up = (dir == "up"),
        padding = $settings.windowPadding,
        listTop = parseNum(list.css("top")),
        listHeight = target.height(),
        ulTop = parseNum(ul.css("top")),
        ulHeight = ul.height(),
        absTop = list.parent().offset().top - $winTop - padding,
        offsetHeight = ($winHeight - (padding * 5)),
        topDiff = (offsetHeight - listHeight);
        if (offsetHeight > ulHeight) {
            list.data("fitInPage", true);
            offsetHeight = (ulHeight);
            if (!up) {
                absTop = (ulHeight - listHeight) - listTop;
            } else {
                topDiff = (offsetHeight - listHeight);
            }
        }
        list.css("top", listTop);
        list.animate({
            top: -(absTop),
            height: offsetHeight
        },
        {
            duration: (absTop * 1.5),
            easing: "easeInQuad",
            step: $settings.onexpand,
            complete: function () {
                list.data("expanded", true);
                if (!list.data("fitInPage")) {
                    list.find("." + (up ? ($prefix + "-down") : ($prefix + "-up"))).show();
                }
                el.trigger("mouseover");
            }
        });
        if (up) {
            ul.animate({
                top: ulTop + topDiff
            },
            {
                duration: (absTop * 1.5),
                easing: "easeInQuad"
            });
        }
    };
    var generateButtons = function (list, ul) {
        var target = list;
        if ($customWrapper) {
            target = list.find("." + $listwrap);
        }
        var up = $(HTML.SCROLL.UP),
        down = $(HTML.SCROLL.DOWN);
        target.append(up, down);
        var buttons = target.find("." + $scroller),
        currTop = parseNum(ul.css("top")),
        globalTimer = (500 * (target.find("li").length / 10));
        var animate = function (dir, to, timer) {
            ul.animate({
                top: to
            },
            {
                duration: timer,
                easing: "easeOutQuad",
                complete: function () {
                    target.find("." + $prefix + "-" + dir).hide();
                }
            });
        };
        buttons.mouseover(function () {
            var el = $(this),
            dir = el.attr("rel"),
            listHeight = target.height(),
            ulTop = parseNum(ul.css("top")),
            ulHeight = ul.height();
            if (!list.data("expanded")) {
                expandList.call(this, dir, list, ul);
            } else { if (!list.data("fitInPage")) {
                    buttons.not(this).show();
                }
                var diff, percent, time, to;
                if (dir == "down") {
                    to = ulHeight - listHeight;
                    diff = (ulTop + to);
                    to = -(to);
                } else {
                    to = 0;
                    diff = -(ulTop);
                }
                percent = (diff / ulHeight);
                time = globalTimer * percent;
                time = (time < 250) ? 250 : time;
                animate(dir, to, time);
            }
        });
        buttons.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
        });
        buttons.mouseout(function () {
            list.stop();
            ul.stop();
        });
        return {
            up: up,
            down: down
        };
    };
    var scrollEvent = function (list, ul) {
        list.bind("wheel", function (e, delta, value) {
            if (list.hasClass($scrollable)) {
                e.preventDefault();
                var increment, dir;
                if (typeof delta == "string") {
                    increment = (delta == "down") ? 40 : -40;
                    dir = delta;
                } else {
                    increment = (delta > 0) ? 40 : -40;
                    dir = (delta > 0) ? "down" : "up";
                }
                var listTop = parseNum(list.css("top")),
                listHeight = list.height(),
                ulTop = parseNum(ul.css("top")),
                ulHeight = ul.height(),
                maxHeight = -(ulHeight - listHeight);
                if (!list.data("expanded")) {
                    var inactive = list.find("." + $scroller + ":hidden"),
                    to = (inactive.is("." + $prefix + "-up")) ? "up" : "down";
                    if (!inactive[0]) {
                        list.data("expanded", true);
                    } else if ((dir === to)) {
                        var padding = $settings.windowPadding,
                        up = (dir === "up"),
                        top = Math.round(listTop),
                        absTop = Math.round(-(list.parent().offset().top - $winTop - padding));
                        var offsetHeight = ($winTop - (padding * 5));
                        if (ulHeight < offsetHeight) {
                            list.data("fitInPage", true);
                            offsetHeight = ulHeight;
                            absTop = absTop + ($winTop - ulHeight) - (padding * 5);
                        }
                        if (value) {
                            increment = value;
                        }
                        if (!up) {
                            offsetHeight = $winHeight - (padding * 5);
                        }
                        if (up) {
                            increment = ((top + increment) < absTop) ? (absTop - top) : increment;
                        } else {
                            increment = ((listHeight + increment) > offsetHeight) ? (offsetHeight - listHeight) : increment;
                        }
                        if ((top > absTop) && up) {
                            list.css({
                                top: top + increment,
                                height: listHeight - increment
                            });
                            if (parseNum(list.css("top")) == absTop) {
                                list.data("expanded", true);
                            }
                        } else if (listHeight < offsetHeight) {
                            ul.css("top", parseNum(ul.css("top")) + increment);
                            list.height(listHeight + increment);
                            if (list.height() == offsetHeight) {
                                list.data("expanded", true);
                            }
                        }
                    }
                } else {
                    var buttons = list.find("." + $scroller);
                    value = value || (ulTop + increment);
                    if (!list.data("fitInPage")) {
                        buttons.show();
                    }
                    if (value >= 0) {
                        value = 0;
                        buttons.filter("." + $prefix + "-up").hide();
                    } else if (value <= maxHeight) {
                        value = maxHeight;
                        buttons.filter("." + $prefix + "-down").hide();
                    }
                    ul.css("top", value);
                }
            }
        });
    };
    var resetDimensions = function (list, ul) {
        $.each([list, ul], function () {
            this.css({
                height: "",
                top: "0"
            });
        });
    };
    var makeScrollable = function (items, list, ul, height) {
        var padding = $settings.windowPadding,
        minHeight = (height * 5);
        list.mousedown(function (e) {
            var target = list,
            wrap = list;
            if ($customWrapper) {
                target = list.find("." + $listwrap);
            }
            var up, down;
            if (!wrap.hasClass($redraw)) {
                var wrapper = list.parent();
                height = wrapper.height();
                repositionList(items, list.find("." + $selected), list, height);
            }
            wrap.addClass($redraw);
            var top, left, trueHeight;
            if (list.height() > ($winHeight / 3)) {
                if (!list.hasClass($scrollable)) {
                    if (list.offset().top < $winTop) {
                        list.addClass($scrollable);
                        var offset = parseNum(list.css("top"));
                        list.css("top", 0);
                        list.css("top", -(list.offset().top - $winTop - padding));
                        top = (offset - parseNum(list.css("top")));
                        ul.css("top", top);
                        trueHeight = top + ul.height();
                        if (trueHeight < minHeight) {
                            var diff = (minHeight - trueHeight);
                            ul.css("top", top + diff);
                            list.css("top", parseNum(list.css("top")) - diff);
                            trueHeight = minHeight;
                        }
                        list.height(trueHeight);
                        list.data("showUpArrow", true);
                    }
                    var offsetTop = list.offset().top,
                    topDiff = (offsetTop - $winTop),
                    offsetHeight = list.height() + topDiff;
                    if (offsetHeight > $winHeight) {
                        list.addClass($scrollable);
                        trueHeight = $winHeight - topDiff - (padding * 4);
                        trueHeight = (trueHeight < minHeight) ? minHeight : trueHeight;
                        list.height(trueHeight);
                        list.data("showDownArrow", true);
                    }
                }
                if (list.hasClass($scrollable) && !list.data("animating")) {
                    up = list.find("." + $prefix + "-up");
                    down = list.find("." + $prefix + "-down");
                    if (!up[0] && !down[0]) {
                        var buttons = generateButtons(list, ul);
                        scrollEvent(list, ul);
                        up = buttons.up;
                        down = buttons.down;
                    }
                    top = parseNum(ul.css("top"));
                    if (!list.data("showUpArrow") && !top) {
                        up.hide();
                    } else {
                        up.show();
                    }
                    if (!list.data("showDownArrow") && top) {
                        down.hide();
                    } else {
                        down.show();
                    }
                }
            }
            top = list.offset().top;
            left = list.offset().left + list.get(0).offsetWidth;
            $winLeft = WIN.width();
            var bottom = top + list.height(),
            scrollBottom = $winTop + $winHeight,
            trueTop;
            if (top < $winTop) {
                trueTop = ($winTop - top) + parseNum(list.css("top"));
                list.animate({
                    "top": trueTop + padding
                },
                350);
            } else if (bottom > scrollBottom) {
                trueTop = (scrollBottom - bottom) + parseNum(list.css("top"));
                list.animate({
                    "top": trueTop - (padding * 4)
                },
                350);
            }
            if (left > $winLeft) {
                list.animate({
                    "left": -((left - $winLeft) + padding)
                },
                350);
            }
        });
        if (!DOC.data("mouseWheel")) {
            DOC.bind("wheel", function (e) {
                var isActive = $("." + $prefix + "-select." + $active);
                if (isActive[0]) {
                    e.preventDefault();
                }
            });
            DOC.data("mouseWheel", true);
        }
    };
    var checkForCustomWrapper = function (list) {
        var up = list.parent();
        if (!up.hasClass($prefix + "-wrap")) {
            while (!up.hasClass($prefix + "-wrap")) {
                up = up.parent();
            }
            $customWrapper = up.children().eq(0);
        }
        return $customWrapper || list;
    };
    var hideActiveSelects = function (parent) {
        var active = $("." + $prefix + "-select" + "." + $prefix + "-focus");
        if (active[0] && (!parent || (parent && !parent.hasClass($active)))) {
            active.find("select").blur();
        }
    };
    var checkIfDisabled = function (parent) {
        return parent.hasClass($disabled);
    };
    var truncateIfNecessary = function (select, selected, force) {
        var text = selected.text();
        var clone, remove = 12;
        if (!$.support.textOverflow && (select.css("display") == "block")) {
            var parent = select.parent();
            var sWidth = function () {
                return select.get(0).offsetWidth;
            } ();
            clone = selected.clone(true).css({
                "width": "",
                "min-width": "0",
                "display": "inline"
            }).insertAfter(select);
            var padding = parseFloat(clone.css("padding-left")) + parseFloat(clone.css("padding-right"));
            var cWidth = function () {
                return clone.width() + padding;
            } ();
            if ((cWidth > (sWidth - remove)) || force) {
                if (!force) {
                    var array = text.split(""),
                    i = 0;
                    clone.text("");
                    while (clone.width() < sWidth) {
                        clone.text(clone.text() + array[i]);
                        i++;
                    }
                    array = clone.text().split("");
                    array.splice(array.length - remove, array.length, "\u2026");
                    selected.text(array.join(""));
                }
                var value = "";
                var ul = parent.find("ul");
                if ($.browser.msie) {
                    value = (!isIE6) ? "100%" : ul.width();
                }
                var list = ul.closest("." + $listwrap);
                var wrap = checkForCustomWrapper(ul);
                if (isIE6) {
                    wrap.width(value);
                }
                list.width(value);
            }
            clone.remove();
        }
    };
    var setIEWidth = function (parent, current, list) {
        var parentWidth = parent.get(0).offsetWidth,
        currentWidth = current.get(0).offsetWidth;
        if (currentWidth > parentWidth) {
            parent.width(currentWidth);
            parent.find("roundrect").width(currentWidth - 2);
            var ul = parent.find("ul");
            var wrap = list || checkForCustomWrapper(ul);
            list = ul.closest("." + $listwrap);
            var ulWidth = ul.width();
            currentWidth = (ulWidth > currentWidth) ? ulWidth : currentWidth;
            if (isIE6) {
                wrap.width(currentWidth);
            }
            list.width(currentWidth);
        }
    };
    var elements = {
        wrap: function (el) {
            var clone = el.clone(true);
            var tag = clone[0].nodeName.toLowerCase();
            var name = $prefix + "-" + ((tag === "input") ? clone.attr("type") : tag);
            clone.wrap(HTML.WRAPPER).parent().parent().addClass(name).addClass(clone.attr("class"));
            return clone;
        },
        disabled: function (el) {
            var wrapper = el.parent(),
            parent = wrapper.parent();
            if (el.attr("disabled")) {
                parent.addClass($disabled);
            }
        },
        style: function (el, o) {
            var height = el[0].offsetHeight,
            wrapper = el.parent(),
            parent = wrapper.parent();
            height = ($settings.minHeight > height) ? $settings.minHeight : height;
            if (!parent.data("styled")) {
                var props = ["margin-left", "margin-top", "margin-right", "margin-bottom", "float"];
                $.each(props, function (i, prop) {
                    parent.css(prop, o.css(prop));
                    el.css(prop, (prop == "float") ? "none" : 0);
                });
                if (el.css("display") == "block") {
                    parent.css("display", "block");
                    parent.css("width", el.data("originalWidth") || el.width());
                }
                el.addClass($prefix + "-hide");
                parent.data("styled", true);
            }
            wrapper.css("line-height", height + "px");
        },
        accessibility: function (el, o) {
            var keyDownEvent = function (e) {
                if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) {
                    return true;
                }
                e.preventDefault();
                if (WIN.data("keytime")) {
                    window.clearTimeout(WIN.data("keytime"));
                    WIN.removeData("keytime");
                }
                WIN.data("keydown", true);
                $previousEvent = e.type;
                var el = $keyDownElement,
                parent = el.parent().parent(),
                list = parent.find("." + $listwrap),
                hover = list.find("." + $hover),
                name = $keyDownTarget,
                newEl;
                if (!hover.get(0)) {
                    hover = list.find("." + $selected);
                }
                list = checkForCustomWrapper(list);
                switch (e.which) {
                case 9:
                    parent.removeClass($active);
                    el.blur();
                    break;
                case 13:
                    hover.trigger("mousedown");
                    list.trigger("mousedown");
                    break;
                case 27:
                    if (name == "select") {
                        fadeOut(list, 150, function () {
                            parent.removeClass($active);
                            list.show();
                            hover.removeClass($hover);
                        });
                    }
                    break;
                case 32:
                    if (name == "select") {
                        if (parent.hasClass($active)) {
                            hover.trigger("mousedown");
                        } else {
                            parent.addClass($active);
                        }
                        list.trigger("mousedown");
                    }
                    break;
                case 38:
                case 40:
                    if (name == "select") {
                        if (parent.hasClass($active)) {
                            newEl = (e.which == 38) ? hover.prev() : hover.next();
                            if (newEl[0]) {
                                hover.removeClass($hover);
                                newEl.addClass($hover);
                                if (list.hasClass($scrollable)) {
                                    scrollIntoView(newEl, list);
                                }
                            }
                        } else {
                            hover.trigger("mousedown");
                            list.trigger("mousedown");
                        }
                    }
                    break;
                default:
                    break;
                }
            };
            var keyPressEvent = function (e) {
                if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) {
                    return true;
                }
                e.preventDefault();
                if ($previousEvent == e.type) {
                    e.which = e.which || e.keyCode || e.charCode;
                    keyDownEvent.call(this, e);
                }
                $previousEvent = e.type;
            };
            var keyUpEvent = function (e) {
                WIN.data("keytime", window.setTimeout(function () {
                    WIN.removeData("keydown");
                },
                250));
            };
            var mouseDownEvent = function (e) {
                var target = $(e.target),
                parent = target.parents().andSelf().filter("." + $prefix);
                if (!parent[0]) {
                    $keyDownElement.blur();
                    $(this).unbind("mousedown", mouseDownEvent);
                }
            };
            var label = o.closest("label");
            if (label.get(0)) {
                var evt = function (e) {
                    var el = $(this),
                    wrap = "." + $prefix;
                    e.preventDefault();
                    if (!$(e.target).closest(wrap)[0]) {
                        el.find(wrap).trigger(e.type);
                    }
                };
                label.click(evt);
                label.mousedown(evt);
                label.mouseout(evt);
            }
            el.focus(function (e) {
                e.stopPropagation();
                var el = $(this),
                name = (el.is("input")) ? el.attr("type") : el[0].tagName.toLowerCase();
                switch (name) {
                case "select":
                case "radio":
                case "checkbox":
                    $keyDownElement = el;
                    $keyDownTarget = name;
                    if (!DOC.data("eventsBound")) {
                        DOC.keydown(keyDownEvent).keyup(keyUpEvent).keypress(keyPressEvent).mousedown(mouseDownEvent);
                    }
                    DOC.data("eventsBound", true);
                    break;
                default:
                    break;
                }
                if (name !== "select") {
                    hideActiveSelects();
                }
                el.parent().parent().addClass($prefix + "-focus");
            });
            el.blur(function (e) {
                e.stopPropagation();
                var el = $(this),
                wrapper = el.parent(),
                parent = wrapper.parent(),
                name = (el.is("input")) ? el.attr("type") : el[0].tagName.toLowerCase();
                switch (name) {
                case "select":
                    DOC.unbind("keydown", keyDownEvent).unbind("keyup", keyUpEvent).unbind("keypress", keyPressEvent);
                    DOC.removeData("eventsBound");
                    var list = checkForCustomWrapper(parent.find("." + $listwrap));
                    var datas = ["expanded", "showUpArrow", "showDownArrow", "fitInPage"];
                    $.each(datas, function () {
                        list.removeData(this);
                    });
                    $.each([list, list.find("ul")], function () {
                        this.css({
                            top: "0",
                            left: "0",
                            height: ""
                        });
                    });
                    list.find("." + $hover).removeClass($hover);
                    list.find("." + $scroller).css("display", "");
                    list.removeClass($scrollable).removeClass($redraw);
                    list.show();
                    break;
                case "radio":
                case "checkbox":
                    DOC.unbind("keydown", keyDownEvent).unbind("keyup", keyUpEvent).unbind("keypress", keyPressEvent);
                    break;
                default:
                    break;
                }
                parent.removeClass($active).removeClass($prefix + "-focus");
            });
        },
        checks: function (el) {
            var wrapper = el.parent(),
            parent = wrapper.parent();
            var type = el.attr("type");
            if (el.is(":checked")) {
                parent.addClass($prefix + "-" + type + "-checked");
            }
            parent.mousedown(function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                if (el.is(":checked")) {
                    parent.addClass($prefix + "-" + type + "-active-checked");
                } else {
                    parent.addClass($prefix + "-" + type + "-active");
                }
                hideActiveSelects();
            });
            parent.mouseout(function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                parent.removeClass($prefix + "-" + type + "-active").removeClass($prefix + "-" + type + "-active-checked");
            });
            parent.click(function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                el.click();
            });
            el.click(triggeredEventFix);
            el.click(function (e) {
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                var checked = el.is(":checked");
                if ((type == "radio") && el.attr("name")) {
                    var els = el.closest("form").find("input[type=" + type + "][name=" + el.attr("name") + "]").not(el);
                    els.closest("." + $prefix).removeClass($prefix + "-" + type + "-checked");
                }
                if (checked) {
                    parent.addClass($prefix + "-" + type + "-checked");
                } else {
                    parent.removeClass($prefix + "-" + type + "-checked");
                }
                parent.removeClass($prefix + "-" + type + "-active").removeClass($prefix + "-" + type + "-active-checked");
            });
        },
        submits: function (el) {
            var wrapper = el.parent(),
            height = wrapper.height(),
            parent = wrapper.parent();
            wrapper.prepend($(HTML.SUBMIT).text(el.val()));
            if (isIE6) {
                parent.width(el.data("originalWidth"));
            }
            parent.mousedown(function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                hideActiveSelects();
            });
            el.click(function (e) {
                e.stopPropagation();
                if (el.attr("type") == "reset") {
                    var form = el.closest("form"),
                    inputs = form[0].getElementsByTagName("input");
                    $.each(inputs, function () {
                        if (this.type == "text" || this.type == "password") {
                            this.value = "";
                        }
                        if (this.type == "checkbox" || this.type == "radio") {
                            var parent = $(this).closest("." + $prefix + "-checkbox-checked");
                            parent.trigger("click");
                        }
                    });
                }
            });
            parent.click(function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (checkIfDisabled(parent)) {
                    return false;
                }
                el.click();
            });
        },
        selects: function (el, o) {
            var wrapper = el.parent(),
            height = wrapper.height(),
            parent = wrapper.parent(),
            list = $(HTML.LIST.WRAP).prependTo(wrapper),
            ul = list.find("ul"),
            options = el.children();
            parent.addClass($active);
            var minWidth = o[0].offsetWidth,
            prop = (isIE6) ? "width" : "min-width";
            if ($.browser.safari) {
                minWidth += 2;
            }
            parent.css(prop, minWidth);
            list.css(prop, minWidth);
            parent.removeClass($active);
            var selected = el.find(":selected");
            var current = $(HTML.LIST.VALUE);
			try{
            current.attr("rel", selected.val()).text(selected.text()).appendTo("body");
			} catch(err) {}
            var padding = parseNum(current.css("padding-right"));
            var newProp = $.support.textOverflow ? "width" : prop;
            current.css(newProp, (minWidth - padding));
            current.insertAfter(list);
            parent.one("mousedown", function (e) {
                e.preventDefault();
                options.each(function () {
                    var opt = $(this),
                    li = $(HTML.LIST.ITEM).attr("rel", opt.val()).appendTo(ul);
                    li.find("a").attr("href", "#" + opt.val()).text(opt.text());
                    if (opt.is(":selected")) {
                        li.addClass($selected);
                    }
                });
                var items = list.find("li"),
                links = items.find("a");
                height = wrapper.height();
                list = checkForCustomWrapper(list);
                makeScrollable(items, list, ul, height);
                parent.click(function (e) {
                    e.preventDefault();
                    if (checkIfDisabled(parent)) {
                        return false;
                    }
                    el.focus();
                });
                items.mouseover(function (e) {
                    if (checkIfDisabled(parent)) {
                        return false;
                    }
                    var keyIsDown = WIN.data("keydown");
                    if (!keyIsDown) {
                        items.removeClass($prefix + "-hover");
                        $(this).addClass($prefix + "-hover");
                    }
                });
                items.mouseout(function (e) {
                    if (checkIfDisabled(parent)) {
                        return false;
                    }
                    var keyIsDown = WIN.data("keydown");
                    if (!keyIsDown) {
                        $(this).removeClass($prefix + "-hover");
                    }
                });
                items.mousedown(function (e) {
                    e.preventDefault();
                    if (checkIfDisabled(parent)) {
                        return false;
                    }
                    $winHeight = WIN.height();
                    $winTop = WIN.scrollTop();
                    hideActiveSelects(parent);
                    var selected = $(this),
                    height = wrapper.height();
                    if ((parent.hasClass($prefix + "-focus") && parent.hasClass($active)) || (e.originalEvent && e.originalEvent.force)) {
                        var current = wrapper.find("." + $current),
                        title = current.find("span");
                        current.attr("rel", selected.attr("rel")).text(selected.text()).prepend(title);
                        truncateIfNecessary(parent.find("select"), current);
                        list.data("animating", true);
                        selectOption(list, selected, function () {
                            items.removeClass($selected).removeClass($hover);
                            selected.addClass($selected);
                            list.removeClass($redraw);
                            list.removeData("animating");
                            var datas = ["expanded", "showUpArrow", "showDownArrow", "fitInPage"];
                            $.each(datas, function () {
                                list.removeData(this);
                            });
                            list.find("." + $scroller).css("display", "");
                            list.removeClass($scrollable);
                            resetDimensions(list, ul);
                            var currVal = el.val(),
                            selectedVal = selected.attr("rel");
                            if (currVal !== selectedVal) {
                                el.val(selectedVal);
                                el.trigger("change", true);
                            }
                            list.css("display", "");
                            if (isIE6) {
                                parent.width(current[0].offsetWidth);
                            }
                            parent.removeClass($active);
                        });
                    } else {
                        parent.addClass($active);
                    }
                    el.focus();
                });
                items.bind("contextmenu", function (e) {
                    e.preventDefault();
                    e.stopPropagation();
                });
                links.click(function (e) {
                    e.preventDefault();
                });
                truncateIfNecessary(el, current, true);
                ul.find("." + $selected).trigger("mousedown");
            });
            current.bind("mousedown", function () {
                if (checkIfDisabled(parent)) {
                    return false;
                }
                var active = $("." + $prefix + "-select." + $active);
                if (active[0] && !parent.hasClass($active)) {
                    active.find("select").blur();
                }
                ul.find("." + $selected).trigger("mousedown");
            });
            if ($.onTextResize) {
                var ie6 = isIE6;
                $(document).bind("textresize", function () {
                    el.css("display", "block");
                    var minWidth = el[0].offsetWidth;
                    if ($.browser.safari) {
                        minWidth += 2;
                    }
                    parent.css(prop, minWidth);
                    list.css(prop, minWidth);
                    var padding = ie6 ? -10 : (parseNum(current.css("padding-right")));
                    current.css(prop, (minWidth - padding));
                    if ($.browser.msie) {
                        setIEWidth(parent, current, list);
                    }
                    truncateIfNecessary(el, current);
                    el.css("display", "");
                    if (parent.hasClass($active)) {
                        el.blur();
                    }
                });
            }
            el.change(function (e, breaker) {
                e.stopPropagation();
                if (breaker) {
                    e.preventDefault();
                    return false;
                }
                var el = $(this),
                wrapper = el.parent(),
                parent = wrapper.parent(),
                current = parent.find("." + $current);
                var val = el.val(),
                selected = parent.find("li[rel=" + val + "]");
                var evt = $.Event({
                    type: "mousedown",
                    force: true
                });
                if (!selected.get(0) && !parent.find("li").get(0)) {
                    parent.find(".ui-formulate-current").text(el.children().filter(function () {
                        return $(this).attr("value") == val;
                    }).text());
                } else {
                    selected.trigger(evt);
                }
            });
        },
        inject: function (el) {
            if ($settings.inject) {
                var wrapper = el.parent(),
                parent = wrapper.parent();
                $settings.inject.call(el, parent, wrapper);
            }
        },
        replace: function (clone, el) {
            var parent = clone.parent().parent();
            if ($.browser.safari) {
                CACHE.push({
                    node: el,
                    clone: parent
                });
            }
            el.replaceWith(parent);
            if (clone.is("select")) {
                var loaded = $(window).data("loaded");
                var current = parent.find("." + $current);
                var onReady = function () {
                    truncateIfNecessary(clone, current);
                };
                if (loaded) {
                    onReady();
                } else {
                    $(window).load(function () {
                        onReady();
                        if ($.browser.msie) {
                            setIEWidth(parent, current);
                        }
                        $(window).data("loaded", true);
                    });
                }
            }
        },
        unload: function () {
            $.each(CACHE, function (i, obj) {
                obj.clone.replaceWith(obj.node);
            });
        }
    };
    $.fn.enable = function (disable) {
        return this.each(function () {
            var el = $(this),
            parent = el.closest("." + $prefix + "-select");
            if (!disable) {
                el.removeAttr("disabled");
                parent.removeClass($disabled);
            } else {
                el.attr("disabled", "disabled");
                parent.addClass($disabled);
            }
        });
    };
    $.fn.disable = function () {
        return $(this).enable(true);
    };
    $.fn.formulate = function (options) {
        if (!$.support.inlineBlock) {
            this.filter(function () {
                return $(this).is(":checkbox") || $(this).is(":radio");
            }).click(triggeredEventFix);
            return this;
        }
        $settings = $.extend({},
        $.fn.formulate.defaults, options);
        return this.filter(function () {
            var el = $(this),
            type = el.attr("type"),
            supported = !(/button|file|hidden|image/).test(type);
            return !el.hasClass($noformulate) && supported && el.is(":visible");
        }).each(function () {
            var el = $(this);
            var type = el.attr("type");
            var clone = elements.wrap(el);
            if (!el.hasClass("ui-formulate-button")) {
                el.data("originalWidth", el.width());
                clone.data("originalWidth", el.data("originalWidth"));
                elements.disabled(clone);
                if ((type !== "checkbox") && (type !== "radio")) {
                    elements.style(clone, el);
                    if (type == "submit" || type == "reset") {
                        elements.submits(clone);
                    } else if (clone[0].nodeName.toLowerCase() == "select") {
                        elements.selects(clone, el);
                    }
                } else {
                    clone.addClass($prefix + "-hide");
                    elements.checks(clone);
                }
                elements.accessibility(clone, el);
            } else {
                clone.removeClass($prefix + "-button");
                clone.addClass($prefix + "-value");
            }
            if ($settings.inject) {
                elements.inject(clone);
            }
            elements.replace(clone, el);
            if ($.browser.safari) {
                $(window).bind("unload", elements.unload);
            }
        });
    };
    $.fn.formulate.defaults = {
        windowPadding: 8,
        minHeight: 22,
        fadeOutTimer: 250,
        onexpand: null,
        inject: function (wrapper, parent) {
            var el = $(this);
            var type = el.attr("type");
            var name = el[0].nodeName.toLowerCase();
            var button = wrapper.hasClass("ui-formulate-button");
            if ((name == "select") || (type == "reset") || (type == "submit") || (button)) {
                var gloss = $('<span class="dropDownGloss"></span>').css("opacity", 0.15);
                gloss.appendTo(parent);
                if (button) {
                    el.removeClass("alternate-1").removeClass("alternate-2");
                }
                if (wrapper.is(".alternate-1")) {
                    gloss.css("opacity", 0.55);
                } else if (wrapper.is(".alternate-2")) {
                    gloss.css("opacity", 0.35);
                }
                if ($.browser.msie) {
                    var prepForVML = function () {
                        wrapper.css({
                            "border-width": "0",
                            //"background": "transparent",
                            "position": "relative"
                        });
                        wrapper.find(".ui-formulate-wrap").css("z-index", "2");
                        wrapper.css({
                            "padding-bottom": "2px"
                        });
                    };
                    var setVMLOptions = function (el) {
                        var color = "#313131",
                        color2 = "#1e1e1e";
                        if (el.hasClass("alternate-1")) {
                            color = "#eeeeee";
                            color2 = "#dddddd";
                        } else if (el.hasClass("alternate-2")) {
                            color = "#00d7d7";
                            color2 = "#0e8e8e";
                        }
                        return {
                            fill: {
                                gradient: {
                                    from: color,
                                    to: color2
                                }
                            },
                            stroke: {
                                width: 0,
                                color: "transparent"
                            },
                            shadow: {
                                opacity: 0.6,
                                offset: "0, 2px",
                                color: "#000000"
                            }
                        };
                    };
                    var onReady = function () {
                        wrapper.vmlcorners(setVMLOptions(wrapper));
                        if (wrapper.hasClass("ui-formulate-button")) {
                            var link = wrapper.find("a");
                            link.width(link.get(0).offsetWidth);
                        }
                    };
                    var loaded = $(window).data("loaded");
                    prepForVML();
                    if (loaded) {
                        window.setTimeout(onReady, 0);
                    } else {
                        $(window).load(function () {
                            onReady();
                            $(window).data("loaded", true);
                        });
                    }
                }
            }
            if ($.support.boxShadow) {
                wrapper.addClass("nativeShadow");
            } else { if (name == "select") {
                    wrapper.one("mouseover", function () {
                        var list = wrapper.find(".ui-formulate-list-wrap");
                        list.shadow();
                        var up = list.parent();
                        up.css("min-width", parent.css("min-width"));
                        if ($.browser.msie) {
                            if (isIE6) {
                                up.css("width", parent.css("min-width"));
                            }
                            list.find("ul").mousedown(function (e) {
                                var vml = wrapper.find("roundrect");
                                vml.width(wrapper[0].offsetWidth - 2).height(wrapper[0].offsetHeight - 3);
                            });
                        }
                    });
                    if ($.onTextResize && $.browser.msie) {
                        $(document).bind("textresize", function () {
                            var vml = wrapper.find("roundrect");
                            vml.width(wrapper[0].offsetWidth - 2).height(wrapper[0].offsetHeight - 3);
                        });
                    }
                }
            }
        }
    };
})(jQuery);

(function ($) {
    var $settings;
    var $prefix = "ui-shadow";
    var HTML = {
        WRAP: '<div class="' + $prefix + '"></div>',
        CONTENT: '<div class="' + $prefix + '-content"></div>',
        SPAN: '<span class="' + $prefix + '-el"></span>'
    };
    var WIN = $(window),
    DOC = $(document);
    var nativeShadow = function () {
        if (typeof $.support.boxShadow !== "undefined") {
            return $.support.boxShadow;
        }
        var value = "#000 10px 10px 10px",
        prefixes = ["ms", "moz", "webkit", "o"];
        var dummy = $('<span></span>'),
        prop,
        supported;
        $.each(prefixes, function () {
            prop = "-" + this + "-box-shadow";
            dummy.css(prop, value);
            if (!supported) {
                var string = dummy.css(prop);
                supported = (window.getComputedStyle && (typeof string === "string") && (string !== ""));
            }
        });
        $.extend($.support, {
            boxShadow: supported
        });
        dummy.remove();
        return $.support.boxShadow;
    } ();
    $.fn.shadow = function (options) {
        $settings = $.extend({},
        $.fn.shadow.defaults, options);
        if ($.support.boxShadow && !$settings.force) {
            return this;
        }
        this.filter(function () {
            return !$(this).closest("." + $prefix)[0];
        }).each(function () {
            var el = $(this);
            el.wrap(HTML.WRAP).wrap(HTML.CONTENT);
            var parent = el.parent();
            parent.append($(HTML.SPAN).addClass($prefix + "-top-left"), $(HTML.SPAN).addClass($prefix + "-top-right"), $(HTML.SPAN).addClass($prefix + "-bot-left"), $(HTML.SPAN).addClass($prefix + "-bot-right"));
            if (!el.css("position") || (el.css("position") == "static")) {
                el.css("position", "relative");
            } else if (el.css("position") == "absolute") {
                parent.parent().css({
                    position: el.css("position"),
                    "z-index": el.css("z-index")
                });
                el.css({
                    position: "relative",
                    "left": "0",
                    "top": "0"
                });
            }
            if (!el.css("z-index") || el.css("z-index") == "auto") {
                el.css("z-index", 1000);
            }
            var props = ["margin-left", "margin-top", "margin-right", "margin-bottom", "float"];
            $.each(props, function (i, prop) {
                parent.css(prop, el.css(prop));
                el.css(prop, (prop == "float") ? "none" : 0);
            });
        });
        return this.closest("." + $prefix + "-content");
    };
    $.fn.shadow.defaults = {
        force: false
    };
    $.fn.unshadow = function (options) {
        if ($.support.boxShadow && !options.force) {
            return this;
        }
        return this.each(function () {
            var el = $(this),
            wrap = el.closest("." + $prefix);
            el.attr("style", "");
            el.insertAfter(wrap);
            wrap.remove();
        });
    };
})(jQuery);

(function ($) {
    var $settings;
    var vmlSupport = function () {
        if (typeof $.support.vml !== "undefined") {
            return $.support.vml;
        }
        $.extend($.support, {
            vml: document && document.namespaces
        });
        return $.support.vml;
    } ();
    $.fn.vmlcorners = function (options) {
        if (!$.support.vml) {
            return this;
        }
        $settings = $.extend({},
        $.fn.vmlcorners.defaults, options);
        return this.each(function () {
            var el = $(this),
            target = el[0];
            if (document && document.namespaces && !document.namespaces.v) {
                document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
                var ss = document.createStyleSheet().owningElement;
                ss.styleSheet.cssText = "v\\:roundrect,v\\:fill,v\\:stroke,v\\:shadow{behavior:url(#default#VML);}";
            }
            var arcSize = Math.min((parseInt($settings.radius) || parseInt(el.css("-ms-border-radius")) || parseInt(el.css("ms-border-radius"))) / Math.min(target.offsetWidth, target.offsetHeight), 1);
            var width = target.offsetWidth - 2,
            height = target.offsetHeight - 3;
            var fill = $settings.fill;
            var color = color2 = (typeof fill === "string") ? fill : fill.color;
            var gradient = fill.gradient,
            angle = 0;
            if (gradient) {
                color = gradient.from;
                color2 = gradient.to;
                angle = gradient.angle || 0;
            }
            var hasColor = color ? "True" : "False";
            var stroke = $settings.stroke,
            sWidth, sColor;
            if (typeof stroke === "string") {
                var string = stroke.split(" ");
                sWidth = string[0];
                sColor = string[2];
            } else {
                sWidth = stroke.width || el.css("border-left-width") || 1;
                sColor = stroke.color || el.css("border-left-color") || "#000000";
            }
            var alpha = (stroke.color == "transparent") ? "0%" : "100%";
            var shadow = $settings.shadow,
            hasShadow = (options && options.shadow) ? "True" : "False";
            var wrap = $('<v:roundrect arcsize="' + arcSize + '" strokeweight="0" style="position: absolute; top: 0; left: 0; width: ' + width + 'px; height: ' + height + 'px; antialias: true; padding: 0px; z-index: 1;"><v:fill On="' + hasColor + '" type="Gradient" Angle="' + angle + '" Color="' + color + '" Color2="' + color2 + '" Focus="100%"></v:fill><v:stroke Weight="' + sWidth + '" Opacity="' + alpha + '" Color="' + sColor + '" LineStyle="ThickThin"></v:stroke><v:shadow On="' + hasShadow + '" Color="' + shadow.color + '" Opacity="' + shadow.opacity + '" Offset="' + shadow.offset + '"></v:shadow></v:roundrect>');
            var setIndex = function (el, index) {
                el.css({
                    "position": "relative",
                    "z-index": index || 2
                });
            };
            var targets = el.children().andSelf();
            targets.each(function (i, item) {
                var el = $(item);
                var position = el.css("position");
                if (position == "static") {
                    setIndex(el);
                }
            });
            el.prepend(wrap);
        });
    };
    $.fn.vmlcorners.defaults = {
        radius: 1,
        fill: {
            gradient: null,
            color: null
        },
        stroke: {
            width: null,
            color: null
        },
        shadow: {
            opacity: 1.0,
            offset: "0, 0",
            color: "#000000"
        }
    };
})(jQuery);

var LOGITECH = window.LOGITECH || {};
LOGITECH.com = LOGITECH.com || {};
(function($) { (function () {
    var $self = LOGITECH.com;
    $self.legacy = $.extend($self.legacy, {
        changeLanguage: function (val, form) {
            var splitter = "&cl=",
            values = val.split(","),
            loc = form.attr("action").split(splitter);
            loc[1] = val;
            loc = loc.join(splitter);
            $self.legacy.setCookiesLanguage(values[0], values[1], val);
            location.replace(loc);
        },
        setCookiesLanguage: function (lang, country, val) {
            var cookies = {
                "LANGUAGEID": lang,
                "COUNTRYID": country,
                "CL": val
            };
            $.each(cookies, function (key, value) {
                $.cookie(key, value);
            });
        }
    });
    $self.vars = $.extend($self.vars, {
        prefetch: {
            js: ["/javascript/v2/cmn/lib/plugins/schematic/jquery.scrollbar.js", "/javascript/v2/subcategory.js", "/javascript/v2/category.js", "/javascript/v2/product-detail.js", "/javascript/v2/comparison.js", "/javascript/v2/homepage.js"],
            css: ["/css/v2/cmn/lib/plugins/schematic/scrollbar.css", "/css/v2/subcategory.css", "/css/v2/category.css", "/css/v2/product-detail.css", "/css/v2/comparison.css", "/css/v2/homepage.css"],
            img: ["/images/v2/cmn/shadow/bg-shadow.png", "/images/v2/cmn/shadow/bg-shadow-alternate.png"],
            ie: ["/css/v2/subcategory_ie.css", "/css/v2/category_ie.css", "/css/v2/product-detail_ie.css", "/css/v2/comparison_ie.css", "/css/v2/homepage_ie.css", "/images/v2/cmn/shadow/ie-shadow.png"]
        }
    });
    $self.utils = $.extend($self.utils, {
        init: function (object) {
            $(document).ready(function () {
                for (var key in object) {
                    if (object.hasOwnProperty(key) && (typeof object[key] === "function")) {
                        object[key]();
                    }
                }
            });
        },
        applyStyle: function (spacing) {
            return {
                ".sIFR-root": {
                    "color": "#000000",
                    "letter-spacing": spacing
                },
                "a": {
                    "color": "#000000",
                    "text-decoration": "none"
                },
                "a:hover": {
                    "color": "#000000"
                }
            };
        },
        getQueryString: function (key, href) {
            key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regex = new RegExp("[\\?&]" + key + "=([^&#]*)"),
            qs = regex.exec(href);
            if (qs === null) {
                return null;
            }
            return qs[1];
        },
        filterItems: function (object) {
            var hashTable = object.table;
            var products = object.products;
            var items = object.items;
            var callback = object.callback;
            var checkVisibility = object.checkVisibility;
            var length = 0,
            x = 0,
            once = true;
            var duration = 250;
            var filter;
            var win = $(window),
            winTop = win.scrollTop(),
            winHeight = win.height(),
            winOffset = winTop + winHeight;
            var isVisible = function (el) {
                return !checkVisibility || (el.position().top < winOffset);
            };
            for (var i = 0, j = products.length; i < j; i++) {
                filter = products[i];
                var id = filter.id,
                hasKey = true;
                var target = $("#item-" + id);
                for (var key in hashTable) {
                    if ((hashTable[key] !== null) && !filter[key]) {
                        hasKey = false;
                    }
                }
                if (!hasKey) {
                    length++;
                    var hideOnComplete = function () {
                        x++;
                        var el = $(this);
                        if (el.hasClass("toggled")) {
                            var input = $(this).find(":checked").click();
                        }
                        el.css({
                            "display": ""
                        });
                        if (x == length) {
                            if (callback) {
                                callback();
                            }
                            if (!$self.vars.check) {
                                $self.utils.checkForEmptyResults(items);
                            }
                            $self.vars.check = false;
                        }
                    };
                    var sizeDown = function (el) {
                        el.animate({
                            width: 0,
                            'marginLeft': 0,
                            'marginRight': 0
                        },
                        {
                            duration: duration,
                            complete: hideOnComplete
                        });
                    };
                    target.data("toggled", true);
                    if (!$.browser.msie && isVisible(target)) {
                        target.stop(true, true).animate({
                            opacity: 0
                        },
                        {
                            duration: duration,
                            complete: function () {
                                var el = $(this);
                                el.addClass("toggled");
                                sizeDown(el);
                            }
                        });
                    } else {
                        target.addClass("toggled");
                        hideOnComplete.call(target);
                    }
                } else if (target.data("toggled")) {
                    length++;
                    if (once) {
                        $self.vars.check = true;
                        $self.utils.checkForEmptyResults(items, true);
                        once = false;
                    }
                    var showOnComplete = function (el) {
                        el.css({
                            "overflow": "",
                            "display": "",
                            "visibility": ""
                        });
                        el.removeData("toggled");
                        el.removeClass("toggled");
                        if ($.browser.msie) {
                            target.width(target.data("oWidth") || "");
                        }
                        x++;
                        if (x == length && callback) {
                            callback();
                        }
                        $self.vars.check = false;
                    };
                    if (isVisible(target)) {
                        target.removeClass("disabled");
                    }
                    if (!$.browser.msie && isVisible(target)) {
                        target.stop(true, true).animate({
                            width: target.data("oWidth"),
                            'marginLeft': target.data("lMargin"),
                            'marginRight': target.data("rMargin")
                        },
                        {
                            duration: duration,
                            complete: function () {
                                var el = $(this);
                                el.css("opacity", "0");
                                el.animate({
                                    opacity: 1
                                },
                                {
                                    duration: 250,
                                    complete: function () {
                                        showOnComplete(el);
                                    }
                                });
                            }
                        });
                    } else {
                        showOnComplete(target);
                    }
                }
            }
        },
        toggleFilter: function () {
            var container = $(".filterContainer"),
            h6 = container.find("h6");
            var toggleCollapsedBehavior = function (parent, collapsed) {
                var preventTab = function (e) {
                    if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) {
                        return true;
                    }
                    if (e.which === 9) {
                        e.preventDefault();
                    }
                };
                if (collapsed) {
                    $(document).bind("keydown", preventTab);
                } else {
                    $(document).unbind("keydown", preventTab);
                }
            };
            h6.click(function (e) {
                var el = $(this),
                parent = el.parent();
                if (!parent.data("colHeight")) {
                    var oChild = parent.children(":not(h6):not(:submit)");
                    parent.data("expHeight", parent.height());
                    oChild.toggle();
                    parent.toggleClass("collapsed");
                    parent.data("colHeight", parent.height());
                    parent.toggleClass("collapsed");
                    oChild.toggle();
                }
                parent.toggleClass("collapsed");
                var height = parent.data((parent.hasClass("collapsed")) ? "colHeight" : "expHeight");
                parent.animate({
                    height: height
                },
                350);
                toggleCollapsedBehavior(parent, parent.hasClass("collapsed"));
            });
        },
        checkForEmptyResults: function (items, bypass) {
            var none = $("#noresults"),
            sorter = $("#sortOptions");
            var results = items.filter(function () {
                return !$(this).hasClass("toggled");
            }).get(0) || bypass,
            onComplete;
            if (!results) {
                onComplete = function () {
                    none.css({
                        display: "",
                        filter: ""
                    });
                    none.removeClass("hidden");
                };
                if (!$.browser.msie) {
                    none.stop().fadeIn(250, onComplete);
                } else {
                    onComplete();
                }
                sorter.disable();
            } else {
                onComplete = function () {
                    none.css({
                        display: "",
                        filter: ""
                    });
                    none.addClass("hidden");
                };
                if (!$.browser.msie) {
                    none.stop().fadeOut(250, onComplete);
                } else {
                    onComplete();
                }
                sorter.enable();
            }
        },
        OverlaysController: function () {
            var overlayContainer = $("#overlays");
            var scrim = overlayContainer.find(".scrim");
            function showScrim() {
                scrim.height($("body").height() + 60);
                scrim.show();
            }
            function hideScrim() {
                scrim.hide();
            }
            return {
                show: function (overlayObject) {
                    showScrim();
                    if (overlayObject && typeof overlayObject.show === "function") {
                        overlayObject.show();
                    }
                },
                hide: function (overlayObject) {
                    hideScrim();
                    if (overlayObject && typeof overlayObject.hide === "function") {
                        overlayObject.hide();
                    }
                }
            };
        } (),
        FlashLoader: function () {
            var defaultOptions = {
                wmode: "transparent",
                allowscriptaccess: "always"
            };
            function load(container, options) {
                if (!container) {
                    return;
                }
                options = $.extend({},
                defaultOptions, options);
                var params = getParamsFromInputs(container);
                options.src = options.swf || extractValue(params, "swf");
                options.width = options.width || extractValue(params, "width") || "100%";
                options.height = options.height || extractValue(params, "height") || "100%";
                options.base = extractValue(params, "base");
                options.flashvars = params;
                if (options.src) {
                    container.flash(options);
                    container.find(".alt").addClass("hide");
                }
            }
            function revert(container) {
                if (container.hasClass("flash-replaced")) {
                    var alt = container.find(".alt").remove();
                    container.empty();
                    container.removeClass("flash-replaced");
                    container.append(alt.children());
                }
            }
            function getParamsFromInputs(container) {
                var params = {},
                input, name, value;
                container.find("input").each(function () {
                    input = $(this);
                    name = input.attr("name");
                    value = input.val();
                    if (name !== "width" && name !== "height") {
                        params[name] = decodeURIComponent(value);
                    } else {
                        params[name] = value;
                    }
                });
                if (!params.cl) {
                    var cl = LOGITECH.com.utils.getQueryString("cl");
                    if (cl) {
                        params.cl = cl;
                    }
                }
                return params;
            }
            function extractValue(params, name) {
                var value = params[name];
                delete params[name];
                return value;
            }
            return {
                load: load,
                revert: revert
            };
        } (),
        RoundedCorners: {
            applyToEach: function (elements) {
                if (!$.support.vml) {
                    return;
                }
                elements.each(function () {
                    var el = $(this);
                    el.vmlcorners();
                    el.data("corner", el.find("roundrect"));
                });
            },
            toggleOneInSet: function (set, selectedNode) {
                if (!$.support.vml) {
                    return;
                }
                set.each(function () {
                    if ($(this).data("corner")) {
                        $(this).data("corner").css("display", "none");
                    }
                });
                if (selectedNode.data("corner")) {
                    selectedNode.data("corner").css("display", "block");
                }
            }
        }
    });
    $self.global = function () {
        jQuery.easing.def = "easeInOutExpo";
        if ($.browser.msie) {
            try {
                document.execCommand("BackgroundImageCache", false, true);
            } catch(ex) {}
        }
    };
    $self.sifr = function () {
        var gothambook = {
            name: "Gotham Book",
            src: "http://www.logitech.com/images/v2/fonts/gotham-book.swf",
            ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01]
        };
        var cl = $self.utils.getQueryString("cl", window.location.href);
        if (!cl) {
            cl = $self.utils.getQueryString("cl", $("meta[name=searchURL]").attr("content"));
        }
        if (cl) {
            switch (cl.toLowerCase()) {
            case "gr,el":
            case "bg,bg":
            case "ru,ru":
            case "ua,uk":
            case "jp,ja":
            case "cn,zh":
            case "kr,ko":
            case "tw,zh":
                return false;
            default:
                break;
            }
        }
        $(document).sifr({
            defaultFont: gothambook
        });
		$("#lia-body .lia-content .lia-component-common-widget-page-title .lia-link-navigation").sifr({
            offsetTop: 2,
            tuneHeight: -1,
            css: $self.utils.applyStyle(-1.5)
		});
        $("#headline h1, #feature h1").sifr({
            offsetTop: 2,
            tuneHeight: -1,
            css: $self.utils.applyStyle(-1.5)
        });
        $("#content > h2, .promo h3").sifr({
            offsetTop: 2,
            tuneHeight: -3,
            css: $self.utils.applyStyle(-0.75)
        });
        var h4 = $("#headlinePricing h4");
        h4.sifr({
            offsetTop: 2,
            tuneHeight: -3,
            css: {
                ".sIFR-root": {
                    "color": "#000000",
                    "text-align": "right",
                    "letter-spacing": -0.75
                },
                "a": {
                    "font-size": "45%",
                    "color": "#666666",
                    "text-decoration": "none"
                },
                "a:hover": {
                    "font-size": "45%",
                    "color": "#666666",
                    "text-decoration": "none"
                }
            },
            preventWrap: true
        });
    };
    $self.navigation = function () {
        var header = $("#header"),
        parent = $("#navigation"),
        category = parent.find("ul:first-child > li");
        var itemTimeout, catTimeout;
        category.each(function () {
            var el = $(this).find("span");
            el.data("position", el.css("background-position"));
        });
        category.hover(function (e) {
            if (catTimeout) {
                clearTimeout(catTimeout);
            }
            if ($self.vars.selectIsActive) {
                $(document).trigger("mousedown");
            }
            var el = $(this),
            els,
            clone = parent.find("#" + el.attr("id") + ".clone");
            parent.find(".clone:not(#" + el.attr("id") + ")").each(function () {
                $(this).hide();
                if (!$.browser.msie) {
                    $(this).children().css("opacity", 0);
                }
            });
            var animate = function (els, toggle, easing, callback) {
                els = els || clone.children();
                if ($.browser.msie) {
                    if (callback) {
                        callback();
                    }
                } else {
                    els.stop().animate({
                        opacity: toggle
                    },
                    {
                        duration: 50,
                        easing: easing,
                        complete: callback
                    });
                }
            };
            if (!clone[0]) {
                clone = el.clone();
                clone.addClass("hover").addClass("clone");
                var span = el.find("> a span");
                span.css("background-position", span.data("position"));
                clone.insertAfter(el);
                clone.css({
                    "position": "absolute",
                    "top": el.position().top,
                    "left": el.position().left
                });
                clone.find("> ul").shadow();
                els = clone.children();
                els.each(function () {
                    var el = $(this);
                    var child = el.children().eq(0);
                    if (child.is("ul")) {
                        el.width(child.width());
                    }
                });
                els = clone.children();
                if (!$.browser.msie) {
                    els.css("opacity", 0);
                }
                el.find("ul").hide();
                clone.bind("mouseenter", function (e) {
                    if (catTimeout) {
                        clearTimeout(catTimeout);
                    }
                    el.data("triggerClone", true);
                });
                clone.bind("mouseleave", function (e) {
                    var self = this,
                    el = $(self),
                    list;
                    if (itemTimeout) {
                        clearTimeout(itemTimeout);
                    }
                    if (catTimeout) {
                        clearTimeout(catTimeout);
                    }
                    self.timeout = function () {
                        animate(els, 0, "easeOutQuad", function () {
                            var shadow = clone.find(".ui-shadow-content"),
                            parent = (shadow[0]) ? shadow.children().eq(0) : clone.find("ul"),
                            items = parent.find("li");
                            parent.width("");
                            items.width("");
                            parent.height("");
                            shadow.width("").height("");
                            items.removeClass("active");
                            clone.hide();
                        });
                    };
                    catTimeout = window.setTimeout(self.timeout, 500);
                });
                items = parent.find(".clone ul").eq(0).find("> li");
                var mouseover = function (e) {
                    var el = $(this),
                    parent = el.closest("ul"),
                    shadow = parent.closest(".ui-shadow-content");
                    list = el.find("ul");
                    if (list[0]) {
                        var expando = parent.data("expando");
                        if (!expando) {
                            parent.data("expando", parent.width() + list.width());
                            expando = parent.data("expando");
                        }
                        parent.addClass("hoverFix");
                        parent.css("height", "");
                        if (list[0]) {
                            parent.width(expando);
                            shadow.width(expando);
                            //items.width("50%");
                            list.css("left", "50%");
                            var listHeight = list.height(),
                            parentHeight = parent.height();
                            if (listHeight < parentHeight) {
                                list.height(parentHeight);
                            } else if (parentHeight < listHeight) {
                                parent.height(listHeight);
                            }
                            if ($.browser.msie && $.browser.version <= 6) {
                                shadow.height(parent.height());
                            }
                        } else {
                            parent.width("").height("");
                            shadow.width("").height("");
                        }
                        el.siblings().removeClass("active");
                        el.addClass("active");
                    }
                };
                items.mouseover(function () {
                    if (itemTimeout) {
                        clearTimeout(itemTimeout);
                    }
                    var el = $(this),
                    list = el.find("ul");
                    if (!el.hasClass("active")) {
                        list.hide();
                        itemTimeout = window.setTimeout(function () {
                            list.css("display", "");
                            mouseover.call(el);
                        },
                        250);
                    }
                });
                items.mouseout(function (e) {
                    var el = $(this),
                    list = el.find("ul");
                });
                el.find("ul").remove();
            }
            clone.show();
            animate(els, 1, "easeInQuad");
        },
        function (e) {
            var el = $(this);
            if (itemTimeout) {
                clearTimeout(itemTimeout);
            }
            catTimeout = setTimeout(function () {
                var trigger = el.data("triggerClone");
                if (trigger) {
                    el.removeData("triggerClone");
                } else {
                    parent.find(".clone").trigger("mouseenter");
                    parent.find(".clone").trigger("mouseleave");
                }
            },
            250);
        });
        if ($.onTextResize) {
            $(document).bind("textresize", function () {
                category.each(function () {
                    var el = $(this),
                    parent = el.find("> ul"),
                    item = parent.find("li.active"),
                    list = item.find("> ul");
                    if (el.hasClass("hover") && list[0]) {
                        parent.width("").height("");
                        list.width("").height("");
                        parent.data("expando", parent.width() + list.width());
                        parent.width(parent.data("expando"));
                        item.trigger("mouseover");
                    }
                });
            });
        }
    };
    $self.formElements = function () {
        var switcher = $("#locationSwitcher");
        switcher.addClass("js-enabled");
        $("input, select, .ui-formulate-button").formulate();
        switcher.find("select").change(function (e) {
            $self.legacy.changeLanguage($(this).val(), switcher.find("form"));
        });
        var globalSubmit = $("#globalSubmit");
        globalSubmit.removeAttr("id").removeAttr("class").hide();
        var magGlass = $('<a id="globalSubmit" href="#submit"></a>');
        magGlass.insertAfter(globalSubmit);
        var defaultLabel = $("#globalSearchLabel").html();
        $("#globalSearch").val(defaultLabel).focus(function () {
            if ($(this).val() === defaultLabel) {
                $(this).val("");
            }
        }).blur(function () {
            if ($(this).val() === "") {
                $(this).val(defaultLabel);
            }
        });
        magGlass.click(function (e) {
            e.preventDefault();
            var searchTerm = $("#globalSearch").val();
            if (searchTerm.length > 0 && searchTerm !== defaultLabel) {
                $(this).closest("form").submit();
            }
        });
        $self.vars.immediateChildren = $("#container > *");
        var kids = $self.vars.immediateChildren;
        $("select").focus(function () {
            var el = $(this).closest(".ui-formulate-select");
            var parent = el.closest("#container > *");
            var others = kids.filter(function () {
                return this !== parent.get(0);
            });
            parent.removeClass("inactive");
            others.addClass("inactive");
            $self.vars.selectIsActive = true;
        }).blur(function () {
            kids.removeClass("inactive");
            $self.vars.selectIsActive = false;
        });
        $("input.search").keydown(function () {
            var el = $(this),
            parent = el.closest("form");
            if (!parent.hasClass("activeSearch")) {
                parent.addClass("activeSearch");
            }
        }).blur(function () {
            var el = $(this),
            parent = el.closest("form");
            parent.removeClass("activeSearch");
        });
    };
    $self.promos = function () {
        $(".promo").each(function () {
            var el = $(this),
            link = el.find("a").eq(0);
            var clone = link.clone().html("");
            clone.addClass("clone");
            el.append(clone);
            el.find("img").pngfix();
        });
    };
    $self.findRetailer = function () {
        var findRetailer = $("#findRetailer");
        var retailer = $(".findRetailer .overlayContainer");
        retailer.find("a").click(function (e) {
            e.preventDefault();
            findRetailer.trigger("click");
        });
        var zip = $("#zip").autolabel();
        findRetailer.bind("click", function (e) {
            e.preventDefault();
            var parent = $("#headline");
            parent.toggleClass("showOverlay");
        });
        findRetailer.one("click", function () {
            retailer.shadow();
            retailer.find("input").formulate();
        });
        if (zip[0]) {
            $("#zip").keydown(function (e) {
                if (e.which === 13) {
                    e.preventDefault();
                    $("#stores").click();
                }
            });
            $("#stores").bind("click", function (e) {
                zip = $("#zip");
                if (! (/[0-9\-]+/).test(zip.val())) {
                    alert("Please enter a valid zip code.");
                    e.preventDefault();
                }
            });
        }
    };
    $.fn.customSearchBox = function () {
        return this.each(function () {
            var input = $(this);
            input.closest("form").find(":submit").hide();
            $('<a class="submit"></a>').appendTo(input.parents(":not(div)").eq(0)).click(function (e) {
                e.preventDefault();
                var searchTerm = input.val();
                if (searchTerm.length > 0) {
                    $(this).closest("form").submit();
                }
            });
            if (input.hasClass("autolabel")) {
                input.autolabel();
            }
        });
    };
    $.fn.autolabel = function () {
        var labelsById = {};
        return function () {
            return this.each(function () {
                var input = $(this);
                var label = $("label[for=" + input.attr("id") + "]");
                var labelText = label.html();
                input.val(labelText);
                labelsById[input.attr("id")] = labelText;
                input.focus(function () {
                    var input = $(this);
                    if (input.val() === labelsById[input.attr("id")]) {
                        input.val("");
                    }
                }).blur(function () {
                    var input = $(this);
                    if (input.val() === "") {
                        input.val(labelsById[input.attr("id")]);
                    }
                });
            });
        };
    } ();
    $self.IE6MinWidthFix = function () {
        if ($.browser.msie && $.browser.version <= 6) {
            var win = $(window),
            body = $("body"),
            trigger = "IE6MinWidthFix",
            min = parseInt(body.css("min-width"));
            win.bind("resize", function () {
                if (win.width() <= min) {
                    body.addClass(trigger);
                } else if (body.hasClass(trigger)) {
                    body.removeClass(trigger);
                }
            });
        }
    };
    $self.FOUCFix = function () {
        $('body').css("visibility", "visible");
    };
    $self.checkForProductThread = function () {
        var settings = "LOGI_SUBCATEGORY_SETTINGS";
        var products = "LOGI_SUBCATEGORY_PRODUCTS";
        var scrolled = "LOGI_SUBCATEGORY_SCROLL_POS";
        var cookie = $.cookie(products);
        if (cookie) {
            var json = eval("(" + cookie + ")"),
            productExists;
            for (var i = 0, j = json.products.length; i < j; i++) {
                var obj = json.products[i];
                if (obj.id) {
                    var el = $("#" + obj.id);
                    if (el.get(0)) {
                        productExists = true;
                        break;
                    }
                }
            }
            if (!productExists) {
                $.cookie(settings, null);
                $.cookie(products, null);
                $.cookie(scrolled, null);
            }
        }
    };
    $self.prefetch = function () {
        var prefetch = $self.vars.prefetch;
        var fetchViaIMG = function (url) {
            var img = $('<img />').attr("src", url);
        };
        var cycle = function (obj) {
            $.each(obj, function (i, url) {
                fetchViaIMG(url);
            });
        };
        window.setTimeout(function () {
            for (var key in prefetch) {
                if ((key == "ie")) {
                    if ($.browser.msie) {
                        cycle(prefetch[key]);
                    }
                } else {
                    cycle(prefetch[key]);
                }
            }
        },
        1000);
    };
    $self.ProductOptionsOverlay = function () {
        var overlaysController = $self.utils.OverlaysController;
        var SELECTED_CLASS = "selected";
        var SHOW_CLASS = "show";
        var INVISIBILITY = "invisible";
        var WINDOW = $(window),
        TIMER;
        var Instance = function (container) {
            this.container = container;
            this.largeImages = [];
        };
        Instance.prototype = {
            switchFunction: changeSource,
            show: function () {
                this.container.addClass(SHOW_CLASS).addClass(INVISIBILITY);
                positionContainer(this);
                style(this);
                updateSelected(this);
                this.container.removeClass(INVISIBILITY);
            },
            hide: function () {
                this.container.removeClass(SHOW_CLASS);
                this.header.unsifr();
            }
        };
        function getElements(instance) {
            instance.content = instance.container.find(".content");
            instance.header = instance.container.find("h2");
            instance.form = instance.container.find("form");
            instance.labels = instance.container.find("label");
            instance.radios = instance.container.find("input[type=radio]");
            instance.image = instance.container.find(".imageSwitcherImage");
            instance.mirroredOptions = $("#featureImageSwitcher a");
        }
        function addBehavior(instance) {
            instance.labels.click(function () {
                updateSelected(instance, $(this).data("index"));
            });
            instance.form.find(":reset").click(function (e) {
                e.preventDefault();
                overlaysController.hide(instance);
            });
            WINDOW.bind("scroll", function (e) {
                if (instance.container.hasClass(SHOW_CLASS)) {
                    positionContainer(instance, instance.container.data("run"));
                }
            });
        }
        function positionContainer(instance, run) {
            if (TIMER) {
                clearTimeout(TIMER);
            }
            var offset = function () {
                instance.container.css("top", WINDOW.scrollTop());
            };
            var child = instance.container.children(),
            winHeight = WINDOW.height(),
            instanceOffset = child.height() + parseFloat(child.css("top"));
            if (run && !$.browser.msie && (instanceOffset < winHeight)) {
                TIMER = window.setTimeout(function () {
                    instance.container.stop().animate({
                        top: WINDOW.scrollTop()
                    },
                    {
                        duration: 250
                    });
                },
                250);
            } else if ($.browser.msie && (instanceOffset < winHeight)) {
                offset();
            } else if (!run) {
                if (instanceOffset > winHeight) {
                    window.scrollTo(0, 0);
                }
                offset();
                instance.container.data("run", true);
            }
        }
        function setupData(instance) {
            instance.labels.each(function (i) {
                $(this).data("index", i);
            });
            instance.content.find("input[type=hidden]").each(function () {
                instance.largeImages.push($(this).attr("value"));
            });
        }
        function style(instance) {
            if (!instance.styled) {
                instance.content.shadow();
                instance.content.find("input").formulate();
                $self.utils.RoundedCorners.applyToEach(instance.labels);
                if ($.browser.msie && $.browser.version < 7) {
                    instance.container.find("img").pngfix();
                    var pngfixed = instance.container.find("img.imageSwitcherImage").siblings("span");
                    if (pngfixed && pngfixed[0]) {
                        instance.image = pngfixed;
                        instance.switchFunction = changeFilter;
                    }
                }
                instance.styled = true;
            }
            sifr(instance);
        }
        function sifr(instance) {
            instance.header.sifr({
                offsetTop: 2,
                tuneHeight: 3,
                css: {
                    ".sIFR-root": {
                        "color": "#000000",
                        "text-align": "center",
                        "letter-spacing": 0.75
                    }
                }
            });
        }
        function updateSelected(instance, selectedIndex) {
            var original, label, selectedLabel;
            if (selectedIndex > -1) {
                instance.labels.each(function (i) {
                    label = $(this);
                    if (selectedIndex === i) {
                        selectedLabel = label;
                        selectedLabel.addClass(SELECTED_CLASS);
                        instance.switchFunction(instance, instance.largeImages[i]);
                        $(instance.radios[i]).attr("checked", true);
                    } else {
                        label.removeClass(SELECTED_CLASS);
                        $(instance.radios[i]).attr("checked", false);
                    }
                });
            } else if (instance.mirroredOptions.length > 0) {
                instance.mirroredOptions.each(function (i) {
                    original = $(this);
                    label = $(instance.labels[i]);
                    if (original.hasClass(SELECTED_CLASS)) {
                        selectedLabel = label;
                        selectedLabel.addClass(SELECTED_CLASS);
                        instance.switchFunction(instance, instance.largeImages[i]);
                        $(instance.radios[i]).attr("checked", true);
                    } else {
                        label.removeClass(SELECTED_CLASS);
                        $(instance.radios[i]).attr("checked", false);
                    }
                });
            } else {
                selectedLabel = instance.content.find("." + SELECTED_CLASS);
            }
            if (selectedLabel) {
                $self.utils.RoundedCorners.toggleOneInSet(instance.labels, selectedLabel);
            }
        }
        var filter = {
            prefix: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true", sizingMethod="crop", src="',
            suffix: '")'
        };
        function changeSource(instance, newSource) {
            instance.image.attr("src", newSource);
        }
        function changeFilter(instance, newSource) {
            instance.image.css("filter", filter.prefix + newSource + filter.suffix);
        }
        return {
            initialize: function (container) {
                var newInstance = new Instance(container);
                getElements(newInstance);
                addBehavior(newInstance);
                setupData(newInstance);
                return newInstance;
            }
        };
    } ();
    $self.utils.init($self);
}).call(LOGITECH.com) })(jQuery);
