/*
 This version of hd-all has been edited to destroy videos when popup closed to prevent them from playing again, and because if you don't destory them a bug in the code produces more than one anchor element to click on

 */

if (typeof HD == "undefined" || !HD) {
    var HD = {
        onLoadQueue: [],
        isYuiLoaded: false,
        util: {},
        loader: null,
        classMap: {},
        get: function (A) {
            return YAHOO.util.Dom.get(A)
        },
        getByClass: function (C, B, D, A) {
            return YAHOO.util.Dom.getElementsByClassName.apply(YAHOO.util.Dom, arguments)
        },
        addModules: function (A) {
            for (var B in this.modules) {
                A.addModule(this.modules[B])
            }
        },
        insert: function (B) {
            var A = this.getLoader();
            if (A !== null) {
                A.insert(B)
            }
        },
        getLoader: function () {
            if (this.loader === null) {
                this.loader = new YAHOO.util.YUILoader();
                this.addModules(this.loader)
            }
            return this.loader
        },
        extend: function (E, F) {
            for (var C = 0, A = F.length;
            C < A;
            C++) {
                var D = F[C];
                for (var B in D.prototype) {
                    if (!E.prototype[B]) {
                        E.prototype[B] = D.prototype[B]
                    }
                }
            }
        },
        clone: function (C, B) {
            var A = {};
            for (var D in C) {
                if (B && typeof C[D] == "object") {
                    A[D] = this.clone(C[D], B)
                } else {
                    A[D] = C[D]
                }
            }
            return A
        },
        merge: function (C, B, A) {
            for (var D in B) {
                C[D] = B[D]
            }
            return C
        },
        register: function (A, B, C) {
            HD.classMap[A] = B
        },
        onLoad: function (A) {
            if (typeof YAHOO != "undefined") {
                YAHOO.util.Event.onDOMReady(A)
            } else {
                this.onLoadQueue.push(A)
            }
        },
        addClass: function (A, B) {
            YAHOO.util.Dom.addClass(A, B)
        },
        removeClass: function (A, B) {
            YAHOO.util.Dom.removeClass(A, B)
        },
        replaceClass: function (B, A, C) {
            YAHOO.util.Dom.replaceClass(B, A, C)
        },
        hasClass: function (A, B) {
            return YAHOO.util.Dom.hasClass(A, B)
        },
        show: function (A) {
            HD.removeClass(A, HD.CSS_CLASSES.HIDDEN)
        },
        hide: function (A) {
            HD.addClass(A, HD.CSS_CLASSES.HIDDEN)
        },
        includeJs: function (C, D) {
            var A = D;
            var B = document.createElement("script");
            B.type = "text/javascript";
            B.language = "javascript";
            B.src = C;
            if (navigator.userAgent.indexOf("IE") >= 0) {
                B.onreadystatechange = function () {
                    if (B && ("loaded" == B.readyState || "complete" == B.readyState)) {
                        B.onreadystatechange = null;
                        A()
                    }
                }
            } else {
                B.onload = function () {
                    B.onload = null;
                    A()
                }
            }
            document.getElementsByTagName("head")[0].appendChild(B)
        },
        yuiLoaded: function () {
            for (var B = 0, A = HD.onLoadQueue.length;
            B < A;
            B++) {
                HD.onLoad(HD.onLoadQueue[B])
            }
        },
        containsText: function (A, B) {
            if (A === null) {
                return false
            }
            return A.indexOf(B) > -1
        },
        pluck: function (F, D) {
            var E = [];
            for (var C = 0, B = F.length;
            C < B;
            C++) {
                var A = F[C];
                if (A != D) {
                    E.push(A)
                }
            }
            F = E
        },
        log: function (B, A) {}
    }
}
HD.modules = {
    hd: {
        name: "hd",
        type: "js",
        path: "hd.js",
        requires: [],
        skinnable: true
    },
    hd_common: {
        name: "hd_common",
        type: "js",
        path: "hd_common/hd_common.js",
        requires: []
    },
    hd_dwr: {
        name: "hd_dwr",
        type: "js",
        path: "hd_dwr/hd_dwr.js",
        requires: []
    },
    hd_event: {
        name: "hd_event",
        type: "js",
        path: "hd_event/hd_event.js",
        requires: []
    },
    hd_paging: {
        name: "hd_paging",
        type: "js",
        path: "hd_paging/hd_paging.js",
        requires: ["hd_event"],
        skinnable: true
    },
    hd_widget: {
        name: "hd_widget",
        type: "js",
        path: "hd_widget/hd_widget.js",
        requires: [],
        skinnable: true
    },
    hd_widget_cluster: {
        name: "hd_widget",
        type: "js",
        path: "hd_widget/hd_widget.js",
        requires: ["hd_event"],
        skinnable: true
    },
    hd_gallery_widget: {
        name: "hd_gallery_widget",
        type: "js",
        path: "hd_gallery_widget/hd_gallery_widget.js",
        requires: ["hd_paging"],
        skinnable: true
    },
    hd_detail_widget: {
        name: "hd_detail_widget",
        type: "js",
        path: "hd_detail_widget/hd_detail_widget.js",
        requires: [],
        skinnable: true
    },
    hd_upload_widget: {
        name: "hd_upload_widget",
        type: "js",
        path: "hd_upload_widget/hd_upload_widget.js",
        requires: [],
        skinnable: true
    },
    hd_comments_widget: {
        name: "hd_comments_widget",
        type: "js",
        path: "hd_comments_widget/hd_comments_widget.js",
        requires: [],
        skinnable: true
    },
    hd_most_popular_widget: {
        name: "hd_most_popular_widget",
        type: "js",
        path: "hd_most_popular_widget/hd_most_popular_widget.js",
        requires: [],
        skinnable: true
    },
    hd_monthly_widget: {
        name: "hd_monthly_widget",
        type: "js",
        path: "hd_monthly_widget/hd_monthly_widget.js",
        requires: [],
        skinnable: true
    },
    hd_member_widget: {
        name: "hd_member_widget",
        type: "js",
        path: "hd_member_widget/hd_member_widget.js",
        requires: [],
        skinnable: true
    },
    hd_email: {
        name: "hd_email",
        type: "js",
        path: "hd_email/hd_email.js",
        requires: [],
        skinnable: true
    }
};
HD.SORTS = {
    NEW_TO_OLD: "newToOld",
    OLD_TO_NEW: "oldToNew",
    HIGHEST_RATED: "highestRated",
    MOST_POPULAR: "mostPopular",
    MOST_VOTED: "mostVoted",
    MOST_VIEWED: "mostViewed",
    MOST_COMMENTED: "mostCommented"
};
HD.CSS_CLASSES = {
    WIDGET: "hdWidget",
    GALLERY: "hdGallery",
    MINI_GALLERY: "hdMiniGallery",
    DETAIL: "hdDetail",
    UPLOAD: "hdUpload",
    HANDLE: "hdHandle",
    CONTROL: "hdControl",
    CONTROL_PANEL: "hdControlPanel",
    CONTENT_PANEL: "hdContentPanel",
    SORT: "hdSort",
    MORE: "hdMore",
    LESS: "hdLess",
    PAGING: "hdPaging",
    PAGING_ARROW: "hdPagingArrow",
    PAGING_NONE: "hdNoPaging",
    NEXT: "hdNext",
    CURRENT: "hdCurrent",
    PREVIOUS: "hdPrevious",
    TITLE: "hdTitle",
    AUTHOR: "hdAuthor",
    LABEL: "hdLabel",
    VALUE: "hdValue",
    THUMB: "hdThumb",
    SMALL_THUMB: "hdSmallThumb",
    LARGE_THUMB: "hdLargeThumb",
    SMALL_THUMB_WRAPPER: "hdSmallThumbWrapper",
    LARGE_THUMB_WRAPPER: "hdLargeThumbWrapper",
    THUMB_OVERLAY: "hdThumbOverlay",
    DESCRIPTION: "hdDescription",
    COMMENTS: "hdComments",
    SUBMIT_COMMENT: "hdSubmitComment",
    COMMENT: "hdComment",
    CONSENT: "hdConsent",
    ITEM: "hdItem",
    DATE: "hdDate",
    SHARE: "hdShare",
    SEND_FRIEND: "hdSendFriend",
    SUBSCRIBE: "hdSubscribe",
    LOADING: "hdLoading",
    TOOL_TIP: "hdToolTip",
    HIDDEN: "hdHidden",
    WRAPPER: "hdWrapper",
    EMAIL: "hdEmail",
    EMAIL_FORM: "hdEmailForm",
    BLOG: "hdBlog",
    PHOTO: "hdPhoto",
    VIDEO: "hdVideo",
    VIDEO_PLAYER: "hdVideoPlayer",
    RATING: "hdRating",
    TAG_CLOUD: "hdTagCloud",
    TAG_LIST: "hdTagList",
    CATEGORIES: "hdCategories",
    CATEGORY: "hdCategory",
    TAG: "hdTag",
    TAGS: "hdTags",
    PREVIEW: "hdPreview",
    FULL: "hdFull",
    SHORT: "hdShort",
    MOST_POPULAR: "hdMostPopular",
    MONTHLY_BREAKDOWN: "hdMonthlyBreakdown",
    AUTHOR_BREAKDOWN: "hdAuthorBreakdown",
    STAR_ON: "hdStarOn",
    STAR_OFF: "hdStarOff",
    STAR_OVER: "hdStarOver",
    STAR_HALF: "hdStarHalf",
    SUBMIT: "hdSubmit",
    FIRST: "hdFirst",
    LAST: "hdLast",
    LEFT: "hdLeft",
    RIGHT: "hdRight",
    CENTER: "hdCenter",
    AGREEMENT: "hdAgreement",
    RATED: "hdRated",
    UNRATED: "hdUnrated",
    STATIC: "hdStatic",
    EMPTY: "hdEmpty",
    ERROR: "hdError",
    NAVIGATION: "hdNavigation",
    BACK: "hdBack",
    ACTIVE: "hdActive",
    LIST: "hdList",
    FEATURE_STORIES: "hdFeatureStories",
    CAROUSEL: "hdCarousel",
    EVENTS: "hdEvents",
    EVENT: "hdEvent",
    EVENT_RSVP: "hdEventRSVP",
    RIDES: "hdRides",
    RIDE: "hdRide",
    LOCATION: "hdLocation",
    VIEW_ALL: "hdViewAll",
    VIEW: "hdView",
    CONFIRMATION: "hdConfirmation",
    MEMBER: "hdMember",
    CLOSE: "hdClose",
    ACTION: "hdAction",
    RIDE_PLANNER: "hdRidePlanner",
    SHOW_VIEW: "hdShowView",
    SHOW_ALL: "hdShowAll",
    SHOW_MAX: "hdShowMax",
    SHOW_DEFAULT: "hdShowDefault",
    NO_FLASH: "hdNoFlash",
    MEDIA: "hdMedia",
    TYPE: "hdType",
    CONTEXT: "hdContext",
    SEPARATOR: "hdSeparator",
    TWEET: "hdTweet",
    RETWEET: "hdReTweet",
    REPLY: "hdReply",
    FACEOFF: "hdFaceoff",
    TASKS: "hdTasks",
    FAQ: "hdFAQ",
    POLL: "hdPoll",
    PRINTABLE: "hdPrintable",
    PRINT: "hdPrint",
    PRINT_EXCLUDE_LINK: "hdPrintableLink",
    DISABLED: "hdDisabled"
};
HD.ERRORS = {
    getMessage: function (B, A) {
        if (typeof B == "object") {
            B = B.errorType
        }
        B = (B + "").replace(/\./g, "_");
        return HD.ERRORS[B] || (!A && B) || ""
    },
    getError: function (A) {
        var C = this.getMessage(A, true);
        if (!C) {
            return A.errorMessage || ""
        } else {
            if (typeof C == "function") {
                C = C(A)
            }
            var D = A.errorArguments || [];
            for (var B = 0;
            B < D.length;
            B++) {
                C = C.replace(new RegExp("\\{" + B + "\\}", "g"), this.getMessage(D[B]))
            }
            return C
        }
    },
    sortErrors: function (F, C, B) {
        C = C || [];
        B = B || [];
        var E = {},
            A = {};
        for (var D = 0;
        D < C.length;
        D++) {
            E[C[D]] = D + 1
        }
        for (var D = 0;
        D < B.length;
        D++) {
            A[B[D]] = D + 1
        }
        return F.sort(function (H, G) {
            if ((!E[H.errorType] && E[G.errorType]) || (E[H.errorType] && E[G.errorType] && E[H.errorType] > E[G.errorType])) {
                return 1
            } else {
                if ((!E[G.errorType] && E[H.errorType]) || (E[H.errorType] && E[G.errorType] && E[H.errorType] < E[G.errorType])) {
                    return -1
                } else {
                    if (!A[H.fieldName] && !A[G.fieldName]) {
                        return 0
                    } else {
                        if (!A[H.fieldName]) {
                            return 1
                        } else {
                            if (!A[G.fieldName]) {
                                return -1
                            } else {
                                if (A[H.fieldName] < A[G.fieldName]) {
                                    return -1
                                } else {
                                    if (A[H.fieldName] > A[G.fieldName]) {
                                        return 1
                                    } else {
                                        return 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        })
    },
    selectErrors: function (H, C, B, A) {
        var G = [];
        H = H || [];
        var D = new RegExp("^(" + (C || [".*"]).join("|") + ")$");
        var F = new RegExp("^(" + (B || [".*"]).join("|") + ")$");
        for (var E = 0;
        E < H.length;
        E++) {
            if (H[E].errorType.match(D) && H[E].fieldName.match(F)) {
                G.push(H[E]);
                if (A && G.length == A) {
                    return G
                }
            }
        }
        return G
    },
    hasError: function (D, B, C) {
        D = D || [];
        for (var A = 0;
        A < D.length;
        A++) {
            if ((typeof B !== "undefined" && D[A].errorType == B && typeof C !== "undefined" && D[A].fieldName == C) || (typeof B !== "undefined" && !C && D[A].errorType == B) || (typeof C !== "undefined" && !B && D[A].fieldName == C)) {
                return true
            }
        }
        return false
    },
    error_required: "{0}",
    error_email_invalid: "{0} is invalid, please enter a valid {0}.",
    error_noProfanity: "The {0} cannot contain profanities.",
    error_empty: "The {0} cannot be empty.",
    error_maxlength: "The {0} cannot exceed {1} characters.",
    error_minlength: "The {0} must be at least {1} characters long.",
    error_numbersOnly: "{0} must contain only numbers.",
    error_isDate: "{0} must be a valid date.",
    error_birthdateNumbers: "{0} must contain only numbers.",
    error_birthdateMinAge: "You are not allowed to have a profile if you are younger than {0} years of age.",
    error_passwordsDoNotMatch: "Password and Verify Password must match.",
    error_validZip: "{0} must contain only numbers and be 5 digits long.",
    error_photoEmpty: "You must submit a photo.",
    error_videoEmpty: "You must submit a video.",
    error_mediaEmpty: "You must submit a photo or video.",
    error_photoExt: "Photo must use the following format: (.jpg, .gif)",
    error_videoExt: "Video must use the following format: (.flv, .wmv, .asf, .avi, .mov, .3gp, .mpg, .mpeg, .mp4)",
    error_mediaExt: "Photo must use the following format: (.jpg, .gif)<br/>Video must use the following format: (.flv, .wmv, .asf, .avi, .mov, .3gp, .mpg, .mpeg, .mp4)",
    error_alphaNumeric: "{0} may only contain letters, numbers, and underscores with no spaces.",
    registerForm_username_displayname: "Username",
    registerForm_password_displayname: "Password",
    registerForm_passwordConfirm_displayname: "Verify Password",
    registerForm_firstname_displayname: "First Name",
    registerForm_lastname_displayname: "Last Name",
    registerForm_email_displayname: "Email Address",
    registerForm_dob_displayname: "Birthdate",
    registerForm_screenName_displayname: "Screen Name",
    registerForm_captcha_displayname: "Challenge",
    registerForm_zip_displayname: "ZIP",
    loginForm_email_displayname: "Email Address",
    loginForm_password_displayname: "Password",
    resetPasswordForm_password_displayname: "Password",
    resetPasswordForm_passwordConfirm_displayname: "Verify Password",
    submitComment_commentbody_displayname: "comment body",
    upload_story_displayname: "Story",
    upload_title_displayname: "Title",
    upload_photo_displayname: "Photo",
    upload_video_displayname: "Video",
    upload_media_displayname: "Media",
    upload_category_displayname: "Category"
};
HD.util.Common = {
    observable: null,
    getObservable: function () {
        if (this.observable == null) {
            this.observable = new HD.util.Observable()
        }
        return this.observable
    },
    compareString: function (B, A) {
        return (B === A) ? 0 : (B > A) ? 1 : -1
    },
    showOverlay: function (E, S, J, H, K, B) {
        var F = HD.get("hdwcOverlay");
        if (F) {
            this.hideOverlay(K)
        }
        this.getObservable().notifyObservers("overlayOpen");
        var P = 540 > YAHOO.util.Dom.getViewportHeight() && parseInt(H, 10) > 450;
        if (P) {
            H = YAHOO.util.Dom.getViewportHeight() - 40
        }
        if (!(typeof J == "number")) {
            J = parseInt(J.replace(/px/g, ""))
        }
        if (!(typeof H == "number")) {
            H = parseInt(H.replace(/px/g, ""))
        }
        var D = (YAHOO.util.Dom.getViewportWidth() / 2) - (J / 2);
        var Q = YAHOO.util.Dom.getDocumentScrollTop();
        var C = ((YAHOO.util.Dom.getViewportHeight() + Q) / 2) - (H / 2);
        D = Math.round(D);
        C = Math.round(C);
        var R = {
            constraintoviewport: true,
            close: true,
            draggable: true,
            zIndex: 100000,
            modal: true,
            visible: false,
            iframe: true,
            underlay: "shadow",
            x: D,
            y: C,
            height: typeof H == "number" ? H + "px" : H || null,
            width: typeof J == "number" ? J + "px" : J || null
        };
        var O = new YAHOO.widget.Panel("hdwcOverlay", R);
        O.setBody(E);
        O.render(document.body);
        O.center();
        if (B) {
            var A = HD.get("hdwcOverlay");
            HD.addClass(A, B)
        }
        O.show();
        var I = this;
        var N = function () {
            var T = I.getObservable.call(I);
            ////////EDITED HERE TO DESTROY THE ORIGINAL OVERLAY
            T.notifyObservers("overlayClose_Click");
            HD.util.Common.hideOverlay(/*K*/)
        };
        var F = HD.get("hdwcOverlay");
        var G = HD.getByClass("hdClose", "*", F);
        if (G.length > 0) {
            G[0].onclick = N
        }
        G = HD.getByClass("container-close", "a", F);
        for (var L = 0, M = G.length;
        L < M;
        L++) {
            G[L].href = "javascript:void(0)";
            (function () {
                G[L].onclick = N
            })()
        }
        if (P) {
            YAHOO.util.Event.onContentReady("hdwcBody", function () {
                var U = HD.get("hdwcBody");
                var T = HD.get("scrollableDiv");
                if (U) {
                    U.style.height = (parseInt(H, 10) - 65) + "px"
                }
                if (T) {
                    T.style.height = (parseInt(H, 10) - 90) + "px"
                }
            });
            YAHOO.util.Event.onContentReady("suggestions", function () {
                var U = YAHOO.util.Dom.getElementsByClassName("suggestionsContentWrapper", "div");
                if (U[0]) {
                    for (var T = 0;
                    T < U.length;
                    T++) {
                        U[T].style.height = (parseInt(H, 10) - 65) + "px"
                    }
                }
            })
        }
        this.overlay = O;
        return F
    },
    hideOverlay: function (A) {
        if (this.overlay != null) {
            this.overlay.hide();
            if (!A) {
                this.overlay.destroy()
            }
            this.getObservable().notifyObservers("overlayClose")
        }
    },
    scrollOverlay: function () {
        if (this.overlay != null) {
            var D = this.overlay.getFocusableElements();
            var C = D[0];
            var A = C.contentWindow.document;
            var B = A.getElementById("hdwcBody");
            B.scrollTop = 0
        }
    },
    closeOverlay: function (C) {
        var B = YAHOO.util.Dom.getElementsByClassName(C);
        for (var A = 0;
        A < B.length;
        A++) {
            YAHOO.util.Event.on(B[A], "click", function () {
                if (window.parent) {
                    window.parent.HDWC.util.hideOverlay()
                }
            })
        }
    },
    createModule: function (D, A, B, E, F) {
        var C = new YAHOO.widget.Module(D, {
            visible: A
        });
        C.render();
        var G = A;
        if (B != null) {
            YAHOO.util.Event.on(B, "click", function () {
                G = !G;
                C[G ? "show" : "hide"].call(C)
            })
        }
        if (E != null) {
            YAHOO.util.Event.on(E, "click", function () {
                G = !G;
                C.show.call(C)
            })
        }
        if (F != null) {
            YAHOO.util.Event.on(F, "click", function () {
                G = !G;
                C.hide.call(C)
            })
        }
    },
    createTabs: function (C, F) {
        if (C == null || C.length < 1 || F == null) {
            return null
        }
        var E = new YAHOO.widget.TabView();
        for (var B = 0, A = C.length;
        B < A;
        B++) {
            var D = C[B];
            E.addTab(new YAHOO.widget.Tab({
                label: D.header,
                content: D.body,
                active: D.isActive || false
            }))
        }
        E.appendTo(F);
        return E
    },
    requestContent: function (C, E, D) {
        if (!this.hasValue(D)) {
            D = "GET"
        }
        var A = E;
        var B = {
            success: function (F) {
                A(F.responseText)
            },
            failure: function (F) {}
        };
        YAHOO.util.Connect.asyncRequest(D, C, B)
    },
    hasValue: function (A) {
        return A != null && A != ""
    },
    timestamp: function () {
        return new Date().getTime()
    },
    generateElementId: function () {
        return "hdEl" + this.timestamp() + Math.floor(Math.random() * 10000)
    },
    uploadFile: function (D, C, E) {
        YAHOO.util.Connect.setForm(D, true);
        var A = E;
        var B = {
            upload: function (F) {
                A(F.responseText)
            },
            failure: function (F) {}
        };
        return YAHOO.util.Connect.asyncRequest("POST", C, B)
    },
    getRequestParam: function (B) {
        if (!B) {
            return
        }
        B = B.replace(/\[/g, "[").replace(/\]/g, "]");
        var A = "[\\?&]" + B + "=([^&#]*)";
        var E = new RegExp(A);
        var D = E.exec(window.location.href);
        var C = D == null ? null : D[1];
        return !!C && C.match(/^(true|1)$/) ? true : ( !! C && C.match(/^(false|0)$/) ? false : ( !! C && C.match(/^(null|undefined)$/) ? null : C))
    },
    log: function (A) {},
    includeJs: function (C, D) {
        var A = D;
        var B = document.createElement("script");
        B.type = "text/javascript";
        B.language = "javascript";
        B.src = C;
        if (navigator.userAgent.indexOf("IE") >= 0) {
            B.onreadystatechange = function () {
                if (B && ("loaded" == B.readyState || "complete" == B.readyState)) {
                    B.onreadystatechange = null;
                    A()
                }
            }
        } else {
            B.onload = function () {
                B.onload = null;
                A()
            }
        }
        document.getElementsByTagName("head")[0].appendChild(B)
    },
    callbackCounter: 0,
    insertContent: function (B, A, E) {
        var D = "hdcb" + this.callbackCounter++;
        window[D] = E;
        if (A.indexOf("?") < 0) {
            A += "?"
        } else {
            if (A.indexOf("&") == A.length - 1) {} else {
                A += "&"
            }
        }
        A += "hdcbid=" + D;
        var C = this.get(B);
        this.requestContent(A, function (F) {
            var G = document.createElement("div");
            G.innerHTML = F;
            C.appendChild(G)
        })
    },
    get: function (A) {
        return YAHOO.util.Dom.get(A)
    },
    trim: function (B, A) {
        if (B.length > A) {
            B = B.substr(0, A).replace(/\s*$/, "")
        }
        return B
    },
    stripHtmlTags: function (L, O, P, K, F) {
        if (O) {
            var B = P || ["img", "embed"];
            var N = document.createElement("div");
            N.innerHTML = L;
            var I = function (T) {
                var Q = true;
                if (T.childNodes && T.childNodes.length > 0) {
                    for (var S = 0, R = T.childNodes.length;
                    S < R;
                    S++) {
                        if (!T.childNodes[S].nodeName.match(/^br$/i)) {
                            Q = false;
                            break
                        }
                    }
                }
                return Q
            };
            var E = function (R, S) {
                if (R && (S || I(R))) {
                    var Q = R.parentNode;
                    Q.removeChild(R);
                    arguments.callee(Q)
                }
            };
            if (F) {
                var J = 0;
                var M = new RegExp("^(" + B.join("|") + ")$", "i");
                var D = N.getElementsByTagName("*");
                var A = [];
                for (var H = 0, C = D.length;
                H < C;
                H++) {
                    A.push(D[H])
                }
                for (var G = 0, C = A.length;
                G < C;
                G++) {
                    if (A[G].nodeName.match(M)) {
                        E(A[G], true);
                        J++
                    }
                    if (J >= F) {
                        break
                    }
                }
            } else {
                for (var H = 0;
                H < B.length;
                H++) {
                    var A = N.getElementsByTagName(B[H]);
                    for (var G = A.length - 1;
                    G >= 0;
                    G--) {
                        E(A[G], true)
                    }
                }
            }
            return K ? N : N.innerHTML
        } else {
            return L.replace(/<\S[^><]*>/g, "")
        }
    },
    ellipseText: function (G, C, I) {
        if (G.length > C) {
            if (I) {
                var H = this.stripHtmlTags(G, I, null, true);
                var F = [];
                (function (K) {
                    if (K.nodeType == 3) {
                        F.push(K)
                    } else {
                        for (var J = 0;
                        J < K.childNodes.length;
                        J++) {
                            arguments.callee(K.childNodes[J])
                        }
                    }
                })(H);
                var A = 0;
                var B = null;
                for (var D = 0;
                D < F.length;
                D++) {
                    if (F[D].data.length + A > C) {
                        B = F[D];
                        B.data = this.trim(B.data, C - A);
                        var E = B.data.lastIndexOf(" ");
                        if (E > 0) {
                            B.data = B.data.substr(0, E)
                        }
                        B.data += "...";
                        break
                    } else {
                        A += F[D].data.length
                    }
                }
                if (B) {
                    (function (J) {
                        if (J) {
                            while (J.nextSibling) {
                                J.parentNode.removeChild(J.nextSibling)
                            }
                            arguments.callee(J.parentNode)
                        }
                    })(B)
                }
                G = H.innerHTML
            } else {
                G = this.stripHtmlTags(G, I);
                G = this.trim(G, C);
                var E = G.lastIndexOf(" ");
                if (E > 0) {
                    G = G.substr(0, E)
                }
                G += "..."
            }
        }
        return G
    },
    round: function (B, C) {
        if (C == null) {
            C = 0
        }
        var D = Math.pow(10, C);
        var A = Math.round(B * D);
        return A / D
    },
    getAppUrl: function () {
        return window.location.href.split("?")[0]
    },
    getHostUrl: function () {
        var A = window.location;
        return A.host
    },
    getServerUrl: function () {
        var A = window.location;
        return [A.protocol, "//", A.host].join("")
    },
    setCookie: function (B, C, E) {
        try {
            var A = "";
            if (E != null) {
                A = "; expires=" + E
            }
            document.cookie = B + "=" + C + A + "; path=/"
        } catch (D) {}
    },
    getCookie: function (B, F) {
        try {
            F = F != null ? F : document;
            var E = B + "=";
            var A = F.cookie.split(";");
            for (var C = 0;
            C < A.length;
            C++) {
                var G = A[C];
                while (G.charAt(0) == " ") {
                    G = G.substring(1, G.length)
                }
                if (G.indexOf(E) == 0) {
                    return G.substring(E.length, G.length)
                }
            }
            return null
        } catch (D) {}
    },
    eraseCookie: function (A) {
        setCookie(A, "", -1)
    },
    contains: function (D, C) {
        if (D != null && C != null) {
            for (var B = 0, A = D.length;
            B < A;
            B++) {
                if (D[B] == C) {
                    return true
                }
            }
        }
        return false
    },
    scrollTo: function (A) {
        var C = 0;
        var B = 0;
        while (A != null) {
            C += A.offsetLeft;
            B += A.offsetTop;
            A = A.offsetParent
        }
        window.scrollTo(C, B)
    },
    scrollToTop: function () {
        window.scrollTo(0, 0)
    },
    addImage: function (A, C) {
        var B = new Image();
        if (C) {
            B.onload = C
        }
        B.src = A;
        B.style.width = "0px";
        B.style.height = "0px";
        document.body.appendChild(B)
    },
    printStackTrace: function () {
        var I = [];
        var B = false;
        try {
            D.dont.exist += 0
        } catch (F) {
            if (F.stack) {
                var J = F.stack.split("\n");
                for (var D = 0, E = J.length;
                D < E;
                D++) {
                    if (J[D].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                        I.push(J[D])
                    }
                }
                I.shift();
                B = true
            } else {
                if (window.opera && F.message) {
                    var J = F.message.split("\n");
                    for (var D = 0, E = J.length;
                    D < E;
                    D++) {
                        if (J[D].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                            var H = J[D];
                            if (J[D + 1]) {
                                H += " at " + J[D + 1];
                                D++
                            }
                            I.push(H)
                        }
                    }
                    I.shift();
                    B = true
                }
            }
        }
        if (!B) {
            var A = arguments.callee.caller;
            while (A) {
                var G = A.toString();
                I.push(G);
                A = A.caller
            }
        }
        var C = HD.get("hdConsole");
        if (C == null) {
            C = document.createElement("div");
            C.id = "hdConsole";
            document.body.appendChild(C)
        }
        C.innerHTML = I.join("<br/>");
        return
    },
    analyticsOpenString: function () {
        return "default_analyticsOpenString"
    },
    analyticsCloseString: function () {
        return "default_analyticsCloseString"
    }
};
HD.register("hd_common", HD.util.Common, {
    version: "1.0",
    build: "1"
});
HD.util.DOM = {
    onDOMReady: function (A) {
        YAHOO.util.Event.onDOMReady(A)
    },
    onAvailable: function (A, B) {
        YAHOO.util.Event.onAvailable(A, B)
    },
    onContentReady: function (A, B) {
        YAHOO.util.Event.onContentReady(A, B)
    },
    hide: function (A) {
        HD.addClass(A, HD.CSS_CLASSES.HIDDEN)
    },
    show: function (A) {
        HD.removeClass(A, HD.CSS_CLASSES.HIDDEN)
    }
};
HD.util.DWR = {
    initSession: function () {
        try {
            if (typeof dwr != "undefined" && typeof dwr.engine != "undefined") {
                dwr.engine._getJSessionId = function () {
                    var B = HD.util.DWR.document;
                    if (!B) {
                        var C = document.getElementById("dwr");
                        if (C) {
                            B = C.contentWindow || C.contentDocument;
                            if (B.document) {
                                B = B.document
                            }
                        } else {
                            B = document
                        }
                        HD.util.DWR.document = B
                    }
                    var D = HD.util.Common.getCookie(dwr.engine._sessionCookieName, B);
                    if (D == null) {
                        D = ""
                    }
                    return D
                }
            }
        } catch (A) {}
    },
    getDefaultErrorHandler: function () {
        return function (I, A) {
            var D = [];
            for (var H in A) {
                D.push(H + " : " + A[H] + "\n")
            }
            var G = [];
            var F = A.stackTrace;
            if (F != null) {
                for (var C = 0, E = F.length;
                C < E;
                C++) {
                    var B = F[C];
                    G.push(B.methodName);
                    G.push(" in ");
                    G.push(B.fileName);
                    G.push(" [");
                    G.push(B.lineNumber);
                    G.push("] ");
                    G.push("\n")
                }
            }
        }
    },
    setErrorHandler: function (A) {
        var A = !! A ? A : this.getDefaultErrorHandler();
        dwr.engine.setErrorHandler(A)
    }
};
HD.register("hd_dwr", HD.util.DWR, {
    version: "1.0",
    build: "1"
});
HD.util.Observable = function () {
    this.observers = []
};
HD.util.Observable.prototype = {
    setObservers: function (A) {
        this.observers = A
    },
    addObserver: function (A) {
        this.observers.push(A)
    },
    removeObserver: function (B) {
        var E = [];
        var F = this.observers;
        for (var D = 0, A = F.length;
        D < A;
        D++) {
            var C = F[D];
            if (C != B) {
                E.push(C)
            }
        }
        this.setObservers(E)
    },
    notifyObservers: function (A, C) {
        var D = this.observers;
        for (var B = D.length - 1;
        B > -1;
        B--) {
            D[B].update(A, C)
        }
    },
    checkObservers: function (B) {
        var E = this.observers;
        for (var D = 0, A = E.length;
        D < A;
        D++) {
            var C = E[D];
            if (C == B) {
                return true
            }
        }
        return false
    }
};
HD.register("hd_observable", HD.util.Observable, {
    version: "1.0",
    build: "1"
});
HD.util.Template = function (A) {
    this.config = A;
    this.loadTemplates(arguments.callee)
};
HD.util.Template.prototype = {
    processTemplate: function (C, B, A) {
        B = HD.merge(this.TEMPLATE_CONTEXT, B || {});
        B._MODIFIERS = HD.merge(this.TEMPLATE_MODIFIERS, B._MODIFIERS || {});
        return C.process(B, A)
    },
    loadTemplates: function (A, G, D, H) {
        var B = this,
            F = HD.util.Common,
            C = HD.ERRORS;
        if (typeof A == "function") {
            var E = A;
            A = E.templates;
            G = E.hooks
        }
        if (D) {
            this.config = this.config || {};
            this.config.dateFormat = this.config.dateFormat || D.config.dateFormat || null;
            this.config.templates = HD.merge(HD.clone(A || {}, true), (D.config || this.config)[D.templates] || {});
            this.config.hooks = HD.merge(HD.clone(G || {}, true), (D.config || this.config)[D.hooks] || {})
        } else {
            if (!H) {
                this.config.templates = HD.merge(HD.clone(A || {}, true), this.config.templates || {});
                this.config.hooks = HD.merge(HD.clone(G || {}, true), this.config.hooks || {})
            }
        }
        this.TEMPLATE_CONTEXT = {
            classes: HD.CSS_CLASSES,
            config: this.config || {},
            hooks: this.config ? this.config.hooks || {} : {},
            templates: this.config ? this.config.templates || {} : {}
        };
        this.TEMPLATE_MODIFIERS = {
            date: function (I) {
                return HD.util.Date.format(I, B.config.dateFormat || "")
            },
            ellipse: function () {
                return F.ellipseText.apply(F, arguments)
            },
            facade: function (I) {
                return (I && I.facade.getHtml(B.config, B.model)) || ""
            },
            round: function () {
                return F.round.apply(F, arguments)
            },
            strip: function () {
                return F.stripHtmlTags.apply(F, arguments)
            },
            trim: function () {
                return F.trim.apply(F, arguments)
            },
            sortErrors: function () {
                return C.sortErrors.apply(C, arguments)
            },
            selectErrors: function () {
                return C.selectErrors.apply(C, arguments)
            },
            hasError: function () {
                return C.hasError.apply(C, arguments)
            },
            getError: function () {
                return C.getError.apply(C, arguments)
            }
        }
    },
    getByHook: function (D, B, A, C) {
        return HD.getByClass(this.config.hooks[D], A || "*", C || this.getParent(), B || null)
    }
};
HD.register("hd_template", HD.util.Template, {
    version: "1.0",
    build: "1"
});
HD.util.Printable = function () {};
HD.util.Printable.prototype = {
    printable: true,
    print: function (D) {
        if (!D) {
            return
        }
        var C = HD.CSS_CLASSES;
        var G = HD.util.Common.showOverlay(D.cloneNode(true), "Print", 650, (YAHOO.util.Dom.getViewportHeight() - 100));
        var F = G.getElementsByTagName("*");
        for (var B = 0, A = F.length;
        B < A;
        B++) {
            if (!HD.hasClass(F[B], C.PRINT)) {
                HD.addClass(F[B], YAHOO.util.Dom.getStyle(F[B], "display"))
            }
        }
        var E = G.getElementsByTagName("a");
        for (var B = 0, A = E.length;
        B < A;
        B++) {
            if (!HD.hasClass(E[B], C.PRINT_EXCLUDE_LINK) && !HD.hasClass(E[B], "container-close")) {
                E[B].onclick = function () {
                    return false
                }
            }
        }
        HD.addClass(document.body, C.PRINTABLE);
        HD.util.Common.getObservable().addObserver({
            update: function (H, I) {
                if (H == "overlayClose_Click") {
                    HD.removeClass(document.body, C.PRINTABLE);
                    HD.util.Common.getObservable().removeObserver(this)
                }
            }
        });
        HD.util.Analytics.track(this.analyticsPrintString(this))
    },
    setPrintListeners: function (B) {
        if (!B) {
            return
        }
        var A = this;
        HD.getByClass(HD.CSS_CLASSES.PRINT, "*", B, function (C) {
            C.onclick = function () {
                A.print(B)
            }
        })
    },
    analyticsPrintString: function (A) {
        return "default_analyticsPrintString"
    }
};
HD.register("hd_printable", HD.util.Printable, {
    version: "1.0",
    build: "1"
});
HD.Widget = function (A) {
    this.config = A;
    this.loadTemplates(arguments.callee);
    if (this.config.parent) {
        this.config.parent = HD.get(this.config.parent) || this.config.parent
    }
};
HD.Widget.prototype = {
    getParent: function () {
        return HD.get(this.config.parent)
    },
    render: function (B) {
        var A = this.getParent();
        A.innerHTML = this.getHtml(B);
        this.setListeners(B);
        if (this.printable) {
            this.setPrintListeners(A)
        }
    },
    setListeners: function (A) {},
    destroy: function () {
        var A = this.getParent();
        A.innerHTML = ""
    },
    loading: function (A) {
        var B = this.getParent();
        if (A) {
            HD.addClass(B, HD.CSS_CLASSES.LOADING)
        } else {
            HD.removeClass(B, HD.CSS_CLASSES.LOADING)
        }
    },
    update: function (A, B) {},
    getHtml: function (A) {
        return ""
    },
    analyticsString: function () {
        return ""
    }
};
HD.extend(HD.Widget, [HD.util.Observable, HD.util.Template]);
if (HD.util.Printable) {
    HD.extend(HD.Widget, [HD.util.Printable])
}
HD.register("hd_widget", HD.Widget, {
    version: "1.0",
    build: "1"
});
HD.util.Event = function (A) {
    this.name = A;
    this.listeners = []
};
HD.util.Event.prototype.subscribe = function (A) {
    this.listeners.push(A)
};
HD.util.Event.prototype.unsubscribe = function (E) {
    var D = [];
    for (var C = 0, A = this.listeners.length;
    C < A;
    C++) {
        var B = this.listeners[C];
        if (B != E) {
            D.push(B)
        }
    }
    this.listeners = D
};
HD.util.Event.prototype.unsubscribeAll = function () {
    this.listeners = []
};
HD.util.Event.prototype.fire = function (D, C) {
    for (var B = 0, A = this.listeners.length;
    B < A;
    B++) {
        this.listeners[B](D, C)
    }
};
HD.register("hd_event", HD.util.Event, {
    version: "1.0",
    build: "1"
});
HD.Login = function (A) {
    this.model = new HD.Login.Model(A);
    this.view = new HD.Login.View(this.model);
    this.controller = new HD.Login.Controller(this.model, this.view);
    registerWait = new YAHOO.widget.Panel("registerWait", {
        width: "32px",
        fixedcenter: true,
        close: false,
        draggable: false,
        zindex: 200000,
        modal: true,
        underlay: "none",
        visible: false
    });
    registerWait.setHeader("");
    registerWait.setBody('<img src="' + comMediaBaseUrl + '/hd/hd_login/assets/skins/hd/loading.gif"/>');
    registerWait.render(document.body)
};
HD.Login.ANONYMOUS_USER_NAME = "anonymousUser";
HD.Login.Model = function (A) {
    this.config = A;
    this.config.showSoftLogin = this.config.showSoftLogin || false;
    this.config.updateGlobalNav = this.config.updateGlobalNav || true;
    this.config.showRegOptInFull = this.config.showRegOptInFull || false;
    this.config.regOptInChoices = this.config.regOptInChoices || [];
    this.events = {
        registered: new HD.util.Event("registered"),
        authenticated: new HD.util.Event("authenticated"),
        passwordReset: new HD.util.Event("passwordReset"),
        screenNameCreated: new HD.util.Event("screenNameCreated"),
        subscriptionsUpdated: new HD.util.Event("subscriptionsUpdated")
    };
    this.ready = true;
    this.ilTicket = null;
    this.queue = [];
    this.observers = []
};
HD.Login.Model.prototype = {
    ANONYMOUS: "anonymous",
    REGISTERED: "registered",
    AUTHENTICATED: "authenticated",
    publicSites: [/^https?:\/\/www\.harley-davidson\.com.*/, /^https?:\/\/www\.buell\.com.*/, /^https?:\/\/members\.hog\.com.*/],
    profileUrl: "",
    queueRequest: function (A) {
        if (!this.ready) {
            this.queue.push(A)
        } else {
            A()
        }
    },
    processQueue: function (A) {
        if (this.ready) {
            while (this.queue.length > 0) {
                this.queue.shift()(A)
            }
        }
    },
    setRpc: function (B) {
        this.rpcType = DWREngine._rpcType;
        this.path = UserService._path;
        if (this.isPublicSite() && (!B || !YAHOO.env.ua.ie || YAHOO.env.ua.ie >= 7)) {
            var A = HD.util.Common.getServerUrl();
            if (A.indexOf("https") != 0) {
                A = A.replace(/http/, "https")
            }
            UserService._path = A + UserService._path;
            DWREngine.setMethod(DWREngine.ScriptTag)
        }
    },
    resetRpc: function () {
        DWREngine.setMethod(this.rpcType);
        UserService._path = this.path
    },
    isPublicSite: function () {
        var B = HD.util.Common.getServerUrl();
        for (var C = 0, A = this.publicSites.length;
        C < A;
        C++) {
            if (B.match(this.publicSites[C])) {
                return true
            }
        }
        return false
    },
    cacheUser: function (A) {
        this.ilTicket = (A.loggedInLevel > 1 && A.user && A.user.ilTicket) || null
    },
    clearUser: function () {
        this.ilTicket = null
    },
    getUser: function (C) {
        this.notifyObservers("getUser_Start");
        var A = this;
        var B = {};
        this.setFilters(B);
        UserService.getLoggedInStatus(B, function (D) {
            A.cacheUser(D);
            if (C) {
                C(D)
            }
            A.notifyObservers.call(A, "getUser_Finish", D)
        })
    },
    init: function (D, B) {
        this.forceLogin = !! B;
        this.ready = !this.forceLogin || false;
        if (this.forceLogin) {
            var C = D ||
            function () {};
            D = function () {
                C();
                (function E() {
                    A.getUser(function (F) {
                        if (F.loggedInLevel > 1) {
                            A.ready = true;
                            A.processQueue(F)
                        } else {
                            setTimeout(function () {
                                E()
                            }, 250)
                        }
                    })
                })()
            }
        }
        var A = this;
        this.notifyObservers("loginInit_Start");
        UserService.getIlCookies(function (E) {
            var G = HD.util.Common.getServerUrl() + "/Community/services/ILInit/?secret=" + HD.util.Common.timestamp();
            var F = E.profile + "/cpapp/auth/ILTicket.h-d?nologin=1&ret_uri=" + escape(G);
            A.profileUrl = E.profile;
            HD.util.Common.addImage(F, D || null);
            A.notifyObservers("loginInit_Finish", HD.merge(E, {
                returnUrl: G
            }))
        })
    },
    authenticate: function (C) {
        this.setRpc();
        var A = this;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.authenticate(B, function (D) {
            A.handleAuthenticate.call(A, D);
            registerWait.hide()
        });
        registerWait.show();
        this.resetRpc()
    },
    handleAuthenticate: function (A) {
        this.cacheUser(A);
        if (A != null) {
            if ((A.user.screenName == null) && (A.user.ilTicket != null)) {
                this.events.screenNameCreated.fire(A)
            } else {
                this.events.authenticated.fire(A)
            }
        }
    },
    register: function (C) {
        this.setRpc(true);
        var A = this;
        var D = C;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.register(B, function (F) {
            A.handleRegister.call(A, F);
            registerWait.hide()
        });
        var E = HD.get(HD.Login.Overlay.REGISTER.content.hooks.BODY);
        registerWait.show();
        this.resetRpc()
    },
    handleRegister: function (A) {
        this.cacheUser(A);
        this.events.registered.fire(A)
    },
    resetPassword: function (C) {
        this.setRpc();
        var A = this;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.update(B, function (D) {
            A.handleResetPassword.call(A, D);
            registerWait.hide()
        });
        registerWait.show();
        this.resetRpc()
    },
    handleResetPassword: function (A) {
        this.cacheUser(A);
        this.events.passwordReset.fire(A)
    },
    checkScreenName: function (C) {
        var A = this;
        var D = C;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.checkScreenname(B, function (E) {
            A.handleCheckScreenName.call(A, E);
            registerWait.hide()
        });
        registerWait.show()
    },
    handleCheckScreenName: function (A) {
        this.cacheUser(A);
        this.events.registered.fire(A)
    },
    checkScreenNameCreate: function (C) {
        var A = this;
        var D = C;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.checkScreenname(B, function (E) {
            A.handleCheckScreenNameCreate.call(A, E);
            registerWait.hide()
        });
        registerWait.show()
    },
    handleCheckScreenNameCreate: function (A) {
        this.cacheUser(A);
        this.events.screenNameCreated.fire(A)
    },
    createScreenName: function (C) {
        var A = this;
        var D = C;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.createScreenName(B, function (E) {
            A.handleCreateScreenName.call(A, E);
            registerWait.hide()
        });
        registerWait.show()
    },
    handleCreateScreenName: function (A) {
        this.cacheUser(A);
        this.events.screenNameCreated.fire(A)
    },
    manageSubscriptions: function (C) {
        var A = this;
        var D = C;
        var B = {
            user: C
        };
        this.setFilters(B);
        UserService.update(B, function (E) {
            A.handleManageSubscriptions.call(A, E);
            registerWait.hide()
        });
        registerWait.show()
    },
    handleManageSubscriptions: function (A) {
        this.cacheUser(A);
        this.events.subscriptionsUpdated.fire(A)
    },
    setFilters: function (A) {
        A.siteName = this.config.siteName
    },
    isUserLoggedIn: function (D, C) {
        var B = {},
            A = this;
        this.setFilters(B);
        this.queueRequest(function (E) {
            if ( !! E) {
                A.cacheUser(E);
                D(E)
            } else {
                UserService.getLoggedInStatus(B, function (G) {
                    A.cacheUser(G);
                    if (!C || G.loggedInLevel > 1) {
                        D(G)
                    } else {
                        var F = {
                            update: function (H, I) {
                                if (H == "logged_In") {
                                    D(I);
                                    A.removeObserver(this);
                                    HD.util.Common.getObservable().removeObserver(this)
                                } else {
                                    if (H == "overlayClose_Click") {
                                        A.removeObserver(this);
                                        HD.util.Common.getObservable().removeObserver(this)
                                    }
                                }
                            }
                        };
                        HD.util.Common.getObservable().addObserver(F);
                        A.addObserver(F);
                        if (G.loggedInLevel > 0 && window.login) {
                            login.view.promptCreateScreenName()
                        } else {
                            if (window.login) {
                                login.view.promptAuthentication()
                            }
                        }
                    }
                })
            }
        })
    }
};
HD.extend(HD.Login.Model, [HD.util.Observable]);
HD.Login.View = function (B) {
    this.overlays = HD.Login.Overlay;
    this.model = B;
    this.config = B.config;
    this.AUTHENTICATE_FORM_ID = "hdAuthenticateForm";
    this.AUTHENTICATE_SUBMIT_ID = "hdAuthenticateSubmit";
    this.REGISTER_FORM_ID = "hdRegisterForm";
    this.REGISTER_SUBMIT_ID = "hdRegisterSubmit";
    this.CHECK_SCREENNAME_ID = "hdCheckScreenname";
    this.SUBSCRIPTIONS_ID = "hdSubscriptionsForm";
    this.events = {
        registerClick: new HD.util.Event("registerClick"),
        authenticateClick: new HD.util.Event("authenticateClick"),
        resetPasswordClick: new HD.util.Event("resetPasswordClick"),
        screennameCheckClick: new HD.util.Event("screennameClick"),
        checkSNCreateClick: new HD.util.Event("checkSNCreateClick"),
        createScreenNameClick: new HD.util.Event("createScreenNameClick"),
        manageSubscriptionsClick: new HD.util.Event("manageSubscriptionsClick")
    };
    var A = this;
    this.model.events.authenticated.subscribe(function (C) {
        A.handleAuthenticated.call(A, C)
    });
    this.model.events.registered.subscribe(function (C) {
        A.handleRegistered.call(A, C)
    });
    this.model.events.passwordReset.subscribe(function (C) {
        A.handleResetPassword.call(A, C)
    });
    this.model.events.screenNameCreated.subscribe(function (C) {
        A.handleScreenNameCreated.call(A, C)
    });
    this.model.events.subscriptionsUpdated.subscribe(function (C) {
        A.handleManageSubscriptions.call(A, C)
    });
    this.observers = [];
    this.model.addObserver(this)
};
HD.Login.View.prototype = {
    update: function (B, C) {
        var A = this;
        if (B == "getUser_Finish") {
            A.loginStatus.call(A, C)
        }
    },
    loginStatus: function (B) {
        var A = "notLogged_In";
        if (B != null) {
            if (B.loggedInLevel > 1) {
                A = "logged_In"
            }
        }
        this.model.notifyObservers(A, B)
    },
    showForm: function (E, C) {
        var A = this;
        var B = E.content;
        var D = HD.util.Common.timestamp();
        registerWait.show();
        var F = HD.util.Common.showOverlay(E.getHtml(HD.merge(C || {}, {
            profile: this.model.profileUrl || "",
            showRegFullOptIn: this.config.showRegOptInFull,
            regOptInChoices: this.config.regOptInChoices
        })), B.title, B.width, B.height);
        A.setupListeners.call(A, F, B);
        registerWait.hide()
    },
    showFormScrolled: function (G, C) {
        var A = this;
        var B = G.content;
        var E = HD.util.Common.timestamp();
        registerWait.show();
        var H = HD.util.Common.showOverlay(G.getHtml(HD.merge(C || {}, {
            profile: this.model.profileUrl || "",
            showRegFullOptIn: this.config.showRegOptInFull,
            regOptInChoices: this.config.regOptInChoices
        })), B.title, B.width, B.height);
        A.setupListeners.call(A, H, B);
        var D = HD.get(B.hooks.BODY);
        var F = HD.get(B.hooks.FORM_BOTTOM).offsetTop;
        D.scrollTop = F;
        registerWait.hide()
    },
    setupListeners: function (E, C) {
        var B = HD.getByClass(C.hooks.FORM, "form", E)[0] || null;
        var A = this;
        if (B != null) {
            B.onsubmit = function () {
                HD.addClass(B, "hdFormLoading");
                A[C.callback].call(A, B);
                return false
            };
            HD.getByClass(C.hooks.OPT_IN, "*", B, function (F) {
                F.onclick = function () {
                    HD.getByClass(C.hooks.OPT_IN_SUB, "*", B, function (G) {
                        if (!F.checked) {
                            G.checked = false;
                            G.disabled = true
                        } else {
                            G.disabled = false
                        }
                    })
                }
            })
        }
        var D = HD.getByClass(C.hooks.SHOW_REGISTER || "hdShowRegister", "*", E);
        if (D != null && D.length > 0) {
            D[0].onclick = function () {
                A.promptRegistration.call(A)
            }
        }
        D = HD.getByClass(C.hooks.LOGOUT || "hdLogout", "*", E);
        if (D != null && D.length > 0) {
            D[0].onclick = function () {
                A.logoutUser.call(A);
                HD.util.Common.hideOverlay()
            }
        }
    },
    promptCreateScreenName: function (A) {
        HD.util.Analytics.track(this.analyticsScreenNameString());
        this.showForm(this.overlays.SCREENNAME, A || null)
    },
    onScreenNameSubmit: function (B) {
        var A = this.collectUserData(B);
        if ((B.checkingScreenname.value == "true")) {
            this.events.checkSNCreateClick.fire(A)
        } else {
            this.events.createScreenNameClick.fire(A)
        }
    },
    promptSubscriptions: function (A) {
        HD.util.Analytics.track(this.analyticsSubscriptionsString());
        this.showForm(this.overlays.SUBSCRIPTIONS, A || null)
    },
    onSubscriptionsSubmit: function (B) {
        var A = this.collectUserData(B);
        this.events.manageSubscriptionsClick.fire(A)
    },
    promptAuthentication: function () {
        HD.util.Analytics.track(this.analyticsAuthenticateString());
        if (this.config.showSoftLogin && this.isSoftLoggedIn()) {
            this.showForm(this.overlays.AUTHENTICATE_SOFT)
        } else {
            this.showForm(this.overlays.AUTHENTICATE)
        }
    },
    onAuthenticationSubmit: function (B) {
        var A = this.collectUserAuthenticateData(B);
        this.events.authenticateClick.fire(A)
    },
    promptRegistration: function () {
        HD.util.Analytics.track(this.analyticsRegisterString());
        this.showForm(this.overlays.REGISTER)
    },
    logoutUser: function (B) {
        UserService.clearSessionUserInfo();
        UserService.logoutUser();
        this.model.clearUser();
        this.loginStatus();
        var A = this;
        UserService.getIlCookies(function (C) {
            var D = HD.util.Common.timestamp();
            HD.util.Common.addImage(C.hdLogout + "?timestamp=" + D);
            HD.util.Common.addImage(C.buellLogout + "?timestamp=" + D);
            HD.util.Common.addImage(C.hogLogout + "?timestamp=" + D);
            HD.util.Common.addImage(C.rideplannerLogout + "?timestamp=" + D);
            HD.util.Common.addImage(C.profile + "/cpapp/ilCookie/delete/", B);
            setTimeout(function () {
                if (B) {
                    B()
                }
            }, 2000)
        })
    },
    onRegistrationSubmit: function (B) {
        var A = this.collectUserData(B);
        if ((B.checkingScreenname.value == "true")) {
            this.events.screennameCheckClick.fire(A)
        } else {
            this.events.registerClick.fire(A)
        }
    },
    onResetPasswordSubmit: function (B) {
        var A = this.collectUserData(B);
        this.events.resetPasswordClick.fire(A)
    },
    showLogoutOverlay: function () {
        this.showForm(this.overlays.LOGOUT)
    },
    handleAuthenticated: function (C) {
        var A = this;
        var B = C.user;
        if (C.resetPassword) {
            C.errors = null;
            C.user.oldPassword = C.user.password;
            this.showForm(this.overlays.RESET_PASSWORD, C)
        } else {
            if (C.loggedInLevel == 0) {
                if (this.config.showSoftLogin && this.isSoftLoggedIn()) {
                    this.showForm(this.overlays.AUTHENTICATE_SOFT, C)
                } else {
                    this.showForm(this.overlays.AUTHENTICATE, C)
                }
            } else {
                if (C.loggedInLevel == 1) {
                    this.promptCreateScreenName(C)
                } else {
                    HD.util.Common.hideOverlay();
                    A.loginStatus(C);
                    A.writeCookies(B, function () {
                        A.updateGlobalNav()
                    });
                    if (this.config.showSoftLogin && this.isSoftLoggedIn()) {
                        HD.util.Analytics.track(this.analyticsAuthenticateVerifiedString(B))
                    } else {
                        HD.util.Analytics.track(this.analyticsAuthenticateConfirmString(B))
                    }
                }
            }
        }
    },
    updateGlobalNav: function (A) {
        if (this.config.updateGlobalNav && HD && HD.Nav) {
            setTimeout(function () {
                HD.Nav.toggleLoginState();
                if (A) {
                    A()
                }
            }, 2000)
        }
    },
    closeAndAuthenticate: function () {
        HD.util.Common.hideOverlay();
        this.promptAuthentication()
    },
    updateNavAndAuthenticate: function () {
        var A = this;
        this.updateGlobalNav(function () {
            A.closeAndAuthenticate()
        })
    },
    handleRegistered: function (C) {
        var B = C.user;
        var E = C.errors;
        var D = C.screenNameCheck;
        var A = this;
        if ((E == null || E.length < 1) && !D) {
            HD.util.Common.hideOverlay();
            HD.util.Analytics.track(this.analyticsRegisteredString(B));
            A.showForm(this.overlays.CONFIRMATION, C);
            A.loginStatus(C);
            A.writeCookies(B, function () {
                A.updateGlobalNav()
            })
        } else {
            if (D) {
                this.showFormScrolled(this.overlays.REGISTER, C)
            } else {
                this.showForm(this.overlays.REGISTER, C)
            }
        }
    },
    handleResetPassword: function (B) {
        var A = B.user;
        var C = B.errors;
        if ((C == null || C.length < 1)) {
            this.handleAuthenticated(B)
        } else {
            this.showForm(this.overlays.RESET_PASSWORD, B)
        }
    },
    handleScreenNameCreated: function (B) {
        var A = B.user;
        var D = B.errors;
        var C = B.screenNameCheck;
        if ((D == null || D.length < 1) && !C && (A != null) && (A.screenName != null)) {
            HD.util.Common.hideOverlay();
            this.showForm(this.overlays.SN_CONFIRMATION, B);
            HD.util.Analytics.track(this.analyticsScreenNameCreatedString(A));
            this.loginStatus(B)
        } else {
            this.promptCreateScreenName(B)
        }
    },
    handleManageSubscriptions: function (C) {
        var B = C.user;
        var E = C.errors;
        var D = C.screenNameCheck;
        var A = this;
        if ((E == null || E.length < 1) && !D && !! B) {
            HD.util.Common.hideOverlay();
            HD.util.Analytics.track(this.analyticsSubscriptionsUpdatedString(B));
            A.showForm(this.overlays.UPDATED, C);
            A.loginStatus(C)
        } else {
            this.showForm(this.overlays.SUBSCRIPTIONS, C)
        }
    },
    collectUserData: function (C) {
        var B = {};
        if (C.hdwcPassword != null) {
            B.password = C.hdwcPassword.value
        }
        if (C.hdwcPassword2 != null) {
            B.passwordConfirm = C.hdwcPassword2.value
        }
        if (C.hdwcOldPassword != null) {
            B.oldPassword = C.hdwcOldPassword.value
        }
        if (C.hdwcIlTicket != null) {
            B.ilTicket = C.hdwcIlTicket.value
        }
        if (C.hdwcFirstName != null) {
            B.firstName = C.hdwcFirstName.value
        }
        if (C.hdwcMiddleName != null) {
            B.middleName = C.hdwcMiddleName.value
        }
        if (C.hdwcLastName != null) {
            B.lastName = C.hdwcLastName.value
        }
        if (C.hdwcEmailAddress != null) {
            B.userName = C.hdwcEmailAddress.value
        }
        if (C.hdwcUserName != null) {
            B.userName = C.hdwcUserName.value
        }
        if (C.hdwcSelectMonth != null && C.hdwcSelectDay != null && C.hdwcSelectYear != null) {
            var A = (C.hdwcSelectMonth.value && ((C.hdwcSelectMonth.value.length < 2 ? "0" : "") + C.hdwcSelectMonth.value)) + "/";
            A += (C.hdwcSelectDay.value && ((C.hdwcSelectDay.value.length < 2 ? "0" : "") + C.hdwcSelectDay.value)) + "/";
            A += C.hdwcSelectYear.value;
            B.dob = A
        }
        if (C.optIn != null) {
            B.optIn = C.optIn.checked
        }
        HD.getByClass(HD.Login.Overlay.REGISTER.content.hooks.OPT_IN_SUB, "input", C, function (D) {
            B[D.name] = D.checked
        });
        if (C.screenName != null) {
            B.screenName = C.screenName.value
        }
        if (C.hdwcZip != null) {
            B.zip = C.hdwcZip.value
        }
        return B
    },
    collectUserAuthenticateData: function (B) {
        var A = {};
        if (B.password != null) {
            A.password = B.password.value
        }
        if (B.email != null) {
            A.userName = B.email.value
        }
        return A
    },
    writeCookies: function (B, C) {
        var A = this;
        A.user = B;
        UserService.getIlCookies(function (D) {
            var E = HD.util.Common.timestamp();
            HD.util.Common.addImage(D.hdLogin + "?timestamp=" + E);
            HD.util.Common.addImage(D.buellLogin + "?timestamp=" + E);
            HD.util.Common.addImage(D.hogLogin + "?timestamp=" + E);
            HD.util.Common.addImage(D.rideplannerLogin + "?timestamp=" + E);
            HD.util.Common.addImage(D.profile + "/cpapp/ilCookie/add/" + A.user.ilTicket + "/" + A.user.userName + "/" + A.user.screenName, C);
            setTimeout(function () {
                if (C) {
                    C()
                }
            }, 2000)
        })
    },
    isSoftLoggedIn: function () {
        var A = false;
        var C = null;
        try {
            C = YAHOO.util.Cookie.get("WC_PROFILEUSER_NICKNAME")
        } catch (B) {
            if (document.cookie.indexOf("WC_PROFILEUSER_NICKNAME=") > -1) {
                C = decodeComponent(document.cookie.substring(document.cookie.indexOf("WC_PROFILEUSER_NICKNAME=") + "WC_PROFILEUSER_NICKNAME=".length, document.cookie.indexOf(";", document.cookie.indexOf("WC_PROFILEUSER_NICKNAME=") + "WC_PROFILEUSER_NICKNAME=".length)))
            }
        }
        if (C) {
            A = true
        }
        return A
    },
    softLogout: function () {
        var A = this;
        this.logoutUser(function () {
            A.updateNavAndAuthenticate()
        })
    },
    analyticsAuthenticateString: function () {
        return "default_analyticsAuthenticateString"
    },
    analyticsRegisterString: function () {
        return "default_analyticsRegisterString"
    },
    analyticsRegisteredString: function () {
        return "default_analyticsRegisteredString"
    },
    analyticsScreenNameString: function () {
        return "default_analyticsScreenNameString"
    },
    analyticsScreenNameCreatedString: function () {
        return "default_analyticsScreenNameCreatedString"
    },
    analyticsSubscriptionsString: function () {
        return "default_analyticsSubscriptionsString"
    },
    analyticsSubscriptionsUpdatedString: function () {
        return "default_analyticsSubscriptionsUpdatedString"
    },
    analyticsAuthenticateConfirmString: function () {
        return "default_analyticsAuthenticateConfirmString"
    },
    analyticsAuthenticateVerifiedString: function () {
        return "default_analyticsAuthenticateVerifiedString"
    }
};
HD.extend(HD.Login.View, [HD.util.Observable]);
HD.Login.Controller = function (C, B) {
    this.model = C;
    this.view = B;
    var A = this;
    this.view.events.registerClick.subscribe(function (D) {
        A.handleRegister.call(A, D)
    });
    this.view.events.authenticateClick.subscribe(function (D) {
        A.handleAuthenticate.call(A, D)
    });
    this.view.events.resetPasswordClick.subscribe(function (D) {
        A.handleResetPassword.call(A, D)
    });
    this.view.events.screennameCheckClick.subscribe(function (D) {
        A.handleCheckScreenname.call(A, D)
    });
    this.view.events.checkSNCreateClick.subscribe(function (D) {
        A.handleCheckSNCreate.call(A, D)
    });
    this.view.events.createScreenNameClick.subscribe(function (D) {
        A.handleCreateScreenName.call(A, D)
    });
    this.view.events.manageSubscriptionsClick.subscribe(function (D) {
        A.handleManageSubscriptions.call(A, D)
    })
};
HD.Login.Controller.prototype = {
    authenticateUser: function () {
        this.view.promptAuthentication()
    },
    registerUser: function () {
        this.view.promptRegistration()
    },
    handleRegister: function (A) {
        this.model.register(A)
    },
    handleAuthenticate: function (A) {
        this.model.authenticate(A)
    },
    handleResetPassword: function (A) {
        this.model.resetPassword(A)
    },
    handleCheckScreenname: function (A) {
        this.model.checkScreenName(A)
    },
    handleCheckSNCreate: function (A) {
        this.model.checkScreenNameCreate(A)
    },
    handleCreateScreenName: function (A) {
        this.model.createScreenName(A)
    },
    handleManageSubscriptions: function (A) {
        this.model.manageSubscriptions(A)
    }
};
HD.register("hd_login_widget", "HD.Login", {
    version: "1.0",
    build: "1"
});
HD.Login.Overlay = function (A) {
    this.content = HD.Login.Content[A];
    this.config = {
        templates: this.content.templates,
        hooks: this.content.hooks
    };
    this.loadTemplates(arguments.callee, null, null, true)
};
HD.Login.Overlay.prototype = {
    getHtml: function (A) {
        A = A || {};
        return this.processTemplate(this.config.templates.getHtml(), {
            siteName: comSiteName,
            errors: A.errors || null,
            profile: A.profile || "",
            screenNameCheck: A.screenNameCheck || false,
            user: A.user || null,
            showRegFullOptIn: A.showRegFullOptIn || "",
            regOptInChoices: A.regOptInChoices || []
        })
    }
};
HD.extend(HD.Login.Overlay, [HD.util.Template]);
HD.register("hd_login_overlay", HD.Login.Overlay, {
    version: "1.0",
    build: "1"
});
HD.Login.Content = {
    AUTHENTICATE: {
        id: "hdAuthenticateForm",
        title: "Login",
        callback: "onAuthenticationSubmit",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/authenticate.jsp"
        },
        refresh: "hdCaptchaRefresh",
        image: "hdCaptchaImage",
        width: "584px",
        height: "320px",
        templates: {
            loginTitle: "LOGIN",
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            descriptionText: "Enter your email address and password to log in.",
            requiredFieldLabel: "*",
            emailAddressLabel: "Email Address",
            passwordLabel: "Password",
            loginLabel: "Login",
            forgotPasswordLabel: "Forgot your password?",
            createProfileTitle: "CREATE A NEW PROFILE",
            createProfileIntro: "New visitor? Create a profile on H-D.com. An online profile will allow you to:",
            createProfileReasons: ["Add or update your personal information including your login and email preferences.", "Stay connected with the latest H-D news and events.", "Manage your H-D memberships, ride plans, shopping, and more."],
            createProfileLabel: "CREATE PROFILE",
            invalidLoginError: "The email address and/or password you entered does not match our records.",
            getLoginTitle: function () {
                return this.loginTitle
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getRequiredFieldLabel: function () {
                return this.requiredFieldLabel
            },
            getEmailAddressLabel: function () {
                return this.emailAddressLabel
            },
            getPasswordLabel: function () {
                return this.passwordLabel
            },
            getLoginLabel: function () {
                return this.loginLabel
            },
            getForgotPasswordLabel: function () {
                return this.forgotPasswordLabel
            },
            getCreateProfileTitle: function () {
                return this.createProfileTitle
            },
            getCreateProfileIntro: function () {
                return this.createProfileIntro
            },
            getCreateProfileReasons: function () {
                return this.createProfileReasons
            },
            getCreateProfileLabel: function () {
                return this.createProfileLabel
            },
            getInvalidLoginError: function () {
                return this.invalidLoginError
            },
            getHtml: function () {
                return this.html
            },
            html: '		        <div id="hdwcLoginUnrecognized">		            <div id="${hooks.BODY}" class="${hooks.BODY}">		                <div id="hdwcContentTwoColumnOverlayNormal">		                    <div id="hdwcColumnOne" {if siteName != "Dark Custom"}${" "}style="width:280px;"{/if}>		                        <div class="dblRuleBtm">		                            <p class="hdwcHeaderStyle">		                                ${templates.getLoginTitle()}		                            </p>		                        </div>		                        <div class="hdwcMedPadBtm">		                            <p class="hdwcText">		                                ${templates.getDescriptionText()}		                            </p>		                        </div>		                        <div class="hdwcMedPadBtm">									{if errors && errors.length > 0}										{if _MODIFIERS.hasError(errors,"error.required")}											<div class="hdwcValidationError">												<p class="formLabel">${templates.getErrorRequiredFieldsText()}</p>											</div>										{/if}										{var reqErrorsDone = false}										{for error in _MODIFIERS.sortErrors(errors,["error.required"])}											{if error.errorType == "error.required"}												<div id="hdwcErrorOverlayLarge">- ${error|getError}</div>											{else}												{if _MODIFIERS.hasError(errors,"error.required") && !reqErrorsDone}													<br />													{var reqErrorsDone = true}												{/if}												<div id="hdwcErrorOverlayLarge">												{if !error.errorType && error.errorMessage.match(/invalid/i)}													${templates.getInvalidLoginError()}												{else}													${error|getError}												{/if}												</div>											{/if}										{/for}									{/if}		                            <div id="hdwcContentMessageError" class="hdwcErrorMsgOff">										<!--Error-->		                            </div>		                        </div>		                        <div id="hdwcValidateArea" {if siteName != "Dark Custom"}${" "}style="overflow:hidden;"{/if}>		                            <form class="${hooks.FORM}" id="hdAuthenticateForm">		                                <div class="hdwcMedPadBtm">		                                    <div class="formLabel" {if siteName != "Dark Custom"}${" "}style="width:275px;"{/if}>		                                        ${templates.getEmailAddressLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                    </div>		                                    <input type="text" class="hdwcInput" name="${hooks.EMAIL}" id="emailAddress" size="30" style="width:200px; margin:0px;padding:2px;" {if user}${" "}value="${user.userName}"{/if}/>		                                </div>		                                <div class="hdwcMedPadBtm">		                                    <div class="formLabel">		                                        ${templates.getPasswordLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                    </div>		                                    <input type="password" class="hdwcInput" name="${hooks.PASSWORD}" id="password" size="30" style="width:200px; margin:0px;padding:2px;" {if user}${" "}value="${user.password}"{/if}/>		                                </div>		                                <input type="submit" class="btnOrange hdAuthenticateBtn" value="{if siteName != "Dark Custom"}${templates.getLoginLabel()}{/if}"/><br />		                            </form>		                        </div>		                        <p class="hdwcText" {if siteName == "Dark Custom"}${" "}style="display: block;margin-top:10px;"{else}${" "}style="position:relative;top:4px;"{/if}>		                        	<a href="${profile}/cpapp/auth/loginPage.h-d?forgotPassword=true">${templates.getForgotPasswordLabel()}</a>		                       	</p>		                    </div>		                    <div id="hdwcColumnTwo" {if siteName != "Dark Custom"}style="height:247px"{/if}>		                        <div class="dblRuleBtm">		                            <p class="hdwcHeaderStyle">		                                ${templates.getCreateProfileTitle()}		                            </p>		                        </div>		                        <div class="hdwcMedPadBtm">		                            <p class="hdwcText">		                                ${templates.getCreateProfileIntro()}		                            </p>		                        </div>		                        <div class="hdwcMedPadBtm">		                            <ul class="hdwcStandardUl">										{for reason in templates.getCreateProfileReasons()}			                                <li class="hdwcStandardLi">			                                    ${reason}			                                </li>										{/for}		                            </ul>		                            <br class="clear" />		                        </div>		                        <div>		                        	<div class="extraTopMarginAuth">			                            <div class="btnOrange ${hooks.SHOW_REGISTER}">			                                <a href="javascript:void(0)">${templates.getCreateProfileLabel()}</a>			                            </div>									</div>		                        </div>		                    </div>		                </div>		            </div>		        </div>'
        },
        hooks: {
            BODY: "hdwcBody",
            FORM: "hdForm",
            PASSWORD: "password",
            EMAIL: "email",
            SHOW_REGISTER: "hdShowRegister"
        }
    },
    AUTHENTICATE_SOFT: {
        id: "hdAuthenticateForm",
        title: "Login",
        callback: "onAuthenticationSubmit",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/authenticate.jsp"
        },
        refresh: "hdCaptchaRefresh",
        image: "hdCaptchaImage",
        width: "584px",
        height: "235px",
        templates: {
            loginTitle: "VERIFY YOUR ONLINE PROFILE",
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            descriptionText: "In order to use all the features you'll need to verify your H-D.com profile first.  ",
            requiredFieldLabel: "*",
            emailAddressLabel: "Email Address",
            passwordLabel: "Password",
            loginLabel: "Login",
            forgotPasswordLabel: "Forgot your password?",
            invalidLoginError: "The email and/or password you entered does not match our records.",
            personalizedLabel: 'You are logged in as: [${USERNAME}] <a href="javascript:void(0)" onclick="login.view.softLogout.call(login.view);">Not ${USERNAME}?</a>',
            getLoginTitle: function () {
                return this.loginTitle
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getRequiredFieldLabel: function () {
                return this.requiredFieldLabel
            },
            getEmailAddressLabel: function () {
                return this.emailAddressLabel
            },
            getPasswordLabel: function () {
                return this.passwordLabel
            },
            getLoginLabel: function () {
                return this.loginLabel
            },
            getForgotPasswordLabel: function () {
                return this.forgotPasswordLabel
            },
            getInvalidLoginError: function () {
                return this.invalidLoginError
            },
            getPersonalizedLabel: function () {
                var A = this.personalizedLabel.replace(/\$\{USERNAME\}/g, YAHOO.util.Cookie.get("WC_PROFILEUSER_NICKNAME"));
                return A
            },
            getHtml: function () {
                return this.html
            },
            html: '		        <div id="hdwcLoginSoft">		            <div id="${hooks.BODY}" class="${hooks.BODY}">		                        <div class="dblRuleBtm">		                        <p class="hdwcHeaderStyle">		                                ${templates.getLoginTitle()}		                            </p>		                        </div>		                        <div id="hdwcSoftBody">			                        <div class="hdwcMedPadBtm">					                    <p class="hdwcPersonalizedLabel">			                        		${templates.getPersonalizedLabel()}			                        	</p>			                            <p class="hdwcText">			                                ${templates.getDescriptionText()}			                            </p>			                        </div>			                        <div class="hdwcMedPadBtm">										{if errors && errors.length > 0}											{if _MODIFIERS.hasError(errors,"error.required")}												<div class="hdwcValidationError">													<p class="formLabel">${templates.getErrorRequiredFieldsText()}</p>												</div>											{/if}											{var reqErrorsDone = false}											{for error in _MODIFIERS.sortErrors(errors,["error.required"])}												{if error.errorType == "error.required"}													<div id="hdwcErrorOverlayLarge">- ${error|getError}</div>												{else}													{if _MODIFIERS.hasError(errors,"error.required") && !reqErrorsDone}														<br />														{var reqErrorsDone = true}													{/if}													<div id="hdwcErrorOverlayLarge">													{if !error.errorType && error.errorMessage.match(/invalid/i)}														${templates.getInvalidLoginError()}													{else}														${error|getError}													{/if}													</div>												{/if}											{/for}										{/if}			                            <div id="hdwcContentMessageError" class="hdwcErrorMsgOff">											<!--Error-->			                            </div>			                        </div>			                        <div id="hdwcValidateArea" >			                            <form class="${hooks.FORM}" id="hdAuthenticateForm">			                                <div class="hdwcMedPadBtm">			                                    <div class="formLabel">			                                        ${templates.getEmailAddressLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>			                                    </div>			                                    <input type="text" class="hdwcInput" name="${hooks.EMAIL}" id="emailAddress" size="30" style="width:260px; margin:0px;padding:2px;" {if user}${" "}value="${user.userName}"{/if}/>			                                </div>			                                <div class="hdwcMedPadBtm last">			                                    <div class="formLabel">			                                        ${templates.getPasswordLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>			                                    </div>			                                    <input type="password" class="hdwcInput" name="${hooks.PASSWORD}" id="password" size="30" style="width:240px; margin:0px;padding:2px;" {if user}${" "}value="${user.password}"{/if}/>			                                </div>			                                <div style="clear: both;height: 10px;"></div>			                                <input type="submit" class="btnOrange hdAuthenticateBtn" value="{if siteName != "Dark Custom"}${templates.getLoginLabel()}{/if}"/>			                                <p class="hdwcText hdForgotPassword">				                        		<a href="${profile}/cpapp/auth/loginPage.h-d?forgotPassword=true">${templates.getForgotPasswordLabel()}</a>				                        	</p>			                            </form>			                        </div>			                </div>			                </div>		        </div>'
        },
        hooks: {
            BODY: "hdwcBody",
            FORM: "hdForm",
            PASSWORD: "password",
            EMAIL: "email"
        }
    },
    REGISTER: {
        id: "hdRegisterForm",
        title: "Register",
        callback: "onRegistrationSubmit",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/register.jsp"
        },
        width: "654px",
        height: "510px",
        templates: {
            overlayTitle: "CREATE AN ONLINE PROFILE",
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            instructionsText: "Create your profile by completing the form below.",
            requiredFieldLabel: "*",
            requiredFieldText: "Indicates required field",
            emailAddressLabel: "Email Address",
            emailAddressText: "Email address will be used to log in.",
            passwordLabel: "Password",
            passwordText: "Your password must contain 7 or more characters including at least one letter and one number. It can not contain spaces.",
            verifyPasswordLabel: "Verify Password",
            firstNameLabel: "First Name",
            middleInitialLabel: "MI",
            lastNameLabel: "Last Name",
            zipLabel: "ZIP Code",
            birthdateLabel: "Birth Date",
            birthdateText: "(mm/dd/yyyy)",
            screenNameLabel: "Screen Name",
            screenNameText: "Your screen name will be used to identify any content you submit on Harley-Davidson websites. <b>Once you submit your screen name, you will not be able to change your screen name later.</b>",
            checkAvailabilityLabel: "CHECK AVAILABILITY",
            optInSectionLabel: "My Email Subscriptions",
            optInLabel: "I WANT TO RECEIVE PROMOTIONAL EMAIL FROM HARLEY-DAVIDSON.",
            optInText: "By checking the above box, I agree that I have read the <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/privacy_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Privacy Policy</a> and that I want to receive promotional email from Harley-Davidson.",
            createProfileLabel: "Create Profile",
            cancelLabel: "CANCEL",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            getInstructionsText: function () {
                return this.instructionsText
            },
            getRequiredFieldLabel: function () {
                return this.requiredFieldLabel
            },
            getRequiredFieldText: function () {
                return this.requiredFieldText
            },
            getEmailAddressLabel: function () {
                return this.emailAddressLabel
            },
            getEmailAddressText: function () {
                return this.emailAddressText
            },
            getPasswordLabel: function () {
                return this.passwordLabel
            },
            getPasswordText: function () {
                return this.passwordText
            },
            getVerifyPasswordLabel: function () {
                return this.verifyPasswordLabel
            },
            getFirstNameLabel: function () {
                return this.firstNameLabel
            },
            getMiddleInitialLabel: function () {
                return this.middleInitialLabel
            },
            getLastNameLabel: function () {
                return this.lastNameLabel
            },
            getZipLabel: function () {
                return this.zipLabel
            },
            getBirthdateLabel: function () {
                return this.birthdateLabel
            },
            getBirthdateText: function () {
                return this.birthdateText
            },
            getScreenNameLabel: function () {
                return this.screenNameLabel
            },
            getScreenNameText: function () {
                return this.screenNameText
            },
            getCheckAvailabilityLabel: function () {
                return this.checkAvailabilityLabel
            },
            getOptInSectionLabel: function () {
                return this.optInSectionLabel
            },
            getOptInLabel: function () {
                return this.optInLabel
            },
            getOptInText: function () {
                return this.optInText
            },
            getCreateProfileLabel: function () {
                return this.createProfileLabel
            },
            getCancelLabel: function () {
                return this.cancelLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				{cdata}				<script type="text/javascript">					(function() {						enterClicked = {						  	init: function() {						    	var ENTER = 13;						    	var forms = document.getElementsByTagName("form");						    	for (var i=0; i < forms.length; i++) {						      		var enterKeyListener = new YAHOO.util.KeyListener(forms[i], {keys:ENTER},{fn:enterClicked.check});						      		enterKeyListener.enable();						    	}						  	},						  	check: function(etype,args) {						    	var ENTER = 13;						    	var keycode = args[0];						    	if (keycode == ENTER) {					 				var target = YAHOO.util.Event.getTarget(args[1]);					 				if(target.id != "screenName"){					  					YAHOO.util.Event.stopEvent(args[1]);					    			}						    	}						  	}						};					})();					YAHOO.util.Event.onDOMReady(enterClicked.init);				<\/script>				{/cdata}		        <div id="hdwcCommCreateProfile">		            <div class="dblRuleBtm">		                <div class="head">${templates.getOverlayTitle()}</div>		            </div>					<div id="${hooks.BODY}" class="${hooks.BODY}" style="{if siteName != "Dark Custom"}height:440px;{/if}overflow-y:auto;overflow-x:hidden;">						{if errors && errors.length > 0}							<div id="hdValidationErrors">								{if _MODIFIERS.hasError(errors,["error.required"])}									<div class="hdwcValidationError">										<p class="formLabel">${templates.getErrorRequiredFieldsText()}</p>									</div>								{/if}								{for error in _MODIFIERS.sortErrors(errors,["error.required"],["user.userName","user.password","user.passwordConfirm","user.firstName","user.lastName","user.dob","user.screenName"])}									{if error.errorType == "error.required"}										<div id="hdwcErrorOverlayLarge">- ${error|getError}</div>									{/if}								{/for}								{if _MODIFIERS.hasError(errors,["error.required"])}									<br />								{/if}								{for error in errors}									{if ((error.errorType != "error.required" && error.errorType != "error.passedSnCheck" && !screenNameCheck) || (screenNameCheck && !error.fieldName && !error.errorType)) && !(error.errorType == "error.passwordsDoNotMatch" && _MODIFIERS.hasError(errors,"error.required","user.passwordConfirm"))}										<div id="hdwcErrorOverlayLarge">${error|getError}</div>									{/if}								{/for}							</div>						{/if}						<form class="${hooks.FORM} hdwcInputContent" id="hdRegisterForm" name="registerForm">			                <div class="hdwcMedPadBtm">			                    <p id="hdwcInstructions">			                        ${templates.getInstructionsText()}			                    </p>			                </div>			                <div class="hdwcLrgPadBtm">			                    <p>			                        ${templates.getRequiredFieldLabel()} ${templates.getRequiredFieldText()}			                    </p>			                </div>			                <div id="hdwcContentMessageError" class="hdwcErrorMsgOff">					            <!--Error-->			                </div>			                <div id="hdwcValidateArea" style="width: 100%">		                        <div class="hdwcMedPadBtm {if _MODIFIERS.hasError(errors,null,"user.userName")|| _MODIFIERS.hasError(errors,"duplicateEmail","user.userName")}${" "}hdwcValidationError{/if}">		                            <div class="formLabel">		                                ${templates.getEmailAddressLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                </div>		                                <div class="hdwcMedPadBtm">${templates.getEmailAddressText()}		                                <span class="formLabelErrorTextOff"></span>		                            </div>		                            <input type="text" class="hdwcInput" name="${hooks.EMAIL}" id="${hooks.EMAIL}" size="30" style="width:200px; margin:0px; padding:2px;" {if user}${" "}value="${user.userName}"{/if}/>		                        </div>		                        <div class="hdwcMedPadBtm {if _MODIFIERS.hasError(errors,null,"user.password")}${" "}hdwcValidationError{/if}">		                            <div class="formLabel">		                                ${templates.getPasswordLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                </div>		                                <div class="hdwcMedPadBtm">${templates.getPasswordText()}		                                <span class="formLabelErrorTextOff"></span>		                            </div>		                            <input type="password" class="hdwcInput" name="${hooks.PASSWORD}" id="${hooks.PASSWORD}" size="30" style="width:200px; margin:0px; padding:2px;" {if user}${" "}value="${user.password}"{/if}/>		                        </div>		                        <div class="hdwcMedPadBtm {if _MODIFIERS.hasError(errors,null,"user.passwordConfirm")}${" "}hdwcValidationError{/if}">		                            <div class="formLabel">		                                ${templates.getVerifyPasswordLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                <span class="formLabelErrorTextOff"></span>		                            </div>		                            <input type="password" class="hdwcInput" name="${hooks.PASSWORD_CONFIRM}" id="${hooks.PASSWORD_CONFIRM}" size="30" style="width:200px; margin:0px; padding:2px;" {if user && user.password.length > 0}${" "}value="${user.passwordConfirm}"{/if}/>		                        </div>		                        <div class="hdwcMedPadBtm">		                            <div class="hdwcFormRow {if _MODIFIERS.hasError(errors,null,"user.firstName")}${" "}hdwcValidationError{/if}" style="width:103px;">		                                <div class="formLabel">		                                    ${templates.getFirstNameLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                    <span class="formLabelErrorTextOff"></span>		                                </div>		                                <input type="text" class="hdwcInput" name="${hooks.FIRST_NAME}" size="15" style="width:100px; margin:0px; padding:2px;" {if user}${" "}value="${user.firstName}"{/if}/>		                            </div>		                            <div class="hdwcFormRow" style="width:43px;">		                                <div class="formLabel">		                                    ${templates.getMiddleInitialLabel()}		                                </div>		                                <input type="text" class="hdwcInput" name="${hooks.MIDDLE_NAME}" size="5" style="width:40px; margin:0px; padding:2px;" {if user}${" "}value="${user.middleName}"{/if}/>		                            </div>		                            <div class="hdwcFormRow {if _MODIFIERS.hasError(errors,null,"user.lastName")}${" "}hdwcValidationError{/if}" style="width:190px;">		                                <div class="formLabel">		                                    ${templates.getLastNameLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                                    <span class="formLabelErrorTextOff"></span>		                                </div>		                                <input type="text" class="hdwcInput" name="${hooks.LAST_NAME}" size="30" style="width:190px; margin:0px; padding:2px;" {if user}${" "}value="${user.lastName}"{/if}/>		                            </div>		                            <br class="clear"/>		                        </div>		                        <div class="hdwcMedPadBtm {if _MODIFIERS.hasError(errors,null,"user.zip")}${" "}hdwcValidationError{/if}"">		                            <div class="formLabel">${templates.getZipLabel()}</div>		                            <input type="text" class="hdwcInput" name="hdwcZip" id="${hooks.ZIP}" size="7" maxlength="5" style="margin:0px; padding:2px;" {if user}${" "}value="${user.zip}"{/if}/>		                        </div>		                        <div class="hdwcLrgPadBtm {if _MODIFIERS.hasError(errors,null,"user.dob")}${" "}hdwcValidationError{/if}">		                            <div class="formLabel">		                            	${templates.getBirthdateLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                            </div>		                            <div class="hdwcFormRow">		                                <input type="text" size="2" style="margin:0px; padding:2px;" class="hdwcInput" maxlength="2" name="${hooks.DOB_MONTH}" {if user && user.dobMonth}${" "}value="${user.dobMonth}"{/if}/>		                            	<input type="text" style="margin:0px; padding:2px;" size="2" class="hdwcInput" maxlength="2" name="${hooks.DOB_DAY}" {if user && user.dobDay}${" "}value="${user.dobDay}"{/if}/>										<input type="text" size="4" style="margin:0px; padding:2px;" class="hdwcInput" maxlength="4" name="${hooks.DOB_YEAR}" {if user && user.dobYear}${" "}value="${user.dobYear}"{/if}/>		                            </div><p>${templates.getBirthdateText()}</p>		                            <br class="clear" />		                        </div>		                        <div class="hdwcSmlPadBtm {if _MODIFIERS.hasError(errors,null,"user.screenName") || ((screenNameCheck || errors && errors.length == 1) && _MODIFIERS.hasError(errors,"",""))}${" "}hdwcValidationError{/if}">		                            <div class="subhead2">		                                ${templates.getScreenNameLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>		                            </div>		                            <div class="hdwcSmlPadBtm">${templates.getScreenNameText()}</div>		                            <div id="hdwcContentMessageError" class="hdwcErrorMsgOff">			                      		<!--Error-->		                            </div>		                        </div>		                        <div class="hdwcLrgPadBtm formElement" style="float:left;">		                        	<input id="checkingScreenname" name="checkingScreenname" type="hidden" value="false"></input>		                            <input type="text" maxlength="23" class="hdwcInput" name="${hooks.SCREEN_NAME}" id="${hooks.SCREEN_NAME}" size="35" onchange="var el = document.getElementById(\'screenNameMessage\'); if (el) el.parentNode.removeChild(el)" onkeypress="var el = document.getElementById(\'screenNameMessage\'); if (el) el.parentNode.removeChild(el)" style="width:280px; margin:0px; padding:2px;" {if user}${" "}value="${user.screenName}"{/if}/>		                        </div>		                        <div class="hdwcLrgPadBtm submitCheckScreenName" style="overflow: hidden; float:left; position: relative; left: 10px;">			                    	<input type="submit" onclick="document.getElementById(\'checkingScreenname\').value = \'true\';" style="background-color:#333333;" class="btnDarkGrey hdAuthenticateBtn" value="{if siteName != "Dark Custom"}${templates.getCheckAvailabilityLabel()}{/if}"/>			                    </div>			          			{if screenNameCheck}									{for error in _MODIFIERS.selectErrors(errors,null,["snFeedback","user.screenName"],1)}										{if error.errorType == "error.failedSnCheck"}						          			<div id="screenNameMessage" class="hdwcValidationError" style="clear:both;">						          				<div class="formLabel snLabel">${error|getError}</div>						          			</div>										{elseif error.errorType == "error.passedSnCheck"}						          			<div id="screenNameMessage" class="screennameValidationPassed" style="clear:both;">						          				<div class="snLabel">${error|getError}</div>						          			</div>										{else}						          			<div id="screenNameMessage" class="hdwcValidationError" style="clear:both;">						          				<div class="formLabel snLabel">${error|getError}</div>						          			</div>										{/if}					               	{/for}				          		{/if}			                </div>			                <br class="clear" />			                <div class="hdwcLrgPadBtm" style="overflow: hidden; width: 100%">			                	{if showRegFullOptIn}				                	<div class="formLabel">				                		${templates.getOptInSectionLabel()}		                            </div>		                            <div class="hdwcCheckContainer">				                        <div class="hdwcCheckBox">				                            <input name="${hooks.OPT_IN}" type="checkbox" class="${hooks.OPT_IN}" {if (user && user.optIn) || !user}${" "}checked="checked"{/if}/>				                        </div>				                        <div class="hdwcCheckText">				                            <p>				                                ${templates.getOptInLabel()}				                                <br/>				                                ${templates.getOptInText()}				                            </p>				                            {for choice in regOptInChoices}					                            <div class="hdwcCheckBox">						                            <input name="${choice.elName}" type="checkbox" class="${hooks.OPT_IN_SUB}" {if (user && user[choice.elName]) || (!user && choice.checkedByDefault)}${" "}checked="checked"{/if}/>						                        </div>						                        <div class="hdwcCheckText">						                            <p>						                            	${choice.label}						                            </p>						                        </div>						                        <br class="clear" />						                    {/for}				                        </div>				                        <br class="clear" />				                    </div>			                	{else}			                	<div class="hdwcCheckContainer">			                        <div class="hdwcCheckBox">			                            <input name="${hooks.OPT_IN}" type="checkbox" class="${hooks.OPT_IN}" {if (user && user.optIn) || !user}${" "}checked="checked"{/if}/>			                        </div>			                        <div class="hdwcCheckText">			                            <p>			                                ${templates.getOptInLabel()}			                                <br/>			                                ${templates.getOptInText()}			                            </p>			                        </div>			                        <br class="clear" />			                    </div>			                    {/if}			                </div>			                <div class="hdwcSmlPadBtm" id="${hooks.FORM_BOTTOM}">			                    <input type="submit" id="submitProfile" style="display:none;"  value="${templates.getCreateProfileLabel()}"/>				                <div class="btnOrange">						        	<a id="hdwcLoginSaveButton" href="javascript:void(0)" onclick="document.getElementById(\'submitProfile\').click();">{if siteName != "Dark Custom"}${templates.getCreateProfileLabel()}{/if}</a>						       	</div>			                    <div class="btnDarkGrey hdClose">			                        <a class="closeOverlay" href="javascript:void(0)">${templates.getCancelLabel()}</a>			                    </div>			                    <br class="clear" />			              	</div>						</form>		            </div>		        </div>'
        },
        hooks: {
            BODY: "hdwcBody",
            FORM: "hdForm",
            FORM_BOTTOM: "formBottom",
            PASSWORD: "hdwcPassword",
            PASSWORD_CONFIRM: "hdwcPassword2",
            FIRST_NAME: "hdwcFirstName",
            MIDDLE_NAME: "hdwcMiddleName",
            LAST_NAME: "hdwcLastName",
            EMAIL: "hdwcEmailAddress",
            DOB_MONTH: "hdwcSelectMonth",
            DOB_DAY: "hdwcSelectDay",
            DOB_YEAR: "hdwcSelectYear",
            OPT_IN: "optIn",
            OPT_IN_SUB: "optInSub",
            SCREEN_NAME: "screenName",
            ZIP: "hdwcZip"
        }
    },
    SCREENNAME: {
        id: "hdScreenNameForm",
        title: "Screen Name",
        callback: "onScreenNameSubmit",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/screenName.jsp"
        },
        width: "634px",
        height: "300px",
        templates: {
            overlayTitle: "PROVIDE YOUR SCREEN NAME",
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            requiredFieldLabel: "*",
            requiredFieldText: "Indicates required field",
            screenNameLabel: "Screen Name",
            screenNameText: 'Your screen name will be used to identify any content you submit on Harley-Davidson websites. <span class="bold">Once you submit your screen name, you will not be able to change your screen name later.</span>',
            validateLabel: "VALIDATE SCREEN NAME",
            saveLabel: "SAVE",
            cancelLabel: "CANCEL",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            getRequiredFieldLabel: function () {
                return this.requiredFieldLabel
            },
            getRequiredFieldText: function () {
                return this.requiredFieldText
            },
            getScreenNameLabel: function () {
                return this.screenNameLabel
            },
            getScreenNameText: function () {
                return this.screenNameText
            },
            getValidateLabel: function () {
                return this.validateLabel
            },
            getSaveLabel: function () {
                return this.saveLabel
            },
            getCancelLabel: function () {
                return this.cancelLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcLoginUnrecognized" class="hdwcLoginScreenName">			    	<div id="${hooks.BODY}" class="${hooks.BODY}">			        	<div id="{if siteName == "Dark Custom"}hdwcContentMain{else}hdwcContentTwoColumnOverlayNormal{/if}">							<div class="dblRuleBtm"><span class="head">${templates.getOverlayTitle()}</span></div>							{if errors && errors.length > 0}								<div id="hdwcErrorOverlayLarge">								{if _MODIFIERS.hasError(errors,"error.required")}									<div class="hdwcValidationError">										<p class="formLabel">${templates.getErrorRequiredFieldsText()}</p>									</div>								{/if}								{for error in _MODIFIERS.sortErrors(errors,["error.required"])}									{if error.errorType == "error.required"}										<div id="hdwcErrorOverlayLarge">- ${error|getError}</div>									{elseif error.fieldName != "snFeedback"}										<div id="hdwcErrorOverlayLarge" class="hdwcSmlPadBtm">${error|getError}</div>									{/if}								{/for}								</div>							{/if}							<div class="hdwcMedPadBtm">								<p><span class="reqIndicator">${templates.getRequiredFieldLabel()}</span> ${templates.getRequiredFieldText()}</p>							</div>							<form class="${hooks.FORM}" id="hdScreenNameForm" name="screenNameForm">								<div>									<div class="hdwcSmlPadBtm {if _MODIFIERS.hasError(errors,null,"user.screenName")}${" "}hdwcValidationError{/if}">					                    <div class="subhead2">					                        ${templates.getScreenNameLabel()} <span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>					                    </div>					                    <p>${templates.getScreenNameText()}</p>					                    <div id="hdwcContentMessageError" class="hdwcErrorMsgOff">							              <!--Error-->					                    </div>					             	</div>					                <div class="formElement" style="float:left;">					                    <input id="checkingScreenname" name="checkingScreenname" type="hidden" value="false"></input>					                	<input type="text" maxlength="23" class="hdwcInput" name="${hooks.SCREEN_NAME}" id="${hooks.SCREEN_NAME}" size="35" onchange="var el = document.getElementById(\'screenNameMessage\'); if (el) el.parentNode.removeChild(el)" onkeypress="var el = document.getElementById(\'screenNameMessage\'); if (el) el.parentNode.removeChild(el)" style="width:300px; margin:0px; padding:2px;" {if user && user.screenName}value="${user.screenName}"{/if}/>					                </div>									{if siteName == "HOG"}					                    <input type="submit" id="submitScreenNameCheck" style="display:none;" value="${templates.getValidateLabel()}"/>										<a class="btnCheckName submitCheckScreenName" href="javascript:void(0)" title="${templates.getValidateLabel()}" onclick="document.getElementById(\'checkingScreenname\').value = \'true\';document.getElementById(\'submitScreenNameCheck\').click();" id="hdwcLoginSaveButton"></a>									{else}						                <div class="hdwcMedPadBtm submitCheckScreenName" style="overflow: hidden; float:left; position: relative; left: 10px;">						                 	<input type="submit" onclick="document.getElementById(\'checkingScreenname\').value = \'true\';"  style="background-color:#333333;" class="btnDarkGrey hdAuthenticateBtn" value="{if siteName != "Dark Custom"}${templates.getValidateLabel()}{/if}"/>					                    </div>									{/if}				          			{if screenNameCheck}										{for error in _MODIFIERS.selectErrors(errors,null,["snFeedback","user.screenName"],1)}						          			<br class="clear" />											{if error.errorType == "error.failedSnCheck"}							          			<div id="screenNameMessage" class="hdwcValidationError" style="clear:both;">							          				<div class="formLabel snLabel">${error|getError}</div>							          			</div>											{elseif error.errorType == "error.passedSnCheck"}							          			<div id="screenNameMessage" class="screennameValidationPassed" style="clear:both;">							          				<div class="snLabel">${error|getError}</div>							          			</div>											{else}							          			<div id="screenNameMessage" class="hdwcValidationError" style="clear:both;">							          				<div class="formLabel snLabel">${error|getError}</div>							          			</div>											{/if}						               	{/for}					          		{/if}				          			<br class="clear" />								</div>								<div class="hdwcSmlPadBtm screennameSubmission" id="${hooks.FORM_BOTTOM}">									{if siteName == "HOG"}					                    <input type="submit" id="submitScreenName" style="display:none;" value=""/>										<a class="btnSave" href="javascript:void(0)" title="{if siteName == "HOG"}Save{else}${templates.getSaveLabel()}{/if}" onclick="document.getElementById(\'submitScreenName\').click();" id="hdwcLoginSaveButton"></a>										<a class="btnCancel hdClose" id="cancel" href="javascript:void(0)" title="{if siteName == "HOG"}Cancel{else}${templates.getCancelLabel()}{/if}"></a>									{else}					                    <input type="submit" id="submitScreenName" style="display:none;" value=""/>						                <div class="btnOrange">								        	<a id="hdwcLoginSaveButton" href="javascript:void(0)" onclick="document.getElementById(\'submitScreenName\').click();">${templates.getSaveLabel()}</a>								       	</div>					                    <div class="btnDarkGrey hdClose">					                        <a class="closeOverlay" href="javascript:void(0)">${templates.getCancelLabel()}</a>					                    </div>					                    <br class="clear" />									{/if}				                </div>							</form>						</div>					</div>				</div>'
        },
        hooks: {
            BODY: "hdwcBody",
            FORM: "hdForm",
            FORM_BOTTOM: "formBottom",
            SCREEN_NAME: "screenName"
        }
    },
    CONFIRMATION: {
        id: "hdConfirmation",
        title: "",
        callback: "",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/profileCreationConfirmationOverlay.jsp"
        },
        width: "654px",
        height: "150px",
        templates: {
            overlayTitle: "ONLINE PROFILE CONFIRMATION",
            descriptionText: "Congratulations, your online profile has been created.  You will receive a confirmation email shortly.",
            closeLabel: "CONTINUE",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getCloseLabel: function () {
                return this.closeLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcProfileConfirmation" style="{if siteName != "Dark Custom"}height:170px;{/if}">			    	<div class="dblRuleBtm">				    	<div class="head">${templates.getOverlayTitle()}</div>					</div>					<div class="hdwcLrgPadBtm">					  	<p>${templates.getDescriptionText()}</p>					</div>			        <div class="hdwcMedPadBtm">			            <div class="btnOrange hdClose"><a href="javascript:void(0)">${templates.getCloseLabel()}</a></div>			        </div>			    </div>'
        },
        hooks: {}
    },
    SN_CONFIRMATION: {
        id: "hdConfirmation",
        title: "",
        callback: "",
        getContent: function () {
            return ""
        },
        width: "654px",
        height: "150px",
        templates: {
            overlayTitle: "THANKS FOR CREATING YOUR SCREEN NAME",
            descriptionText: "Your new screen name has been added to your H-D.com profile. You are currently logged in. ",
            closeLabel: "CONTINUE",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getCloseLabel: function () {
                return this.closeLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcProfileConfirmation">			    	<div class="dblRuleBtm">				    	<div class="head">${templates.getOverlayTitle()}</div>					</div>					<div class="hdwcLrgPadBtm">					  	<p>${templates.getDescriptionText()}</p>					</div>			        <div class="hdwcMedPadBtm">			            <div class="btnOrange hdClose"><a href="javascript:void(0)">${templates.getCloseLabel()}</a></div>			        </div>			    </div>'
        },
        hooks: {}
    },
    RESET_PASSWORD: {
        id: "hdResetPasswordForm",
        callback: "onResetPasswordSubmit",
        getContent: function () {
            return ""
        },
        width: "600px",
        height: "510px",
        templates: {
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            getSaveLabel: function () {
                return this.saveLabel
            },
            getHtml: function () {
                return this.html
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            html: '				<div id="hdwcCommCreateProfile">					<div id="hdwcHeader" class="dblRuleBtm">		    		   <div class="head">RESET PASSWORD</div>				    </div>                    <div class="hdwcMedPadBtm">					{if errors && errors.length > 0}						{if _MODIFIERS.hasError(errors,["error.required"])}							<div class="hdwcValidationError">								<p class="formLabel">${templates.getErrorRequiredFieldsText()}</p>							</div>						{/if}						{for error in _MODIFIERS.sortErrors(errors,["error.required"],["user.userName","user.password","user.passwordConfirm","user.firstName","user.lastName","user.dob","user.screenName"])}							{if error.errorType == "error.required"}								<div class="hdwcValidationError">							      <p class="formLabel">- ${error|getError}</p>							    </div>							{/if}						{/for}						{for error in errors}							{if ((error.errorType != "error.required" && error.errorType != "error.passedSnCheck" && !screenNameCheck) || (screenNameCheck && !error.fieldName && !error.errorType)) && !(error.errorType == "error.passwordsDoNotMatch" && _MODIFIERS.hasError(errors,"error.required","user.passwordConfirm"))}								<div class="hdwcValidationError">							      <p class="formLabel">${error|getError}</p>							    </div>							{/if}						{/for}						<br/>				    {/if}	                    <p id="hdwcInstructions">	                        We have updated our system to improve how we secure our data.	                        Your current password does not meet these new standards.<br/><br/>							Please update your password to contain 7 or more characters including							at least one letter and one number. It cannot contain spaces.<br/><br/>	            		</p>	                </div>	                <div id="hdwcValidateArea" style="width: 100%">	                   <form class="${hooks.FORM}" id="hdResetPasswordForm">	                   <input type="hidden" name="hdwcOldPassword"  value="${user.oldPassword}"/>	                   <input type="hidden" name="hdwcUserName"  value="${user.userName}"/>	                   		<div class="hdwcMedPadBtm">	                            <div class="hdwcFormRow" style="width:230px;">	                                <div class="formLabel">	                                    Password<span class="reqIndicator">*</span>	                                    <span class="formLabelErrorTextOff"></span>	                                </div>	                                <input type="password" class="hdwcInput" name="hdwcPassword" id="hdwcPassword" size="30" style="width:200px; margin:0px; padding:2px;" />	                            </div>	                            <div class="hdwcFormRow" style="width:230px;">	                                <div class="formLabel">	                                    Verify Password<span class="reqIndicator">*</span>	                                    <span class="formLabelErrorTextOff"></span>	                                </div>	                                <input type="password" class="hdwcInput" name="hdwcPassword2" id="hdwcPassword2" size="30" style="width:200px; margin:0px; padding:2px;" />	                            </div>	                            <br class="clear"/>	                            <input type="submit" id="submitResetPassword" style="display:none;"  value=""/>	                        </div>	                    </form>	                </div>	                <br class="clear" />	                <div class="hdwcLrgPadBtm">			           <div class="btnOrange ${hooks.FORM}"><a href="javascript:void(0)" onclick="document.getElementById(\'submitResetPassword\').click();" >SAVE</a></div>			        </div>			    </div>'
        },
        hooks: {
            FORM: "hdForm"
        }
    },
    LOGOUT: {
        id: "hdLogout",
        title: "",
        callback: "",
        getContent: function () {
            return comSvcBaseUrl + "/hd/user/assets/logout.jsp"
        },
        width: "584px",
        height: "150px",
        templates: {
            overlayTitle: "ARE YOU SURE YOU WANT TO LOGOUT?",
            descriptionText: "If you have been shopping and have added items to your shopping cart, those items will be moved to your wish list.",
            logoutLabel: "YES, LOGOUT",
            closeLabel: "NO, I'LL CONTINUE",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getLogoutLabel: function () {
                return this.logoutLabel
            },
            getCloseLabel: function () {
                return this.closeLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcLogoutConfirm" style="height:140px;">			    	<div id="hdwcHeader" class="dblRuleBtm">			    		<div class="head">${templates.getOverlayTitle()}</div>					</div>					<div class="hdwcLrgPadBtm">				        <div id="hdwcText">${templates.getDescriptionText()}</div>			        </div>					<div class="hdwcLrgPadBtm">			           <div class="btnOrange ${hooks.LOGOUT}"><a href="javascript:void(0)">${templates.getLogoutLabel()}</a></div>			           <div class="btnDarkGrey hdClose"><a href="javascript:void(0)">${templates.getCloseLabel()}</a></div>			        </div>			    </div>'
        },
        hooks: {
            LOGOUT: "hdLogout"
        }
    },
    SUBSCRIPTIONS: {
        id: "hdSubscriptionsForm",
        title: "Manage Subscriptions",
        callback: "onSubscriptionsSubmit",
        width: "634px",
        height: "290px",
        templates: {
            overlayTitle: "MANAGE EMAIL SUBSCRIPTIONS",
            overlayDescription: "Stay motivated throughout your adventure with helpful updates to keep you on track.",
            errorRequiredFieldsText: "Fields in bold with an asterisk (*) are required.",
            emailAddressLabel: "Email Address",
            emailAddressText: "Note: The email address you enter here will update the existing email address saved in your H-D.com profile.",
            saveLabel: "SIGN UP",
            optInLabel: "I WANT TO RECEIVE PROMOTIONAL EMAIL FROM HARLEY-DAVIDSON.",
            optInText: "By checking the above box, I agree that I have read the <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/privacy_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Privacy Policy</a> and that I want to receive promotional email from Harley-Davidson.",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getOverlayDescription: function () {
                return this.overlayDescription
            },
            getErrorRequiredFieldsText: function () {
                return this.errorRequiredFieldsText
            },
            getRequiredFieldLabel: function () {
                return this.requiredFieldLabel
            },
            getRequiredFieldText: function () {
                return this.requiredFieldText
            },
            getEmailAddressLabel: function () {
                return this.emailAddressLabel
            },
            getEmailAddressText: function () {
                return this.emailAddressText
            },
            getSaveLabel: function () {
                return this.saveLabel
            },
            getOptInSectionLabel: function () {
                return this.optInSectionLabel
            },
            getOptInLabel: function () {
                return this.optInLabel
            },
            getOptInText: function () {
                return this.optInText
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcLoginSubscriptions" class="hdwcLoginSubscriptions">			    	<div id="${hooks.BODY}" class="${hooks.BODY}" style="overflow-y:auto;overflow-x:hidden;">			        	<div id="hdwcContentMain">							<div class="dblRuleBtm"><span class="head">${templates.getOverlayTitle()}</span></div>							<div class="hdwcMedPadBtm">								<p>${templates.getOverlayDescription()}</p>							</div>							<div class="hdwcMedPadBtm">								<p><em>${templates.getEmailAddressText()}</em></p>							</div>							{if errors && errors.length > 0}								{for error in _MODIFIERS.sortErrors(errors,["error.required"])}									<div id="hdwcErrorOverlayLarge">${error|getError}</div>								{/for}							{/if}							<form class="${hooks.FORM}" id="hdSubscriptionsForm" name="hdSubscriptionsForm">							<input type="hidden" name="hdwcIlTicket"  value="${user.ilTicket}"/>				                <div id="hdwcValidateArea" style="width: 100%">			                        <div class="hdwcMedPadBtm {if _MODIFIERS.hasError(errors,null,"user.userName")}${" "}hdwcValidationError{/if}">			                            <div class="formLabel">			                                ${templates.getEmailAddressLabel()}<span class="reqIndicator">${templates.getRequiredFieldLabel()}</span>			                                <span class="formLabelErrorTextOff"></span>			                            </div>			                            <input type="text" class="hdwcInput" name="${hooks.EMAIL}" id="${hooks.EMAIL}" size="30" style="width:200px; margin:0 10px 0 0; float: left; padding:2px;" {if user}${" "}value="${user.userName}"{/if}/>										<div class="btnOrange">						                    <input type="submit" id="submitSubscriptions" style="display:none;" value=""/>								        	<a id="hdwcLoginSaveButton" href="javascript:void(0)" onclick="document.getElementById(\'submitSubscriptions\').click();">${templates.getSaveLabel()}</a>										</div>			                        </div>				                    <br class="clear" />					                <div class="hdwcLrgPadBtm" style="overflow: hidden; width: 100%">					                	{if showRegFullOptIn}				                            <div class="hdwcCheckContainer">						                        <div class="hdwcCheckBox">						                            <input name="${hooks.OPT_IN}" type="checkbox" class="${hooks.OPT_IN}" {if (user && user.optIn) || !user}${" "}checked="checked"{/if}/>						                        </div>						                        <div class="hdwcCheckText">						                            <p>						                                ${templates.getOptInLabel()}						                                <br/>						                                ${templates.getOptInText()}						                            </p>						                            {for choice in regOptInChoices}							                            <div class="hdwcCheckBox">								                            <input name="${choice.elName}" type="checkbox" class="${hooks.OPT_IN_SUB}" {if (user && user[choice.elName]) || !user}${" "}checked="checked"{/if}/>								                        </div>								                        <div class="hdwcCheckText">								                            <p>								                            	${choice.label}								                            </p>								                        </div>								                        <br class="clear" />								                    {/for}						                        </div>						                        <br class="clear" />						                    </div>					                	{else}					                	<div class="hdwcCheckContainer">					                        <div class="hdwcCheckBox">					                            <input name="${hooks.OPT_IN}" type="checkbox" class="${hooks.OPT_IN}" {if (user && user.optIn) || !user}${" "}checked="checked"{/if}/>					                        </div>					                        <div class="hdwcCheckText">					                            <p>					                                ${templates.getOptInLabel()}					                                <br/>					                                ${templates.getOptInText()}					                            </p>					                        </div>					                        <br class="clear" />					                    </div>					                    {/if}					                </div>				                    <br class="clear" />								</div>							</form>						</div>					</div>				</div>'
        },
        hooks: {
            BODY: "hdwcBody",
            FORM: "hdForm",
            OPT_IN: "optIn",
            OPT_IN_SUB: "optInSub",
            EMAIL: "hdwcEmailAddress"
        }
    },
    UPDATED: {
        id: "hdConfirmation",
        title: "",
        callback: "",
        width: "654px",
        height: "150px",
        templates: {
            overlayTitle: "THANK YOU",
            descriptionText: "Congratulations, your online profile has been updated.",
            closeLabel: "CONTINUE",
            getOverlayTitle: function () {
                return this.overlayTitle
            },
            getDescriptionText: function () {
                return this.descriptionText
            },
            getCloseLabel: function () {
                return this.closeLabel
            },
            getHtml: function () {
                return this.html
            },
            html: '				<div id="hdwcProfileConfirmation" style="{if siteName != "Dark Custom"}height:170px;{/if}">			    	<div class="dblRuleBtm">				    	<div class="head">${templates.getOverlayTitle()}</div>					</div>					<div class="hdwcLrgPadBtm">					  	<p>${templates.getDescriptionText()}</p>					</div>			        <div class="hdwcMedPadBtm">			            <div class="btnOrange hdClose"><a href="javascript:void(0)">${templates.getCloseLabel()}</a></div>			        </div>			    </div>'
        },
        hooks: {}
    }
};
for (var name in HD.Login.Content) {
    HD.Login.Overlay[name] = new HD.Login.Overlay(name)
}
HD.register("hd_login_content", HD.Login.Content, {
    version: "1.0",
    build: "1"
});
HD.util.Email = function (A) {
    this.model = new HD.util.Email.Model(A);
    this.view = new HD.util.Email.View(this.model);
    this.controller = new HD.util.Email.Controller(this.model, this.view);
    this.model.addObserver(this.view)
};
HD.util.Email.prototype = {
    init: function (A) {
        this.view.init(A)
    }
};
HD.util.Email.Model = function (A) {
    this.config = A;
    this.observers = []
};
HD.util.Email.Model.prototype = {
    sendEmail: function (B) {
        this.notifyObservers("sendEmail_Start");
        var A = this;
        EmailService.sendEmail(B, function (D) {
            var C = D.success ? "sendEmail_Finish" : "sendEmail_Error";
            A.notifyObservers.call(A, C)
        })
    }
};
HD.extend(HD.util.Email.Model, [HD.util.Observable]);
HD.util.Email.View = function (B) {
    this.model = B;
    this.config = this.model.config;
    this.observers = [];
    this.loadTemplates(arguments.callee);
    this.triggerEl = HD.get(this.config.trigger);
    if (this.triggerEl == null) {
        return
    }
    var A = this;
    this.triggerEl.onclick = function () {
        A.render.call(A)
    }
};
HD.util.Email.View.templates = {
    overlayTitle: "Send via Email",
    successText: "Your email has been successfully sent!",
    failureText: "ERROR: Your Email could not be sent at this time, please verify information entered and/or try again later.",
    fromLabel: "From : ",
    toLabel: "To : ",
    subjectLabel: "Subject : ",
    bodyLabel: "Body : ",
    submitLabel: "Send",
    getOverlayTitle: function () {
        return this.overlayTitle
    },
    getSuccessText: function () {
        return this.successText
    },
    getFailureText: function () {
        return this.failureText
    },
    getFromLabel: function () {
        return this.fromLabel
    },
    getToLabel: function () {
        return this.toLabel
    },
    getSubjectLabel: function () {
        return this.subjectLabel
    },
    getBodyLabel: function () {
        return this.bodyLabel
    },
    getSubmitLabel: function () {
        return this.submitLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<form onsubmit="return false;" class="${classes.EMAIL_FORM}">			<table>				<tr><td>${templates.getFromLabel()}</td><td><input name="from" type="text"></input></td></tr>				<tr><td>${templates.getToLabel()}</td><td><input name="to" type="text"></input><br/></td></tr>				<tr><td>${templates.getSubjectLabel()}</td><td><input name="subject" type="text"></input><br/></td></tr>				<tr><td>${templates.getBodyLabel()}</td><td><textarea name="body" cols="30" rows="5"></textarea><br/></td></tr>				<tr><td></td><td><input type="Submit" value="${templates.getSubmitLabel()}"></input></td></tr>			</table>		</form>'
};
HD.util.Email.View.prototype = {
    render: function () {
        var C = this.getHtml();
        var F = HD.util.Common.showOverlay(C, HD.util.Email.View.templates.getOverlayTitle(), "500px", "300px");
        var B = F.getElementsByTagName("form")[0];
        this.parentEl = B;
        var E = B.getElementsByTagName("input");
        var D = E[E.length - 1];
        var A = this.model;
        D.onclick = function () {
            var G = {
                to: B.to.value,
                from: B.from.value,
                subject: B.subject.value,
                body: B.body.value
            };
            A.sendEmail.call(A, G)
        }
    },
    getParent: function () {
        return this.parentEl
    },
    update: function (B, D) {
        var A = HD.util.Common,
            C = HD.util.Email.View.templates;
        if (B == "sendEmail_Start") {
            this.loading(true)
        } else {
            if (B == "sendEmail_Finish") {
                this.loading(false);
                A.showOverlay(C.getSuccessText(), C.getOverlayTitle(), "500px", "300px");
                setTimeout("HD.util.Common.hideOverlay()", 3000)
            } else {
                if (B == "sendEmail_Error") {
                    this.loading(false);
                    A.showOverlay(C.getFailureText(), C.getOverlayTitle(), "500px", "300px");
                    setTimeout("HD.util.Common.hideOverlay()", 5000)
                }
            }
        }
    },
    getHtml: function () {
        return this.processTemplate(this.config.templates.getHtml())
    }
};
HD.extend(HD.util.Email.View, [HD.Widget]);
HD.util.Email.Controller = function (B, A) {
    this.model = B;
    this.view = A
};
HD.util.Email.Controller.prototype = {};
HD.register("hd_email", HD.util.Email, {
    version: "1.0",
    build: "1"
});
HD.util.StarRating = function (A) {
    this.observers = [];
    this.config = A || {};
    if (A.captionParent != null) {
        this.captionParent = HD.get(A.captionParent)
    }
    if (A.starRatingParent != null) {
        this.starRatingParent = HD.get(A.starRatingParent)
    }
    if (A.textRatingParent != null) {
        this.textRatingParent = HD.get(A.textRatingParent)
    }
    if (A.numOfVotesParent != null) {
        this.numOfVotesParent = HD.get(A.numOfVotesParent)
    }
    if (A.numOfDecimals == null || A.numOfDecimals < 0) {
        this.config.numOfDecimals = 0
    }
    this.config.requiresLogin = this.config.requiresLogin || false;
    this.config.showRatingHalves = this.config.showRatingHalves || false;
    this.config.showYourRatingText = this.config.showYourRatingText || false;
    this.queue = new HD.util.Queue();
    this.render();
    HD.util.StarRating.monitor.add(this)
};
HD.util.StarRating.monitor = {
    init: false,
    ratings: [],
    user: null,
    update: function (A, C) {
        if (A == "logged_In" || A == "notLogged_In") {
            this.user = C && C.loggedInLevel > 1 ? C.user && C.user.userName : null;
            this.clean();
            for (var B = 0;
            B < this.ratings.length;
            B++) {
                this.ratings[B].render()
            }
        }
    },
    add: function (A) {
        if (!this.init) {
            login.model.addObserver(HD.util.StarRating.monitor);
            this.init = true
        }
        this.ratings.push(A)
    },
    clean: function () {
        for (var A = this.ratings.length - 1;
        A >= 0;
        A--) {
            if (!this.isLiveElement(this.ratings[A].starRatingParent)) {
                this.ratings.splice(A, 1)
            }
        }
    },
    isLiveElement: function (A) {
        while (A != null && A.nodeName.toLowerCase() != "body") {
            A = A.parentNode
        }
        return !!A
    }
};
HD.util.StarRating.CSS_CLASSES = {
    CAPTION: "hdCaption",
    STAR_RATING: "hdStarRating",
    TEXT_RATING: "hdTextRating",
    NUM_OF_VOTES: "hdNumOfVotes",
    AVERAGE_RATING: "hdAverageRating",
    MY_RATING: "hdMyRating"
};
HD.util.StarRating.templates = {
    oneStarLabel: "Poor",
    twoStarLabel: "Fair",
    threeStarLabel: "Good",
    fourStarLabel: "Great",
    fiveStarLabel: "Excellent",
    rateThisLabel: "Rate this: ",
    yourRatingLabel: "Your rating: ",
    ratingLabel: "Rating: ",
    rateThisText: "Not yet rated",
    yourRatingText: "${rating} stars",
    getOneStarLabel: function () {
        return this.oneStarLabel
    },
    getTwoStarLabel: function () {
        return this.twoStarLabel
    },
    getThreeStarLabel: function () {
        return this.threeStarLabel
    },
    getFourStarLabel: function () {
        return this.fourStarLabel
    },
    getFiveStarLabel: function () {
        return this.fiveStarLabel
    },
    getRateThisLabel: function () {
        return this.rateThisLabel
    },
    getYourRatingLabel: function () {
        return this.yourRatingLabel
    },
    getRatingLabel: function () {
        return this.ratingLabel
    },
    getRateThisText: function () {
        return this.rateThisText
    },
    getYourRatingText: function (A) {
        return this.yourRatingText.replace(/\$\{rating\}/, A)
    }
};
HD.util.StarRating.prototype = {
    render: function () {
        var D = HD.util.StarRating.templates;
        this.stars = [new HD.util.StarRatingImage("star1", D.getOneStarLabel()), new HD.util.StarRatingImage("star2", D.getTwoStarLabel()), new HD.util.StarRatingImage("star3", D.getThreeStarLabel()), new HD.util.StarRatingImage("star4", D.getFourStarLabel()), new HD.util.StarRatingImage("star5", D.getFiveStarLabel())];
        this.checkIfRated(this.config.itemId);
        var B = this.config.isStatic;
        var G = this.config.isRated;
        if (B) {
            HD.addClass(this.starRatingParent, HD.CSS_CLASSES.STATIC)
        } else {
            HD.removeClass(this.starRatingParent, HD.CSS_CLASSES.STATIC);
            if (G) {
                HD.addClass(this.starRatingParent, HD.CSS_CLASSES.RATED);
                HD.removeClass(this.starRatingParent, HD.CSS_CLASSES.UNRATED)
            } else {
                HD.removeClass(this.starRatingParent, HD.CSS_CLASSES.RATED);
                HD.addClass(this.starRatingParent, HD.CSS_CLASSES.UNRATED)
            }
        }
        this.starRatingParent.innerHTML = "";
        for (var A = 0;
        A < this.stars.length;
        A++) {
            var E = this.stars[A];
            if (!B && !G) {
                this.attachEvents(E, A)
            }
            E.out();
            this.starRatingParent.appendChild(E.image)
        }
        if (B) {
            this.selectedIndex = this.config.averageRating - 1
        } else {
            if (G) {
                this.selectedIndex = this.config.myRating - 1
            } else {
                this.selectedIndex = -1
            }
        }
        if (this.selectedIndex >= 0) {
            this.over(this.selectedIndex)
        }
        var C = D.getRateThisLabel();
        var F = this.config.averageRating;
        if (G && !B) {
            C = D.getYourRatingLabel()
        }
        if (B) {
            C = D.getRatingLabel()
        }
        if (this.config.showYourRatingText && !B) {
            F = D.getRateThisText();
            if (G) {
                F = D.getYourRatingText(this.config.myRating)
            }
        }
        this.setNumOfVotes(this.config.numOfVotes);
        this.setTextRating(F, this.config.showYourRatingText && !B);
        this.setCaption(C)
    },
    attachEvents: function (B, A) {
        var C = this;
        B.image.onmouseover = function () {
            C.overUnrated(A)
        };
        B.image.onmouseout = function () {
            C.out(A)
        };
        B.image.onclick = function () {
            C.click(A)
        }
    },
    overUnrated: function (C) {
        if (this.config.showRatingHalves) {
            C = Math.min(Math.round(C * 100), (this.stars.length - 1) * 100);
            for (var D = 0;
            D <= (this.stars.length - 1) * 100;
            D += 100) {
                var A = C - D + 100;
                if (A >= 26 && A <= 75) {
                    this.stars[Math.floor(D / 100)].half()
                } else {
                    if (A > 75) {
                        this.stars[Math.floor(D / 100)].overUnrated()
                    } else {
                        this.stars[Math.floor(D / 100)].out()
                    }
                }
            }
        } else {
            C = Math.min(Math.round(C), this.stars.length - 1);
            for (var D = 0;
            D <= C;
            D++) {
                this.stars[D].overUnrated()
            }
            for (var B = C + 1;
            B < this.stars.length;
            B++) {
                this.stars[B].out()
            }
        }
    },
    click: function (B) {
        var C = B;
        var A = this;
        this.queue.add(function () {
            if (!A.checkIfRated(A.config.itemId)) {
                A.executeClick.call(A, C)
            }
        });
        if (this.config.requiresLogin) {
            login.model.isUserLoggedIn(function (E) {
                if (E && E.loggedInLevel > 1) {
                    HD.util.StarRating.monitor.user = (E.user && E.user.userName) || null;
                    A.queue.execute()
                } else {
                    HD.util.StarRating.monitor.user = null;
                    var D = {
                        update: function (F, G) {
                            if (F == "logged_In" && G && G.loggedInLevel > 1) {
                                HD.util.StarRating.monitor.user = (G && G.loggedInLevel > 1 && G.user && G.user.userName) || null;
                                A.queue.execute();
                                login.model.removeObserver(this);
                                HD.util.Common.getObservable().removeObserver(this)
                            } else {
                                if (F == "overlayClose_Click") {
                                    login.model.removeObserver(this);
                                    HD.util.Common.getObservable().removeObserver(this)
                                }
                            }
                        }
                    };
                    HD.util.Common.getObservable().addObserver(D);
                    login.model.addObserver(D);
                    if (E.loggedInLevel > 0) {
                        login.view.promptCreateScreenName()
                    } else {
                        login.view.promptAuthentication()
                    }
                }
            })
        } else {
            this.queue.execute()
        }
    },
    executeClick: function (A) {
        this.selectedIndex = A;
        this.markRated(A + 1);
        this.config.isRated = true;
        this.notifyObservers("starRating_Selected", A + 1);
        this.render()
    },
    out: function (B) {
        if (this.selectedIndex >= 0) {
            this.over(this.selectedIndex)
        } else {
            for (var A = 0;
            A <= B;
            A++) {
                this.stars[A].out()
            }
        }
    },
    over: function (C) {
        if (this.config.showRatingHalves) {
            C = Math.min(Math.round(C * 100), (this.stars.length - 1) * 100);
            for (var D = 0;
            D <= (this.stars.length - 1) * 100;
            D += 100) {
                var A = C - D + 100;
                if (A >= 26 && A <= 75) {
                    this.stars[Math.floor(D / 100)].half()
                } else {
                    if (A > 75) {
                        this.stars[Math.floor(D / 100)].over()
                    } else {
                        this.stars[Math.floor(D / 100)].out()
                    }
                }
            }
        } else {
            C = Math.min(Math.round(C), this.stars.length - 1);
            for (var D = 0;
            D <= C;
            D++) {
                this.stars[D].over()
            }
            for (var B = C + 1;
            B < this.stars.length;
            B++) {
                this.stars[B].out()
            }
        }
    },
    setCaption: function (A) {
        if (this.captionParent != null) {
            this.captionParent.innerHTML = A
        }
    },
    setTextRating: function (B, A) {
        if (this.textRatingParent != null) {
            this.textRatingParent.innerHTML = !! A ? B : HD.util.Common.round(B, this.config.numOfDecimals)
        }
    },
    setNumOfVotes: function (A) {
        if (this.numOfVotesParent != null) {
            this.numOfVotesParent.innerHTML = A
        }
    },
    setRating: function (A) {
        this.selectedIndex = A - 1
    },
    getRating: function () {
        return this.selectedIndex + 1
    },
    getUser: function () {
        return (this.config.requiresLogin && !this.config.isStatic && HD.util.StarRating.monitor.user) || "-"
    },
    markRated: function (B) {
        var A = this.getRatingCookie("ratedItems");
        this.getRatingFromCookie(A, this.config.itemId, this.getUser()).rating = B;
        this.setRatingCookie("ratedItems", A)
    },
    checkIfRated: function (C) {
        this.config.isRated = false;
        var A = this.getRatingCookie("ratedItems");
        var B = this.getRatingFromCookie(A, C, this.getUser());
        if (B.rating > 0) {
            this.config.isRated = true;
            this.config.myRating = B.rating
        }
        return this.config.isRated
    }
};
HD.util.StarRatingCookie = function () {};
HD.util.StarRatingCookie.prototype = {
    getRatingCookie: function (G) {
        var A = HD.util.Common;
        G = G || "ratedItems";
        var D = (decodeURIComponent(A.getCookie(G)) || "").split("|");
        for (var C = 0;
        C < D.length;
        C++) {
            var F = D[C].split("=");
            F = {
                id: F[0] || "",
                ratings: F[1] || ""
            };
            F.ratings = F.ratings.split(",");
            for (var B = 0;
            B < F.ratings.length;
            B++) {
                var E = F.ratings[B].split(":");
                E = {
                    username: E[0] || "",
                    rating: E[1] || 0
                };
                F.ratings[B] = E
            }
            D[C] = F
        }
        return D
    },
    setRatingCookie: function (B, A) {
        HD.util.Common.setCookie(B || "ratedItems", this.serializeRatingCookie(A))
    },
    serializeRatingCookie: function (C) {
        for (var B = 0;
        B < C.length;
        B++) {
            for (var A = 0;
            A < C[B].ratings.length;
            A++) {
                C[B].ratings[A] = C[B].ratings[A].username + ":" + C[B].ratings[A].rating
            }
            C[B] = C[B].id + "=" + C[B].ratings.join(",")
        }
        return encodeURIComponent(C.join("|"))
    },
    getRatingFromCookie: function (C, D, E) {
        E = E || "-";
        for (var B = 0;
        B < C.length;
        B++) {
            if (C[B].id == D) {
                for (var A = 0;
                A < C[B].ratings.length;
                A++) {
                    if (C[B].ratings[A].username == E) {
                        return C[B].ratings[A]
                    }
                }
                C[B].ratings.push({
                    username: E,
                    rating: 0
                });
                return C[B].ratings[C[B].ratings.length - 1]
            }
        }
        C.push({
            id: D,
            ratings: [{
                username: E,
                rating: 0
            }]
        });
        return C[C.length - 1].ratings[0]
    }
};
HD.extend(HD.util.StarRating, [HD.util.Observable, HD.util.StarRatingCookie]);
HD.util.StarRatingImage = function (C, A, B) {
    this.id = C;
    this.caption = A;
    this.image = document.createElement("span");
    this.image.innerHTML = "&nbsp;";
    this.image.className = HD.CSS_CLASSES.STAR_OFF
};
HD.util.StarRatingImage.prototype = {
    over: function () {
        this.image.className = HD.CSS_CLASSES.STAR_ON
    },
    out: function () {
        this.image.className = HD.CSS_CLASSES.STAR_OFF
    },
    half: function () {
        this.image.className = HD.CSS_CLASSES.STAR_HALF
    },
    overUnrated: function () {
        this.image.className = "hdStarOver"
    }
};
HD.register("hd_star_rating", "HD.util.StarRating", {
    version: "1.0",
    build: "1"
});
HD.util.Date = {
    format: function (B, C) {
        var A = function () {
            var D = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
                E = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
                G = /[^-+\dA-Z]/g,
                F = function (I, H) {
                    I = String(I);
                    H = H || 2;
                    while (I.length < H) {
                        I = "0" + I
                    }
                    return I
                };
            return function (O, Y, U) {
                var K = A;
                if (arguments.length == 1 && (typeof O == "string" || O instanceof String) && !/\d/.test(O)) {
                    Y = O;
                    O = undefined
                }
                O = O ? new Date(O) : new Date();
                if (isNaN(O)) {
                    throw new SyntaxError("invalid date")
                }
                Y = String(K.masks[Y] || Y || K.masks["default"]);
                if (Y.slice(0, 4) == "UTC:") {
                    Y = Y.slice(4);
                    U = true
                }
                var W = U ? "getUTC" : "get",
                    R = O[W + "Date"](),
                    I = O[W + "Day"](),
                    P = O[W + "Month"](),
                    T = O[W + "FullYear"](),
                    V = O[W + "Hours"](),
                    Q = O[W + "Minutes"](),
                    X = O[W + "Seconds"](),
                    S = O[W + "Milliseconds"](),
                    J = U ? 0 : O.getTimezoneOffset(),
                    N = {
                        d: R,
                        dd: F(R),
                        ddd: K.i18n.dayNames[I],
                        dddd: K.i18n.dayNames[I + 7],
                        m: P + 1,
                        mm: F(P + 1),
                        mmm: K.i18n.monthNames[P],
                        mmmm: K.i18n.monthNames[P + 12],
                        yy: String(T).slice(2),
                        yyyy: T,
                        h: V % 12 || 12,
                        hh: F(V % 12 || 12),
                        H: V,
                        HH: F(V),
                        M: Q,
                        MM: F(Q),
                        s: X,
                        ss: F(X),
                        l: F(S, 3),
                        L: F(S > 99 ? Math.round(S / 10) : S),
                        t: V < 12 ? "a" : "p",
                        tt: V < 12 ? "am" : "pm",
                        T: V < 12 ? "A" : "P",
                        TT: V < 12 ? "AM" : "PM",
                        Z: U ? "UTC" : (String(O).match(E) || [""]).pop().replace(G, ""),
                        o: (J > 0 ? "-" : "+") + F(Math.floor(Math.abs(J) / 60) * 100 + Math.abs(J) % 60, 4),
                        S: ["th", "st", "nd", "rd"][R % 10 > 3 ? 0 : (R % 100 - R % 10 != 10) * R % 10]
                    };
                return Y.replace(D, function (H) {
                    return H in N ? N[H] : H.slice(1, H.length - 1)
                })
            }
        }();
        A.masks = {
            "default": "ddd mmm dd yyyy HH:MM:ss",
            shortDate: "m/d/yy",
            mediumDate: "mmm d, yyyy",
            longDate: "mmmm d, yyyy",
            fullDate: "dddd, mmmm d, yyyy",
            shortTime: "h:MM TT",
            mediumTime: "h:MM:ss TT",
            longTime: "h:MM:ss TT Z",
            isoDate: "yyyy-mm-dd",
            isoTime: "HH:MM:ss",
            isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
            isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
        };
        A.i18n = {
            dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
        };
        return A(B, C)
    }
};
HD.util.Paging = function (A) {
    this.model = new HD.util.Paging.Model(A);
    this.view = new HD.util.Paging.View(this.model);
    this.controller = new HD.util.Paging.Controller(this.model, this.view);
    this.init(A)
};
HD.util.Paging.prototype = {
    init: function (A) {
        this.model.startingPage = A.startingPage;
        this.view.containers = A.containers;
        this.model.viewAllMax = A.viewAllMax;
        this.model.defaultPageSize = A.defaultPageSize;
        this.model.showPageSizeSwitch = A.showPageSizeSwitch;
        this.model.showItemCount = A.showItemCount
    }
};
HD.util.Paging.Model = function (A) {
    this.config = A;
    this.totalPages = 0;
    this.pageNumber = this.startingPage || 0;
    this.observers = [];
    this.showPageSizeSwitch = this.showPageSizeSwitch || false;
    this.showItemCount = this.showItemCount || false;
    this.viewAllMax = this.viewAllMax || 50;
    this.defaultPageSize = this.defaultPageSize || this.pageSize
};
HD.util.Paging.Model.prototype = {};
HD.extend(HD.util.Paging.Model, [HD.util.Observable]);
HD.util.Paging.View = function (A) {
    this.model = A;
    this.config = A.config;
    this.containers = this.config.containers;
    this.observers = [];
    this.model.addObserver(this);
    this.loadTemplates(arguments.callee)
};
HD.util.Paging.View.templates = {
    nextText: "Next&gt;",
    previousText: "&lt;Prev",
    ellipsisText: " ... ",
    showAllText: "View All",
    showPageSizeText: "View ${number} per Page",
    showItemCountText: "${start} - ${end} of ${total}",
    getNextText: function () {
        return this.nextText
    },
    getPreviousText: function () {
        return this.previousText
    },
    getEllipsisText: function () {
        return this.ellipsisText
    },
    getShowAllText: function () {
        return this.showAllText
    },
    getShowPageSizeText: function (A) {
        return this.showPageSizeText.replace(/\$\{number\}/, A)
    },
    getShowItemText: function (B, A, D) {
        var F = ((B - 1) * A) + 1;
        var E = ((B - 1) * A) + 6;
        if (E > D) {
            E = D
        }
        var C = this.showItemCountText.replace(/\$\{start\}/, F);
        C = C.replace(/\$\{end\}/, E);
        C = C.replace(/\$\{total\}/, D);
        return C
    },
    getHtml: function () {
        return this.html
    },
    html: '		{if showItemCount}			<span class="${classes.PAGING}-count">			${templates.getShowItemText(pageNumber, pageSize, totalMedia)}			</span>		{/if}		<span class="${classes.PAGING}">		{if hasPrevious}			<span class="${hooks.PREVIOUS} ${hooks.PAGING_ARROW}">${templates.getPreviousText()}</span> 			{if previousPages == 1}				 <span class="${hooks.PAGING_ARROW}">${pageNumber - 1}</span>			{elseif previousPages == 2}				 <span class="${hooks.PAGING_ARROW}">${startPage}</span>				 <span class="${hooks.PAGING_ARROW}">${pageNumber - 1}</span>			{elseif previousPages > 2}				 <span class="${hooks.PAGING_ARROW}">${startPage}</span>				${templates.getEllipsisText()}				{if !hasNext}					 <span class="${hooks.PAGING_ARROW}">${pageNumber - 2}</span>				{/if}				 <span class="${hooks.PAGING_ARROW}">${pageNumber - 1}</span>			{/if}		{/if}		 <span class="${classes.CURRENT}">${pageNumber}</span> 		{if hasNext}			{if nextPages == 1}				 <span class="${hooks.PAGING_ARROW}">${pageNumber + 1}</span>			{elseif nextPages == 2}				 <span class="${hooks.PAGING_ARROW}">${pageNumber + 1}</span>				 <span class="${hooks.PAGING_ARROW}">${totalPages}</span>			{elseif nextPages > 2}				 <span class="${hooks.PAGING_ARROW}">${pageNumber + 1}</span>				{if !hasPrevious}					 <span class="${hooks.PAGING_ARROW}">${pageNumber + 2}</span>				{/if}				${templates.getEllipsisText()}				 <span class="${hooks.PAGING_ARROW}">${totalPages}</span>			{/if}			 <span class="${hooks.NEXT} ${hooks.PAGING_ARROW}">${templates.getNextText()}</span>		{/if}		{if showPageSize}			<span class="${classes.SHOW_VIEW}">			{if pageSize == viewAllMax}		    	<span class="${classes.SHOW_DEFAULT}">${templates.getShowPageSizeText(defaultPageSize)}</span>			{elseif totalMedia < viewAllMax}		    	<span class="${classes.SHOW_MAX}">${templates.getShowPageSizeText(viewAllMax)}</span>			{else}		    	<span class="${classes.SHOW_ALL}">${templates.getShowAllText()}</span>			{/if}			</span>		{/if}		</span>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.util.Paging.View.hooks = {
        NEXT: A.NEXT,
        PREVIOUS: A.PREVIOUS,
        PAGING_ARROW: A.PAGING_ARROW
    }
})();
HD.util.Paging.View.prototype = {
    render: function () {
        var D = HD.CSS_CLASSES;
        var H = this.model.startingPage;
        var L = this.model.pageNumber;
        var G = this.model.totalPages;
        if (L == H && L == G) {
            for (var E = 0, I = this.containers.length;
            E < I;
            E++) {
                var B = HD.get(this.containers[E]);
                HD.addClass(B.parentNode, D.PAGING_NONE)
            }
            return ""
        }
        var J = L - H;
        var F = J > 0;
        var C = G - L;
        var A = C > 0;
        var K = this.processTemplate(this.config.templates.getHtml(), {
            startPage: H,
            pageNumber: L,
            totalPages: G,
            hasPrevious: F,
            hasNext: A,
            previousPages: J,
            nextPages: C,
            showItemCount: this.model.showItemCount,
            showPageSize: this.model.showPageSizeSwitch,
            pageSize: this.model.pageSize,
            viewAllMax: this.model.viewAllMax,
            totalMedia: this.model.totalMedia,
            defaultPageSize: this.model.defaultPageSize
        });
        for (var E = 0, I = this.containers.length;
        E < I;
        E++) {
            var B = HD.get(this.containers[E]);
            B.innerHTML = K;
            HD.removeClass(B.parentNode, D.PAGING_NONE)
        }
        this.setListeners()
    },
    setListeners: function () {
        for (var B = 0, A = this.containers.length;
        B < A;
        B++) {
            this.setListener(HD.get(this.containers[B]))
        }
    },
    setListener: function (B) {
        var I = this.config.hooks;
        var C = this;
        var E = HD.getByClass(I.PREVIOUS, "*", B, function (J) {
            J.onclick = function () {
                C.notifyObservers.call(C, "paging_Previous")
            }
        });
        var D = HD.getByClass(I.NEXT, "*", B, function (J) {
            J.onclick = function () {
                C.notifyObservers.call(C, "paging_Next")
            }
        });
        var G = HD.getByClass(I.PAGING_ARROW, "*", B, function (J) {
            if (!HD.hasClass(J, I.PREVIOUS) && !HD.hasClass(J, I.NEXT)) {
                J.onclick = function () {
                    C.notifyObservers.call(C, "paging_Page", parseInt(this.innerHTML))
                }
            }
        });
        var H = HD.getByClass(I.SHOW_ALL, "*", B, function (J) {
            J.onclick = function () {
                C.notifyObservers.call(C, "show_All")
            }
        });
        var A = HD.getByClass(I.SHOW_MAX, "*", B, function (J) {
            J.onclick = function () {
                C.notifyObservers.call(C, "show_Max")
            }
        });
        var F = HD.getByClass(I.SHOW_DEFAULT, "*", B, function (J) {
            J.onclick = function () {
                C.notifyObservers.call(C, "show_Default")
            }
        })
    },
    update: function (A, B) {
        if (A == "paging_Update") {
            this.render()
        }
    }
};
HD.extend(HD.util.Paging.View, [HD.util.Observable, HD.util.Template]);
HD.util.Paging.Controller = function (B, A) {
    this.model = B;
    this.view = A
};
HD.util.Paging.Controller.prototype = {
    updatePagingData: function (A) {
        this.model.pageNumber = A.pageNumber;
        this.model.totalPages = A.totalPages;
        this.model.totalMedia = A.totalMedia;
        this.model.pageSize = A.pageSize;
        this.model.notifyObservers("paging_Update")
    }
};
HD.register("hd_paging", HD.util.Paging, {
    version: "1.0",
    build: "1"
});
HD.Content = function (A) {
    this.model = new HD.Content.Model(A);
    this.view = new HD.Content.View(this.model);
    this.controller = new HD.Content.Controller(this.model, this.view);
    this.model.addObserver(this.view)
};
HD.Content.prototype = {
    addObserver: function (A) {
        this.model.addObserver(A)
    }
};
HD.Content.Model = function (A) {
    this.config = A;
    this.observers = []
};
HD.Content.Model.prototype = {
    getContent: function (B) {
        this.notifyObservers("getContent_Start");
        var B = HD.util.Common.hasValue(B) ? B : this.config.source;
        var A = this;
        HD.util.Common.requestContent(B, function (D) {
            var C = HD.util.Common.hasValue(D) ? "getContent_Finish" : "getContent_Error";
            A.notifyObservers.call(A, C, D)
        })
    }
};
HD.extend(HD.Content.Model, [HD.util.Observable]);
HD.Content.View = function (A) {
    this.model = A;
    this.config = this.model.config;
    var B = HD.get(this.config.trigger);
    var C = function () {
        A.getContent.call(A)
    };
    if (this.config.onclick != null) {
        C = this.config.onclick
    }
    B.onclick = C;
    this.observers = []
};
HD.Content.View.prototype = {
    update: function (C, F) {
        if (C == "getContent_Start") {
            this.loading(true)
        } else {
            if (C == "getContent_Finish") {
                var G = HD.util.Common.generateElementId();
                var D = ['<div id="', G, '">', F, "</div>"].join("");
                var E = this.getParent();
                var B = this.model;
                var A = this;
                HD.util.DOM.onContentReady(G, function () {
                    B.notifyObservers.call(B, "getContent_Rendered");
                    A.loading.call(A, false)
                });
                this.render(D)
            }
        }
    },
    getHtml: function (A) {
        return A
    }
};
HD.extend(HD.Content.View, [HD.Widget]);
HD.Content.Controller = function (B, A) {
    this.model = B;
    this.view = A
};
HD.Content.Controller.prototype = {};
HD.register("hd_content", "HD.Content", {
    version: "1.0",
    build: "1"
});
HD.util.Player = function (A) {
    A = A || {};
    A.renderMode = A.renderMode || "media";
    this.model = new HD.util.Player.Model(A);
    this.view = new HD.util.Player.View(this.model);
    this.controller = new HD.util.Player.Controller(this.model, this.view);
    this.model.addObserver(this.view)
};
HD.util.Player.Model = function (A) {
    this.config = A;
    this.observers = []
};
HD.util.Player.Model.prototype = {};
HD.extend(HD.util.Player.Model, [HD.util.Observable]);
HD.util.Player.View = function (B) {
    this.model = B;
    this.config = this.model.config;
    this.observers = [];
    this.player = null;
    this.playerId = HD.util.Common.generateElementId();
    this.loadTemplates(arguments.callee);
    var A = this
};
HD.util.Player.View.templates = {
    placeholderText: '<a href="http://get.adobe.com/flashplayer/"><img src="/en_US/Media/images/content/pictorial/dark_custom_v2/img_no_flash.jpg" alt="" /></a>',
    getPlaceholderText: function () {
        return this.placeholderText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div id="${playerId}-container" class="${classes.VIDEO_PLAYER}">			<div class="${classes.NO_FLASH}">${templates.getPlaceholderText()}</div>		</div>'
};
HD.util.Player.View.prototype = {
    EVENTS: {
        PLAY: "PLAY",
        STOP: "STOP"
    },
    setStyle: function (A) {
        this.playerStyle = A
    },
    setListeners: function (F) {
        var D = this.getParent();
        var E = D.getElementsByTagName("div")[0];
        var C = HD.util.Common.generateElementId();
        this.data = F || null;
        var B;
        if (this.config.renderMode == "youtube") {
            B = F.videoUrl
        } else {
            B = comMediaBaseUrl + "/hd/hd_player/assets/player.swf"
        }
        var A = new SWFObject(B, C, this.config.width, this.config.height, "9");
        A.addParam("allowfullscreen", "true");
        A.addParam("wmode", "transparent");
        A.addParam("allowscriptaccess", "always");
        if (this.config.renderMode == "youtube") {
            A.addParam("flashvars", "rel=0" + (this.playerStyle || ""))
        } else {
            A.addParam("flashvars", "file=" + F.videoUrl + "&image=" + F.thumbUrl + (this.playerStyle || "") + "&type=video")
        }
        A.write(E.id);
        HD.util.Player.View.views[C] = this;
        this.playerId = C
    },
    destroy: function () {
        var B = this.getParent();
        B.innerHTML = "";
        var A = HD.util.Player.View.views;
        if (A[this.playerId]) {
            delete A[this.playerId]
        }
    },
    update: function (A, B) {
        if (A == "doSomething_Start") {
            this.loading(true)
        } else {
            if (A == "doSomething_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            playerId: this.playerId
        })
    },
    setPlayerListeners: function () {},
    play: function () {
        if (this.player) {
            var A = YAHOO.util.Dom.get(this.player.id);
            if (A && A.sendEvent) {
                A.sendEvent("PLAY", "true")
            }
        }
    },
    pause: function () {
        if (this.player) {
            var A = YAHOO.util.Dom.get(this.player.id);
            if (A && A.sendEvent) {
                A.sendEvent("PLAY", "false")
            }
        }
    },
    stop: function () {
        if (this.player) {
            var A = YAHOO.util.Dom.get(this.player.id);
            if (A && A.sendEvent) {
                A.sendEvent("STOP")
            }
        }
    }
};
HD.extend(HD.util.Player.View, [HD.Widget]);
window.playerReady = function (A) {
    if (A.id != undefined) {
        HD.util.Player.View.views[A.id].player = A;
        HD.util.Player.View.views[A.id].setPlayerListeners()
    }
};
HD.util.Player.View.views = {};
HD.util.Player.View.stopAll = function (C) {
    var A = HD.util.Player.View.views;
    if (C) {
        for (var B = 0;
        B < C.length;
        B++) {
            if (A[C[B]]) {
                A[C[B]].stop()
            }
        }
    } else {
        for (var D in A) {
            A[D].stop()
        }
    }
};
HD.util.Player.Controller = function (B, A) {
    this.model = B;
    this.view = A
};
HD.util.Player.Controller.prototype = {};
if (YAHOO.env.ua.ie > 0) {
    document.onpropertychange = function () {
        try {
            if (document && typeof document.title !== "undefined" && document.location.hash && document.title.indexOf(document.location.hash) > -1) {
                document.title = document.title.replace(document.location.hash, "")
            }
        } catch (A) {}
    }
}
HD.register("hd_player", HD.util.Player, {
    version: "1.0",
    build: "1"
});
if (typeof deconcept == "undefined") {
    var deconcept = new Object()
}
if (typeof deconcept.util == "undefined") {
    deconcept.util = new Object()
}
if (typeof deconcept.SWFObjectUtil == "undefined") {
    deconcept.SWFObjectUtil = new Object()
}
deconcept.SWFObject = function (K, B, L, D, H, I, F, E, C, J) {
    if (!document.getElementById) {
        return
    }
    this.DETECT_KEY = J ? J : "detectflash";
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if (K) {
        this.setAttribute("swf", K)
    }
    if (B) {
        this.setAttribute("id", B)
    }
    if (L) {
        this.setAttribute("width", L)
    }
    if (D) {
        this.setAttribute("height", D)
    }
    if (H) {
        this.setAttribute("version", new deconcept.PlayerVersion(H.toString().split(".")))
    }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if (!window.opera && document.all && this.installedVer.major > 7) {
        deconcept.SWFObject.doPrepUnload = true
    }
    if (I) {
        this.addParam("bgcolor", I)
    }
    var A = F ? F : "high";
    this.addParam("quality", A);
    this.setAttribute("useExpressInstall", false);
    this.setAttribute("doExpressInstall", false);
    var G = (E) ? E : window.location;
    this.setAttribute("xiRedirectUrl", G);
    this.setAttribute("redirectUrl", "");
    if (C) {
        this.setAttribute("redirectUrl", C)
    }
};
deconcept.SWFObject.prototype = {
    useExpressInstall: function (A) {
        this.xiSWFPath = !A ? "expressinstall.swf" : A;
        this.setAttribute("useExpressInstall", true)
    },
    setAttribute: function (A, B) {
        this.attributes[A] = B
    },
    getAttribute: function (A) {
        return this.attributes[A]
    },
    addParam: function (B, A) {
        this.params[B] = A
    },
    getParams: function () {
        return this.params
    },
    addVariable: function (B, A) {
        this.variables[B] = A
    },
    getVariable: function (A) {
        return this.variables[A]
    },
    getVariables: function () {
        return this.variables
    },
    getVariablePairs: function () {
        var C = new Array();
        var B;
        var A = this.getVariables();
        for (B in A) {
            C[C.length] = B + "=" + A[B]
        }
        return C
    },
    getSWFHTML: function () {
        var B = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "PlugIn");
                this.setAttribute("swf", this.xiSWFPath)
            }
            B = '<embed type="application/x-shockwave-flash" src="' + this.getAttribute("swf") + '" width="' + this.getAttribute("width") + '" height="' + this.getAttribute("height") + '" style="' + this.getAttribute("style") + '"';
            B += ' id="' + this.getAttribute("id") + '" name="' + this.getAttribute("id") + '" ';
            var F = this.getParams();
            for (var E in F) {
                B += [E] + '="' + F[E] + '" '
            }
            var D = this.getVariablePairs().join("&");
            if (D.length > 0) {
                B += 'flashvars="' + D + '"'
            }
            B += "/>"
        } else {
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "ActiveX");
                this.setAttribute("swf", this.xiSWFPath)
            }
            B = '<object id="' + this.getAttribute("id") + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getAttribute("width") + '" height="' + this.getAttribute("height") + '" style="' + this.getAttribute("style") + '">';
            B += '<param name="movie" value="' + this.getAttribute("swf") + '" />';
            var C = this.getParams();
            for (var E in C) {
                B += '<param name="' + E + '" value="' + C[E] + '" />'
            }
            var A = this.getVariablePairs().join("&");
            if (A.length > 0) {
                B += '<param name="flashvars" value="' + A + '" />'
            }
            B += "</object>"
        }
        return B
    },
    write: function (B) {
        if (this.getAttribute("useExpressInstall")) {
            var A = new deconcept.PlayerVersion([6, 0, 65]);
            if (this.installedVer.versionIsValid(A) && !this.installedVer.versionIsValid(this.getAttribute("version"))) {
                this.setAttribute("doExpressInstall", true);
                this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl")));
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                this.addVariable("MMdoctitle", document.title)
            }
        }
        if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) {
            var C = (typeof B == "string") ? document.getElementById(B) : B;
            C.innerHTML = this.getSWFHTML();
            return true
        } else {
            if (this.getAttribute("redirectUrl") != "") {
                document.location.replace(this.getAttribute("redirectUrl"))
            }
        }
        return false
    }
};
deconcept.SWFObjectUtil.getPlayerVersion = function () {
    var E = new deconcept.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var A = navigator.plugins["Shockwave Flash"];
        if (A && A.description) {
            E = new deconcept.PlayerVersion(A.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."))
        }
    } else {
        if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
            var B = 1;
            var C = 3;
            while (B) {
                try {
                    C++;
                    B = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + C);
                    E = new deconcept.PlayerVersion([C, 0, 0])
                } catch (D) {
                    B = null
                }
            }
        } else {
            try {
                var B = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
            } catch (D) {
                try {
                    var B = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                    E = new deconcept.PlayerVersion([6, 0, 21]);
                    B.AllowScriptAccess = "always"
                } catch (D) {
                    if (E.major == 6) {
                        return E
                    }
                }
                try {
                    B = new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
                } catch (D) {}
            }
            if (B != null) {
                E = new deconcept.PlayerVersion(B.GetVariable("$version").split(" ")[1].split(","))
            }
        }
    }
    return E
};
deconcept.PlayerVersion = function (A) {
    this.major = A[0] != null ? parseInt(A[0]) : 0;
    this.minor = A[1] != null ? parseInt(A[1]) : 0;
    this.rev = A[2] != null ? parseInt(A[2]) : 0
};
deconcept.PlayerVersion.prototype.versionIsValid = function (A) {
    if (this.major < A.major) {
        return false
    }
    if (this.major > A.major) {
        return true
    }
    if (this.minor < A.minor) {
        return false
    }
    if (this.minor > A.minor) {
        return true
    }
    if (this.rev < A.rev) {
        return false
    }
    return true
};
deconcept.util = {
    getRequestParameter: function (C) {
        var D = document.location.search || document.location.hash;
        if (C == null) {
            return D
        }
        if (D) {
            var B = D.substring(1).split("&");
            for (var A = 0;
            A < B.length;
            A++) {
                if (B[A].substring(0, B[A].indexOf("=")) == C) {
                    return B[A].substring((B[A].indexOf("=") + 1))
                }
            }
        }
        return ""
    }
};
deconcept.SWFObjectUtil.cleanupSWFs = function () {
    var B = document.getElementsByTagName("OBJECT");
    for (var C = B.length - 1;
    C >= 0;
    C--) {
        B[C].style.display = "none";
        for (var A in B[C]) {
            if (typeof B[C][A] == "function") {
                B[C][A] = function () {}
            }
        }
    }
};
if (deconcept.SWFObject.doPrepUnload) {
    if (!deconcept.unloadSet) {
        deconcept.SWFObjectUtil.prepUnload = function () {
            __flash_unloadHandler = function () {};
            __flash_savedUnloadHandler = function () {};
            window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs)
        };
        window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
        deconcept.unloadSet = true
    }
}
if (!document.getElementById && document.all) {
    document.getElementById = function (A) {
        return document.all[A]
    }
}
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;
HD.WidgetView = function (A) {
    this.config = A;
    this.observers = [];
    this.navigationEl = HD.get(this.config.navigation);
    this.canvasEl = HD.get(this.config.canvas)
};
HD.WidgetView.prototype = {
    showDiv: function (C, A, B) {
        this.setActiveDiv(HD.get(C));
        this.setupNav(A, B)
    },
    setActiveDiv: function (B) {
        var E = this.canvasEl;
        if (E.hasChildNodes()) {
            var F = E.childNodes;
            for (var D = 0, A = F.length;
            D < A;
            D++) {
                var C = F[D];
                if (C.id != null) {
                    HD.hide(C)
                }
            }
        }
        HD.show(B)
    },
    setupNav: function (B, C) {
        var A = HD.CSS_CLASSES;
        HD.addClass(this.navigationEl, A.CONTROL);
        this.setNavText(B);
        if (C != null) {
            HD.addClass(this.navigationEl, A.CONTROL);
            this.navigationEl.onclick = C
        } else {
            HD.removeClass(this.navigationEl, A.CONTROL)
        }
    },
    revertNavText: function () {
        this.navigationEl.innerHTML = this.previousNavHTML
    },
    setNavText: function (A) {
        this.previousNavHTML = this.navigationEl.innerHTML;
        this.navigationEl.innerHTML = A
    }
};
HD.extend(HD.WidgetView, [HD.util.Observable]);
HD.register("hd_widget_view", HD.WidgetView, {
    version: "1.0",
    build: "1"
});
HD.WidgetCluster = function (C, A, B) {
    this.model = C;
    this.view = A;
    this.config = B;
    this.widgets = []
};
HD.WidgetCluster.prototype = {
    init: function (A, B) {
        this.addWidgets(A);
        if (B != null) {
            B()
        }
    },
    loadDependencies: function (C, D) {
        var A = this;
        var B = widgetsConfig;
        HD.insert({
            filter: "raw",
            require: C,
            base: this.config.baseUrl + "/hd/",
            loadOptional: true,
            skin: {
                base: "assets/skins/",
                defaultSkin: "hd"
            },
            onSuccess: function (E) {
                A.addWidgets.call(A, B);
                if (D != null) {
                    D()
                }
            }
        })
    },
    addWidgets: function (C) {
        for (var B = 0, A = C.length;
        B < A;
        B++) {
            this.addWidget(C[B])
        }
    },
    addWidget: function (A) {
        var C = this.getClass(HD.classMap[A.type]);
        if (C != null) {
            var B = new C(A);
            if (this.model != null) {
                this.model.addObserver(B);
                B.model = this.model
            }
            if (this.view != null) {
                this.view.addObserver(B);
                B.view = this.view
            }
            this.widgets.push(B);
            return B
        }
    },
    removeWidget: function (E) {
        this.model.removeObserver(E);
        var B = [];
        var D = this.widgets;
        for (var C = 0, A = D.length;
        C < A;
        C++) {
            var F = D[C];
            if (F != E) {
                B.push(F)
            }
        }
        this.widgets = B
    },
    getWidget: function (A) {
        return this.widgets[A]
    },
    getClass: function (D) {
        if (D == null) {
            return null
        }
        var E = D.split(".");
        var B = window;
        for (var C = 0, A = E.length;
        C < A;
        C++) {
            B = B[E[C]]
        }
        return B
    }
};
HD.register("hd_widget_cluster", HD.WidgetCluster, {
    version: "1.0",
    build: "1"
});
HD.util.REST = {
    useProxy: false,
    forceNoCache: true,
    handleResponse: function (A, C) {
        if (A && A.responseText) {
            var B = A.responseText;
            if (B.match(/^[\r\n\s]*$/)) {
                B = '{"success":false}'
            }
            B = YAHOO.lang.JSON.parse(B);
            if (typeof B.success === "undefined") {
                B.success = !B.error
            }
            C(B)
        }
    },
    request: function (A, I, E, G) {
        var H = this;
        A = A || "GET";
        I = I || "";
        E = E || {};
        G = G ||
        function () {};
        var B = I;
        var F = null;
        if (E && E.data) {
            F = YAHOO.lang.JSON.stringify(E.data) || null;
            delete E.data
        }
        if (this.forceNoCache && A === "GET") {
            E._noCache = "no-cache-" + (new Date().getTime()) + Math.floor(Math.random() * 10000)
        }
        if (this.useProxy) {
            B += "&params=" + YAHOO.lang.JSON.stringify(E)
        } else {
            B += "?";
            for (var D in E) {
                B += D + "=" + E[D] + "&"
            }
        }
        var C = {
            success: function (J) {
                H.handleResponse(J, G)
            },
            failure: function (J) {
                G({
                    success: false
                })
            }
        };
        YAHOO.util.Connect.setDefaultPostHeader(false);
        YAHOO.util.Connect.initHeader("Content-Type", "application/json");
        YAHOO.util.Connect.asyncRequest(A.toUpperCase(), B, C, F);
        YAHOO.util.Connect.setDefaultPostHeader(true)
    }
};
HD.CommunityDAO = function (A) {
    this.config = A || {};
    this.config.secure = this.config.secure || false;
    if (this.config.secure && typeof this.config.secure == "boolean") {
        this.config.secure = "https://www.harley-davidson.com/"
    }
    this.mediaBaseUrl = "http://media.kickstatic.com/";
    this.mediaUrlFields = ["thumbUrl", "url"];
    this.pageNumber = A.startIndex;
    this.initialPageIndex = A.startIndex;
    this.totalPages = A.startIndex;
    this.totalMedia = 0;
    this.activeItem = null;
    this.filters = A.filters || {};
    this.activeItemIndexOnPage = 0;
    this.activeItemPage = A.startIndex;
    this.observers = [];
    this.ratings = [];
    this.rest = HD.util.REST || null;
    if (this.rest && !HD.util.Common.getServerUrl().match(/^https?:\/\/[^/]*?\.harley-davidson\.com.*/)) {
        this.rest.useProxy = false
    }
    this.restAuth = {};
    if ( !! this.config.restoreState) {
        this.restoreState(typeof this.config.restoreState == "string" ? this.config.restoreState : null,
        true)
    }
};
HD.CommunityDAO.prototype = {
    adapter: {
        getMedia: function (B, A) {
            CommunityService.getMedia(B, A)
        },
        getPopularMedia: function (B, A) {
            CommunityService.getPopularMedia(B, A)
        },
        getMedium: function (B, A) {
            CommunityService.getMedium(B, A)
        },
        getMultipleMedium: function (B, A) {
            CommunityService.getMultipleMedium(B, A)
        },
        getComments: function (B, A) {
            CommunityService.getComments(B, A)
        },
        getFaceoff: function (B, A) {
            CommunityService.getFaceoff(B, A)
        },
        getTags: function (B, A) {
            CommunityService.getTags(B, A)
        },
        getRatings: function (B, A) {
            CommunityService.getRatings(B, A)
        },
        getMonthly: function (B, A) {
            CommunityService.getMonthly(B, A)
        },
        getAllBlogAuthors: function (B, A) {
            CommunityService.getAllBlogAuthors(A)
        },
        getMemberProfile: function (B, A) {
            CommunityService.getMemberProfile(B, A)
        },
        submitBlogEntry: function (B, A) {
            CommunityService.submitBlogEntry(B, A)
        },
        submitComment: function (B, A) {
            CommunityService.submitComment(B, A)
        },
        rateMedia: function (B, A) {
            CommunityService.rateMedia(B, A)
        },
        getPollsFeed: function (B, A) {
            CommunityService.getPollsFeed(B, A)
        },
        getAllFacebookEvents: function (B, A) {
            CommunityService.getAllFacebookEvents(B, A)
        },
        getAllFacebookEventsAfterDate: function (B, A) {
            CommunityService.getAllFacebookEventsAfterDate(B, A)
        },
        getFutureFacebookEvents: function (B, A) {
            CommunityService.getFutureFacebookEvents(B, A)
        },
        getAllFacebookAttendeesForEvent: function (B, A) {
            CommunityService.getAllFacebookAttendeesForEvent(B, A)
        },
        getTwitterFeed: function (B, A) {
            CommunityService.getTwitterFeed(A)
        },
        getYoutubeMedia: function (B, A) {
            CommunityService.getYoutubeMedia(B, A)
        }
    },
    getMedia: function (C, H, F, B) {
        this.notifyObservers("getMedia_Start");
        this.pageIndex = C;
        var E = {
            pageNumber: C
        };
        this.setFilters(E);
        var A = this;
        var G = H;
        var F = F || false;
        var D = {
            callback: function (P) {
                var N = P.success ? "getMedia_Finish" : "getMedia_Error";
                var J = P.media;
                var K = [];
                var L = null;
                for (var M = 0, O = J.length;
                M < O;
                M++) {
                    var R = J[M];
                    if (R != null) {
                        if (L != null) {
                            R.previous = L
                        }
                        if (M < O - 1) {
                            R.next = J[M + 1]
                        }
                        A.setFacade.call(A, R);
                        K.push(R)
                    }
                    L = R
                }
                var Q = B || (G ? J.length - 1 : 0);
                if (K.length > 0 && !F) {
                    A.activeItem = K[Q]
                }
                A.totalPages = P.totalPages;
                A.pageNumber = P.pageNumber;
                A.totalMedia = P.totalMedia;
                A.media = K;
                P.media = K;
                A.notifyObservers.call(A, N, P);
                if (K.length > 0) {
                    var I = K[Q];
                    if (!F) {
                        A.activeItem = null;
                        A.setActiveItem.call(A, I)
                    }
                }
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        if (this.config.preloadedMedia == null) {
            this.adapter.getMedia(E, D)
        } else {
            D.callback(this.config.preloadedMedia.getMedia());
            this.config.preloadedMedia = null
        }
    },
    applySecureUrl: function (A) {
        if (this.config.secure) {
            for (var B = 0;
            B < this.mediaUrlFields.length;
            B++) {
                var C = [this.mediaUrlFields[B]];
                if (A[C]) {
                    A[C] = A[C].replace(this.mediaBaseUrl, this.config.secure)
                }
            }
        }
        return A
    },
    hasNextPage: function () {
        return this.pageNumber < this.totalPages
    },
    hasPreviousPage: function () {
        return this.pageNumber > this.initialPageIndex
    },
    getNextPage: function (A) {
        if (this.hasNextPage()) {
            this.getMedia(++this.pageNumber, null, A)
        }
    },
    getSamePage: function () {
        this.getMedia(this.pageNumber)
    },
    getPreviousPage: function (B, A) {
        if (this.hasPreviousPage()) {
            this.getMedia(--this.pageNumber, B, A)
        }
    },
    getActiveItem: function () {
        return this.activeItem
    },
    hasNextItem: function () {
        if (this.activeItem && this.activeItem.next != null) {
            return true
        }
        return this.hasNextPage()
    },
    hasPreviousItem: function () {
        if (this.activeItem && this.activeItem.previous != null) {
            return true
        }
        return this.hasPreviousPage()
    },
    getNextItem: function () {
        if (this.activeItem.next != null) {
            this.setActiveItem(this.activeItem.next)
        } else {
            if (this.hasNextPage()) {
                this.getNextPage();
                this.notifyObservers("activeItem_PageChange")
            }
        }
    },
    getPreviousItem: function () {
        if (this.activeItem.previous != null) {
            this.setActiveItem(this.activeItem.previous)
        } else {
            if (this.hasPreviousPage()) {
                this.getPreviousPage(true);
                this.notifyObservers("activeItem_PageChange")
            }
        }
    },
    setActiveItem: function (A) {
        if (this.activeItem != null && this.activeItem.mediaId == A.mediaId) {
            return
        }
        this.activeItem = A;
        this.notifyObservers("activeItem_Change", A)
    },
    setFacade: function (A) {
        if (A != null) {
            this.applySecureUrl(A);
            var D = /^hd:([a-zA-Z0-9_]+?)(=(.+))?$/;
            if (A.tags && A.tags.length > 0) {
                A.metaTags = {};
                for (var B = A.tags.length - 1;
                B >= 0;
                B--) {
                    var C = A.tags[B].match(D);
                    if (C) {
                        A.tags.splice(B, 1);
                        A.metaTags[C[1]] = C[3] || true
                    }
                }
            }
            if (HD.community.isBlog(A.contentType)) {
                A.facade = new HD.community.Blog(A)
            } else {
                if (HD.community.isPhoto(A.contentType)) {
                    A.facade = new HD.community.Photo(A)
                } else {
                    if (HD.community.isVideo(A.contentType)) {
                        A.facade = new HD.community.Video(A)
                    }
                }
            }
        }
    },
    getMedium: function (E, G, F) {
        this.notifyObservers("getMedium_Start");
        var C = {
            mediaId: E
        };
        this.setFilters(C);
        if (F != null) {
            C.contentType = F
        }
        var A = this;
        var D = G;
        var B = {
            callback: function (K) {
                var J = K.media;
                var I = K.success ? "getMedium_Finish" : "getMedium_Error";
                var H = J[0];
                A.setFacade.call(A, H);
                A.insertItem.call(A, H);
                if (D != null) {
                    D(H)
                }
                A.addCachedMedium.call(A, H);
                A.setActiveItem.call(A, H);
                A.notifyObservers.call(A, I, H)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getMedium(C, B)
    },
    getMultipleMedium: function (C, G, F) {
        this.notifyObservers("getMultipleMedium_Start");
        var D = {
            mediaId: (C || []).join(","),
            contentType: F || this.config.contentType
        };
        this.setFilters(D);
        if (F != null) {
            D.contentType = F
        }
        var A = this;
        var E = G;
        var B = {
            callback: function (K) {
                var J = K.media;
                var H = K.success ? "getMultipleMedium_Finish" : "getMultipleMedium_Error";
                for (var I = 0;
                I < J.length;
                I++) {
                    A.setFacade.call(A, J[I]);
                    A.insertItem.call(A, J[I]);
                    A.addCachedMedium.call(A, J[I])
                }
                if ( !! E) {
                    E(J)
                }
                A.notifyObservers.call(A, H, J)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getMultipleMedium(D, B)
    },
    getTags: function (D) {
        this.notifyObservers("getTags_Start");
        var C = {
            itemsLimit: D
        };
        this.setFilters(C);
        if (C.tags) {
            delete C.tags
        }
        var A = this;
        var B = {
            callback: function (H) {
                var E = H.success ? "getTags_Finish" : "getTags_Error";
                var G = /^hd:([a-zA-Z0-9_]+?)(=(.+))?$/;
                for (var F = H.tags.length - 1;
                F >= 0;
                F--) {
                    if (H.tags[F].tagName.match(G)) {
                        H.tags.splice(F, 1)
                    }
                }
                A.notifyObservers.call(A, E, H)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getTags(C, B)
    },
    getMonthly: function (D) {
        this.notifyObservers("getMonthly_Start");
        var C = {
            itemsLimit: D
        };
        this.setFilters(C);
        var A = this;
        var B = {
            callback: function (F) {
                var E = F.success ? "getMonthly_Finish" : "getMonthly_Error";
                A.notifyObservers.call(A, E, F)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getMonthly(C, B)
    },
    getAllBlogAuthors: function (D) {
        this.notifyObservers("getAllBlogAuthors_Start");
        var C = {
            itemsLimit: D
        };
        this.setFilters(C);
        var A = this;
        var B = {
            callback: function (F) {
                var E = "getAllBlogAuthors_Finish";
                A.notifyObservers.call(A, E, F)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getAllBlogAuthors(B)
    },
    getFacebookEvents: function () {
        this.notifyObservers("getFacebookEvents_Start");
        var A = this;
        var B = {
            callback: function (D) {
                var C = "getFacebookEvents_Finish";
                A.notifyObservers.call(A, C, D)
            },
            parameters: {
                siteName: this.config.siteName,
                userId: "87949232233",
                eventsToReturn: 8
            }
        };
        this.adapter.getAllFacebookEvents(parameters, B)
    },
    getFutureFacebookEvents: function () {
        this.notifyObservers("getFutureFacebookEvents_Start");
        var A = this;
        var B = {
            callback: function (E) {
                var D = "getFutureFacebookEvents_Finish";
                A.notifyObservers.call(A, D, E)
            }
        };
        var C = {
            userId: "87949232233",
            eventsToReturn: 8,
            startDate: "now",
            endDate: ""
        };
        this.adapter.getFutureFacebookEvents(C, B)
    },
    getAllFacebookAttendeesForEvent: function (D, B) {
        this.notifyObservers("getFacebookAttendeesForEvent_Start");
        var A = this;
        var C = {
            callback: function (G) {
                var F = "getFacebookAttendeesForEvent_Finish";
                A.notifyObservers.call(A, F, G)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        var E = {
            userId: "1047443325",
            eventId: D,
            numberOfUsersToReturn: B
        };
        this.adapter.getAllFacebookAttendeesForEvent(E, C)
    },
    getYoutubeMedia: function (D) {
        this.notifyObservers("getYoutube_Start");
        var B = {
            numberToReturn: D
        };
        var A = this;
        var C = {
            callback: function (F) {
                var E = "getYoutube_Finish";
                A.notifyObservers.call(A, E, F)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getYoutubeMedia(B, C)
    },
    getTwitterFeed: function () {
        this.notifyObservers("getTwitterFeed_Start");
        var A = this;
        var B = {
            callback: function (D) {
                var C = "getTwitterFeed_Finish";
                A.notifyObservers.call(A, C, D)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getTwitterFeed(B)
    },
    getPollsFeed: function () {
        this.notifyObservers("getPollsFeed_Start");
        var A = this;
        var B = {
            callback: function (D) {
                var C = "getPollsFeed_Finish";
                A.notifyObservers.call(A, C, D)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getPollsFeed(B)
    },
    getPopular: function (D, E) {
        this.notifyObservers("getPopular_Start");
        var C = {
            itemsLimit: D
        };
        this.setFilters(C);
        if (!HD.util.Common.hasValue(E)) {
            E = HD.SORTS.HIGHEST_RATED
        }
        C.sortType = E;
        var A = this;
        var B = {
            callback: function (L) {
                var I = L.success ? "getPopular_Finish" : "getPopular_Error";
                var K = L.media;
                var G = null;
                for (var J = 0, F = K.length;
                J < F;
                J++) {
                    var H = K[J];
                    if (H != null) {
                        if (G != null) {
                            H.previous = G
                        }
                        if (J < F - 1) {
                            H.next = K[J + 1]
                        }
                    }
                    A.setFacade.call(A, H);
                    G = H
                }
                L.media = K;
                A.notifyObservers.call(A, I, L)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getPopularMedia(C, B)
    },
    getComments: function (D, E) {
        this.notifyObservers("getComments_Start");
        var C = {
            mediaId: D
        };
        this.setFilters(C);
        if (HD.util.Common.hasValue(E)) {
            C.contentType = E
        }
        var A = this;
        var B = {
            callback: function (L) {
                var G = L.success ? "getComments_Finish" : "getComments_Error";
                var J = L.media;
                var F = J[0];
                var K = F.comments;
                for (var H = 0;
                H < K.length;
                H++) {
                    var I = K[H].submittedBy;
                    if (I.match(/^anonymoususer/i)) {
                        K[H].submittedBy = "anonymous"
                    }
                }
                A.notifyObservers.call(A, G, F)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getComments(C, B)
    },
    getFaceoff: function (D) {
        this.notifyObservers("getFaceoff_Start");
        this.notifyObservers("getComments_Start");
        var A = this;
        var C = {
            mediaId: D
        };
        this.setFilters(C);
        var B = {
            callback: function (F) {
                if (F.success) {
                    A.setFacade(F.faceoff);
                    for (var G = 0;
                    G < F.media.length;
                    G++) {
                        A.setFacade(F.media[G])
                    }
                }
                var E = F.success ? "_Finish" : "_Error";
                A.notifyObservers("getComments" + E, F.faceoff || null);
                A.notifyObservers("getFaceoff" + E, F)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getFaceoff(C, B)
    },
    submitMedium: function (D) {
        this.notifyObservers("submitMedium_Start");
        var C = "";
        var B = D;
        if (D.type.value != null && D.type.value != "") {
            C = "?type=" + D.type.value
        }
        var A = this;
        return HD.util.Common.uploadFile(D, this.config.baseUrl + "/fileUpload" + C, function (G) {
            var E = (G.indexOf("success") >= 0) ? "submitMedium_Finish" : "submitMedium_Error";
            var F = new Array(5);
            F[0] = G;
            F[1] = B.title.value;
            F[2] = B.story.value;
            F[3] = B.type.value || "";
            F[4] = (B.category && B.category.value) || "";
            clearTimeout(HD.UploadWidget.progressTimer);
            A.notifyObservers.call(A, E, F)
        })
    },
    submitComment: function (D, F, E) {
        this.notifyObservers("submitComment_Start", E);
        var C = {
            mediaId: D,
            comment: E,
            contentType: F
        };
        this.setFilters(C);
        var A = this;
        var B = {
            callback: function (I) {
                var H = I.success ? "submitComment_Finish" : "submitComment_Error";
                var G = null;
                if (I.success) {
                    G = I.media[0];
                    A.setFacade.call(A, G)
                } else {
                    G = I.errors
                }
                HD.util.Analytics.track(A.analyticsCommentString.call(A, G));
                A.notifyObservers.call(A, H, G)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.submitComment(C, B)
    },
    rateMedia: function (E, F, D) {
        this.notifyObservers("rateMedia_Start");
        var C = {
            mediaId: E,
            rating: D,
            contentType: F
        };
        this.setFilters(C);
        var A = this;
        var B = {
            callback: function (J) {
                var H = J.success && J.media != null ? "rateMedia_Finish" : "rateMedia_Error";
                var G = null;
                var I = J.media;
                if (I != null) {
                    G = I[0];
                    A.setFacade.call(A, G);
                    A.insertItem.call(A, G);
                    A.addCachedMedium.call(A, G);
                    HD.util.Analytics.track(A.analyticsRatingString.call(A, G))
                }
                A.notifyObservers.call(A, H, G)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.rateMedia(C, B)
    },
    _parseTasks: function (D) {
        var A = D.steps;
        for (var C = 0;
        C < A.length;
        C++) {
            A[C].createDate = new Date(A[C].createDate);
            A[C].modifiedDate = new Date(A[C].modifiedDate);
            A[C]._stepIndex = C;
            for (var B = 0;
            B < A[C].tasks.length;
            B++) {
                A[C].tasks[B]._stepIndex = C;
                A[C].tasks[B]._taskIndex = B;
                A[C].tasks[B].createDate = new Date(A[C].tasks[B].createDate);
                A[C].tasks[B].modifiedDate = new Date(A[C].tasks[B].modifiedDate)
            }
        }
        return D
    },
    getTasks: function (D, C) {
        var A = this,
            B = {
                type: D || "roadmap",
                name: C || "test"
            };
        this.notifyObservers("getTasks_Start", B);
        if (B.type === "roadmap") {
            this.restAuthenticate(B.type, null, function (F) {
                var E = "/roadmap/services/retrieve/" + B.name + ".json";
                A.rest.request("GET", A.rest.useProxy ? "/Community/services/hd/hd_rest/assets/proxy.jsp?call=" + encodeURIComponent("http://hdgisscwasd01:9202" + E) : E,
                F.success ? {
                    ilticket: F.ilTicket
                } : null,


                function (G) {
                    var H = "getTasks_" + (G.success ? "Finish" : "Error");
                    if (G.success) {
                        G = A._parseTasks(G.usermap)
                    }
                    A.notifyObservers(H, G)
                })
            })
        }
    },
    updateTask: function (F, D, E, A) {
        var B = this,
            C = {
                type: F || "roadmap",
                name: D || "test",
                taskId: E || "",
                status: A || "I"
            };
        this.notifyObservers("updateTask_Start", C);
        if (C.type === "roadmap") {
            this.restAuthenticate(C.type, null, function (H) {
                if (H.success) {
                    var G = "/roadmap/services/updateTask/" + C.name + "/" + C.taskId + "/" + C.status + ".json";
                    B.rest.request("GET", B.rest.useProxy ? "/Community/services/hd/hd_rest/assets/proxy.jsp?call=" + encodeURIComponent("http://hdgisscwasd01:9202" + G) : G,
                    {
                        ilticket: H.ilTicket
                    },


                    function (I) {
                        var J = "updateTask_" + (I.success ? "Finish" : "Error");
                        if (I.success) {
                            I = B._parseTasks(I.usermap)
                        }
                        B.notifyObservers(J, I)
                    })
                } else {
                    B.notifyObservers("updateTask_Error", H)
                }
            })
        }
    },
    setTasksFastTrack: function (E, C, D) {
        var A = this,
            B = {
                type: E || "roadmap",
                name: C || "test",
                isFastTrack: D || false
            };
        this.notifyObservers("setTasksFastTrack_Start", B);
        if (B.type === "roadmap") {
            this.restAuthenticate(B.type, null, function (G) {
                if (G.success) {
                    var F = "/roadmap/services/fastTrack/" + B.name + "/" + B.isFastTrack.toString() + ".json";
                    A.rest.request("GET", A.rest.useProxy ? "/Community/services/hd/hd_rest/assets/proxy.jsp?call=" + encodeURIComponent("http://hdgisscwasd01:9202" + F) : F,
                    {
                        ilticket: G.ilTicket
                    },


                    function (H) {
                        var I = "setTasksFastTrack_" + (H.success ? "Finish" : "Error");
                        if (H.success) {
                            H = A._parseTasks(H.usermap)
                        }
                        A.notifyObservers(I, H)
                    })
                } else {
                    A.notifyObservers("setTasksFastTrack_Error", G)
                }
            })
        }
    },
    restAuthenticate: function (D, E, F) {
        var B = this,
            C = {
                type: D || "roadmap",
                params: E || {}
            };
        this.notifyObservers("restAuthenticate_Start", C);
        if (D === "roadmap") {
            if (login.model.ilTicket) {
                var A = {
                    success: true,
                    ilTicket: login.model.ilTicket
                };
                this.notifyObservers("restAuthenticate_Finish", A);
                F(A)
            } else {
                var A = {
                    success: false,
                    ilTicket: null
                };
                this.notifyObservers("restAuthenticate_Error", A);
                F(A)
            }
        }
    },
    insertItem: function (B) {
        var D = this.media;
        if (D != null) {
            for (var C = 0, A = D.length;
            C < A;
            C++) {
                if (D[C] != null && D[C].mediaId == B.mediaId) {
                    if (C > 0) {
                        B.previous = D[C - 1]
                    }
                    if (C < A - 1) {
                        B.next = D[C + 1]
                    }
                    D[C] = B
                }
            }
        }
        this.media = D
    },
    getMemberProfile: function (B) {
        this.notifyObservers("getMember_Start");
        var D = {
            memberId: B
        };
        this.setFilters(D);
        var A = this;
        var C = {
            callback: function (F) {
                var G = F.profile;
                var E = F.success ? "getMember_Finish" : "getMember_Error";
                A.notifyObservers.call(A, E, G)
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getMemberProfile(D, C)
    },
    getRatings: function (B) {
        this.notifyObservers("getRatings_Start");
        if (B == null) {
            B = this.media
        }
        var H = this.config.siteName;
        var C = [];
        for (var E = 0, G = B.length;
        E < G;
        E++) {
            var J = B[E];
            C.push({
                mediaId: J.mediaId,
                contentType: J.contentType,
                siteName: H
            })
        }
        var A = {
            ratings: C
        };
        this.setFilters(A);
        var D = this;
        var F = B;
        var I = {
            callback: function (R) {
                var M = R.success ? "getRatings_Finish" : "getRatings_Error";
                var P = R.ratings;
                var Q = F;
                for (var N = 0, K = Q.length;
                N < K;
                N++) {
                    var L = Q[N];
                    var O = P[N];
                    if (L != null && O != null) {
                        L.currentUserRating = O.rating;
                        D.addCachedMedium(L);
                        L.facade.updateRatingWidgets(L)
                    }
                }
            },
            parameters: {
                siteName: this.config.siteName
            }
        };
        this.adapter.getRatings(A, I)
    },
    getCachedMedium: function (F) {
        var B = this.ratings[F];
        if (B == null && this.media != null) {
            var E = this.media;
            for (var D = 0, A = E.length;
            D < A;
            D++) {
                var C = E[D];
                if (C != null && C.mediaId == F) {
                    B = C;
                    break
                }
            }
        }
        return B
    },
    addCachedMedium: function (A) {
        this.ratings[A.mediaId] = A
    },
    setFilters: function (C) {
        var B = this.filters;
        var A = this.config;
        C.siteName = A.siteName;
        if (B.startDate != null) {
            C.startDate = B.startDate
        }
        if (B.endDate != null) {
            C.endDate = B.endDate
        }
        if (B.sortType != null) {
            C.sortType = B.sortType
        }
        if (B.tags != null) {
            C.tags = B.tags
        }
        if (B.members != null) {
            C.members = B.members
        }
        if (B.metaTags != null) {
            C.tags = (C.tags || []).concat(B.metaTags)
        }
        if (B.author != null) {
            C.author = B.author
        }
        if (B.contentSubtype != null) {
            C.contentSubtype = B.contentSubtype
        }
        if (B.numberToReturn != null) {
            C.numberToReturn = B.numberToReturn
        }
        if (A.categories != null) {
            C.categories = A.categories
        }
        if (A.contentType != null && C.contentType == null) {
            C.contentType = A.contentType
        }
        if (A.pageSize != null) {
            C.pageSize = A.pageSize
        }
        if (A.thumbWidth != null) {
            C.thumbWidth = A.thumbWidth
        }
        if (A.mediaWidth != null) {
            C.mediaWidth = A.mediaWidth
        }
    },
    setDateRange: function (C, B, A) {
        this.notifyObservers("dateRange_Set", C);
        this.filters.startDate = C.startDate;
        this.filters.endDate = C.endDate;
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    clearDateRange: function (B, A) {
        this.notifyObservers("dateRange_Clear");
        delete this.filters.startDate;
        delete this.filters.endDate;
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    setMetaTags: function (A, C, B) {
        this.filters.metaTags = typeof A == "string" ? [A] : A;
        if (this.filters.metaTags.length == 0) {
            return this.clearMetaTags(C)
        }
        this.notifyObservers("metaTags_Set", this.filters.metaTags);
        if (!C) {
            this.getMedia(1, null, !B)
        }
    },
    clearMetaTags: function (B, A) {
        delete this.filters.metaTags;
        this.notifyObservers("metaTags_Clear", []);
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    setTags: function (A, C, B) {
        this.filters.tags = typeof A == "string" ? [A] : A;
        if (this.filters.tags.length == 0) {
            return this.clearTags(C)
        }
        this.notifyObservers("tags_Set", this.filters.tags);
        if (!C) {
            this.getMedia(1, null, !B)
        }
    },
    clearTags: function (B, A) {
        delete this.filters.tags;
        this.notifyObservers("tags_Clear", []);
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    setAuthor: function (A, C, B) {
        this.filters.author = A.userName;
        if (this.filters.author.length == 0) {
            return this.clearAuthor(C)
        }
        this.notifyObservers("author_Set", A);
        if (!C) {
            this.getMedia(1, null, !B)
        }
    },
    clearAuthor: function (B, A) {
        delete this.filters.author;
        this.notifyObservers("author_Clear", []);
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    setContentSubtype: function (A, C, B) {
        this.filters.contentSubtype = A;
        if (this.filters.contentSubtype.length == 0) {
            return this.clearContentSubtype(C)
        }
        this.notifyObservers("contentSubtype_Set", this.filters.contentSubtype);
        if (!C) {
            this.getMedia(1, null, !B)
        }
    },
    clearContentSubtype: function (B, A) {
        delete this.filters.contentSubtype;
        this.notifyObservers("contentSubtype_Clear", []);
        if (!B) {
            this.getMedia(1, null, !A)
        }
    },
    setCategories: function (A, C, B) {
        this.config.categories = A.slice(0);
        this.notifyObservers("categories_Set", A);
        if (!C) {
            this.getMedia(1, null, !B)
        }
    },
    setSort: function (A) {
        this.notifyObservers("sortType_Change", A);
        this.filters.sortType = A;
        this.pageNumber = this.initialPageIndex;
        this.getSamePage()
    },
    getSort: function (A) {
        return this.filters.sortType
    },
    isInCurrentPage: function (D) {
        var B = false;
        var C = this.media;
        for (var A = 0;
        A < C.length;
        A++) {
            if (C[A].mediaId == D) {
                B = true;
                break
            }
        }
        return B
    },
    _generateState: function () {
        var A = {
            categories: this.config.categories.join(";")
        };
        if (this.filters.tags) {
            A.tags = this.filters.tags.join(";")
        }
        if (this.filters.members) {
            A.members = this.filters.members.join(";")
        }
        if (this.filters.author) {
            A.author = this.filters.author.join(";")
        }
        if (this.filters.contentSubtype) {
            A.contentSubtype = this.filters.contentSubtype.join(";")
        }
        if (this.filters.startDate) {
            A.startDate = this.filters.startDate
        }
        if (this.filters.endDate) {
            A.startDate = this.filters.startDate
        }
        if (this.filters.sortType) {
            A.sortType = this.filters.sortType
        }
        return A
    },
    _applyState: function (A, B) {
        if (!A) {
            return false
        }
        if (typeof A == "string") {
            A = YAHOO.util.Cookie._parseCookieHash(A)
        }
        if (A.categories) {
            this.setCategories(A.categories.split(";"), true)
        }
        if (A.tags) {
            this.setTags(A.tags.split(";"), true)
        }
        if (A.author) {
            this.setAuthor(A.author)
        }
        if (A.contentSubtype) {
            this.setContentSubtype(A.contentSubtype)
        }
        if (A.startDate) {
            this.filters.startDate = A.startDate
        }
        if (A.endDate) {
            this.filters.endDate = A.endDate
        }
        if (A.sortType) {
            this.filters.sortType = A.sortType
        }
        if (!B) {
            this.getMedia(1)
        }
        return true
    },
    exportState: function () {
        return YAHOO.util.Cookie._createCookieHashString(this._generateState())
    },
    importState: function (A, B) {
        return this._applyState(A, B)
    },
    storeState: function (A) {
        return YAHOO.util.Cookie.setSubs(A || this.config.siteName, this._generateState())
    },
    restoreState: function (A, B) {
        return this._applyState(YAHOO.util.Cookie.getSubs(A || this.config.siteName), B)
    },
    clearState: function (A) {
        return YAHOO.util.Cookie.remove(A || this.config.siteName)
    },
    analyticsRatingString: function (A) {
        return "default_analyticsRatingString"
    },
    analyticsCommentString: function (A) {
        return "default_analyticsCommentString"
    }
};
HD.extend(HD.CommunityDAO, [HD.util.Observable]);
HD.register("hd_community_model", "HD.CommunityDAO", {
    version: "1.0",
    build: "1"
});
HD.CommunityEngine = function (C) {
    this.config = HD.merge({
        dao: {},
        view: {},
        cluster: {},
        widgets: {},
        observers: []
    }, C || {});
    var F = [],
        B = {};
    for (var E in this.config.widgets) {
        B[E] = F.length;
        F.push(this.config.widgets[E])
    }
    this.dao = new HD.CommunityDAO(this.config.dao);
    this.view = new HD.WidgetView(this.config.view);
    this.cluster = new HD.WidgetCluster(this.dao, this.view, this.config.cluster);
    this.cluster.init(F);
    this.widgets = {
        dao: this.dao,
        view: this.view
    };
    for (var A in B) {
        var E = this.cluster.getWidget(B[A]);
        this.widgets[A] = E;
        E.engine = this
    }
    for (var D = 0;
    D < this.config.observers.length;
    D++) {
        this.addObserver(this.config.observers[D])
    }
    this.observers = []
};
HD.CommunityEngine.prototype = {
    addObserver: function (A) {
        for (var B = 0;
        B < A.widgets.length;
        B++) {
            try {
                if (typeof A.widgets[B] == "string") {
                    this.widgets[A.widgets[B]].addObserver(A)
                } else {
                    A.widgets[B].addObserver(A)
                }
            } catch (C) {}
        }
    },
    removeObserver: function (A) {
        for (var B = 0;
        B < A.widgets.length;
        B++) {
            try {
                if (typeof A.widgets[B] == "string") {
                    this.widgets[A.widgets[B]].removeObserver(A)
                } else {
                    A.widgets[B].removeObserver(A)
                }
            } catch (C) {}
        }
    },
    addWidgets: function (B) {
        for (var A in B) {
            var C = this.cluster.addWidget(B[A]);
            this.widgets[A] = C;
            C.engine = this
        }
    },
    getWidgetName: function (B) {
        for (var A in this.widgets) {
            if (this.widgets[A] === B) {
                return A
            }
        }
        return null
    },
    getWidget: function (A) {
        return this.widgets[A] || null
    }
};
HD.extend(HD.CommunityEngine, [HD.util.Observable]);
HD.register("hd_community_engine", "HD.CommunityEngine", {
    version: "1.0",
    build: "1"
});
if (typeof HD.community == "undefined" || !HD.community) {
    HD.community = {
        CONTENT_TYPES: {
            BLOG: "blog",
            PHOTO: "photo",
            VIDEO: "video",
            BOTH: "both"
        },
        getType: function (B) {
            if (B.indexOf(" ") < 0) {
                return B
            }
            var A = B.split(" ");
            return A[1]
        },
        isPhoto: function (A) {
            return this.getType(A) == this.CONTENT_TYPES.PHOTO
        },
        isVideo: function (A) {
            return this.getType(A) == this.CONTENT_TYPES.VIDEO
        },
        isBlog: function (A) {
            return this.getType(A) == this.CONTENT_TYPES.BLOG
        },
        isBoth: function (A) {
            return this.getType(A) == this.CONTENT_TYPES.BOTH
        }
    }
}
HD.register("hd_community", "HD.community", {
    version: "1.0",
    build: "1"
});
HD.CarouselWidget = function (A) {
    this.config = A || {};
    this.config.compact = this.config.compact || false;
    this.config.delay = this.config.delay || 10;
    this.config.pageSize = this.config.pageSize || 5;
    this.config.contentFeed = this.config.contentFeed || "getMedia";
    this.config.previewLength = this.config.previewLength || 140;
    this.config.playerHeight = this.config.playerHeight || 300;
    this.config.playerWidth = this.config.playerWidth || 400;
    this.config.scrollDirection = this.config.scrollDirection || "horizontal";
    this.renderMode = this.config.contentFeed.match(/youtube/i) ? "youtube" : "media";
    this.offset = 0;
    this.timeout = null;
    this.playerIds = [];
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.CarouselWidget.templates = {
    carouselLabel: "Latest Media",
    viewAllText: "View All",
    viewAllUrl: "#featAnchorAll",
    scrollLeftText: "&lt;",
    scrollRightText: "&gt;",
    authorLabel: "By ",
    getCarouselLabel: function () {
        return this.carouselLabel
    },
    getViewAllText: function () {
        return this.viewAllText
    },
    getViewAllUrl: function () {
        return this.viewAllUrl
    },
    getScrollLeftText: function () {
        return this.scrollLeftText
    },
    getScrollRightText: function () {
        return this.scrollRightText
    },
    getAuthorLabel: function () {
        return this.authorLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		{macro youtube(item, isThumb)}			<div class="${classes.ITEM} ${classes.ITEM}-youtube">				{if isThumb}					<div class="${classes.SMALL_THUMB_WRAPPER}">						<div class="${classes.SMALL_THUMB}" style="background-image: url(${item.thumbnailUrl})"></div>					</div>				{else}					<div class="${classes.LARGE_THUMB_WRAPPER}">						<div class="${classes.LARGE_THUMB} ${hooks.YOUTUBE}"></div>					</div>				{/if}				<a class="${classes.TITLE}" href="${item.playerUrl}">${item.title|ellipse:config.titleLength || item.title.length}</a>				{if !!item.uploader}				<div class="${classes.AUTHOR}">				 	<div class="${classes.LABEL}">${templates.getAuthorLabel()}</div>				 	<a class="${classes.VALUE}" href="http://www.youtube.com/user/${item.uploader}">${item.uploader}</a>				</div>				{/if}				<div class="${classes.DESCRIPTION}">${item.description|ellipse:config.previewLength || item.description.length}</div>			</div>		{/macro}		{macro thumbs(isCompact)}			{if !isCompact}			<div class="${classes.CAROUSEL}-scroller">				<div class="${hooks.SCROLL_LEFT}">${templates.getScrollLeftText()}</div>				<div class="${hooks.SCROLL_CONTAINER}">			{/if}				<ul class="${hooks.THUMBS_CONTAINER}">					{for item in items}						<li class="${hooks.THUMB}{if item_index==0}${" "}${classes.CAROUSEL}-active{/if}">							{if renderMode=="youtube"}								${youtube(item, true)}							{else}								${item|facade}							{/if}						</li>					{/for}				</ul>			{if !isCompact}				</div>				<div class="${hooks.SCROLL_RIGHT}">${templates.getScrollRightText()}</div>			</div>			{/if}		{/macro}		<div class="${classes.CAROUSEL} ${classes.CAROUSEL}-{if config.compact}compact{else}full{/if} ${classes.WIDGET}">			<span class="${classes.TITLE}">${templates.getCarouselLabel()}</span>			{if config.compact}${thumbs(config.compact)}{/if}			<ul class="${hooks.ITEMS_CONTAINER}">				{for item in items}					<li class="${hooks.ITEM}{if item_index==0}${" "}${classes.CAROUSEL}-active{/if}">						{if renderMode=="youtube"}							${youtube(item)}						{else}							${item|facade}						{/if}					</li>				{/for}			</ul>			{if !config.compact}${thumbs(config.compact)}{/if}			<a href="${templates.getViewAllUrl()}" name="featAnchorAll" class="${classes.VIEW_ALL} ${classes.CONTROL} ${hooks.VIEW_ALL}">${templates.getViewAllText()}</a>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.CarouselWidget.hooks = {
        ITEM: A.CAROUSEL + "-item",
        THUMB: A.CAROUSEL + "-thumb",
        YOUTUBE: A.CAROUSEL + "-youtube",
        SCROLL_LEFT: A.CAROUSEL + "-scroll-left",
        SCROLL_RIGHT: A.CAROUSEL + "-scroll-right",
        SCROLL_CONTAINER: A.CAROUSEL + "-scroll-container",
        ITEMS_CONTAINER: A.CAROUSEL + "-items",
        THUMBS_CONTAINER: A.CAROUSEL + "-thumbs",
        VIEW_ALL: A.CAROUSEL + "-viewall"
    }
})();
HD.CarouselWidget.prototype = {
    update: function (A, B) {
        if (A == this.config.contentFeed + "_Start") {
            this.loading(true)
        } else {
            if (A == this.config.contentFeed + "_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    scrollMedia: function (E, A) {
        var B = HD.CSS_CLASSES;
        var F = this.getParent();
        var I = HD.getByClass(this.config.hooks.ITEM, "*", F);
        var H = HD.getByClass(this.config.hooks.THUMB, "*", F);
        this.offset = E;
        if (E >= ((this.config.compact && this.config.pageSize) || I.length)) {
            this.offset = 0
        }
        if (E < 0) {
            this.offset = ((this.config.compact && this.config.pageSize) || I.length) - 1
        }
        if (this.playerIds && this.playerIds.length > 0) {
            HD.util.Player.View.stopAll(this.playerIds)
        }
        if (this.config.compact || !A) {
            for (var C = 0;
            C < I.length;
            C++) {
                if (C == this.offset) {
                    HD.addClass(I[C], B.CAROUSEL + "-active");
                    if (H[C]) {
                        HD.addClass(H[C], B.CAROUSEL + "-active")
                    }
                } else {
                    HD.removeClass(I[C], B.CAROUSEL + "-active");
                    if (H[C]) {
                        HD.removeClass(H[C], B.CAROUSEL + "-active")
                    }
                }
            }
        }
        if (!this.config.compact && this.scrollContainerEl) {
            if (this.config.scrollDirection == "vertical") {
                this.thumbMeasure = this.thumbHeight;
                this.scrollMeasure = this.scrollContainerEl.scrollTop;
                this.scrollClientMeasure = this.scrollContainerEl.clientHeight
            } else {
                this.thumbMeasure = this.thumbWidth;
                this.scrollMeasure = this.scrollContainerEl.scrollLeft;
                this.scrollClientMeasure = this.scrollContainerEl.clientWidth
            }
            var D = (this.thumbMeasure + this.thumbOffset) * this.offset;
            if (D < this.scrollMeasure || (D + this.thumbMeasure > this.scrollMeasure + this.scrollClientMeasure)) {
                if (D + this.thumbMeasure > this.scrollMeasure + this.scrollClientMeasure) {
                    D += this.thumbMeasure - this.scrollClientMeasure
                }
                if (this.thumbScroll && this.thumbScroll.isAnimated) {
                    this.thumbScroll.stop()
                }
                if (this.config.scrollDirection == "vertical") {
                    this.ScrollCoords = [0, D]
                } else {
                    this.ScrollCoords = [D, 0]
                }
                var G = Math.min(1.25, 0.8 * Math.abs(this.scrollMeasure - D) / 100);
                this.thumbScroll = new YAHOO.util.Scroll(this.scrollContainerEl, {
                    scroll: {
                        to: this.ScrollCoords
                    }
                }, G, YAHOO.util.Easing.easeOut);
                this.thumbScroll.animate()
            }
        }
        this.resetQueue()
    },
    setQueue: function () {
        var A = this;
        this.timeout = setTimeout(function () {
            A.scrollMedia(A.offset + 1)
        }, 1000 * this.config.delay)
    },
    clearQueue: function () {
        if (this.timeout) {
            clearTimeout(this.timeout);
            this.timeout = null
        }
    },
    resetQueue: function () {
        this.clearQueue();
        this.setQueue()
    },
    setListeners: function (H) {
        var M = this,
            C = this.config;
        var I = this.getParent();
        var B;
        if (this.renderMode == "youtube") {
            B = H
        } else {
            B = H.media
        }
        var L = HD.getByClass(this.config.hooks.ITEM, "*", I);
        var K = HD.getByClass(this.config.hooks.THUMB, "*", I);
        var F = HD.getByClass(this.config.hooks.VIEW_ALL, "*", I);
        if (!this.config.compact) {
            this.thumbsContainerEl = HD.getByClass(this.config.hooks.THUMBS_CONTAINER, "*", I)[0] || null;
            this.itemsContainerEl = HD.getByClass(this.config.hooks.ITEMS_CONTAINER, "*", I)[0] || null;
            this.scrollContainerEl = HD.getByClass(this.config.hooks.SCROLL_CONTAINER, "*", I)[0] || null;
            this.scrollLeftEls = HD.getByClass(this.config.hooks.SCROLL_LEFT, "*", I) || null;
            this.scrollRightEls = HD.getByClass(this.config.hooks.SCROLL_RIGHT, "*", I) || null;
            if (this.config.scrollDirection == "vertical") {
                this.thumbHeight = 0, this.thumbTotalHeight = 0;
                if (K[0] && K[1]) {
                    this.thumbHeight = K[0].offsetHeight;
                    this.thumbOffset = K[1].offsetTop - K[0].offsetTop - this.thumbHeight
                }
                if (this.thumbsContainerEl) {
                    this.thumbsContainerEl.style.height = ((this.thumbHeight + this.thumbOffset) * K.length) + "px"
                }
                if (this.scrollContainerEl) {
                    var J = this.config.pageSize;
                    if (K.length < this.config.pageSize) {
                        J = K.length
                    }
                    this.scrollContainerEl.style.height = (this.thumbHeight * J + this.thumbOffset * (J - 1)) + "px";
                    this.scrollContainerEl.scrollTop = 0
                }
            } else {
                this.thumbWidth = 0, this.thumbTotalWidth = 0;
                if (K[0] && K[1]) {
                    this.thumbWidth = K[0].offsetWidth;
                    this.thumbOffset = K[1].offsetLeft - K[0].offsetLeft - this.thumbWidth
                }
                if (this.thumbsContainerEl) {
                    this.thumbsContainerEl.style.width = ((this.thumbWidth + this.thumbOffset) * K.length) + "px"
                }
                if (this.scrollContainerEl) {
                    this.scrollContainerEl.style.width = (this.thumbWidth * this.config.pageSize + this.thumbOffset * (this.config.pageSize - 1)) + "px";
                    this.scrollContainerEl.scrollLeft = 0
                }
            }
            if (this.scrollLeftEls) {
                for (var G = 0;
                G < this.scrollLeftEls.length;
                G++) {
                    this.scrollLeftEls[G].onclick = function () {
                        M.scrollMedia(M.offset - 1)
                    }
                }
            }
            if (this.scrollRightEls) {
                for (var G = 0;
                G < this.scrollRightEls.length;
                G++) {
                    this.scrollRightEls[G].onclick = function () {
                        M.scrollMedia(M.offset + 1)
                    }
                }
            }
        }
        for (var G = 0, E = Math.min(B.length, (this.config.compact && this.config.pageSize) || B.length);
        G < E;
        G++) {
            (function () {
                var S = B[G];
                var R = G;
                if (S && S.facade) {
                    if (L[G]) {
                        S.facade.setListener(L[G], M)
                    }
                    if (K[G]) {
                        S.facade.setListener(K[G], M)
                    }
                }
                if (L[G] && K[G]) {
                    L[G].onclick = function () {
                        M.notifyObservers("viewCarouselItem", S);
                        M.clearQueue();
                        return false
                    };
                    var N = HD.getByClass(HD.community.Media.hooks.MEDIA_TITLE, "*", L[G])[0] || null;
                    if (N) {
                        N.onclick = function () {
                            M.notifyObservers("viewCarouselItemTitle", S);
                            return false
                        }
                    }
                    var P = function () {
                        if (M.timeout) {
                            M.resetQueue()
                        }
                    };
                    L[G].onmouseover = P;
                    L[G].onmouseout = P;
                    L[G].onmousemove = P;
                    var Q = HD.getByClass(M.config.hooks.YOUTUBE, "*", L[G]);
                    if (Q[0] && M.renderMode == "youtube") {
                        var O = new HD.util.Player({
                            parent: Q[0],
                            width: C.playerWidth || 400,
                            height: C.playerHeight || 300,
                            parentWidget: M,
                            templates: C.playerTemplates || {},
                            hooks: C.playerHooks || {},
                            renderMode: M.renderMode
                        });
                        O.view.render({
                            videoUrl: S.mediaUrl
                        })
                    }
                }
                if (K[G]) {
                    K[G].onclick = function () {
                        M.notifyObservers("scrollCarouselItem", S);
                        M.notifyObservers("viewCarouselItemThumb", S);
                        M.scrollMedia(R);
                        return false
                    }
                }
            })()
        }
        var A = HD.getByClass(HD.CSS_CLASSES.VIDEO_PLAYER, "*", I);
        this.playerIds = [];
        for (var G = 0, D = A.length;
        G < D;
        G++) {
            if (A[G].firstChild && A[G].firstChild.id) {
                this.playerIds.push(A[G].firstChild.id)
            }
        }
        if (F[0]) {
            F[0].onclick = function () {
                M.notifyObservers("viewAllCarouselItems", B);
                return false
            }
        }
        this.offset = 0;
        this.setQueue()
    },
    getHtml: function (B) {
        var C;
        if (this.renderMode == "youtube") {
            C = (B && B.slice(0, Math.min(B.length, (this.config.compact && this.config.pageSize) || B.length))) || []
        } else {
            C = (B && B.media && B.media.slice(0, Math.min(B.media.length, (this.config.compact && this.config.pageSize) || B.media.length))) || [];
            for (var A = 0;
            A < C.length;
            A++) {
                C[A].description = HD.util.Common.ellipseText(C[A].description, this.config.previewLength)
            }
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            items: C,
            community: HD.community,
            renderMode: this.renderMode
        })
    }
};
HD.extend(HD.CarouselWidget, [HD.Widget]);
HD.register("hd_carousel_widget", "HD.CarouselWidget", {
    version: "1.0",
    build: "1"
});
HD.DetailWidget = function (A) {
    this.config = A;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.DetailWidget.templates = {
    getHtml: function () {
        return this.html
    },
    html: '		{if data}			<div class="${classes.DETAIL} ${classes.WIDGET}">				${data|facade}			</div>		{/if}'
};
HD.DetailWidget.prototype = {
    setListeners: function (A) {
        if (A != null) {
            HD.util.Analytics.track(this.analyticsString(A));
            A.facade.setListener(this.getParent(), this)
        }
    },
    update: function (A, B) {
        if (A == "getMedium_Start") {
            this.loading(true)
        } else {
            if (A == "getMedium_Finish") {
                this.loading(false)
            } else {
                if (A == "activeItem_Change") {
                    this.loading(false);
                    this.render(B)
                }
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            data: A
        })
    },
    analyticsString: function (A) {
        return "default_analyticsDetailString"
    }
};
HD.extend(HD.DetailWidget, [HD.Widget]);
HD.register("hd_detail_widget", "HD.DetailWidget", {
    version: "1.0",
    build: "1"
});
HD.FeatureStoriesWidget = function (A) {
    this.config = A || {};
    this.config.pageSize = this.config.pageSize || 3;
    this.config.previewLength = this.config.previewLength || 140;
    this.config.contentFeed = this.config.contentFeed || "getPopular";
    this.config.randomize = this.config.randomize || false;
    this.config.mediaHooks = this.config.mediaHooks || HD.community.Media.hooks;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.FeatureStoriesWidget.templates = {
    featureStoriesLabel: "Feature Stories",
    viewStoryText: "View Story",
    viewAllStoriesText: "View All Stories",
    watchVideoText: "Watch Video",
    getFeatureStoriesLabel: function () {
        return this.featureStoriesLabel
    },
    getViewStoryText: function () {
        return this.viewStoryText
    },
    getViewAllStoriesText: function () {
        return this.viewAllStoriesText
    },
    getWatchVideoText: function () {
        return this.watchVideoText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.FEATURE_STORIES} ${classes.WIDGET}">			<span class="${classes.TITLE}">${templates.getFeatureStoriesLabel()}</span>			<ul class="${classes.LIST}">				{for item in items}					<li class="${hooks.STORY}">${item|facade}						{if community.isVideo(item.contentType)}							<span class="${classes.VIDEO}"><a href="#featAnchor${item_index}" name="featAnchor${item_index}" class="${classes.VIEW} ${classes.CONTROL}">${templates.getWatchVideoText()}</a></span>						{else}							<span class="${classes.PHOTO}"><a href="#featAnchor${item_index}" name="featAnchor${item_index}" class="${classes.VIEW} ${classes.CONTROL}">${templates.getViewStoryText()}</a></span>						{/if}					</li>				{/for}			</ul>			<a href="#featAnchorAll" name="featAnchorAll" class="${classes.VIEW_ALL} ${classes.CONTROL} ${hooks.VIEW_ALL}">${templates.getViewAllStoriesText()}</a>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.FeatureStoriesWidget.hooks = {
        STORY: A.FEATURE_STORIES + "-story",
        VIEW_ALL: A.FEATURE_STORIES + "-viewall"
    }
})();
HD.FeatureStoriesWidget.prototype = {
    update: function (A, B) {
        if (A == this.config.contentFeed + "_Start") {
            this.loading(true)
        } else {
            if (A == this.config.contentFeed + "_Finish") {
                this.loading(false);
                if (this.config.randomize) {
                    B.media.sort(function () {
                        return 0.5 - Math.random()
                    })
                }
                this.render(B)
            }
        }
    },
    setListeners: function (G) {
        var B = HD.CSS_CLASSES;
        var H = this.getParent();
        var A = G.media;
        var I = HD.getByClass(this.config.hooks.STORY, "*", H);
        var D = HD.getByClass(this.config.hooks.VIEW_ALL, "*", H);
        var J = this;
        var E = 0;
        for (var F = 0, C = Math.min(A.length, this.config.pageSize || 3);
        F < C;
        F++) {
            (function () {
                var O = A[F];
                var Q = function () {
                    J.notifyObservers("viewFeatureStory", O);
                    return false
                };
                if (I[F]) {
                    I[F].onclick = Q;
                    var S = HD.getByClass(J.config.mediaHooks.MEDIA_RATING_AVG, "*", I[F])[0] || null;
                    var T = S && (HD.getByClass(J.config.mediaHooks.MEDIA_RATING_STAR, "*", S)[0] || null);
                    var K = S && (HD.getByClass(J.config.mediaHooks.MEDIA_VOTES, "*", S)[0] || null);
                    if (T && K) {
                        var R = new HD.util.StarRating({
                            starRatingParent: T,
                            numOfVotesParent: K,
                            numOfVotes: O.numberOfVotes,
                            averageRating: O.rating,
                            isStatic: true,
                            itemId: O.mediaId,
                            numOfDecimals: 1,
                            requiresLogin: false
                        })
                    }
                }
                if ( !! O.category && I[F]) {
                    var N = HD.getByClass(J.config.mediaHooks.MEDIA_CATEGORY, "*", I[F]);
                    if (N[0]) {
                        N[0].onclick = function (U) {
                            J.notifyObservers("viewCategory", O.category);
                            if (!U) {
                                var U = window.event
                            }
                            U.cancelBubble = true;
                            if (U.stopPropagation) {
                                U.stopPropagation()
                            }
                        }
                    }
                }
                if (O.tags && O.tags.length > 0 && I[F]) {
                    var P = HD.getByClass(J.config.mediaHooks.MEDIA_TAG, "*", I[F]);
                    for (var L = 0, M = P.length;
                    L < M;
                    L++) {
                        (function () {
                            var U = O.tags[L];
                            P[L].onclick = function (V) {
                                J.notifyObservers("viewTag", U);
                                if (!V) {
                                    var V = window.event
                                }
                                V.cancelBubble = true;
                                if (V.stopPropagation) {
                                    V.stopPropagation()
                                }
                            }
                        })()
                    }
                }
            })();
            E += 2
        }
        if (D[0]) {
            D[0].onclick = function () {
                J.notifyObservers("viewAllFeatureStories", A);
                return false
            }
        }
    },
    getHtml: function (B) {
        var C = (B && B.media && B.media.slice(0, Math.min(B.media.length, this.config.pageSize || 3))) || [];
        for (var A = 0;
        A < C.length;
        A++) {
            C[A].description = HD.util.Common.ellipseText(C[A].description, this.config.previewLength)
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            ratingClasses: HD.util.StarRating.CSS_CLASSES,
            items: C,
            community: HD.community
        })
    }
};
HD.extend(HD.FeatureStoriesWidget, [HD.Widget]);
HD.register("hd_feature_stories_widget", "HD.FeatureStoriesWidget", {
    version: "1.0",
    build: "1"
});
HD.GalleryWidget = function (A) {
    this.config = A || {};
    this.config.titleLength = this.config.titleLength || 0;
    this.config.viewAllMax = this.config.viewAllMax || 50;
    this.config.embedShare = this.config.embedShare || false;
    this.config.shareConfig = this.config.shareConfig || {};
    this.config.embedSendFriend = this.config.embedSendFriend || false;
    this.config.sendFriendConfig = this.config.sendFriendConfig || {};
    this.config.showMatrix = this.config.showMatrix || false;
    this.config.showPageSizeSwitch = this.config.showPageSizeSwitch || false;
    this.config.showItemCount = this.config.showItemCount || false;
    this.observers = [];
    this.loadTemplates(arguments.callee);
    this.config.sorts = this.config.sorts || [{
        name: this.config.templates.getSortNewToOldText(),
        value: HD.SORTS.NEW_TO_OLD,
        isDefault: false
    },
    {
        name: this.config.templates.getSortOldToNewText(),
        value: HD.SORTS.OLD_TO_NEW,
        isDefault: true
    }]
};
HD.GalleryWidget.templates = {
    sortByLabel: "Sort By",
    sortNewToOldText: "Newest To Oldest",
    sortOldToNewText: "Oldest To Newest",
    getSortByLabel: function () {
        return this.sortByLabel
    },
    getSortNewToOldText: function () {
        return this.sortNewToOldText
    },
    getSortOldToNewText: function () {
        return this.sortOldToNewText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.GALLERY} ${classes.WIDGET}">		{if community.isBoth(contentType) || community.isPhoto(contentType) || community.isVideo(contentType) || config.showMatrix}			<div class="${classes.CONTROL_PANEL}">				<span class="${classes.SORT}">					<span>${templates.getSortByLabel()}</span>					<select class="${hooks.SORTING}">						{for sort in config.sorts}							{if selectedSort == sort.value || sort.isDefault}								<option value="${sort.value}" selected>${sort.name}</option>							{else}								<option value="${sort.value}">${sort.name}</option>							{/if}						{/for}					</select>				</span>				<span class="${hooks.PAGING}"></span>			</div>			<div class="${classes.CONTENT_PANEL}">				<table>					<tr class="{if rows == 1}${classes.LAST}{else}${classes.FIRST}{/if}">					{var rows = Math.ceil(items.length / config.itemsX)}					{for item in items}						{if item_index > 0 && item_index % config.itemsX == 0}							{if rows == (Math.ceil(item_index / config.itemsX) + 1)}								</tr><tr class="${classes.LAST}">							{else}								</tr><tr>							{/if}						{/if}						<td>${item|facade}</td>					{/for}					</tr>				</table>			</div>			<div class="${classes.CONTROL_PANEL}">				<span class="${hooks.PAGING}"></span>			</div>		{elseif community.isBlog(contentType)}			<div class="${classes.CONTROL_PANEL}">				<span class="${classes.PAGING}"></span>			</div>			<div class="${classes.CONTENT_PANEL}">				{for blog in items}					${blog|facade}				{/for}			</div>			<div class="${classes.CONTROL_PANEL} ${classes.LAST}">				<span class="${classes.PAGING}"></span>			</div>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.GalleryWidget.hooks = {
        PAGING: A.PAGING,
        SORTING: A.SORT + "-list"
    }
})();
HD.GalleryWidget.prototype = {
    update: function (A, C) {
        if (A == "getMedia_Start") {
            this.loading(true)
        } else {
            if (A == "getMedia_Finish") {
                this.loading(false);
                if (this.mediaCache) {
                    for (var B = 0;
                    B < this.mediaCache.length;
                    B++) {
                        this.mediaCache[B].facade.destroy()
                    }
                }
                this.mediaCache = C.media;
                this.render(C);
                if (this.paging != null) {
                    this.paging.controller.updatePagingData(C)
                }
            }
        }
    },
    setListeners: function (A) {
        if (HD.community.isBoth(A.contentType) || HD.community.isPhoto(A.contentType) || HD.community.isVideo(A.contentType) || this.config.showMatrix) {
            return this.setBothListeners(A)
        } else {
            if (HD.community.isBlog(A.contentType)) {
                return this.setBlogListeners(A)
            }
        }
    },
    setBothListeners: function (J) {
        var F = HD.CSS_CLASSES;
        var G = this.config.viewAllMax;
        var P = this.config.itemsX * this.config.itemsY;
        var H = this.config.showPageSizeSwitch;
        var B = this.config.showItemCount;
        var K = this.getParent();
        if (J.media.length > 0) {
            var N = HD.getByClass(J.media[0].facade.config.hooks.MEDIA_ITEM, "*", K);
            var O = J.media;
            for (var I = 0, M = O.length;
            I < M;
            I++) {
                if (O[I] && N[I]) {
                    O[I].facade.setListener(N[I], this, this.config)
                }
            }
        }
        var D = HD.getByClass(this.config.hooks.PAGING, "*", K);
        if (D.length > 0) {
            var C = new HD.util.Paging({
                startingPage: 1,
                containers: D,
                viewAllMax: G,
                defaultPageSize: P,
                showPageSizeSwitch: H,
                showItemCount: B,
                templates: this.config.pagingTemplates || {},
                hooks: this.config.pagingHooks || {}
            });
            var E = this;
            var A = this.model;
            var L = {
                update: function (Q, R) {
                    if (Q == "paging_Next") {
                        A.getNextPage.call(A)
                    } else {
                        if (Q == "paging_Previous") {
                            A.getPreviousPage.call(A)
                        } else {
                            if (Q == "paging_Page") {
                                A.getMedia.call(A, R)
                            } else {
                                if (Q == "show_All" || Q == "show_Max") {
                                    A.config.pageSize = G;
                                    A.getSamePage.call(A)
                                } else {
                                    if (Q == "show_Default") {
                                        A.config.pageSize = P;
                                        A.getSamePage.call(A)
                                    }
                                }
                            }
                        }
                    }
                }
            };
            C.view.addObserver(L);
            this.paging = C
        }
        HD.getByClass(this.config.hooks.SORTING, "*", K, function (Q) {
            Q.onchange = function () {
                var R = Q.options[Q.selectedIndex].value;
                A.setSort.call(A, R)
            }
        })
    },
    setBlogListeners: function (H) {
        var G = HD.CSS_CLASSES;
        var K = this.getParent();
        var D = H.media;
        var E = this.config;
        var J = this.model;
        var N = HD.getByClass(G.ITEM, "div", K);
        for (var I = 0, M = N.length;
        I < M;
        I++) {
            var O = D[I];
            if (O != null) {
                O.facade.setListener(N[I], this, E)
            }
        }
        var C = HD.getByClass(this.config.hooks.PAGING, "*", K);
        if (C.length > 0) {
            var B = new HD.util.Paging({
                startingPage: 1,
                containers: C,
                templates: this.config.pagingTemplates || {},
                hooks: this.config.pagingHooks || {}
            });
            var F = this;
            var A = this.model;
            var L = {
                update: function (P, Q) {
                    if (P == "paging_Next") {
                        A.getNextPage.call(A)
                    } else {
                        if (P == "paging_Previous") {
                            A.getPreviousPage.call(A)
                        } else {
                            if (P == "paging_Page") {
                                A.getMedia.call(A, Q)
                            }
                        }
                    }
                }
            };
            B.view.addObserver(L);
            this.paging = B
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: (A && A.media) || [],
            contentType: A.contentType || "",
            selectedSort: this.model.getSort() || "",
            sorts: HD.SORTS,
            community: HD.community
        })
    }
};
HD.extend(HD.GalleryWidget, [HD.Widget]);
HD.register("hd_gallery_widget", "HD.GalleryWidget", {
    version: "1.0",
    build: "1"
});
HD.MiniGalleryWidget = function (A) {
    this.config = A;
    this.observers = [];
    this.loadTemplates(arguments.callee);
    this.initialPageIndex = 0
};
HD.MiniGalleryWidget.templates = {
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.MINI_GALLERY} ${classes.WIDGET}">	   		<div class="${classes.WRAPPER}">			{if hasPrevious}				<div class="${hooks.PAGING_ARROW} ${hooks.PREVIOUS}">&nbsp;</div>    		{/if}			</div>			{for item in items}				${item|facade}			{/for}	   		<div class="${classes.WRAPPER}">			{if hasNext}				<div class="${hooks.PAGING_ARROW} ${hooks.NEXT}">&nbsp;</div>    		{/if}			</div>    	</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.MiniGalleryWidget.hooks = {
        NEXT: A.NEXT,
        PREVIOUS: A.PREVIOUS,
        PAGING_ARROW: A.PAGING_ARROW
    }
})();
HD.MiniGalleryWidget.prototype = {
    update: function (A, C) {
        if (A == "getMedia_Start") {
            this.loading(true)
        } else {
            if (A == "getMedia_Finish") {
                this.loading(false);
                if (this.mediaCache) {
                    for (var B = 0;
                    B < this.mediaCache.length;
                    B++) {
                        this.mediaCache[B].facade.destroy()
                    }
                }
                this.mediaCache = C.media;
                this.separateItems(C);
                if ( !! this.queueSetActive) {
                    this.setActive(this.queueSetActive)
                }
                this.render(C)
            } else {
                if (A == "activeItem_Change") {
                    this.setActive(C)
                }
            }
        }
    },
    getHtml: function () {
        if (this.model.isLastIndexActive) {
            this.activePage = Math.floor(this.model.config.pageSize / this.config.numOfItems) - 1;
            this.model.isLastIndexActive = false
        }
        this.hasPreviousMiniPage = this.activePage > this.initialPageIndex;
        this.hasPreviousPage = this.model.hasPreviousPage();
        this.hasNextMiniPage = this.activePage < this.pages.length - 1;
        this.hasNextPage = this.model.hasNextPage();
        return this.processTemplate(this.config.templates.getHtml(), {
            hasPrevious: this.hasPreviousMiniPage || this.hasPreviousPage,
            hasNext: this.hasNextMiniPage || this.hasNextPage,
            items: this.pages[this.activePage]
        })
    },
    setActive: function (M) {
        if (!this.pages) {
            this.queueSetActive = M;
            return
        }
        var B = HD.CSS_CLASSES;
        var G = this.getParent();
        var K = this.activePage;
        var A = this.pages;
        for (var F = 0, H = A.length;
        F < H;
        F++) {
            var C = A[F];
            for (var E = 0, D = C.length;
            E < D;
            E++) {
                var J = C[E];
                if (J != null && J.mediaId == M.mediaId) {
                    this.activePage = F;
                    break
                }
            }
        }
        if (K != this.activePage) {
            this.render()
        }
        var C = this.pages[this.activePage];
        var I = HD.getByClass(B.ITEM, "div", G);
        for (var F = 0, H = C.length;
        F < H;
        F++) {
            var J = C[F];
            var L = I[F];
            if (J != null && J.mediaId == M.mediaId) {
                HD.addClass(L, B.ACTIVE)
            } else {
                HD.removeClass(L, B.ACTIVE)
            }
        }
    },
    separateItems: function (D) {
        this.pages = [];
        this.activePage = this.initialPageIndex;
        var B = this.config.numOfItems;
        var F = 0;
        this.pages[F] = [];
        var C = D.media;
        for (var E = 0, A = C.length;
        E < A;
        E++) {
            if (E > 0 && E % B == 0) {
                F++;
                this.pages[F] = []
            }
            this.pages[F].push(C[E])
        }
    },
    setListeners: function (F) {
        var M = this.config.hooks;
        var I = this.getParent();
        var B = HD.getByClass(M.PAGING_ARROW, "*", I);
        var H = null;
        var C = null;
        for (var G = 0, J = B.length;
        G < J;
        G++) {
            var L = B[G];
            if (HD.hasClass(L, M.NEXT)) {
                C = L
            } else {
                if (HD.hasClass(L, M.PREVIOUS)) {
                    H = L
                }
            }
        }
        var D = this;
        var A = this.model;
        if (H != null) {
            H.onclick = function () {
                if (D.hasPreviousMiniPage) {
                    D.activePage--;
                    D.render.call(D)
                } else {
                    if (D.hasPreviousPage) {
                        A.getPreviousPage(true, true);
                        A.isLastIndexActive = true
                    }
                }
            }
        }
        if (C != null) {
            C.onclick = function () {
                if (D.hasNextMiniPage) {
                    D.activePage++;
                    D.render.call(D)
                } else {
                    if (D.hasNextPage) {
                        A.getNextPage(true)
                    }
                }
            }
        }
        var E = this.pages[this.activePage];
        if (E.length > 0) {
            var K = HD.getByClass(E[0].facade.config.hooks.MEDIA_ITEM, "*", I);
            for (var G = 0, J = E.length;
            G < J;
            G++) {
                if (K[G] && E[G]) {
                    this.setItemListener(K[G], E[G])
                }
            }
        }
    },
    setItemListener: function (C, D) {
        var A = this;
        var B = D;
        C.onclick = function () {
            A.view.notifyObservers.call(A.view, "itemChange_Start", B);
            A.model.setActiveItem.call(A.model, B);
            A.model.activeItemPage = A.model.pageNumber
        }
    }
};
HD.extend(HD.MiniGalleryWidget, [HD.Widget]);
HD.register("hd_mini_gallery_widget", "HD.MiniGalleryWidget", {
    version: "1.0",
    build: "1"
});
HD.MostPopularWidget = function (A) {
    this.config = A;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.MostPopularWidget.templates = {
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.MOST_POPULAR} ${classes.WIDGET}">		{for item in items}			<div class="${classes.TITLE} ${classes.CONTROL} ${hooks.ITEM}">${item.title}</div>		{/for}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.MostPopularWidget.hooks = {
        ITEM: A.ITEM
    }
})();
HD.MostPopularWidget.prototype = {
    setListeners: function (F) {
        var D = HD.CSS_CLASSES;
        var E = this.getParent();
        var G = F.media;
        var B = HD.getByClass(this.config.hooks.ITEM, "*", E);
        for (var C = 0, A = G.length;
        C < A;
        C++) {
            if (B[C]) {
                this.setListener(B[C], G[C])
            }
        }
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        C.onclick = function () {
            A.model.setActiveItem.call(A.model, B);
            A.notifyObservers.call(A, "itemSelected", B)
        }
    },
    update: function (A, B) {
        if (A == "getPopular_Start") {
            this.loading(true)
        } else {
            if (A == "getPopular_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: (A && A.media) || []
        })
    }
};
HD.extend(HD.MostPopularWidget, [HD.Widget]);
HD.register("hd_most_popular_widget", "HD.MostPopularWidget", {
    version: "1.0",
    build: "1"
});
HD.MonthlyWidget = function (A) {
    this.config = A;
    this.config.renderMode = this.config.renderMode || "list" || "select";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.MonthlyWidget.templates = {
    defaultSelectLabel: "By date",
    getDefaultSelectLabel: function () {
        return this.defaultSelectLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.MONTHLY_BREAKDOWN} ${classes.WIDGET}">		{if config.renderMode == "list"}			{for item in items}				{if item && item.itemCount > 0}					<div>						<span class="${classes.TITLE} ${classes.CONTROL} ${hooks.ITEM}">${item.startDate|date}</span>						<span class="${classes.VALUE}"> (${item.itemCount})</span>					</div>				{/if}			{/for}		{elseif config.renderMode == "select"}			<select class="${hooks.LIST}">			<option class="${hooks.ITEM}" value="" selected="selected">${templates.getDefaultSelectLabel()}</option>			{for item in items}				{if item && item.itemCount > 0}					<option class="${hooks.ITEM}" value="${item_index}">${item.startDate|date}</option>				{/if}			{/for}			</select>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.MonthlyWidget.hooks = {
        ITEM: A.ITEM,
        LIST: A.LIST
    }
})();
HD.MonthlyWidget.prototype = {
    setListeners: function (C) {
        var E = this.getParent();
        var A = C.media;
        if (this.config.renderMode == "list") {
            var F = HD.getByClass(this.config.hooks.ITEM, "*", E);
            var H = 0;
            for (var D = 0, G = A.length;
            D < G;
            D++) {
                var I = A[D];
                if (I != null && I.itemCount > 0) {
                    if (F[H]) {
                        this.setListener(F[H], A[D])
                    }
                    H++
                }
            }
        } else {
            if (this.config.renderMode == "select") {
                var B = this;
                HD.getByClass(this.config.hooks.LIST, "*", E, function (J) {
                    J.onchange = function () {
                        var K = J.options[J.selectedIndex].value;
                        if (K != "" && K >= 0) {
                            var L = A[K];
                            var M = {
                                startDate: L.startDate,
                                endDate: L.endDate
                            };
                            B.model.setDateRange.call(B.model, M)
                        }
                    }
                })
            }
        }
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        if (D.itemCount > 0) {
            C.onclick = function () {
                var E = {
                    startDate: B.startDate,
                    endDate: B.endDate
                };
                A.model.setDateRange.call(A.model, E)
            }
        }
    },
    update: function (A, B) {
        if (A == "getMonthly_Finish") {
            this.loading(false);
            this.render(B)
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: (A && A.media) || []
        })
    }
};
HD.extend(HD.MonthlyWidget, [HD.Widget]);
HD.register("hd_monthly_widget", "HD.MonthlyWidget", {
    version: "1.0",
    build: "1"
});
HD.CommentsWidget = function (A) {
    this.config = A || {};
    this.config.requiresLogin = this.config.requiresLogin || false;
    this.config.submitAbove = this.config.submitAbove || false;
    this.config.submitBelow = this.config.submitBelow || false;
    this.config.confirmation = this.config.confirmation || false;
    this.config.showCharCount = this.config.showCharCount || false;
    this.config.paginate = this.config.paginate || false;
    this.config.pageSize = this.config.pageSize || 10;
    this.config.firstPageSize = this.config.firstPageSize || this.config.pageSize;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.CommentsWidget.templates = {
    titleLabel: "Comments",
    postCommentLabel: "Post a Comment",
    commentFieldLabel: "Comment:",
    submitLabel: "Submit",
    loadingText: "Loading comments...",
    noCommentsText: "This item has no comments, be the first to leave your mark.",
    confirmationLabel: "Thank You",
    confirmationValue: "Thank you for your submission. After a quick review, your content will be posted to the website within one or two business days. Content deemed to be off topic, offensive or promoting dangerous riding cannot be posted.",
    submitAnotherText: "Post another comment",
    termsConditionsShortPreText: "By submitting your comment, you confirm that you are at least 18 years of age (or the age of majority in your state of residence) and agree to the terms and conditions stated in <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/user_content_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Harley-Davidson's Policy For User-Submitted Content</a>.",
    maxCharValue: 200,
    getTitleLabel: function () {
        return this.titleLabel
    },
    getPostCommentLabel: function () {
        return this.postCommentLabel
    },
    getCommentFieldLabel: function () {
        return this.commentFieldLabel
    },
    getSubmitLabel: function () {
        return this.submitLabel
    },
    getLoadingText: function () {
        return this.loadingText
    },
    getNoCommentsText: function () {
        return this.noCommentsText
    },
    getConfirmationLabel: function () {
        return this.confirmationLabel
    },
    getConfirmationValue: function () {
        return this.confirmationValue
    },
    getSubmitAnotherText: function () {
        return this.submitAnotherText
    },
    getTermsConditionsShortPreText: function () {
        return this.termsConditionsShortPreText
    },
    getErrorsHtml: function () {
        return this.errorsHtml
    },
    getMaxCharValue: function () {
        return this.maxCharValue
    },
    getHtml: function () {
        return this.html
    },
    errorsHtml: '		{if errors}			{for error in errors}				<div class="${classes.ERROR}">${error.errorMessage}</div>			{/for}		{/if}',
    html: '		{if comments}			{macro commentsForm()}				<li><form class="${hooks.FORM}">					<div class="${classes.TITLE}">${templates.getPostCommentLabel()}</div>					<div class="${classes.WRAPPER} ${hooks.ERROR}"></div>					<div class="${classes.LABEL}">${templates.getCommentFieldLabel()}</div>					<textarea cols="30" rows="5" class="${classes.VALUE} ${hooks.TEXTAREA}"></textarea><br/>					{if config.showCharCount}						<div id="hdCharCount"><input type="text" class="${hooks.CHARCOUNT}" value="${templates.getMaxCharValue()}" /></div>					{/if}					<div class="${classes.AGREEMENT}">						<div class="${classes.LABEL} ${hooks.LEGAL_SM}">							${templates.getTermsConditionsShortPreText()}						</div>					</div>					<input type="Submit" value="${templates.getSubmitLabel()}" class="${hooks.SUBMIT}" />				</form></li>				<li class="${classes.HIDDEN}">					<div class="${classes.CONFIRMATION} ${hooks.CONFIRMATION}">						<div class="${classes.LABEL}">${templates.getConfirmationLabel()}</div>						<div class="${classes.VALUE}">${templates.getConfirmationValue()}</div>						<div class="hdSubmitComment hdSubmitAnotherComment ${hooks.SUBMIT_ANOTHER_COMMENT}">${templates.getSubmitAnotherText()}</div>					</div>				</li>			{/macro}			{macro commentDisplay()}				<li class="${classes.COMMENT}">					<div>						<span class="${classes.DATE}">${comment.createdDate|date}</span> 						<span class="${classes.AUTHOR}">${comment.submittedBy}</span>					</div>					<div class="${classes.VALUE}">${comment.text}</div>				</li>			{/macro}			<div class="${classes.COMMENTS} ${classes.WIDGET}">				<ul>				{if config.submitAbove}					${commentsForm()}				{/if}				{if comments.length > 0}					{if config.paginate}						{for comment in comments}							{if comment_index < (config.pageSize*pageNumber) && comment_index >= (config.pageSize*(pageNumber-1))}								${commentDisplay()}							{/if}						{/for}						<li><span class="${hooks.PAGING}"></span></li>					{else}						<li class="${classes.TITLE}">${templates.getTitleLabel()}</li>						{for comment in comments}							${commentDisplay()}						{/for}					{/if}				{else}					<li class="${classes.EMPTY}">${templates.getNoCommentsText()}</li>				{/if}				</ul>			</div>			{if config.submitBelow}				${commentsForm()}			{/if}		{else}			${templates.getLoadingText()}		{/if}'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.CommentsWidget.hooks = {
        FORM: A.COMMENTS + "-form",
        TEXTAREA: A.COMMENTS + "-textarea",
        LEGAL_SM: A.COMMENTS + "-legal-sm",
        LEGAL_FULL: A.COMMENTS + "-legal-full",
        TERMS_BUTTON: A.COMMENTS + "-terms-btn",
        SUBMIT_ANOTHER_COMMENT: A.COMMENTS + "-submit-comment",
        COMMENT_SUBMITTED: A.COMMENTS + "-" + A.LOADING,
        ERROR: A.COMMENTS + "-error",
        CONFIRMATION: A.COMMENTS + "-confirmation",
        CHARCOUNT: A.COMMENTS + "-charcount",
        SUBMIT: A.COMMENTS + "-submit",
        PAGING: A.PAGING
    }
})();
HD.CommentsWidget.prototype = {
    setListeners: function (H) {
        if (H == null) {
            return
        }
        var E = HD.CSS_CLASSES;
        var J = this.getParent();
        var O = HD.getByClass(this.config.hooks.FORM, "*", J)[0];
        var L = HD.getByClass(this.config.hooks.TEXTAREA, "*", J)[0];
        var F = HD.getByClass(this.config.hooks.CHARCOUNT, "*", J)[0];
        if (O && L) {
            HD.removeClass(O, E.ERROR);
            var A = this.model;
            var M = H;
            var D = this;
            if (this.config.showCharCount && F) {
                L.onkeyup = function () {
                    var R = L.value.length;
                    var S = D.config.templates.getMaxCharValue();
                    F.value = S - R;
                    D.getByHook("SUBMIT", function (T) {
                        if (R > S) {
                            T.disabled = true;
                            HD.addClass(T, E.DISABLED)
                        } else {
                            T.disabled = false;
                            HD.removeClass(T, E.DISABLED)
                        }
                    }, "*", J)
                }
            }
            O.onsubmit = function () {
                var S = HD.util.Common.stripHtmlTags(L.value);
                var R = function () {
                    A.submitComment.call(A, M.mediaId, M.contentType, S)
                };
                if (D.config.requiresLogin) {
                    login.model.isUserLoggedIn(function (U) {
                        if (U.loggedInLevel > 1) {
                            R()
                        } else {
                            var T = {
                                update: function (V, W) {
                                    if (V == "logged_In") {
                                        R();
                                        login.model.removeObserver(this);
                                        HD.util.Common.getObservable().removeObserver(this)
                                    } else {
                                        if (V == "overlayClose_Click") {
                                            login.model.removeObserver(this);
                                            HD.util.Common.getObservable().removeObserver(this)
                                        }
                                    }
                                }
                            };
                            HD.util.Common.getObservable().addObserver(T);
                            login.model.addObserver(T);
                            if (U.loggedInLevel > 0) {
                                login.view.promptCreateScreenName()
                            } else {
                                login.view.promptAuthentication()
                            }
                        }
                    })
                } else {
                    R()
                }
                return false
            };
            var N = HD.getByClass(this.config.hooks.LEGAL_SM, "*", J)[0];
            var G = HD.getByClass(this.config.hooks.LEGAL_FULL, "*", J)[0];
            var Q = HD.getByClass(this.config.hooks.TERMS_BUTTON, "*", J)[0];
            if (Q && G) {
                Q.onclick = function () {
                    if (HD.hasClass(G, E.HIDDEN)) {
                        HD.removeClass(G, E.HIDDEN)
                    } else {
                        HD.addClass(G, E.HIDDEN)
                    }
                }
            }
        }
        var C = HD.getByClass(this.config.hooks.PAGING, "*", J);
        if (C.length > 0) {
            var B = new HD.util.Paging({
                startingPage: 1,
                containers: C,
                defaultPageSize: this.config.pageSize,
                templates: this.config.pagingTemplates || {},
                hooks: this.config.pagingHooks || {}
            });
            var P = this;
            var K = {
                update: function (R, S) {
                    if (R == "paging_Next") {
                        P.preparePaging(P.commentData, P.commentData.pageNumber + 1, true)
                    } else {
                        if (R == "paging_Previous") {
                            P.preparePaging(P.commentData, P.commentData.pageNumber - 1, true)
                        } else {
                            if (R == "paging_Page") {
                                P.preparePaging(P.commentData, S, true)
                            }
                        }
                    }
                }
            };
            B.view.addObserver(K);
            this.paging = B
        }
        var D = this;
        var I = HD.getByClass(this.config.hooks.SUBMIT_ANOTHER_COMMENT, "*", J)[0];
        if (I != null) {
            I.onclick = function () {
                D.hideConfirmation.call(D)
            }
        }
    },
    setAuthorListener: function (B, C) {
        if (B == null || C == null) {
            return
        }
        var A = this;
        B.onclick = function () {
            A.notifyObservers.call(A, "authorSelected", C);
            A.model.getMemberProfile.call(A.model, C)
        }
    },
    preparePaging: function (C, B, A) {
        C.pageNumber = B;
        C.totalPages = Math.ceil(C.numberOfComments / this.config.pageSize);
        C.totalMedia = C.numberOfComments;
        C.pageSize = this.config.pageSize;
        this.commentData = HD.clone(C || {}, false);
        if (A) {
            this.render(C)
        }
        this.paging.controller.updatePagingData(C)
    },
    update: function (A, E) {
        var C = HD.CSS_CLASSES;
        var D = this.getParent();
        var F = HD.getByClass(this.config.hooks.TEXTAREA, "*", D)[0];
        if (A == "getComments_Start") {
            this.loading(true);
            this.render(E)
        } else {
            if (A == "getComments_Finish") {
                this.loading(false);
                this.render(E);
                if (this.config.paginate) {
                    this.preparePaging(E, 1, false)
                }
            } else {
                if (A == "submitComment_Start") {
                    if (F) {
                        HD.addClass(F, this.config.hooks.COMMENT_SUBMITTED)
                    }
                } else {
                    if (A == "submitComment_Finish") {
                        this.loading(false);
                        if (F) {
                            HD.removeClass(F, this.config.hooks.COMMENT_SUBMITTED)
                        }
                        var B = HD.getByClass(this.config.hooks.CHARCOUNT, "*", D)[0];
                        if (this.config.showCharCount && B) {
                            B.value = this.config.templates.getMaxCharValue()
                        }
                        if (this.config.confirmation) {
                            this.showConfirmation(E)
                        } else {
                            this.render(E);
                            if (this.config.paginate) {
                                this.preparePaging(E, 1, false)
                            }
                        }
                    } else {
                        if (A == "submitComment_Error") {
                            this.loading(false);
                            if (F) {
                                HD.removeClass(F, this.config.hooks.COMMENT_SUBMITTED)
                            }
                            this.renderError(E)
                        }
                    }
                }
            }
        }
    },
    showConfirmation: function () {
        var B = HD.CSS_CLASSES;
        var D = this.getParent();
        var A = HD.getByClass(this.config.hooks.FORM, "*", D)[0];
        var C = HD.getByClass(this.config.hooks.TEXTAREA, "*", D)[0];
        var E = HD.getByClass(this.config.hooks.ERROR, "*", D)[0];
        var F = HD.getByClass(this.config.hooks.CONFIRMATION, "*", D)[0];
        if (C) {
            C.value = ""
        }
        if (A) {
            HD.addClass(A.parentNode, B.HIDDEN);
            HD.removeClass(A, B.ERROR)
        }
        if (E) {
            E.innerHTML = ""
        }
        if (F) {
            HD.removeClass(F.parentNode, B.HIDDEN)
        }
    },
    hideConfirmation: function () {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.FORM, "*", C)[0];
        var D = HD.getByClass(this.config.hooks.CONFIRMATION, "*", C)[0];
        if (D) {
            HD.addClass(D.parentNode, B.HIDDEN)
        }
        if (A) {
            HD.removeClass(A.parentNode, B.HIDDEN)
        }
    },
    renderError: function (E) {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.FORM, "*", C)[0];
        var D = HD.getByClass(this.config.hooks.ERROR, "*", C)[0];
        if (A) {
            HD.addClass(A, B.ERROR)
        }
        if (D) {
            D.innerHTML = this.getErrorsHtml(E)
        }
    },
    getErrorsHtml: function (A) {
        return this.processTemplate(this.config.templates.getErrorsHtml(), {
            errors: A
        })
    },
    getHtml: function (B) {
        var A = this;
        return this.processTemplate(this.config.templates.getHtml(), {
            comments: (B && B.comments) || null,
            pageNumber: (B && B.pageNumber) || 1
        })
    }
};
HD.extend(HD.CommentsWidget, [HD.Widget]);
HD.register("hd_comments_widget", "HD.CommentsWidget", {
    version: "1.0",
    build: "1"
});
HD.MemberWidget = function (A) {
    this.config = A;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.MemberWidget.templates = {
    noProfileText: "This user does not have a public profile.",
    getNoProfileText: function () {
        return this.noProfileText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.MEMBER} ${classes.WIDGET}">		{if profile}			<div class="dblRuleBtm"><span class="head">${config.title}</span></div>			<div class="${classes.THUMB}" {if profile.pathToProfilePhoto}style="background: transparent url(${profile.pathToProfilePhoto}) no-repeat 50% 50%;"{/if}></div>			<div class="${classes.DESCRIPTION}">				<div class="${classes.TITLE}">${profile.firstName} ${profile.lastName}</div>				<div class="${classes.VALUE}">${profile.aboutMe}</div>			</div>		{else}			${templates.getNoProfileText()}		{/if}		</div>'
};
HD.MemberWidget.prototype = {
    update: function (A, B) {
        if (A == "getMember_Start") {
            this.loading(true)
        } else {
            if (A == "getMember_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            profile: A
        })
    }
};
HD.extend(HD.MemberWidget, [HD.Widget]);
HD.register("hd_member_widget", "HD.MemberWidget", {
    version: "1.0",
    build: "1"
});
HD.ShareWidget = function (A) {
    var C = HD.ShareWidget.SERVICES;
    this.config = A || {};
    this.config.embedMode = this.config.embedMode || false;
    this.config.standaloneMode = this.config.standaloneMode || false;
    this.config.previewLength = this.config.previewLength || 0;
    this.config.services = this.config.services || [C.DIGG, C.FACEBOOK, C.TWITTER];
    this.config.getPermalink = this.config.getPermalink ||
    function (F, D, E) {
        return F.facade.generatePermalink()
    };
    this.config.useShareAPI = this.config.useShareAPI == null ? true : this.config.useShareAPI;
    this.config.callback = this.config.callback ||
    function (D, F, H, E, I, G) {};
    for (var B = this.config.services.length - 1;
    B >= 0;
    B--) {
        if (typeof this.config.services[B] == "string") {
            this.config.services[B] = this.getService(this.config.services[B]);
            if (!this.config.services[B]) {
                this.config.services[B].splice(B, 1)
            }
        }
    }
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.ShareWidget.SERVICES = {
    BLOGGER: {
        name: "Blogger",
        url: null,
        callback: null
    },
    DELICIOUS: {
        name: "Delicious",
        url: null,
        callback: null
    },
    DIGG: {
        name: "Digg",
        url: null,
        callback: null
    },
    FACEBOOK: {
        name: "Facebook",
        url: null,
        callback: null
    },
    FRIENDFEED: {
        name: "Friendfeed",
        url: null,
        callback: null
    },
    GOOGLE: {
        name: "Google",
        url: null,
        callback: null
    },
    LINKEDIN: {
        name: "Linked In",
        url: null,
        callback: null
    },
    MAGNOLIA: {
        name: "Magnolia",
        url: null,
        callback: null
    },
    MIXX: {
        name: "Mixx",
        url: null,
        callback: null
    },
    MYSPACE: {
        name: "MySpace",
        url: null,
        callback: null
    },
    NEWSVINE: {
        name: "NewsVine",
        url: null,
        callback: null
    },
    REDDIT: {
        name: "Reddit",
        url: null,
        callback: null
    },
    SLASHDOT: {
        name: "Slashdot",
        url: null,
        callback: null
    },
    STUMBLEUPON: {
        name: "Stumble Upon",
        url: null,
        callback: null
    },
    TECHNORATI: {
        name: "Technorati",
        url: null,
        callback: null
    },
    TWITTER: {
        name: "Twitter",
        url: null,
        callback: null
    },
    WORDPRESS: {
        name: "Wordpress",
        url: null,
        callback: null
    }
};
HD.ShareWidget.templates = {
    shareLabel: "Share: ",
    getShareLabel: function () {
        return this.shareLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.SHARE} ${classes.WIDGET}">			<span>${templates.getShareLabel()}</span>			<ul>			{for service in config.services}				<li class="${service|getClass} ${hooks.ITEMSHARE}">					<a class="${hooks.ITEMLINK}" 						{if _MODIFIERS.getUrl(service,media)}							href="${service|getUrl:media}" target="_blank"						{else}							href="javascript:void(0)"						{/if}					></a>					<div><span>${service.name}</span></div></li>			{/for}			</ul>		</div>		<div class="${classes.SHARE}Clear"></div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.ShareWidget.hooks = {
        ITEMSHARE: A.SHARE + "-item",
        ITEMLINK: A.SHARE + "-link"
    }
})();
HD.ShareWidget.prototype = {
    setListeners: function (D) {
        if (!D) {
            return
        }
        var A = this;
        var B = HD.getByClass(this.config.hooks.ITEMLINK, "*", this.getParent());
        var E = HD.getByClass(this.config.hooks.ITEMSHARE, "*", this.getParent());
        for (var C = 0;
        C < this.config.services.length;
        C++) {
            if (E[C]) {
                E[C].onmouseover = function () {
                    HD.addClass(this, HD.CSS_CLASSES.SHARE + "Hover")
                };
                E[C].onmouseout = function () {
                    HD.removeClass(this, HD.CSS_CLASSES.SHARE + "Hover")
                }
            }(function () {
                var F = A.config.services[C];
                if (B[C]) {
                    B[C].onclick = function () {
                        if (F.callback) {
                            D = F.callback(D) || D
                        }
                        A.notifyObservers("share", {
                            service: F,
                            media: D
                        });
                        HD.util.Analytics.track(A.analyticsShareString(F, D));
                        if (A.config.callback) {
                            var G = HD.util.Common.stripHtmlTags(D.description);
                            if (A.config.useShareAPI && window.HDSocial) {
                                HDSocial.hdSocialShare(A.getServiceHash(F), A.config.getPermalink(D, F, A.config), D.title, HD.util.Common.ellipseText(G, A.config.previewLength || G.length), D.thumbUrl, null, null, D)
                            }
                            A.config.callback(F, A.config.getPermalink(D, F, A.config), D.title, HD.util.Common.ellipseText(G, A.config.previewLength || G.length), D.thumbUrl, D)
                        }
                    }
                }
            })()
        }
    },
    update: function (A, B) {
        if (this.config.standaloneMode) {
            if (A == "loadShare_Start") {
                this.render(B)
            }
        } else {
            if (!this.config.embedMode) {
                if (A == "getMedium_Start") {
                    this.loading(true)
                } else {
                    if (A == "getMedium_Finish") {
                        this.loading(false);
                        this.render(B)
                    } else {
                        if (A == "activeItem_Change") {
                            this.render(B)
                        }
                    }
                }
            }
        }
    },
    getHtml: function (B) {
        if (!B) {
            return
        }
        var A = this;
        return this.processTemplate(this.config.templates.getHtml(), {
            media: B,
            _MODIFIERS: {
                getClass: function (C) {
                    return A.getClass(C)
                },
                getUrl: function (C, D) {
                    return A.getUrl(C, D)
                }
            }
        })
    },
    getServiceHash: function (A) {
        return A.name.replace(/\s+/g, "").toLowerCase() || null
    },
    getService: function (A) {
        return HD.ShareWidget.SERVICES[A.replace(/\s+/g, "").toUpperCase()] || null
    },
    getClass: function (A) {
        return HD.CSS_CLASSES.SHARE + A.name.replace(/\s+/g, "")
    },
    getUrl: function (A, C) {
        if (A.url) {
            var B = A.url;
            B = B.replace(/\{permalink\}/, encodeURIComponent(this.config.getPermalink(C)));
            B = B.replace(/\{title\}/, encodeURIComponent(C.title));
            B = B.replace(/\{thumbnail\}/, encodeURIComponent(C.thumbUrl));
            B = B.replace(/\{description\}/, encodeURIComponent(HD.util.Common.ellipseText(C.description, this.config.previewLength || C.description.length)));
            return B
        } else {
            return null
        }
    },
    analyticsShareString: function (A, B) {
        return "default_analyticsShareString"
    }
};
HD.extend(HD.ShareWidget, [HD.Widget]);
HD.register("hd_share_widget", "HD.ShareWidget", {
    version: "1.0",
    build: "1"
});
HD.SendFriendWidget = function (A) {
    this.config = A || {};
    this.config.embedMode = this.config.embedMode || false;
    this.config.standaloneMode = this.config.standaloneMode || false;
    this.config.showTooltip = this.config.showTooltip || false;
    this.config.sendAnother = this.config.sendAnother || false;
    this.config.callback = this.config.callback ||
    function (C, B) {};
    this.config.submission = this.config.submission || {};
    this.config.submission.url = this.config.submission.url || "http://hdonline.rsys1.net/servlet/campaignrespondent";
    this.config.submission.id = this.config.submission.id || "hdm.526";
    this.config.submission.community = this.config.submission.community || window.comSiteName || "Harley-Davidson";
    this.config.submission.media = null;
    this.config.overlayHeight = this.config.overlayHeight || "290px";
    this.config.overlayWidth = this.config.overlayWidth || "425px";
    this.config.confOverlayHeight = this.config.confOverlayHeight || this.config.overlayHeight;
    this.config.confOverlayWidth = this.config.confOverlayWidth || this.config.overlayWidth;
    this.config.getParams = this.config.getParams ||
    function (C, B) {
        C.view = "detail";
        return C
    };
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.SendFriendWidget.templates = {
    sendFriendLabel: "Send to a Friend",
    errorInstrText: "Fields in bold with an asterisk (*) are required.<br /><br />",
    errorUserNameText: "- Your Name",
    errorFriendNameText: "- Friend's Name",
    errorFriendEmailText: "- Friend's Email Address",
    errorFriendEmailInvalidText: "Your Friend's Email address is not valid",
    errorYourEmailText: "- Your Email Address",
    errorYourEmailInvalidText: "Your Email address is not valid",
    sendFriendInstructionalText: "<p>Send your friend a link to this page so they can become involved in the community.</p><p>Enter the name and Email address of your friend below. We will not use this information for any other purposes. Review our <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/privacy_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Privacy Policy</a> for more details.</p><p>* Indicates required fields</p>",
    overlayTitle: "SEND TO A FRIEND",
    overlaySuccessTitle: "THANK YOU",
    friendsNameText: "Friend's Name",
    friendsEmailText: "Friend's Email Address",
    yourNameText: "Your Name",
    yourEmailText: "Your Email Address",
    cancelLabel: "CANCEL",
    closeLabel: "CLOSE",
    sendLabel: "SEND",
    successText: "Your email was sent successfully. Thanks for sharing with your fellow riding enthusiasts.",
    errorMessage: '<div class="hdwcErrorOverlayLarge">${error}</div>',
    getOverlayTitle: function () {
        return this.overlayTitle
    },
    getOverlaySuccessTitle: function () {
        return this.overlaySuccessTitle
    },
    getFriendsNameText: function () {
        return this.friendsNameText
    },
    getFriendsEmailText: function () {
        return this.friendsEmailText
    },
    getYourNameText: function () {
        return this.yourNameText
    },
    getYourEmailText: function () {
        return this.yourEmailText
    },
    getCancelLabel: function () {
        return this.cancelLabel
    },
    getCloseLabel: function () {
        return this.closeLabel
    },
    getSendLabel: function () {
        return this.sendLabel
    },
    getSuccessText: function (A) {
        return this.successText.replace(/\$\{recipient\}/, A)
    },
    getErrorMessage: function (A) {
        return this.errorMessage.replace(/\$\{error\}/, A)
    },
    getSendFriendLabel: function () {
        return this.sendFriendLabel
    },
    getErrorInstrText: function () {
        return this.errorInstrText
    },
    getErrorUserNameText: function () {
        return this.errorUserNameText
    },
    getErrorFriendNameText: function () {
        return this.errorFriendNameText
    },
    getErrorFriendEmailText: function () {
        return this.errorFriendEmailText
    },
    getErrorFriendEmailInvalidText: function () {
        return this.errorFriendEmailInvalidText
    },
    getErrorYourEmailText: function () {
        return this.errorYourEmailText
    },
    getErrorYourEmailInvalidText: function () {
        return this.errorYourEmailInvalidText
    },
    getInstructionalText: function () {
        return this.sendFriendInstructionalText
    },
    getHtml: function () {
        return this.html
    },
    getOverlayHtml: function () {
        return this.overlayHtml
    },
    html: '		<div class="${classes.SEND_FRIEND} ${classes.WIDGET}">			<span class="${hooks.SENDBUTTON}">${templates.getSendFriendLabel()}</span>			<div class="${hooks.SENDBUTTON_TOOLTIP}">${templates.getSendFriendLabel()}</div>		</div>',
    overlayHtml: '		{if !url}		    <div id="hdwcShareFriendOverlay">		    	<div class="dblRuleBtm">		    		<div class="head">${templates.getOverlayTitle()}</div>		    	</div>				<div id="hdwcBody" style="{if siteName != "Dark Custom"}height:225px;{/if}overflow-y:auto;overflow-x:hidden;">				    <div id="submissionInstructions">		    			<div id="${hooks.INSTRUCTIONS}" class="hdSendFriendBox ${hooks.INSTRUCTIONS}"></div>					</div>		 	    	<div>			        	<div>				        	<form name="${hooks.FORM}" id="${hooks.FORM}" class="${hooks.FORM}">								<table width="100%"><tr><td>									<div>										<span id="${hooks.FORM_FRIEND_NAME_LABEL}" class="${hooks.FORM_FRIEND_NAME_LABEL}">${templates.getFriendsNameText()} <span class="reqIndicator">*</span></span>										<input type="text" name="friendName" class="${hooks.FORM_FRIEND_NAME}"></input>									</div>								</td><td>									<div>										<span id="${hooks.FORM_FRIEND_EMAIL_LABEL}" class="${hooks.FORM_FRIEND_EMAIL_LABEL}">${templates.getFriendsEmailText()} <span class="reqIndicator">*</span></span>										<input type="text" name="friendEmail" class="${hooks.FORM_FRIEND_EMAIL}"></input>									</div>								</td></tr>								<tr><td>									<div>										<span id="${hooks.FORM_USER_NAME_LABEL}" class="${hooks.FORM_USER_NAME_LABEL}">${templates.getYourNameText()} <span class="reqIndicator">*</span></span>										<input type="text" name="userName" class="${hooks.FORM_USER_NAME}"></input>									</div>								</td><td>									<div>										<span id="${hooks.FORM_USER_EMAIL_LABEL}" class="${hooks.FORM_USER_EMAIL_LABEL}">${templates.getYourEmailText()} <span class="reqIndicator">*</span></span>										<input type="text" name="userEmail" class="${hooks.FORM_USER_EMAIL}"></input>									</div>								</td></tr></table>								<div class="hdwcMedPadBtm">					        		<input type="submit" value="${templates.getSendLabel()}" id="sendFriendButton" style="display:none;"/>					        		<div class="btnOrange">			                       		<a href="javascript:void(0)" onclick="document.getElementById(\'sendFriendButton\').click();">${templates.getSendLabel()}</a>			                    	</div>					            	<div class="btnDarkGrey hdClose">					            		<a href="javascript:void(0)">${templates.getCancelLabel()}</a>									</div>					        	</div>							</form>			        	</div>					</div>				</div>		    </div>		{else}		    <div id="hdwcShareFriendSuccessOverlay">			   	<div class="dblRuleBtm">		    		<div class="head">${templates.getOverlaySuccessTitle()}</div>		    	</div>				<div id="hdwcBody">		 	       <div>			        	<div>							<div class="hdwcMedPadBtm">								{if siteName == "Dark Custom"}									<p class="hdTitle">The Internet Loves You</p>									<p>Your email to ${recipient} was sent successfully. Feel it?</p>								{else}									<p>${templates.getSuccessText(recipient)}</p>								{/if}								<div class="btnOrange hdClose">				            		<a href="javascript:void(0)">${templates.getCloseLabel()}</a>								</div>				        	</div>							<iframe src="${url}" style="height: 1px; width: 1px; visibility: hidden;"></iframe>			        	</div>					</div>				</div>		    </div>		{/if}'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.SendFriendWidget.hooks = {
        SENDBUTTON: A.SEND_FRIEND + "-button",
        SENDBUTTON_TOOLTIP: A.SEND_FRIEND + "-tooltip",
        INSTRUCTIONS: "sendFriendInstructions",
        FORM: "hdSendToFriendForm",
        FORM_FRIEND_NAME_LABEL: A.SEND_FRIEND + "-FriendName",
        FORM_FRIEND_EMAIL_LABEL: A.SEND_FRIEND + "-FriendEmail",
        FORM_USER_NAME_LABEL: A.SEND_FRIEND + "-UserName",
        FORM_USER_EMAIL_LABEL: A.SEND_FRIEND + "-UserEmail",
        FORM_FRIEND_NAME: A.SEND_FRIEND + "-form-friend-name",
        FORM_FRIEND_EMAIL: A.SEND_FRIEND + "-form-friend-email",
        FORM_USER_NAME: A.SEND_FRIEND + "-form-user-name",
        FORM_USER_EMAIL: A.SEND_FRIEND + "-form-user-email",
        ERRORS: "hdValidationErrors"
    }
})();
HD.SendFriendWidget.prototype = {
    setListeners: function (B) {
        if (!B) {
            return
        }
        var A = this;
        this.getByHook("SENDBUTTON", function (C) {
            A.getByHook("SENDBUTTON_TOOLTIP", function (D) {
                C.onmouseover = function () {
                    HD.addClass(D, HD.CSS_CLASSES.SHARE + "Hover")
                };
                C.onmouseout = function () {
                    HD.removeClass(D, HD.CSS_CLASSES.SHARE + "Hover")
                }
            });
            C.onclick = function () {
                A.openForm(B)
            }
        })
    },
    update: function (A, B) {
        if (!this.config.embedMode) {
            if (this.config.standaloneMode) {
                if (A == "loadSTAF_Start") {
                    this.render(B)
                }
            } else {
                if (A == "getMedium_Start") {
                    this.loading(true)
                } else {
                    if (A == "getMedium_Finish") {
                        this.loading(false);
                        this.render(B)
                    } else {
                        if (A == "activeItem_Change") {
                            this.render(B)
                        }
                    }
                }
            }
        }
    },
    getHtml: function (A) {
        if (!A) {
            return
        }
        return this.processTemplate(this.config.templates.getHtml(), {})
    },
    openForm: function (B) {
        var A = this;
        A.config.callback(B);
        HD.util.Analytics.track(A.analyticsSendFriendString(B));
        var C = HD.util.Common.showOverlay(this.processTemplate(this.config.templates.getOverlayHtml(), {
            siteName: comSiteName,
            recipient: null,
            url: null
        }), this.config.templates.getSendFriendLabel().toUpperCase(), A.config.overlayWidth, A.config.overlayHeight);
        this.getByHook("INSTRUCTIONS", function (D) {
            D.innerHTML = A.config.templates.getInstructionalText()
        }, null, C);
        this.getByHook("FORM", function (D) {
            D.onsubmit = function () {
                A.handleSubmit(D, B, C);
                return false
            }
        }, "form", C)
    },
    handleSubmit: function (D, F, I) {
        var L = "";
        var C = /.+@.+\..+/;
        var Q = this;
        var N = (this.getByHook("FORM_USER_NAME", null, "input", D)[0] || {}).value || "";
        var G = (this.getByHook("FORM_USER_EMAIL", null, "input", D)[0] || {}).value || "";
        var M = (this.getByHook("FORM_FRIEND_NAME", null, "input", D)[0] || {}).value || "";
        var E = (this.getByHook("FORM_FRIEND_EMAIL", null, "input", D)[0] || {}).value || "";
        var O = this.config.templates;
        if (!M || !N || !E || !G) {
            L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorInstrText())
        }
        this.getByHook("FORM_FRIEND_NAME_LABEL", function (R) {
            HD.removeClass(R, "hdwcValidationError");
            if (!M) {
                L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorFriendNameText());
                HD.addClass(R, "hdwcValidationError")
            }
        }, null, D);
        this.getByHook("FORM_USER_NAME_LABEL", function (R) {
            HD.removeClass(R, "hdwcValidationError");
            if (!N) {
                L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorUserNameText());
                HD.addClass(R, "hdwcValidationError")
            }
        }, null, D);
        this.getByHook("FORM_FRIEND_EMAIL_LABEL", function (R) {
            HD.removeClass(R, "hdwcValidationError");
            if (!E) {
                L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorFriendEmailText());
                HD.addClass(R, "hdwcValidationError")
            } else {
                if (!E.match(C)) {
                    HD.addClass(R, "hdwcValidationError")
                }
            }
        }, null, D);
        this.getByHook("FORM_USER_EMAIL_LABEL", function (R) {
            HD.removeClass(R, "hdwcValidationError");
            if (!G) {
                L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorYourEmailText());
                HD.addClass(R, "hdwcValidationError")
            } else {
                if (!G.match(C)) {
                    HD.addClass(R, "hdwcValidationError")
                }
            }
        }, null, D);
        if (L && (!E.match(C) || !G.match(C))) {
            L += "<br />"
        }
        if (E && !E.match(C)) {
            L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorFriendEmailInvalidText())
        }
        if (G && !G.match(C)) {
            L += Q.config.templates.getErrorMessage(Q.config.templates.getErrorYourEmailInvalidText())
        }
        var K = this.getByHook("ERRORS", null, null, I)[0] || null;
        if (L) {
            if (!K) {
                K = document.createElement("div");
                K.id = this.config.hooks.ERRORS;
                K.className = this.config.hooks.ERRORS;
                this.getByHook("INSTRUCTIONS", function (R) {
                    R.parentNode.insertBefore(K, R.nextSibling)
                }, null, I)
            }
            K.innerHTML = L
        } else {
            if (K) {
                K.parentNode.removeChild(K)
            }
            this.config.submission.media = F.mediaId || "";
            var H = this.config.getParams(this.config.submission, F) || this.config.submission;
            var B = [H.url, "?_ID_=", encodeURIComponent(H.id || ""), "&YOURNAME=", encodeURIComponent(N), "&YOUREMAIL=", encodeURIComponent(G), "&FRIENDNAME=", encodeURIComponent(M), "&FRIENDEMAIL=", encodeURIComponent(E), "&communityID=", encodeURIComponent(H.community || ""), "&mediaID=", encodeURIComponent(H.media || ""), "&viewID=", encodeURIComponent(H.view || "")];
            for (var A in H) {
                if (!A.match(/^(id|community|media|view|url)$/)) {
                    B.push("&", A, "=", encodeURIComponent(H[A]))
                }
            }
            HD.util.Analytics.track(this.analyticsSendFriendConfirmationString(F));
            var J = HD.util.Common.showOverlay(this.processTemplate(this.config.templates.getOverlayHtml(), {
                siteName: comSiteName,
                recipient: E,
                url: B.join("")
            }), this.config.templates.getSendFriendLabel().toUpperCase(), Q.config.confOverlayWidth, Q.config.confOverlayHeight);
            if (Q.config.sendAnother) {
                var P = HD.getByClass("hdClose", "*", J);
                if (P.length > 0) {
                    P[0].onclick = function () {
                        Q.openForm(F)
                    }
                }
            }
        }
    },
    analyticsSendFriendString: function (A) {
        return "default_analyticsSendFriendString"
    },
    analyticsSendFriendConfirmationString: function (A) {
        return "default_analyticsSendFriendConfirmationString"
    }
};
HD.extend(HD.SendFriendWidget, [HD.Widget]);
HD.register("hd_send_friend_widget", "HD.SendFriendWidget", {
    version: "1.0",
    build: "1"
});
HD.EventsWidget = function (A) {
    this.config = A || {};
    this.config.pageSize = this.config.pageSize || 3;
    this.config.location = this.config.location || "";
    this.config.subtype = this.config.subtype || "H-D,DLR,HOG";
    this.config.showLocation = this.config.showLocation || false;
    this.config.handleLinks = this.config.handleLinks == null ? false : this.config.handleLinks;
    this.config.linkToNewWindow = this.config.linkToNewWindow == null ? false : this.config.linkToNewWindow;
    this.config.filter = this.config.filter || "";
    this.config.orderByDate = this.config.orderByDate || false;
    this.config.country = this.config.country || "us";
    this.observers = [];
    this.addObserver(this);
    this.loadTemplates(arguments.callee)
};
HD.EventsWidget.templates = {
    eventsLabel: "Events",
    viewEventText: "View Event",
    viewAllEventsText: "View All Events",
    locationLabel: "Look for events in your area:",
    blankLocationText: "address, state, city or zip",
    submitLocationText: "Go",
    getEventsLabel: function () {
        return this.eventsLabel
    },
    getViewEventText: function () {
        return this.viewEventText
    },
    getViewAllEventsText: function () {
        return this.viewAllEventsText
    },
    getLocationLabel: function () {
        return this.locationLabel
    },
    getBlankLocationText: function () {
        return this.blankLocationText
    },
    getSubmitLocationText: function () {
        return this.submitLocationText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.EVENTS} ${classes.WIDGET}">			<span class="${classes.TITLE}">${templates.getEventsLabel()}</span>			<ul class="${classes.LIST}">			{for event in events}				<li class="${hooks.ITEMEVENT}">					<div class="${classes.ITEM} ${classes.EVENT}">						<div class="${classes.SMALL_THUMB_WRAPPER} ${classes.CATEGORY} ${classes.CATEGORY}${event.category[0]}">							<div class="${classes.SMALL_THUMB}">	 							<div class="${classes.THUMB_OVERLAY}"></div>							</div>						</div>						<div class="${classes.TITLE}">${event.title[0]}</div>						<div class="${classes.DATE}">${event|date}&nbsp;&#150;&nbsp;${event|location}</div>						<span><a 							{if config.handleLinks}								href="${event.link[0]}" 							{else}								href="#eventAnchor${event_index}" 							{/if}							" 							{if config.handleLinks && config.linkToNewWindow}								target="_blank" 							{/if}						name="eventAnchor${event_index}" class="${classes.VIEW} ${classes.CONTROL}">${templates.getViewEventText()}</a></span>					</div>				</li>			{/for}			</ul>			{if config.showLocation}				<div class="${classes.LOCATION}"><span>${templates.getLocationLabel()}</span>					<form class="${hooks.LOCATIONFORM}"><input type="text" class="${hooks.LOCATIONINPUT}" value="{if data.location}${data.location}{else}${templates.getBlankLocationText()}{/if}"/>					<a href="javascript:void(0)" class="${hooks.LOCATIONLINK}">${templates.getSubmitLocationText()}</a></form>				</div>			{/if}			<a href="#eventsAnchorAll" name="eventsAnchorAll" class="${classes.VIEW_ALL} ${classes.CONTROL}">${templates.getViewAllEventsText()}</a>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.EventsWidget.hooks = {
        ITEMEVENT: A.EVENTS + "-item",
        LOCATIONFORM: A.EVENTS + "-locform",
        LOCATIONINPUT: A.EVENTS + "-locinput",
        LOCATIONLINK: A.EVENTS + "-loclink"
    }
})();
HD.EventsWidget.prototype = {
    getFeed: function (B, A) {
        var C = this;
        B = B || this.config.subtype;
        A = A || this.config.location;
        var D = this.config.filter ? "?filter=" + this.config.filter : "";
        var E = "country=" + this.config.country;
        this.notifyObservers("getRidePlannerFeed_Events_Start", {
            subtype: B,
            location: A
        });
        HD.util.RSS.getRidePlannerFeed("events/" + B + "/" + A + D + (D ? "&" : "?") + E, function (F) {
            C.notifyObservers("getRidePlannerFeed_Events_Finish", {
                feed: F,
                subtype: B,
                location: A
            })
        })
    },
    update: function (A, B) {
        if (A == "getRidePlannerFeed_Events_Start") {
            this.loading(true)
        } else {
            if (A == "getRidePlannerFeed_Events_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    setListeners: function (F) {
        if (!F) {
            return
        }
        var B = HD.CSS_CLASSES;
        var H = this.getParent();
        var L = this;
        var I = HD.getByClass(this.config.hooks.ITEMEVENT, "*", H);
        var D = HD.getByClass(B.VIEW_ALL, "*", H)[0];
        var K = F.feed.channel[0];
        var L = this;
        for (var G = 0, C = Math.min(K.item.length, this.config.pageSize || 3);
        G < C;
        G++) {
            (function () {
                var N = K.item[G];
                var M = function () {
                    L.notifyObservers("viewEvent", N);
                    return false
                };
                I[G].onclick = M
            })()
        }
        D.onclick = function () {
            L.notifyObservers("viewAllEvents", K);
            return false
        };
        var J = HD.getByClass(this.config.hooks.LOCATIONFORM, "*", H)[0];
        var A = HD.getByClass(this.config.hooks.LOCATIONLINK, "*", H)[0];
        var E = HD.getByClass(this.config.hooks.LOCATIONINPUT, "*", H)[0];
        if (A) {
            A.onclick = function () {
                L.getFeed(null, E.value)
            }
        }
        if (E) {
            E.onfocus = function () {
                if (this.value == HD.EventsWidget.templates.getBlankLocationText()) {
                    this.value = ""
                }
            };
            E.onblur = function () {
                if (!this.value) {
                    this.value = HD.EventsWidget.templates.getBlankLocationText()
                }
            }
        }
        if (J) {
            J.onsubmit = function () {
                L.getFeed(null, E.value);
                return false
            }
        }
    },
    getHtml: function (C) {
        if (!C) {
            return ""
        }
        var A = C.feed.channel[0].item;
        var F = /^(.+\s+\d+,\s+\d+)/;
        var B = /\n\s+(.+)/g;
        var E = /\n\s+(.+)/;
        var D = function (I) {
            var G = I.match(B);
            for (var H = 0;
            H < G.length;
            H++) {
                G[H] = G[H].match(E)[1]
            }
            return G.join(" ")
        };
        if (this.config.orderByDate) {
            A.sort(function (J, I) {
                J.date = J.description[0].match(F)[0];
                I.date = I.description[0].match(F)[0];
                var H = Date.parse(J.date);
                var G = Date.parse(I.date);
                return H - G
            })
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            data: C,
            events: A.slice(0, Math.min(A.length, this.config.pageSize || 3)),
            _MODIFIERS: {
                date: function (G) {
                    return G.description[0].match(F)[0]
                },
                location: function (G) {
                    return D(G.description[0])
                }
            }
        })
    }
};
HD.extend(HD.EventsWidget, [HD.Widget]);
HD.register("hd_events_widget", "HD.EventsWidget", {
    version: "1.0",
    build: "1"
});
HD.RidesWidget = function (A) {
    this.config = A || {};
    this.config.pageSize = this.config.pageSize || 1;
    this.config.location = this.config.location || "";
    this.config.subtype = this.config.subtype || "USR,GR";
    this.config.showLocation = this.config.showLocation || false;
    this.config.handleLinks = this.config.handleLinks == null ? false : this.config.handleLinks;
    this.config.linkToNewWindow = this.config.linkToNewWindow == null ? false : this.config.linkToNewWindow;
    this.observers = [];
    this.addObserver(this);
    this.loadTemplates(arguments.callee)
};
HD.RidesWidget.templates = {
    ridesLabel: "Rides",
    viewRideText: "View Ride",
    locationLabel: "Look for rides in your area:",
    blankLocationText: "address, state, city or zip",
    submitLocationText: "Go",
    getRidesLabel: function () {
        return this.ridesLabel
    },
    getViewRideText: function () {
        return this.viewRideText
    },
    getLocationLabel: function () {
        return this.locationLabel
    },
    getBlankLocationText: function () {
        return this.blankLocationText
    },
    getSubmitLocationText: function () {
        return this.submitLocationText
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.RIDES} ${classes.WIDGET}">			<span class="${classes.TITLE}">${templates.getRidesLabel()}</span>			<ul class="${classes.LIST}">			{for ride in rides}				<li>					<div class="${classes.ITEM} ${hooks.RIDE}">						<div class="${classes.SMALL_THUMB_WRAPPER} ${classes.CATEGORY} ${classes.CATEGORY}${ride.category[0]}">							<div class="${classes.SMALL_THUMB}">	 							<div class="${classes.THUMB_OVERLAY}"></div>							</div>						</div>						<div class="${classes.TITLE}">${ride.title[0]}</div>						<div class="${classes.DATE}">${ride.description[0]}</div>						<span><a 							{if config.handleLinks}								href="${ride.link[0]}" 							{else}								href="#rideAnchor${ride_index}" 							{/if}							" 							{if config.handleLinks && config.linkToNewWindow}								target="_blank" 							{/if}						name="rideAnchor${ride_index}" class="${classes.VIEW} ${classes.CONTROL}">${templates.getViewRideText()}</a></span>					</div>				</li>			{/for}			</ul>			{if config.showLocation}				<div class="${classes.LOCATION}"><span>${templates.getLocationLabel()}</span>					<form class="${hooks.LOCATIONFORM}"><input class="${hooks.LOCATIONINPUT}" type="text" value="{if data.location}${data.location}{else}${templates.getBlankLocationText()}{/if}"/>					<a href="javascript:void(0)" class="${hooks.LOCATIONLINK}">${templates.getSubmitLocationText()}</a></form>				</div>			{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.RidesWidget.hooks = {
        RIDE: A.RIDE,
        LOCATIONFORM: A.RIDES + "-locform",
        LOCATIONINPUT: A.RIDES + "-locinput",
        LOCATIONLINK: A.RIDES + "-loclink"
    }
})();
HD.RidesWidget.prototype = {
    getFeed: function (B, A) {
        var C = this;
        B = B || this.config.subtype;
        A = A || this.config.location;
        this.notifyObservers("getRidePlannerFeed_Rides_Start", {
            subtype: B,
            location: A
        });
        HD.util.RSS.getRidePlannerFeed("roads/" + B + "/" + (A || "53208"), function (D) {
            C.notifyObservers("getRidePlannerFeed_Rides_Finish", {
                feed: D,
                subtype: B,
                location: A
            })
        })
    },
    update: function (A, B) {
        if (A == "getRidePlannerFeed_Rides_Start") {
            this.loading(true)
        } else {
            if (A == "getRidePlannerFeed_Rides_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    setListeners: function (D) {
        if (!D) {
            return
        }
        var J = this.config.hooks;
        var F = this.getParent();
        var K = this;
        var G = HD.getByClass(J.RIDE, "*", F);
        var I = D.feed.channel[0];
        var K = this;
        for (var E = 0, B = Math.min(I.item.length, this.config.pageSize || 3);
        E < B;
        E++) {
            if (G[E]) {
                (function () {
                    var M = I.item[E];
                    var L = function () {
                        K.notifyObservers("viewRide", M);
                        return false
                    };
                    G[E].onclick = L
                })()
            }
        }
        var H = HD.getByClass(J.LOCATIONFORM, "*", F)[0] || null;
        var A = HD.getByClass(J.LOCATIONLINK, "*", F)[0] || null;
        var C = HD.getByClass(J.LOCATIONINPUT, "*", F)[0] || null;
        if (H && A && C) {
            A.onclick = function () {
                K.getFeed(null, HD.util.Common.stripHtmlTags(C.value))
            };
            C.onfocus = function () {
                if (this.value == HD.RidesWidget.templates.getBlankLocationText()) {
                    this.value = ""
                }
            };
            C.onblur = function () {
                if (!this.value) {
                    this.value = HD.RidesWidget.templates.getBlankLocationText()
                }
            };
            H.onsubmit = function () {
                K.getFeed(null, HD.util.Common.stripHtmlTags(C.value));
                return false
            }
        }
    },
    getHtml: function (B) {
        if (!B) {
            return ""
        }
        var A = B.feed.channel[0].item;
        return this.processTemplate(this.config.templates.getHtml(), {
            data: B,
            rides: A.slice(0, Math.min(A.length, this.config.pageSize || 3))
        })
    }
};
HD.extend(HD.RidesWidget, [HD.Widget]);
HD.register("hd_rides_widget", "HD.RidesWidget", {
    version: "1.0",
    build: "1"
});
HD.TagCloudWidget = function (A) {
    this.config = A || {};
    this.config.multipleSelect = this.config.multipleSelect || false;
    this.config.pageSize = this.config.pageSize || 0;
    this.config.pageType = this.config.pageType || "limit" || "hint";
    this.config.minFontSize = Math.max(50, this.config.minFontSize || 80);
    this.config.maxFontSize = Math.min(300, this.config.maxFontSize || 150);
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.TagCloudWidget.templates = {
    moreTagsLabel: "More Tags",
    lessTagsLabel: "Less Tags",
    getMoreTagsLabel: function () {
        return this.moreTagsLabel
    },
    getLessTagsLabel: function () {
        return this.lessTagsLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.TAG_CLOUD} ${classes.WIDGET} ${thresholdClasses} ${hooks.CLOUD}">		{for tag in tags}			{if tag_index} {/if}			<a href="javascript:void(0)" class="${classes.TAG} ${activeTags|isActive} {if isHint}scale-${tag.fontSize|parse} {elseif isLimit(tag)}scale-limit {/if} ${hooks.TAG}" style="font-size: ${tag.fontSize}">${tag.tagName}</a>		{/for}		{if hasThreshold}			<div>				<a href="javascript:void(0)" class="${classes.MORE} ${hooks.MORE}">${templates.getMoreTagsLabel()}</a>				<a href="javascript:void(0)" class="${classes.LESS} ${hooks.LESS}">${templates.getLessTagsLabel()}</a>			</div>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.TagCloudWidget.hooks = {
        TAG: A.TAG + "-tag",
        MORE: A.TAG + "-more",
        LESS: A.TAG + "-less",
        CLOUD: A.TAG + "-cloud"
    }
})();
HD.TagCloudWidget.prototype = {
    setListeners: function (C) {
        var K = C.tags;
        var B = HD.CSS_CLASSES;
        var J = this;
        var E = this.getParent();
        var I = HD.getByClass(this.config.hooks.TAG, "*", E);
        for (var D = 0, G = I.length;
        D < G;
        D++) {
            this.assignListener(I[D], K[D])
        }
        var F = HD.getByClass(this.config.hooks.CLOUD, "*", E)[0];
        var A = HD.getByClass(this.config.hooks.MORE, "*", E)[0];
        var H = HD.getByClass(this.config.hooks.LESS, "*", E)[0];
        if (A && H && F) {
            A.onclick = function () {
                HD.replaceClass(F, B.TAG_CLOUD + "-" + B.LESS, B.TAG_CLOUD + "-" + B.MORE)
            };
            H.onclick = function () {
                HD.replaceClass(F, B.TAG_CLOUD + "-" + B.MORE, B.TAG_CLOUD + "-" + B.LESS)
            }
        }
    },
    assignListener: function (C, B) {
        var A = this.model;
        var D = this;
        var F = B;
        var E = HD.CSS_CLASSES;
        C.onclick = function () {
            var K = D.config.multipleSelect;
            var H = A.filters.tags || [];
            if (HD.hasClass(this, E.ACTIVE)) {
                HD.removeClass(this, E.ACTIVE);
                if (!K) {
                    A.clearTags()
                } else {
                    for (var I = 0;
                    I < H.length;
                    I++) {
                        if (H[I] == F.tagName) {
                            H.splice(I, 1);
                            break
                        }
                    }
                    if (H.length > 0) {
                        A.setTags(H)
                    } else {
                        A.clearTags()
                    }
                }
            } else {
                if (!K) {
                    var J = HD.getByClass(D.config.hooks.TAG, "*", D.getParent());
                    for (var I = 0, G = J.length;
                    I < G;
                    I++) {
                        HD.removeClass(J[I], E.ACTIVE)
                    }
                }
                HD.addClass(this, E.ACTIVE);
                A.setTags(K ? H.concat([F.tagName]) : [F.tagName])
            }
        }
    },
    update: function (B, G) {
        if (B == "getTags_Start") {
            this.loading(true)
        } else {
            if (B == "getTags_Finish") {
                this.loading(false);
                this.render(G)
            } else {
                if (B == "tags_Set" || B == "tags_Clear") {
                    var E = HD.CSS_CLASSES;
                    var F = HD.getByClass(this.config.hooks.TAG, "*", this.getParent());
                    for (var D = 0, A = F.length;
                    D < A;
                    D++) {
                        HD.removeClass(F[D], E.ACTIVE);
                        for (var C = 0;
                        C < G.length;
                        C++) {
                            if (F[D].innerHTML == G[C]) {
                                HD.addClass(F[D], E.ACTIVE);
                                break
                            }
                        }
                    }
                }
            }
        }
    },
    getHtml: function (C) {
        var A = HD.CSS_CLASSES;
        var I = C.tags;
        var F = this.setFontSizes(C.tags);
        var G = [];
        var B = this.config.pageSize;
        var E = this.model.filters && this.model.filters.tags ? this.model.filters.tags.slice(0) : [];
        if (F > 0) {
            G.push(A.TAG_CLOUD, "-", A.LESS);
            if (this.config.pageType == "hint") {
                for (var D = F;
                D <= this.config.maxFontSize;
                D += 10) {
                    G.push(" ", A.TAG_CLOUD, "-scale-", D)
                }
            }
        }
        var H = this;
        return this.processTemplate(this.config.templates.getHtml(), {
            activeTags: E,
            data: C,
            tags: C.tags,
            thresholdClasses: G.join(""),
            threshold: F,
            hasThreshold: F > 0,
            limit: B,
            isHint: F > 0 && this.config.pageType == "hint",
            isLimit: function (J) {
                if (F > 0 && H.config.pageType == "limit" && (J.count < F || B == 0)) {
                    return true
                } else {
                    B--;
                    return false
                }
            },
            _MODIFIERS: {
                parse: function (J) {
                    return parseInt(J, 10)
                },
                isActive: function (K) {
                    if (K.length > 0) {
                        for (var J = K.length - 1;
                        J >= 0;
                        J--) {
                            if (K[J] == tag.tagName) {
                                K.splice(J, 1);
                                return HD.CSS_CLASSES.ACTIVE;
                                break
                            }
                        }
                    }
                    return ""
                }
            }
        })
    },
    setFontSizes: function (C) {
        var B = 0,
            G = [],
            E = [];
        var F = function (I, H) {
            return I > H ? 1 : (I < H ? -1 : 0)
        };
        for (var D = 0, A = C.length;
        D < A;
        D++) {
            if (C[D].count > B) {
                B = C[D].count
            }
            E.push(C[D].count)
        }
        for (var D = 0, A = C.length;
        D < A;
        D++) {
            G.push(Math.max(this.config.minFontSize, Math.floor((this.config.maxFontSize / 20) * (1 + (1.5 * C[D].count - B / 2) / B)) * 10));
            C[D].fontSize = G[G.length - 1] + "%"
        }
        if (this.config.pageType == "hint") {
            G = G.sort(F);
            return G.length && this.config.pageSize && G.length > this.config.pageSize && G[G.length - this.config.pageSize] > G[0] ? G[G.length - this.config.pageSize] : 0
        } else {
            if (this.config.pageType == "limit") {
                E = E.sort(F);
                return E.length && this.config.pageSize && E.length > this.config.pageSize ? E[E.length - this.config.pageSize] : 0
            } else {
                return 0
            }
        }
    }
};
HD.extend(HD.TagCloudWidget, [HD.Widget]);
HD.register("hd_tag_cloud_widget", "HD.TagCloudWidget", {
    version: "1.0",
    build: "1"
});
HD.CategoriesWidget = function (A) {
    this.config = A || {};
    this.config.items = this.config.items || [];
    this.config.renderMode = this.config.renderMode || "list" || "select";
    this.observers = [];
    this.categories = this.config.items.length > 0 ? this.config.items[0].categories.join(";") : "";
    this.loadTemplates(arguments.callee);
    this.render()
};
HD.CategoriesWidget.templates = {
    categoryLabel: "Category",
    getCategoryLabel: function () {
        return this.categoryLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.CATEGORIES} ${classes.WIDGET}"><span>${templates.getCategoryLabel()}</span>		{if config.renderMode == "list"}			<ul class="${hooks.LIST}">			{for item in items}				<li class="${hooks.ITEM}{if item_index == 0} ${classes.ACTIVE}{/if}"><a href="javascript:void(0)">${item.name}</a></li>			{/for}			</ul>		{elseif config.renderMode == "select"}			<select class="${hooks.LIST}">			{for item in items}				<option class="${hooks.ITEM}" value="${item_index}"{if item_index == 0} selected="selected"{/if}>${item.name}</option>			{/for}			</select>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.CategoriesWidget.hooks = {
        ITEM: A.ITEM,
        LIST: A.LIST
    }
})();
HD.CategoriesWidget.prototype = {
    setListeners: function (F) {
        var E = HD.CSS_CLASSES;
        var C = this;
        if (this.config.renderMode == "list") {
            var B = HD.getByClass(this.config.hooks.ITEM, "*", this.getParent());
            for (var D = 0, A = B.length;
            D < A;
            D++) {
                (function () {
                    var G = D;
                    B[G].onclick = function () {
                        for (var I = 0;
                        I < A;
                        I++) {
                            HD.removeClass(B[I], E.ACTIVE)
                        }
                        HD.addClass(this, E.ACTIVE);
                        var H = C.config.items[G].categories;
                        C.model.setCategories(H);
                        C.categories = H.join(";")
                    }
                })()
            }
        } else {
            if (this.config.renderMode == "select") {
                HD.getByClass(this.config.hooks.LIST, "*", this.getParent(), function (G) {
                    G.onchange = function () {
                        var H = C.config.items[parseInt(this.options[this.selectedIndex].value, 10)].categories;
                        C.model.setCategories(H);
                        C.categories = H.join(";")
                    }
                })
            }
        }
    },
    update: function (C, F) {
        if (C == "categories_Set") {
            if (F.join(";") != this.categories) {
                var A = F.join(";");
                var B = [];
                var E = HD.CSS_CLASSES;
                if (this.config.renderMode == "list") {
                    B = HD.getByClass(this.config.hooks.ITEM, "*", this.getParent())
                } else {
                    if (this.config.renderMode == "select") {
                        B = HD.getByClass(this.config.hooks.LIST, "*", this.getParent())
                    }
                }
                for (var D = 0;
                D < this.config.items.length;
                D++) {
                    if (this.config.renderMode == "list" && B[D]) {
                        HD.removeClass(B[D], E.ACTIVE)
                    }
                    if (this.config.items[D].categories.join(";") == A) {
                        if (this.config.renderMode == "list" && B[D]) {
                            HD.addClass(B[D], E.ACTIVE)
                        } else {
                            if (this.config.renderMode == "select" && B[0]) {
                                B[0].selectedIndex = D;
                                break
                            }
                        }
                    }
                }
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: this.config.items
        })
    }
};
HD.extend(HD.CategoriesWidget, [HD.Widget]);
HD.register("hd_categories_widget", "HD.CategoriesWidget", {
    version: "1.0",
    build: "1"
});
HD.TagsWidget = function (A) {
    this.config = A || {};
    this.config.renderMode = this.config.renderMode || "list" || "select";
    this.observers = [];
    this.tags = "";
    this.loadTemplates(arguments.callee)
};
HD.TagsWidget.templates = {
    tagLabel: "Tag",
    showAllTagsLabel: "Show all tags",
    getTagLabel: function () {
        return this.tagLabel
    },
    getShowAllTagsLabel: function () {
        return this.showAllTagsLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.TAGS} ${classes.WIDGET}"><span>${templates.getTagLabel()}</span>		{if config.renderMode == "list"}			<ul class="${hooks.LIST}">			{for item in items}				{if item_index == 0}					<li class="${hooks.ITEM} ${classes.ACTIVE}"><a href="javascript:void(0)">${templates.getShowAllTagsLabel()}</a></li>				{else}					<li class="${hooks.ITEM}"><a href="javascript:void(0)">${item.tagName}</a></li>				{/if}			{/for}			</ul>		{elseif config.renderMode == "select"}			<select class="${hooks.LIST}">			{for item in items}				{if item_index == 0}					<option class="${hooks.ITEM}" value="${item_index}" selected="selected">${templates.getShowAllTagsLabel()}</option>				{else}					<option class="${hooks.ITEM}" value="${item_index}">${item.tagName}</option>				{/if}			{/for}			</select>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.TagsWidget.hooks = {
        ITEM: A.ITEM,
        LIST: A.LIST
    }
})();
HD.TagsWidget.prototype = {
    setListeners: function (F) {
        var E = HD.CSS_CLASSES;
        var C = this;
        if (this.config.renderMode == "list") {
            var B = HD.getByClass(this.config.hooks.ITEM, "*", this.getParent());
            for (var D = 0, A = B.length;
            D < A;
            D++) {
                (function () {
                    var G = D;
                    B[G].onclick = function () {
                        for (var I = 0;
                        I < A;
                        I++) {
                            HD.removeClass(B[I], E.ACTIVE)
                        }
                        HD.addClass(this, E.ACTIVE);
                        var H = [C.config.items[G].tagName];
                        C.model.setTags(H);
                        C.tags = H.join(";")
                    }
                })()
            }
        } else {
            if (this.config.renderMode == "select") {
                HD.getByClass(this.config.hooks.LIST, "*", this.getParent(), function (G) {
                    G.onchange = function () {
                        var H = [C.config.items[parseInt(this.options[this.selectedIndex].value, 10)].tagName];
                        C.model.setTags(H);
                        C.tags = H.join(";")
                    }
                })
            }
        }
    },
    update: function (C, F) {
        if (C == "getTags_Start") {
            this.loading(true)
        } else {
            if (C == "getTags_Finish") {
                this.loading(false);
                this.config.items = [""].concat(F.tags).sort(function (H, G) {
                    if (H.tagName > G.tagName) {
                        return 1
                    } else {
                        if (H.tagName < G.tagName) {
                            return -1
                        } else {
                            return 0
                        }
                    }
                });
                this.render()
            }
        }
        if (C == "tags_Set" || C == "tags_Clear") {
            if (F.join(";") != this.tags) {
                var A = F.join(";");
                var B = [];
                var E = HD.CSS_CLASSES;
                if (this.config.renderMode == "list") {
                    B = HD.getByClass(this.config.hooks.ITEM, "*", this.getParent())
                } else {
                    if (this.config.renderMode == "select") {
                        B = HD.getByClass(this.config.hooks.LIST, "*", this.getParent())
                    }
                }
                for (var D = 0;
                D < this.config.items.length;
                D++) {
                    if (this.config.renderMode == "list" && B[D]) {
                        HD.removeClass(B[D], E.ACTIVE)
                    }
                    if (this.config.items[D].tagName == A) {
                        if (this.config.renderMode == "list" && B[D]) {
                            HD.addClass(B[D], E.ACTIVE)
                        } else {
                            if (this.config.renderMode == "select" && B[0]) {
                                B[0].selectedIndex = D;
                                break
                            }
                        }
                    }
                }
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: this.config.items
        })
    }
};
HD.extend(HD.TagsWidget, [HD.Widget]);
HD.register("hd_tags_widget", "HD.TagsWidget", {
    version: "1.0",
    build: "1"
});
HD.FaceoffWidget = function (A) {
    this.config = A || {};
    this.config.comments = this.config.comments || {};
    this.config.previewLength = this.config.previewLength || 0;
    this.config.manualSwitching = this.config.manualSwitching || false;
    this.observers = [];
    this.comments = null;
    this.data = {
        faceoffs: null,
        active: null,
        mediaId: null
    };
    this.listEl = null;
    this.commentsEl = null;
    this.mediaEls = null;
    this.loadTemplates(arguments.callee);
    this.render()
};
HD.FaceoffWidget.templates = {
    voteLabel: "Vote",
    previousLabel: "Previous",
    nextLabel: "Next",
    loadingLabel: "Loading...",
    goLabel: "Go",
    getVoteLabel: function () {
        return this.voteLabel
    },
    getPreviousLabel: function () {
        return this.previousLabel
    },
    getNextLabel: function () {
        return this.nextLabel
    },
    getLoadingLabel: function () {
        return this.loadingLabel
    },
    getGoLabel: function () {
        return this.goLabel
    },
    getNavigationHtml: function () {
        return this.navigationHtml
    },
    getMediaHtml: function () {
        return this.mediaHtml
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.FACEOFF} ${classes.WIDGET}">			<div class="${hooks.NAVIGATION}"></div>			<div class="${classes.FACEOFF}-content">				<div class="${hooks.MEDIA}"></div>				<div class="${hooks.MEDIA}"></div>				<div class="${hooks.COMMENTS}"></div>			</div>		</div>',
    navigationHtml: '		<div class="${classes.FACEOFF}-list-container">			<select class="${hooks.LIST}">			{for faceoff in faceoffs}				<option value="${faceoff.mediaId}">${faceoff.title}</option>			{/for}			</select>			{if config.manualSwitching}				<div class="${hooks.GO}">${templates.getGoLabel()}</div>			{/if}		</div>		<div class="${classes.FACEOFF}-results-container"><div class="${hooks.RESULTS}">View Results</div></div>		<div class="${classes.FACEOFF}-step">			<div class="${hooks.NEXT}">${templates.getNextLabel()}</div>			<div class="${hooks.PREVIOUS}">${templates.getPreviousLabel()}</div>		</div>',
    mediaHtml: '		<div class="${hooks.VOTE}"><div>${templates.getVoteLabel()}</div></div>		<div class="${hooks.VALUE} {if result.won}${" "+classes.FACEOFF+"-won"}{/if}"><div>${result.percentage|round:0}%</div></div>		${media|facade}'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.FaceoffWidget.hooks = {
        MEDIA: A.FACEOFF + "-media",
        VOTE: A.FACEOFF + "-vote",
        GO: A.FACEOFF + "-go",
        PREVIOUS: A.FACEOFF + "-previous",
        NEXT: A.FACEOFF + "-next",
        VALUE: A.FACEOFF + "-value",
        COMMENTS: A.FACEOFF + "-comments",
        NAVIGATION: A.FACEOFF + "-navigation",
        RESULTS: A.FACEOFF + "-results",
        LIST: A.FACEOFF + "-list",
        SHOW_RESULTS: A.FACEOFF + "-show-results",
        HAS_PREVIOUS: A.FACEOFF + "-has-previous",
        HAS_NEXT: A.FACEOFF + "-has-next",
        HAS_FACEOFF: A.FACEOFF + "-has-faceoff"
    }
})();
HD.FaceoffWidget.prototype = {
    setListeners: function (C) {
        var B = HD.CSS_CLASSES;
        var A = this;
        setTimeout(function () {
            A.loading(true);
            A.renderComments();
            A.mediaEls = HD.getByClass(A.config.hooks.MEDIA, "*", A.getParent())
        }, 25)
    },
    update: function (B, D) {
        if (B == "getMedia_Finish") {
            this.loading(false);
            this.renderNavigation(D)
        } else {
            if (B == "getFaceoff_Start") {
                HD.removeClass(this.getParent(), this.config.hooks.HAS_FACEOFF);
                if (this.commentsEl) {
                    this.loading(true, this.commentsEl)
                }
                if (this.mediaEls) {
                    for (var C = 0, A = this.mediaEls.length;
                    C < A;
                    C++) {
                        this.loading(true, this.mediaEls[C]);
                        this.mediaEls[C].innerHTML = this.config.templates.getLoadingLabel() || ""
                    }
                }
            } else {
                if (B == "getFaceoff_Finish") {
                    HD.addClass(this.getParent(), this.config.hooks.HAS_FACEOFF);
                    if (this.mediaEls) {
                        for (var C = 0, A = this.mediaEls.length;
                        C < A;
                        C++) {
                            this.loading(false, this.mediaEls[C])
                        }
                    }
                    this.renderFaceoff(D)
                } else {
                    if (B == "getFaceoffComments_Finish") {
                        if (this.commentsEl) {
                            this.loading(false, this.commentsEl)
                        }
                    }
                }
            }
        }
    },
    switchFaceoff: function (B) {
        this.model.getFaceoff(B);
        this.data.mediaId = B;
        var A = this.getParent();
        this.switchView("results");
        if (this.listEl && this.listEl.options.length > 0) {
            if (this.listEl.selectedIndex > 0) {
                HD.addClass(A, this.config.hooks.HAS_PREVIOUS)
            } else {
                HD.removeClass(A, this.config.hooks.HAS_PREVIOUS)
            }
            if (this.listEl.selectedIndex < this.listEl.options.length - 1) {
                HD.addClass(A, this.config.hooks.HAS_NEXT)
            } else {
                HD.removeClass(A, this.config.hooks.HAS_NEXT)
            }
        }
    },
    switchView: function (A) {
        if (!A || A == "results") {
            HD.addClass(this.getParent(), this.config.hooks.SHOW_RESULTS)
        } else {
            HD.removeClass(this.getParent(), this.config.hooks.SHOW_RESULTS)
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml())
    },
    renderNavigation: function (I) {
        var J = this;
        var F = this.getParent();
        this.data.faceoffs = I.media;
        var B = HD.getByClass(this.config.hooks.NAVIGATION, "*", F);
        if (B && B[0]) {
            B[0].innerHTML = this.processTemplate(this.config.templates.getNavigationHtml(), {
                faceoffs: this.data.faceoffs
            });
            var E = HD.getByClass(this.config.hooks.LIST, "*", F);
            if (E && E[0]) {
                this.listEl = E = E[0];
                var H = function () {
                    if (J.listEl.options[J.listEl.selectedIndex] && J.listEl.options[J.listEl.selectedIndex].value) {
                        J.switchFaceoff(J.listEl.options[J.listEl.selectedIndex].value)
                    }
                };
                if (this.config.manualSwitching) {
                    var G = HD.getByClass(this.config.hooks.GO, "*", F);
                    if (G && G[0]) {
                        G[0].onclick = H
                    }
                } else {
                    E.onchange = H
                }
                var A = HD.getByClass(this.config.hooks.PREVIOUS, "*", F);
                var C = HD.getByClass(this.config.hooks.NEXT, "*", F);
                if (A && A[0]) {
                    A[0].onclick = function () {
                        if (E.options.length > 0 && E.selectedIndex > 0) {
                            E.selectedIndex--;
                            J.switchFaceoff(E.options[E.selectedIndex].value)
                        }
                    }
                }
                if (C && C[0]) {
                    C[0].onclick = function () {
                        if (E.options.length > 0 && E.selectedIndex < E.options.length - 1) {
                            E.selectedIndex++;
                            J.switchFaceoff(E.options[E.selectedIndex].value)
                        }
                    }
                }
            }
            var D = HD.getByClass(this.config.hooks.RESULTS, "*", F);
            if (D && D[0]) {
                D[0].onclick = function () {
                    J.switchView("results")
                }
            }
            this.data.active = this.data.faceoffs[0];
            this.switchFaceoff(this.data.active.mediaId)
        }
    },
    renderFaceoff: function (H) {
        if (H.faceoff.mediaId != this.data.mediaId) {
            return
        }
        var K = this;
        var E = this.getParent();
        this.data.active = H;
        var C = this.data.active.faceoff;
        var F = this.checkIfVoted(this.data.active.faceoff.mediaId);
        var J = (C.metaTags && C.metaTags.active) || null;
        if (!F && ((J && J.toLowerCase() == "yes") || (J === null && C.mediaId == this.data.faceoffs[0].mediaId))) {
            this.switchView("vote")
        } else {
            this.switchView("results")
        }
        var I = this.mediaEls;
        if (I && I.length == this.data.active.media.length) {
            for (var D = 0, B = I.length;
            D < B;
            D++) {
                var G = this.data.active.media[D].description || "";
                if (this.config.previewLength > 0 && HD.util.Common.stripHtmlTags(G).length > this.config.previewLength) {
                    G = HD.util.Common.ellipseText(G, this.config.previewLength)
                } else {
                    G = HD.util.Common.stripHtmlTags(G, true)
                }
                this.data.active.media[D].description = G;
                I[D].innerHTML = this.processTemplate(this.config.templates.getMediaHtml(), {
                    faceoff: this.data.active.faceoff || {},
                    media: this.data.active.media[D] || {},
                    result: this.data.active.results[D] || {}
                });
                (function () {
                    var O = K.data.active.media[D];
                    var N = function () {
                        K.notifyObservers("itemSelected", O);
                        K.model.setActiveItem(O)
                    };
                    var M = HD.getByClass(HD.community.Media.hooks.MEDIA_THUMB, "*", I[D]);
                    var L = HD.getByClass(HD.CSS_CLASSES.TITLE, "*", I[D]);
                    if (M && M[0]) {
                        M[0].onclick = N
                    }
                    if (L && L[0]) {
                        L[0].onclick = N
                    }
                })()
            }
        }
        var A = HD.getByClass(this.config.hooks.VOTE, "*", E);
        if (A && A.length >= 2) {
            for (var D = 0, B = Math.min(A.length, 2);
            D < B;
            D++) {
                (function () {
                    var L = D;
                    A[D].onclick = function () {
                        if (!K.checkIfVoted(K.data.active.faceoff.mediaId)) {
                            K.markVoted(L == 0 ? 1 : 5)
                        }
                    }
                })()
            }
        }
    },
    renderComments: function (C) {
        var D = HD.getByClass(this.config.hooks.COMMENTS, "*", this.getParent());
        if (D && D[0] && this.engine && !this.comments) {
            this.commentsEl = D[0];
            this.config.comments = HD.merge({
                parent: D[0],
                type: "hd_comments_widget",
                contentFeed: "getFaceoffComments",
                submitBelow: true
            }, this.config.comments);
            var B = {},
                A = this.engine.getWidgetName(this) + "_comments";
            B[A] = this.config.comments;
            this.engine.addWidgets(B);
            this.comments = this.engine.getWidget(A)
        }
    },
    markVoted: function (A) {
        var D = this.data.active;
        var C = this.getRatingCookie("faceoffItems");
        this.getRatingFromCookie(C, D.faceoff.mediaId, "-").rating = A;
        this.setRatingCookie("faceoffItems", C);
        this.model.rateMedia(D.faceoff.mediaId, null, A);
        var B = D.results;
        B[A == 1 ? 0 : 1].votes++;
        D.faceoff.numberOfVotes = B[0].votes + B[1].votes;
        B[0].percentage = B[0].votes / D.faceoff.numberOfVotes * 100;
        B[1].percentage = B[1].votes / D.faceoff.numberOfVotes * 100;
        B[0].won = B[0].votes >= B[1].votes;
        B[1].won = B[1].votes >= B[0].votes;
        D.faceoff.rating = (B[0].votes * 1 + B[1].votes * 5) / D.faceoff.numberOfVotes;
        this.renderFaceoff(D)
    },
    checkIfVoted: function (C) {
        this.config.hasVoted = false;
        var B = this.getRatingCookie("faceoffItems");
        var A = this.getRatingFromCookie(B, C, "-");
        if (A.rating > 0) {
            this.config.hasVoted = true;
            this.config.myVote = A.rating
        }
        return this.config.hasVoted
    },
    loading: function (A, B) {
        B = B || this.getParent();
        if (A) {
            HD.addClass(B, HD.CSS_CLASSES.LOADING)
        } else {
            HD.removeClass(B, HD.CSS_CLASSES.LOADING)
        }
    }
};
HD.extend(HD.FaceoffWidget, [HD.Widget, HD.util.StarRatingCookie]);
HD.register("hd_faceoff_widget", "HD.FaceoffWidget", {
    version: "1.0",
    build: "1"
});
HD.FAQWidget = function (A) {
    this.config = A || {};
    this.config.showTooltip = this.config.showTooltip || false;
    this.config.faqs = this.config.faqs || [];
    this.config.overlayHeight = this.config.overlayHeight || "290px";
    this.config.overlayWidth = this.config.overlayWidth || "525px";
    this.config.overlayParent = this.config.overlayParent || "hdwcFAQOverlay";
    this.config.embedPrint = this.config.embedPrint || false;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.FAQWidget.templates = {
    faqLabel: "See FAQs",
    overlayTitle: "Frequently Asked Questions",
    closeLabel: "CLOSE",
    printLabel: "PRINT",
    printBtnLabel: "Send to Printer",
    getOverlayTitle: function () {
        return this.overlayTitle
    },
    getCloseLabel: function () {
        return this.closeLabel
    },
    getPrintLabel: function () {
        return this.printLabel
    },
    getPrintBtnLabel: function () {
        return this.printBtnLabel
    },
    getFAQLabel: function () {
        return this.faqLabel
    },
    getHtml: function () {
        return this.html
    },
    getOverlayHtml: function () {
        return this.overlayHtml
    },
    html: '		<div class="${classes.FAQ} ${classes.WIDGET}">			<span class="${hooks.FAQBUTTON}">${templates.getFAQLabel()}</span>			{if config.showTooltip}			<div class="${hooks.FAQBUTTON_TOOLTIP}">${templates.getFAQLabel()}</div>			{/if}		</div>',
    overlayHtml: '		    <div id="hdwcFAQOverlay">		    	<div class="dblRuleBtm">		    		<div class="head">${templates.getOverlayTitle()}</div>		    	</div>		    	{if config.embedPrint}					<div class="${classes.PRINT}">${templates.getPrintLabel()}</div>					<div class="${classes.PRINT}-button"><a href="javascript:window.print()" title="${templates.getPrintBtnLabel()}" class="container-print">${templates.getPrintBtnLabel()}</a></div>				{/if}				<div id="hdwcBody">		 	    	<div class="${hooks.FAQ_QUESTIONS}">			 	    	{for section in faqsections}							{if section.section_name != ""}								<h2>${section.section_name}</h2>							{/if}							<ol>							{for faq in section.questions}								<li id="faq-question_${section_index}_${faq_index}" class="${hooks.FAQ_QUESTION}">${faq.question}</li>							{/for}							</ol>						{/for}					</div>					<div class="${hooks.FAQ_ANSWERS}">						{for section in faqsections}							{if section.section_name != ""}								<div class="${classes.FAQ}-section">${section.section_name}</div>							{/if}							<ol>							{for faq in section.questions}								<li id="faq-answer_${section_index}_${faq_index}" class="${hooks.FAQ_ANSWER} ${classes.FAQ}-item">									<div class="hdTitle">${faq.question}</div>									<div class="hdDescription">${faq.answer}</div>								</li>							{/for}							</ol>						{/for}					</div>				</div>		    </div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.FAQWidget.hooks = {
        FAQBUTTON: A.FAQ + "-button",
        FAQBUTTON_TOOLTIP: A.FAQ + "-tooltip",
        FAQ_QUESTIONS: A.FAQ + "-questions",
        FAQ_QUESTION: A.FAQ + "-question",
        FAQ_ANSWERS: A.FAQ + "-answers",
        FAQ_ANSWER: A.FAQ + "-answer"
    }
})();
HD.FAQWidget.prototype = {
    setListeners: function (B) {
        var A = this;
        this.getByHook("FAQBUTTON", function (C) {
            A.getByHook("FAQBUTTON_TOOLTIP", function (D) {
                C.onmouseover = function () {
                    HD.addClass(D, HD.CSS_CLASSES.FAQ + "Hover")
                };
                C.onmouseout = function () {
                    HD.removeClass(D, HD.CSS_CLASSES.FAQ + "Hover")
                }
            });
            C.onclick = function () {
                A.openForm()
            }
        })
    },
    update: function (A, B) {
        if (A == "loadFAQ_Start") {
            this.render(B)
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {})
    },
    openForm: function () {
        var A = this;
        var F = this.config.overlayParent;
        var D = HD.CSS_CLASSES;
        HD.util.Analytics.track(A.analyticsFAQString());
        var G = HD.util.Common.showOverlay(this.processTemplate(this.config.templates.getOverlayHtml(), {
            faqsections: A.config.faqs,
            config: A.config,
            _MODIFIERS: {
                html: function (H) {
                    return H.getHtml()
                }
            }
        }), this.config.templates.getFAQLabel().toUpperCase(), A.config.overlayWidth, A.config.overlayHeight, null, "faqOverlay");
        this.setPrintListeners(HD.get(F));
        var B = 0,
            E = [];
        for (var C = 0;
        C < this.config.faqs.length;
        C++) {
            E = E.concat(this.config.faqs[C].questions)
        }
        for (var C = 0;
        C < E.length;
        C++) {
            E[C]._index = C
        }
        this.getByHook("FAQ_QUESTION", function (H) {
            (function () {
                var I = E[B] || null;
                H.onclick = function () {
                    HD.getByClass(D.ACTIVE, "*", F, function (J) {
                        HD.removeClass(this, D.ACTIVE)
                    });
                    HD.addClass(HD.get(this.id.replace(/\question/, "answer")), D.ACTIVE);
                    HD.addClass(H, D.ACTIVE);
                    HD.util.Analytics.track(A.analyticsQuestionString(I));
                    return false
                }
            })();
            B++
        }, "*", F)
    },
    analyticsFAQString: function () {
        return "default_analyticsFAQString"
    },
    analyticsQuestionString: function (A) {
        return "default_analyticsQuestionString"
    }
};
HD.extend(HD.FAQWidget, [HD.Widget]);
HD.register("hd_faq_widget", "HD.FAQWidget", {
    version: "1.0",
    build: "1"
});
HD.UploadWidget = function (A) {
    this.config = A || {};
    this.config.actions = this.config.actions || [];
    this.config.dialog = this.config.dialog || {};
    this.config.categoriesFriendly = this.config.categoriesFriendly || this.config.categories;
    this.config.siteSection = this.config.siteSection || "";
    this.config.overlayWidth = this.config.overlayWidth || "590px";
    this.config.overlayHeight = this.config.overlayHeight || "525px";
    this.config.overlayConfirmationWidth = this.config.overlayConfirmationWidth || this.config.dialog.confirm ? this.config.dialog.confirm[0] : "580px";
    this.config.overlayConfirmationHeight = this.config.overlayConfirmationHeight || this.config.dialog.confirm ? this.config.dialog.confirm[1] : "150px";
    this.config.overlayParent = this.config.overlayParent || "hdwcUGCSubmission";
    this.config.showNewMemberMessage = false;
    this.observers = [];
    this.user = null;
    this.loggedInLevel = null;
    this.progress = null;
    this.file = null;
    this.loadTemplates(arguments.callee)
};
HD.UploadWidget.templates = {
    overlayTitle: "Upload",
    unsupportedFileTypeText: ["You must submit a photo or a video.<br/>", "Photo must use the following format: (.jpg, .gif)<br/>", "Video must use the following format: (.flv, .wmv, .asf, .avi, .mov, .3gp, .mpg, .mpeg, .mp4)<br/>"].join(""),
    uploadLabel: "UPLOAD",
    personalizedLabel: 'You are logged in as: [${USERNAME}] <a href="javascript:void(0)" onclick="login.view.logoutUser.call(login.view);HD.util.Common.hideOverlay();">Not ${USERNAME}?</a>',
    personalizedLabelGeneric: "Your online profile has been created. You will receive a confirmation email shortly.",
    introText: "Just give it a title, upload a file, and type in a description.",
    requiredText: "* Indicates required fields",
    categoryLabel: "Category",
    categoryDefaultText: "Select a Category",
    uploadMediaLabel: "Title",
    uploadMediaTypeBothLabel: "Upload Photo OR Video",
    uploadMediaTypePhotoLabel: "Upload Photo",
    uploadMediaTypeVideoLabel: "Upload Video",
    mediaInstructionsBothText: "<ul><li>Your Photo must be in .jpg or .gif format and no more than 10 MB.  Horizontal formatting is preferred.</li><li>Your Video must be less than 4 minutes, no more than 100 MB and be in one of the following formats: .flv, .wmv, .asf, .avi, .mov, .3gp, .mpg, .mpeg, or .mp4. </li><li>Do not include music in your video.</li></ul>",
    mediaInstructionsPhotoText: "<ul><li>Your Photo must be in .jpg or .gif format and no more than 10 MB.  Horizontal formatting is preferred.</li></ul>",
    mediaInstructionsVideoText: "<ul><li>Your Video must be less than 4 minutes, no more than 100 MB and be in one of the following formats: .flv, .wmv, .asf, .avi, .mov, .3gp, .mpg, .mpeg, or .mp4. </li><li>Do not include music in your video.</li></ul>",
    descriptionLabel: "Description",
    descriptionInstructionText: "Please describe your submission in 2500 characters or less.",
    termsAgreeText: "By submitting your content, you confirm that you are at least 18 years of age (or the age of majority in your state of residence) and agree to the terms and conditions stated in <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/user_content_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Harley-Davidson's Policy For User-Submitted Content</a>.",
    submitLabel: "SUBMIT",
    cancelLabel: "CANCEL",
    suggestionsSwivelText: "&#62",
    suggestionsSwivelTextActive: "v",
    confirmationLabel: "THANK YOU",
    thankYouText: "Thank you for your submission.  Subject to our <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/user_content_policy.jsp?locale=en_US', '', 'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Policy for User-Submitted Content</a>, it generally takes 1-2 business days to post content.",
    continueLabel: "CONTINUE",
    suggestionsAndGuidelinesText: "",
    getOverlayTitle: function () {
        return this.overlayTitle
    },
    getUnsupportedFileTypeText: function () {
        return this.unsupportedFileTypeText
    },
    getSuggestionsAndGuidelinesText: function () {
        return this.suggestionsAndGuidelinesText
    },
    getSuggestionsSwivelText: function () {
        return this.suggestionsSwivelText
    },
    getSuggestionsSwivelTextActive: function () {
        return this.suggestionsSwivelTextActive
    },
    getUploadLabel: function () {
        return this.uploadLabel
    },
    getPersonalizedLabel: function (C, B, A) {
        if (C && B > 1 && !A) {
            return this.personalizedLabel.replace(/\$\{USERNAME\}/g, C.screenName)
        } else {
            return this.personalizedLabelGeneric
        }
    },
    getIntroText: function () {
        return this.introText
    },
    getRequiredText: function () {
        return this.requiredText
    },
    getCategoryLabel: function () {
        return this.categoryLabel
    },
    getCategoryDefaultText: function () {
        return this.categoryDefaultText
    },
    getUploadMediaLabel: function () {
        return this.uploadMediaLabel
    },
    getUploadMediaTypeLabel: function (B) {
        var A = this.uploadMediaTypeBothLabel;
        if (HD.community.isPhoto(B)) {
            A = this.uploadMediaTypePhotoLabel
        } else {
            if (HD.community.isVideo(B)) {
                A = this.uploadMediaTypeVideoLabel
            }
        }
        return A
    },
    getMediaInstructionsText: function (A) {
        var B = this.mediaInstructionsBothText;
        if (HD.community.isPhoto(A)) {
            B = this.mediaInstructionsPhotoText
        } else {
            if (HD.community.isVideo(A)) {
                B = this.mediaInstructionsVideoText
            }
        }
        return B
    },
    getDescriptionLabel: function () {
        return this.descriptionLabel
    },
    getDescriptionInstructionText: function () {
        return this.descriptionInstructionText
    },
    getTermsAgreeText: function () {
        return this.termsAgreeText
    },
    getSubmitLabel: function () {
        return this.submitLabel
    },
    getCancelLabel: function () {
        return this.cancelLabel
    },
    getConfirmationLabel: function () {
        return this.confirmationLabel
    },
    getThankYouText: function () {
        return this.thankYouText
    },
    getContinueLabel: function () {
        return this.continueLabel
    },
    getOverlayHtml: function () {
        return this.overlayHtml
    },
    getOverlayConfirmationHtml: function () {
        return this.overlayConfirmationHtml
    },
    overlayHtml: '		<div id="hdwcUGCSubmission">			<div class="dblRuleBtm">				<div class="head">${templates.getUploadLabel()}</div>			</div>			<div class="hdwcLrgPadBtm">		    	<div id="hdwcInstructions">		    		${templates.getPersonalizedLabel(user, loggedInLevel, config.showNewMemberMessage)}		    	</div>			</div>			<div id="hdwcBody">				<div class="hdwcLrgPadBtm ${hooks.SCROLLER}" id="scrollableDiv" style="height:410px;overflow-y:auto;overflow-x:hidden;padding:0;">					<div class="hdwcLrgPadBtm">					    <div id="submissionInstructions">			    			<div class="hdInstructionsBox">			    				<div class="hdwcMedPadBtm">${templates.getIntroText()}</div>				    			<div class="hdInstructionsBox ${hooks.SUGGESTIONS}" id="suggestionsAndGuidelines"></div>								<div class="boldText">${templates.getRequiredText()}</div>							</div>						</div>				        <div class="hdwcLrgPadBtm">				        	<div id="submissionContent">					        	<form name="hdUploadForm" id="hdUploadForm" class="hdUpload hdWidget ${hooks.FORM}" action="/Community/services/fileUpload" enctype="multipart/form-data" method="post">					        		{if errors && errors.length > 0}						        		<div id="hdValidationErrors">						                    <div id="hdwcErrorOverlayLarge ${hooks.ERRORS}">						                    {if _MODIFIERS.hasError(errors,"error.required")}							                    <div class="hdwcValidationError ${hooks.ERROR_VALIDATION}">						                            <p class="formLabel">Fields in bold with an asterisk (*) are required.</p>						                        </div>						                    {/if}						                    {var reqErrorsDone = false}											{for error in _MODIFIERS.sortErrors(errors,["error.required"])}												{if error.errorType == "error.required"}													<div class="hdwcErrorOverlayLarge">- ${error|getError}</div>												{else}													{if !reqErrorsDone}														<br />														{var reqErrorsDone = true}													{/if}													<div class="hdwcErrorOverlayLarge">${error|getError}</div>												{/if}											{/for}						                    </div>						                  </div>				                    {/if}				                    {if _MODIFIERS.hasError(errors,"error.required","category")}										<div class="hdwcValidationError ${hooks.ERROR_VALIDATION}">									{else}										<div>									{/if}									{if config.categories.length > 1}										<div class="formLabel">${templates.getCategoryLabel()}<span class="reqIndicator">*</span></div>										<select name="category">											<option value="">${templates.getCategoryDefaultText()}&nbsp;</option>											{for category in config.categories}												{if upload.category == category}													<option value="${category}" selected>${config.categoriesFriendly[category_index]}</option>												{else}													<option value="${category}">${config.categoriesFriendly[category_index]}</option>												{/if}											{/for}										</select>									</div><br/>									{else}										<input type="hidden" value="${config.categories[0]}" name="category" style="display:none;"></input>									{/if}									{if _MODIFIERS.hasError(errors,"error.required","title")}										<div class="hdwcValidationError ${hooks.ERROR_VALIDATION}">									{else}										<div>									{/if}										<div class="formLabel">${templates.getUploadMediaLabel()}<span class="reqIndicator">*</span></div>										<input type="text" maxlength="23" class="title" name="title" value="${upload.title}"></input>									</div><br/>									{if _MODIFIERS.hasError(errors,"error.required","path")}										<div class="hdwcValidationError ${hooks.ERROR_VALIDATION}">									{else}										<div>									{/if}										<div class="formLabel">				                            ${templates.getUploadMediaTypeLabel(config.contentType)}<span class="reqIndicator">*</span>				                        </div>										<div class="hdFormattedDiv hdwcSmlPadBtm">											${templates.getMediaInstructionsText(config.contentType)}										</div>										<input type="file" value="Browse" name="path" id="browseFile"></input>										<input type="hidden" value="${config.contentType}" name="type" style="display:none;"></input>										<input type="hidden" value="${config.siteName}" name="siteName" style="display:none;"></input>									</div>									<div id="progressBar" class="${hooks.PROGRESSBAR}" style="display: none;">							            <div id="theMeter">							                <div id="progressBarBox">							                    <div id="progressBarBoxContent" class="${hooks.PROGRESSBAR_METER}"></div>							                </div>							                <div id="progressBarText" class="${hooks.PROGRESSBAR_TEXT}"></div>							            </div>							        </div><br/>							        {if _MODIFIERS.hasError(errors,"error.required","story")}										<div class="hdwcValidationError ${hooks.ERROR_VALIDATION}">									{else}										<div>									{/if}										<div class="formLabel">${templates.getDescriptionLabel()}<span class="reqIndicator">*</span></div>										<textarea cols="70" rows="4" name="story">${upload.story}</textarea>										<br />${templates.getDescriptionInstructionText()}									</div>									<div class="hdwcLrgPadBtm">								  		<br/>								  		<div id="submitStatement">								  			${templates.getTermsAgreeText()}								  		</div>								  	</div>						        	<div class="hdwcMedPadBtm">						        	     <input id="submitVideoButton" type="submit" value="SUBMIT" style="display:none;"></input>						        		 <div class="btnOrange">						        		 	<a onclick="document.getElementById(\'submitVideoButton\').click();" id="hdwcLoginSaveButton" href="javascript:void(0)">${templates.getSubmitLabel()}</a>						        		 </div>						            	<div class="btnDarkGrey hdClose">						            		<a href="javascript:void(0)">${templates.getCancelLabel()}</a></div>						        	</div>								</form>				        	</div>					  </div>				</div>			</div>		</div>',
    overlayConfirmationHtml: '			<div id="hdwcUGCSubmission" class="thankYou">	    		<div class="dblRuleBtm">		    		<div class="head">${templates.getConfirmationLabel()}</div>		    	</div>		    	<div class="hdwcLrgPadBtm">			  		<p id="submitStatement">			  		${templates.getThankYouText()}			  		</p>			  	</div>			  	<div class="hdwcMedPadBtm ${hooks.CONF_ACTIONS}">			  		<div class="btnContinue btnOrange hdClose"><a href="javascript:void(0)">${templates.getContinueLabel()}</a></div>			  	</div>			  </div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.UploadWidget.hooks = {
        CONF_ACTIONS: A.CONFIRMATION + "-" + A.ACTION + "s",
        FORM: A.UPLOAD + "-form",
        ERRORS: A.UPLOAD + "-" + A.ERROR + "s",
        ERROR_VALIDATION: A.UPLOAD + "-validation-" + A.ERROR,
        PROGRESSBAR: A.UPLOAD + "-progressbar",
        PROGRESSBAR_METER: A.UPLOAD + "-progressbar-meter",
        PROGRESSBAR_TEXT: A.UPLOAD + "-progressbar-text",
        TERMS_CONDITIONS: A.UPLOAD + "-terms",
        TERMS_SWIVEL: A.UPLOAD + "-terms-swivel",
        SCROLLER: A.UPLOAD + "-scroller",
        SUGGESTIONS: A.UPLOAD + "-suggestions",
        SUGGESTIONS_SWIVEL: A.UPLOAD + "-suggestions-swivel",
        SUGGESTIONS_BUTTON: A.UPLOAD + "-suggestions-button"
    }
})();
HD.UploadWidget.prototype = {
    supportedVideoTypes: [".flv", ".wmv", ".asf", ".avi", ".mov", ".3gp", ".mpg", ".mpeg", ".mp4"],
    supportedPhotoTypes: [".jpeg", ".jpg", ".gif"],
    getUnsupportedFileTypeError: function (A) {
        return HD.UploadWidget.templates.getUnsupportedFileTypeText()
    },
    render: function (E, C, B, D) {
        this.config.contentType = E || this.config.contentType;
        this.config.category = C || this.config.category;
        this.config.categories = B || this.config.categories;
        this.config.categoriesFriendly = D || B || this.config.categoriesFriendly;
        var A = this;
        login.model.isUserLoggedIn(function (G) {
            if (G.loggedInLevel > 1) {
                A.user = G.user;
                A.loggedInLevel = G.loggedInLevel;
                A.getHtml(null);
                var F = {
                    update: function (H, I) {
                        if (H == "overlayClose_Click") {
                            HD.util.Common.getObservable().removeObserver(this);
                            A.clearProgress()
                        }
                    }
                };
                HD.util.Common.getObservable().addObserver(F)
            } else {
                var F = {
                    update: function (I, J) {
                        if (I == "logged_In") {
                            A.user = J.user;
                            A.loggedInLevel = J.loggedInLevel;
                            var H = A.user;
                            if (H.passwordConfirm != null) {
                                A.config.showNewMemberMessage = true
                            }
                            A.getHtml(null);
                            A.config.showNewMemberMessage = false;
                            login.model.removeObserver(this);
                            HD.util.Common.getObservable().removeObserver(this)
                        } else {
                            if (I == "overlayClose_Click") {
                                login.model.removeObserver(this);
                                HD.util.Common.getObservable().removeObserver(this)
                            }
                        }
                    }
                };
                HD.util.Common.getObservable().addObserver(F);
                login.model.addObserver(F);
                login.model.addObserver(F);
                if (G.loggedInLevel > 0) {
                    login.view.promptCreateScreenName()
                } else {
                    login.view.promptAuthentication()
                }
            }
        })
    },
    renderPhoto: function (B, A, C) {
        this.render("photo", B, A, C)
    },
    renderVideo: function (B, A, C) {
        this.render("video", B, A, C)
    },
    renderBoth: function (B, A, C) {
        this.render("both", B, A, C)
    },
    loading: function (A) {
        var B = this.getParent();
        if (A) {
            HD.addClass(B, HD.CSS_CLASSES.LOADING)
        } else {
            HD.removeClass(B, HD.CSS_CLASSES.LOADING)
        }
    },
    update: function (A, C) {
        var B = this.config;
        if (A == "submitMedium_Start") {
            this.loading(true)
        } else {
            if (A == "submitMedium_Finish") {
                this.loading(false);
                this.clearProgress();
                this.getConfirmationHtml(C)
            } else {
                if (A == "submitMedium_Error") {
                    this.loading(false);
                    this.clearProgress();
                    this.getHtml(C)
                }
            }
        }
    },
    getHtml: function (D, F) {
        var A = this;
        var B = this.config;
        var E = HD.util.Common.timestamp();
        var C = B.category;
        if (F != null) {
            C = F
        }
        HD.util.Analytics.track(this.analyticsUploadString());
        var G = HD.util.Common.showOverlay(this.processTemplate(B.templates.getOverlayHtml(), {
            errors: (D && D.errors) || [],
            upload: (D && D.media) || [],
            user: A.user || {},
            loggedInLevel: A.loggedInLevel || 0
        }), B.templates.getOverlayTitle(), B.overlayWidth, B.overlayHeight);
        A.setListeners.call(A)
    },
    getConfirmationHtml: function (I) {
        var F = this;
        var D = this.config;
        var E = HD.CSS_CLASSES;
        HD.util.Analytics.track(this.analyticsUploadConfirmationString(I[3] || "", I[4] || ""));
        var H = HD.util.Common.showOverlay(this.processTemplate(D.templates.getOverlayConfirmationHtml()), D.templates.getOverlayTitle(), D.overlayConfirmationWidth, D.overlayConfirmationHeight);
        if (D.actions.length > 0) {
            var A = HD.getByClass(this.config.hooks.CONF_ACTIONS, "*", H)[0];
            if (A) {
                var B = document.createElement("div");
                B.className = "btnOrange " + E.ACTION;
                B.innerHTML = "<a href='#'></a>";
                for (var G = 0;
                G < D.actions.length;
                G++) {
                    var C = B.cloneNode(true);
                    (function () {
                        var J = D.actions[G];
                        C.firstChild.innerHTML = J;
                        C.firstChild.onclick = function () {
                            HD.util.Common.hideOverlay();
                            self.model.notifyObservers("submitMedium_Action", J)
                        }
                    })();
                    A.appendChild(C)
                }
            }
        }
    },
    setListeners: function () {
        var B = this;
        var A = this.model;
        this.getByHook("FORM", function (C) {
            C.onsubmit = function () {
                var E = this;
                var D = E.path.value;
                var I = B.getFileExtension.call(B, D);
                var G = null;
                B.removeErrors(E);
                if (B.isSupportedVideoFile(I) || B.config.contentType == "video") {
                    E.type.value = "video"
                } else {
                    if (B.isSupportedPhotoFile(I) || B.config.contentType == "photo") {
                        E.type.value = "photo"
                    } else {
                        E.type.value = ""
                    }
                }
                var H = E.category.value;
                var F = {
                    title: E.title.value,
                    path: E.path.value,
                    story: E.story.value,
                    type: E.type.value,
                    category: H
                };
                ValidationService.validateUpload(F, function (J) {
                    if (J.errors.length > 0) {
                        B.getHtml(J, H)
                    } else {
                        B.startProgress();
                        B.file = A.submitMedium.call(A, E)
                    }
                    return false
                });
                return false
            }
        }, "form", this.config.overlayParent);
        B.setToggleSuggestions()
    },
    removeErrors: function (A) {
        this.getByHook("ERRORS", function (B) {
            B.parentNode.removeChild(B)
        }, "*", A);
        this.getByHook("ERROR_VALIDATION", function (D) {
            for (var C = 0, B = D.length;
            C < B;
            C++) {
                HD.removeClass(D[C], "hdwcValidationError")
            }
        }, "*", A)
    },
    refreshProgress: function (B) {
        var A = this;
        this.progress = setTimeout(function () {
            UploadMonitor.getUploadInfo(function (C) {
                A.updateProgress(C);
                return false
            })
        }, B || 5000)
    },
    updateProgress: function (D) {
        if (D.inProgress) {
            try {
                var B = D.fileIndex;
                var A = Math.ceil((D.bytesRead / D.totalSize) * 100);
                if (this.progress) {
                    this.refreshProgress()
                }
                this.getByHook("PROGRESSBAR_TEXT", function (E) {
                    E.innerHTML = A + "%"
                }, "*", this.config.overlayParent);
                this.getByHook("PROGRESSBAR_METER", function (E) {
                    E.style.width = parseInt(A * 3.5) + "px"
                }, "*", this.config.overlayParent)
            } catch (C) {}
        }
    },
    startProgress: function () {
        this.getByHook("PROGRESSBAR", function (A) {
            A.style.display = "block"
        }, "*", this.config.overlayParent);
        this.getByHook("PROGRESSBAR_TEXT", function (A) {
            A.innerHTML = "0%"
        }, "*", this.config.overlayParent);
        this.refreshProgress(500)
    },
    clearProgress: function () {
        this.progress = null;
        if (this.file) {
            try {
                YAHOO.util.Connect.abort(this.file)
            } catch (A) {}
            this.file = null
        }
    },
    toggleSuggestions: function () {
        var A = this;
        var B = HD.util.Common.get("sgSwivel");
        this.getByHook("SUGGESTIONS", function (C) {
            if (C.style.display != "block") {
                YAHOO.util.Dom.setStyle(C, "display", "block");
                C.innerHTML = HD.UploadWidget.templates.getSuggestionsAndGuidelinesText();
                B.innerHTML = A.config.templates.getSuggestionsSwivelTextActive()
            } else {
                YAHOO.util.Dom.setStyle(C, "display", "none");
                B.innerHTML = A.config.templates.getSuggestionsSwivelText()
            }
        }, "*", this.config.overlayParent)
    },
    setToggleSuggestions: function () {
        var A = this;
        var B = HD.util.Common.get("sgButton");
        if (B) {
            B.onclick = function () {
                A.toggleSuggestions();
                return false
            }
        }
    },
    getFileExtension: function (A) {
        if (A == null) {
            return ""
        }
        return A.substring(A.lastIndexOf("."))
    },
    isSupportedVideoFile: function (A) {
        return this.isSupportedType(A, this.supportedVideoTypes)
    },
    isSupportedPhotoFile: function (A) {
        return this.isSupportedType(A, this.supportedPhotoTypes)
    },
    isSupportedType: function (C, D) {
        if (C == null || D == null) {
            return false
        }
        C = C.toLowerCase();
        for (var B = 0, A = D.length;
        B < A;
        B++) {
            if (D[B] == C) {
                return true
            }
        }
        return false
    },
    showError: function (A, B) {
        B = HD.get(B);
        B.innerHTML += "<div id='hdwcErrorOverlayLarge'>" + A + "</div>"
    },
    analyticsUploadBothString: function () {
        return "default_analyticsUploadBothString"
    },
    analyticsUploadPhotoString: function () {
        return "default_analyticsUploadPhotoString"
    },
    analyticsUploadVideoString: function () {
        return "default_analyticsUploadVideoString"
    },
    analyticsUploadString: function () {
        if (this.config.contentType == "photo") {
            HD.util.Analytics.track(this.analyticsUploadPhotoString())
        } else {
            if (this.config.contentType == "video") {
                HD.util.Analytics.track(this.analyticsUploadVideoString())
            } else {
                if (this.config.contentType == "both") {
                    HD.util.Analytics.track(this.analyticsUploadBothString())
                } else {
                    return "default_analyticsUploadString"
                }
            }
        }
    },
    analyticsUploadConfirmationString: function (B, A) {
        return "default_analyticsUploadConfirmationString"
    }
};
HD.extend(HD.UploadWidget, [HD.Widget]);
HD.register("hd_upload_widget", "HD.UploadWidget", {
    version: "1.0",
    build: "1"
});
HD.TasksWidget = function (A) {
    this.config = A || {};
    this.config.filter = this.config.filter || null;
    this.config.taskType = this.config.taskType || "roadmap";
    this.config.taskName = this.config.taskName || "womens";
    this.config.stepFilter = this.config.stepFilter || null;
    this.config.showFastTrack = this.config.showFastTrack || false;
    this.config.showInfo = this.config.showInfo || false;
    this.config.showSkip = this.config.showSkip || false;
    this.config.showDate = this.config.showDate || false;
    this.config.dateFormat = this.config.dateFormat || "mmm d, yyyy";
    this.config.collapsible = this.config.collapsible || false;
    this.config.collapseMode = this.config.collapseMode || "all-open" || "all-closed" || "all-incomplete-open" || "first-open" || "first-incomplete-open" || [0, 1, 2];
    this.config.collapseLimit = this.config.collapseLimit || "none" || "single";
    this.config.infoMode = this.config.infoMode || "all-closed" || "all-open" || "all-incomplete-open" || "first-open" || "first-incomplete-open";
    this.config.infoLimit = this.config.infoLimit || "none" || "single";
    this.data = null;
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.TasksWidget.templates = {
    tasksLabel: "Tasks",
    fastTrackLabel: "Fast Track",
    infoLabel: "Info",
    skipLabel: "Skip",
    undoLabel: "Undo",
    getTasksLabel: function () {
        return this.tasksLabel
    },
    getFastTrackLabel: function () {
        return this.fastTrackLabel
    },
    getInfoLabel: function () {
        return this.infoLabel
    },
    getSkipLabel: function () {
        return this.skipLabel
    },
    getUndoLabel: function () {
        return this.undoLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.TASKS} ${classes.WIDGET}">			{macro renderTask(task,isStep)}				<div class="${hooks.TASK_ITEM}${" "}{if task.status === "C"}${hooks.TASK_COMPLETED}{elseif task.status == "S"}${hooks.TASK_SKIPPED}{else}${hooks.TASK_INCOMPLETE}{/if}${" "}{if !task.optional}${hooks.TASK_REQUIRED}{/if}">					{if isStep}						<div class="${hooks.TASK_TITLE}">${task.title}</div>					{else}						<input class="${hooks.TASK_INPUT}" type="checkbox"${" "}{if task.status === "C"}checked="checked"{elseif task.status === "S"}disabled="disabled"{/if}/>						<div class="${hooks.TASK_TITLE}">${task.title}</div>						{if config.showInfo || config.showSkip || config.showDate || task.status !== "I"}						<div class="${hooks.TASK_ACTIONS}">							{if config.showDate && task.status === "C"}<span class="${hooks.TASK_DATE}">${task.modifiedDate|date}</span>{/if}							{if config.showInfo && task.description}<span class="${hooks.TASK_INFO}">${templates.getInfoLabel()}</span>{/if}							{if !isStep && config.showSkip && task.status === "I"}<span class="${hooks.TASK_SKIP}">${templates.getSkipLabel()}</span>{/if}							{if !isStep && task.status !== "I"}<span class="${hooks.TASK_UNDO}">${templates.getUndoLabel()}</span>{/if}						</div>						{/if}						{if config.showInfo && task.description}<div class="${hooks.TASK_DESCRIPTION}">${task.description}</div>{/if}					{/if}				</div>			{/macro}			<div class="${classes.TITLE}">${templates.getTasksLabel()}</div>			{if config.showFastTrack}<div class="${hooks.FAST_TRACK}"><input class="${hooks.FAST_TRACK_INPUT}" type="checkbox"{if tasklist.fastTrack}${" "}checked="checked"{/if}/><div>${templates.getFastTrackLabel()}</div></div>{/if}			<ul class="${hooks.STEPLIST}${" "}{if config.collapsible}${hooks.COLLAPSIBLE}{/if}${" "}{if tasklist.fastTrack}${hooks.FAST_TRACKED}{/if}">			{for step in tasklist.steps}				{if _MODIFIERS.visible(step)}				<li class="${hooks.STEP} ${hooks.STEP}-${step_index}${" "}{if _MODIFIERS.collapsed(step)}${hooks.STEP_COLLAPSED} ${hooks.STEP_COLLAPSED}-${step_index}{/if}${" "}{if _MODIFIERS.infoShown(step)}${hooks.TASK_SHOW_INFO}{/if}">					${renderTask(step,true)}					<ul class="${hooks.TASKLIST}">					{for task in step.tasks}						<li class="${hooks.TASK} ${hooks.TASK}-${task_index}${" "}{if _MODIFIERS.infoShown(task)}${hooks.TASK_SHOW_INFO}{/if}">${renderTask(task)}</li>					{/for}					</ul>				</li>				{/if}			{/for}			</ul>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.TasksWidget.hooks = {
        TASK_ITEM: A.TASKS + "-task-item",
        TASK_COMPLETED: A.TASKS + "-task-completed",
        TASK_SKIPPED: A.TASKS + "-task-skipped",
        TASK_INCOMPLETE: A.TASKS + "-task-incomplete",
        TASK_REQUIRED: A.TASKS + "-task-required",
        TASK_SHOW_INFO: A.TASKS + "-task-show-info",
        TASK_HIDDEN: A.TASKS + "-task-hidden",
        TASK_TITLE: A.TASKS + "-task-title",
        TASK_ACTIONS: A.TASKS + "-task-actions",
        TASK_INFO: A.TASKS + "-task-info",
        TASK_SKIP: A.TASKS + "-task-skip",
        TASK_UNDO: A.TASKS + "-task-undo",
        TASK_DATE: A.TASKS + "-task-date",
        TASK_DESCRIPTION: A.TASKS + "-task-description",
        STEPLIST: A.TASKS + "-steplist",
        STEP: A.TASKS + "-step",
        STEP_COLLAPSED: A.TASKS + "-step-collapsed",
        TASKLIST: A.TASKS + "-steplist",
        TASK: A.TASKS + "-task",
        TASK_INPUT: A.TASKS + "-task-input",
        FAST_TRACK: A.TASKS + "-fast-track",
        FAST_TRACK_INPUT: A.TASKS + "-fast-track-input",
        FAST_TRACKED: A.TASKS + "-fast-tracked",
        COLLAPSIBLE: A.TASKS + "-collapsible"
    }
})();
HD.TasksWidget.prototype = {
    update: function (A, D) {
        if (A == "getTasks_Start" || A == "updateTask_Start" || A == "setTasksFastTrack_Start") {
            this.loading(true)
        } else {
            if (A == "getTasks_Finish" || A == "updateTask_Finish" || A == "setTasksFastTrack_Finish") {
                this.loading(false);
                if (this.data && (A == "updateTask_Finish" || A == "setTasksFastTrack_Finish")) {
                    for (var C = 0;
                    C < D.steps.length;
                    C++) {
                        if (typeof this.data.steps[C]._collapsed === "boolean") {
                            D.steps[C]._collapsed = this.data.steps[C]._collapsed
                        }
                        if (typeof this.data.steps[C]._infoShown === "boolean") {
                            D.steps[C]._infoShown = this.data.steps[C]._infoShown
                        }
                        for (var B = 0;
                        B < D.steps[C].tasks.length;
                        B++) {
                            if (typeof this.data.steps[C].tasks[B]._infoShown === "boolean") {
                                D.steps[C].tasks[B]._infoShown = this.data.steps[C].tasks[B]._infoShown
                            }
                        }
                    }
                }
                this.data = D;
                this.render(this.data)
            } else {
                if (A == "getTasks_Error" || A == "updateTask_Error" || A == "setTasksFastTrack_Error") {
                    this.loading(false)
                }
            }
        }
    },
    setListeners: function (F) {
        var D = 0,
            C = HD.CSS_CLASSES,
            E = this.getParent(),
            A = YAHOO.util.Event;
        var B = this,
            G = B.config.hooks.TASK_SHOW_INFO;
        this.getByHook("STEP", function (I) {
            var H = 0;
            var J = B.config.stepFilter ? F.steps[B.config.stepFilter[D]] : F.steps[D];
            var O = B.getByHook("TASK_ITEM", null, null, I)[0] || null;
            var M = B.getByHook("TASK_INPUT", null, null, I)[0] || null;
            var N = B.getByHook("TASK_SKIP", null, null, I)[0] || null;
            var K = B.getByHook("TASK_INFO", null, null, I)[0] || null;
            if (O) {
                var L = B.config.hooks.STEP_COLLAPSED;
                (function () {
                    var P = D;
                    O.onclick = function () {
                        if (B.config.collapsible) {
                            var R = HD.hasClass(I, L);
                            if (B.config.collapseLimit === "single") {
                                var Q = 0;
                                B.getByHook("STEP", function (T) {
                                    var S = B.config.stepFilter ? F.steps[B.config.stepFilter[Q]] : F.steps[Q];
                                    HD.addClass(T, L);
                                    HD.addClass(T, L + "-" + Q++);
                                    S._collapsed = true
                                })
                            }
                            if (R) {
                                HD.removeClass(I, L);
                                HD.removeClass(I, L + "-" + P);
                                J._collapsed = false
                            } else {
                                HD.addClass(I, L);
                                HD.addClass(I, L + "-" + P);
                                J._collapsed = true
                            }
                            B.notifyObservers("tasks_stepCollapse", {
                                data: B.data,
                                step: J,
                                collapse: J._collapsed
                            })
                        }
                    }
                })()
            }
            B.getByHook("TASK", function (Q) {
                var P = J.tasks[H];
                B.getByHook("TASK_INPUT", function (R) {
                    R.onclick = function (S) {
                        A.stopPropagation(S || window.event);
                        B.setTaskStatus(P, this.checked ? "C" : "I");
                        B.render(F)
                    }
                }, null, Q);
                B.getByHook("TASK_SKIP", function (R) {
                    R.onclick = function (S) {
                        A.stopPropagation(S || window.event);
                        B.setTaskStatus(P, "S");
                        B.render(F)
                    }
                }, null, Q);
                B.getByHook("TASK_UNDO", function (R) {
                    R.onclick = function (S) {
                        A.stopPropagation(S || window.event);
                        B.setTaskStatus(P, "I");
                        B.render(F)
                    }
                }, null, Q);
                B.getByHook("TASK_INFO", function (R) {
                    R.onclick = function (U) {
                        A.stopPropagation(U || window.event);
                        var T = HD.hasClass(Q, G);
                        if (B.config.infoLimit === "single") {
                            var S = 0;
                            B.getByHook("STEP", function (X) {
                                var V = 0,
                                    W = B.config.stepFilter ? F.steps[B.config.stepFilter[S]] : F.steps[S];
                                HD.removeClass(X, G);
                                W._infoShown = false;
                                B.getByHook("TASK", function (Y) {
                                    HD.removeClass(Y, G);
                                    W.tasks[V]._infoShown = false;
                                    V++
                                });
                                S++
                            })
                        }
                        if (T) {
                            HD.removeClass(Q, G);
                            P._infoShown = false
                        } else {
                            HD.addClass(Q, G);
                            P._infoShown = true
                        }
                    }
                }, null, Q);
                ++H
            }, null, I);++D
        });
        this.getByHook("FAST_TRACK", function (H) {
            B.getByHook("FAST_TRACK_INPUT", function (I) {
                I.onclick = function (J) {
                    A.stopPropagation(J || window.event);
                    B.setFastTrack(F, this.checked);
                    B.render(F)
                }
            }, null, H)
        })
    },
    toggleAllSteps: function (D) {
        var B = 0,
            A = this,
            C = this.config.hooks.STEP_COLLAPSED;
        this.getByHook("STEP", function (E) {
            var F = A.config.stepFilter ? A.data.steps[A.config.stepFilter[B]] : A.data.steps[B];
            if (D) {
                HD.addClass(E, C);
                HD.addClass(E, C + "-" + B++)
            } else {
                HD.removeClass(E, C);
                HD.removeClass(E, C + "-" + B++)
            }
            F._collapsed = D
        })
    },
    getToggleState: function () {
        var B = false;
        if (this.config.stepFilter) {
            for (var A = 0;
            A < this.config.stepFilter.length;
            A++) {
                B = B || this.data.steps[this.config.stepFilter[A]]._collapsed
            }
        } else {
            for (var A = 0;
            A < this.data.steps.length;
            A++) {
                B = B || this.data.steps[A]._collapsed
            }
        }
        return B
    },
    setTaskStatus: function (B, A) {
        this.updateTask(B, A)
    },
    setStepStatus: function (D, B) {
        var A = B === true || B !== "I";
        for (var C = 0;
        C < D.tasks.length;
        C++) {
            A = A && D.tasks[C].status !== "I"
        }
        this.setTaskStatus(D, B);
        for (var C = 0;
        C < D.tasks.length;
        C++) {
            if (D.tasks[C].status !== "S" && D.status !== D.tasks[C].status) {
                this.setTaskStatus(D.tasks[C], B)
            }
        }
    },
    setFastTrack: function (B, A) {
        B.fastTrack = A;
        HD.util.Analytics.track(this.analyticsFastTrackString(B));
        this.model.setTasksFastTrack(this.config.taskType, this.config.taskName, B.fastTrack)
    },
    updateTask: function (B, A) {
        A = A || "I";
        B.modifiedDate = new Date();
        B.status = A;
        if (A === "C") {
            HD.util.Analytics.track(this.analyticsCompletedString(this.data, this.data.steps[B._stepIndex], B))
        } else {
            if (A === "S") {
                HD.util.Analytics.track(this.analyticsSkippedString(this.data, this.data.steps[B._stepIndex], B))
            } else {
                HD.util.Analytics.track(this.analyticsUndoString(this.data, this.data.steps[B._stepIndex], B))
            }
        }
        this.model.updateTask(this.config.taskType, this.config.taskName, B.id, B.status)
    },
    getHtml: function (C) {
        var A = this;
        var B = function (E) {
            for (var D = 0;
            D < C.steps.length;
            D++) {
                if (C.steps[D] === E) {
                    return D
                }
            }
            return -1
        };
        return this.processTemplate(this.config.templates.getHtml(), {
            _MODIFIERS: {
                collapsed: function (E) {
                    var D = this;
                    var F = (function (J) {
                        if (A.config.collapsible) {
                            var L = A.config.collapseMode,
                                I = A.config.stepFilter,
                                G = B(J);
                            if (typeof J._collapsed === "boolean") {
                                return J._collapsed
                            } else {
                                if (L === "all-closed") {
                                    return true
                                } else {
                                    if (L === "all-open") {
                                        return false
                                    } else {
                                        if (L === "all-incomplete-open") {
                                            return J.status !== "I"
                                        } else {
                                            if (L === "first-open") {
                                                return !((I && I[0] === G) || (!I && G === 0))
                                            } else {
                                                if (L === "first-incomplete-open") {
                                                    var K = false;
                                                    for (var H = 0;
                                                    H < C.steps.length;
                                                    H++) {
                                                        if (D.visible(C.steps[H])) {
                                                            if (H === G && C.steps[H].status === "I") {
                                                                return K
                                                            } else {
                                                                if (C.steps[H].status === "I") {
                                                                    K = true
                                                                }
                                                            }
                                                        }
                                                    }
                                                    return true
                                                } else {
                                                    if (L instanceof Array) {
                                                        for (var H = 0;
                                                        H < L.length;
                                                        H++) {
                                                            if (L[H] === G) {
                                                                return false
                                                            }
                                                        }
                                                        return true
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            return false
                        } else {
                            return false
                        }
                    })(E);
                    E._collapsed = F;
                    return F
                },
                infoShown: function (D) {
                    var F = this;
                    var E = (function (G) {
                        if (A.config.showInfo) {
                            var M = A.config.infoMode,
                                J = A.config.stepFilter;
                            if (typeof G._infoShown === "boolean") {
                                return G._infoShown
                            } else {
                                if (M === "all-closed") {
                                    return false
                                } else {
                                    if (M === "all-open") {
                                        return !!G.description
                                    } else {
                                        if (M === "all-incomplete-open") {
                                            return G.description && G.status === "I"
                                        } else {
                                            if (M === "first-open" && !! G.description) {
                                                var L = true;
                                                for (var I = 0;
                                                I < C.steps.length;
                                                I++) {
                                                    if (F.visible(C.steps[I])) {
                                                        var K = C.steps[I];
                                                        if (K === G) {
                                                            return L
                                                        }
                                                        L = L && !K.description;
                                                        for (var H = 0;
                                                        H < K.tasks.length;
                                                        H++) {
                                                            if (K.tasks[H] === G) {
                                                                return L
                                                            }
                                                            L = L && !K.tasks[H].description
                                                        }
                                                    }
                                                }
                                                return false
                                            } else {
                                                if (M === "first-incomplete-open" && !! G.description && G.status === "I") {
                                                    var L = true;
                                                    for (var I = 0;
                                                    I < C.steps.length;
                                                    I++) {
                                                        var K = C.steps[I];
                                                        if (F.visible(K)) {
                                                            if (K === G) {
                                                                return L
                                                            }
                                                            L = L && (!K.description || K.status !== "I");
                                                            for (var H = 0;
                                                            H < K.tasks.length;
                                                            H++) {
                                                                if (K.tasks[H] === G) {
                                                                    return L
                                                                }
                                                                L = L && (!K.tasks[H].description || K.tasks[H].status !== "I")
                                                            }
                                                        }
                                                    }
                                                    return false
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            return false
                        } else {
                            return false
                        }
                    })(D);
                    D._infoShown = E;
                    return E
                },
                visible: function (F) {
                    if (!A.config.stepFilter) {
                        return true
                    }
                    var D = B(F);
                    for (var E = 0;
                    E < A.config.stepFilter.length;
                    E++) {
                        if (A.config.stepFilter[E] === D) {
                            return true
                        }
                    }
                    return false
                }
            },
            tasklist: C
        })
    },
    analyticsFastTrackString: function (A) {
        return "default_analyticsFastTrackString"
    },
    analyticsCompletedString: function (C, B, A) {
        return "default_analyticsCompletedString"
    },
    analyticsSkippedString: function (C, B, A) {
        return "default_analyticsSkippedString"
    },
    analyticsUndoString: function (C, B, A) {
        return "default_analyticsUndoString"
    }
};
HD.extend(HD.TasksWidget, [HD.Widget]);
HD.register("hd_tasks_widget", "HD.TasksWidget", {
    version: "1.0",
    build: "1"
});
HD.community.Media = function (A) {
    this.data = A
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.community.Media.hooks = {
        MEDIA_ITEM: A.MEDIA + "-item",
        MEDIA_RATING_MY: A.MEDIA + "-rating-my",
        MEDIA_RATING_AVG: A.MEDIA + "-rating-avg",
        MEDIA_RATING_STAR: A.MEDIA + "-rating-star",
        MEDIA_RATING_TEXT: A.MEDIA + "-rating-text",
        MEDIA_CAPTION: A.MEDIA + "-caption",
        MEDIA_VOTES: A.MEDIA + "-votes",
        MEDIA_CATEGORY: A.MEDIA + "-category",
        MEDIA_TAG: A.MEDIA + "-tag",
        MEDIA_MORE: A.MEDIA + "-more",
        MEDIA_THUMB: A.MEDIA + "-thumb",
        MEDIA_THUMB_LG: A.MEDIA + "-thumb-lg",
        MEDIA_COMMENTS_BTN: A.MEDIA + "-comments-btn",
        MEDIA_TITLE: A.MEDIA + "-title",
        MEDIA_AUTHOR: A.MEDIA + "-author",
        MEDIA_NEXT: A.MEDIA + "-next",
        MEDIA_PREVIOUS: A.MEDIA + "-previous"
    }
})();
HD.community.Media.prototype = {
    getHtml: function (A) {
        this.loadTemplates(HD.community.Media.templates, HD.community.Media.hooks, {
            config: A,
            templates: "mediaTemplates",
            hooks: "mediaHooks"
        });
        return this.processTemplate(this.config.templates.getHtml(), {
            config: A
        })
    },
    incrementViews: function () {
        var A = comSvcBaseUrl + "/hd/hd_media/assets/incrementCount.jsp?viewUrl=" + this.data.viewUrl;
        HD.util.Common.requestContent(A, function (B) {})
    },
    updateRating: function (A, B) {
        B.config.numOfVotes = A.numberOfVotes;
        B.config.averageRating = A.rating;
        B.config.myRating = parseInt(A.currentUserRating);
        if (B.config.myRating != null && B.config.myRating > 0) {
            B.config.isRated = true
        }
        B.render()
    },
    updateRatingWidgets: function (B) {
        var E = this.ratings;
        if (E != null) {
            for (var C = 0, A = E.length;
            C < A;
            C++) {
                var D = E[C];
                if (D != null) {
                    this.updateRating(B, D)
                }
            }
        }
    },
    generatePermalink: function (D) {
        var E = this.data;
        var G = window.location.href;
        D = D || {};
        var C = HD.util.Common.getRequestParam("locale");
        if (HD.util.Common.hasValue(C)) {
            C = "locale=" + C + "&"
        } else {
            C = ""
        }
        var I = "?" + C + "mediaId=" + E.mediaId + "&contentType=" + E.contentType;
        for (var B in D) {
            I += "&" + B + "=" + D[B]
        }
        I += "#loc=detail/" + E.contentType + "/" + E.mediaId + "/1";
        var A = G.indexOf("?");
        var H = G.indexOf("#");
        var F = -1;
        if (A > -1) {
            F = A
        } else {
            if (H > -1) {
                F = H
            }
        }
        if (F > -1) {
            G = G.substr(0, F)
        }
        var J = G + I;
        return J
    }
};
HD.extend(HD.community.Media, [HD.util.Template]);
HD.register("hd_media", "HD.community.Media", {
    version: "1.0",
    build: "1"
});
HD.community.Blog = function (A) {
    this.data = A;
    this.ratings = []
};
HD.community.Blog.templates = {
    authorLabel: "By ",
    dateLabel: "Submitted ",
    tagsLabel: "Tags: ",
    categoryLabel: "Category: ",
    moreText: "More",
    commentsTextFirst: "Add the first comment",
    commentsText: "Comments ({number})",
    toTopText: "Back to top",
    nextLabel: "Next",
    previousLabel: "Previous",
    averageVotesText: "Average of ${num_of_votes}&nbsp;ratings:&nbsp;${text_rating}&nbsp;stars",
    emailText: "Send to a friend",
    getAuthorLabel: function () {
        return this.authorLabel
    },
    getDateLabel: function () {
        return this.dateLabel
    },
    getTagsLabel: function () {
        return this.tagsLabel
    },
    getCategoryLabel: function () {
        return this.categoryLabel
    },
    getMoreText: function () {
        return this.moreText
    },
    getNextLabel: function () {
        return this.nextLabel
    },
    getPreviousLabel: function () {
        return this.previousLabel
    },
    getCommentsText: function (A) {
        var B = this.commentsTextFirst;
        if (A != null && A > 0) {
            B = this.commentsText.replace(/\{number\}/, A)
        }
        return B
    },
    getToTopText: function () {
        return this.toTopText
    },
    getAverageVotesText: function (B, A) {
        return this.averageVotesText.replace(/\$\{num_of_votes\}/, B).replace(/\$\{text_rating\}/, A)
    },
    getEmailText: function () {
        return this.emailText
    },
    getHtml: function () {
        return this.html
    },
    getVotesText: function () {
        return HD.util.StarRating.CSS_CLASSES.NUM_OF_VOTES + " " + HD.community.Blog.hooks.MEDIA_VOTES
    },
    getRatingText: function () {
        return HD.util.StarRating.CSS_CLASSES.TEXT_RATING + " " + HD.community.Blog.hooks.MEDIA_RATING_TEXT
    },
    html: '		<div class="${classes.ITEM} ${classes.BLOG}{if !blog.previous} ${classes.FIRST}{/if}{if !blog.next} ${classes.LAST}{/if} ${hooks.MEDIA_ITEM}">			<div class="${classes.TITLE} ${hooks.MEDIA_TITLE}">${blog.title|ellipse:config.titleLength || blog.title.length}</div>			{if config.embedBlogDetailNavigation}			<div class="${classes.NAVIGATION}">				<div class="${classes.PREVIOUS} ${hooks.MEDIA_PREVIOUS}">${templates.getPreviousLabel()}</div>				<div class="${classes.NEXT} ${hooks.MEDIA_NEXT}">${templates.getNextLabel()}</div>			</div>			{/if}			<div class="${classes.RATING}">				<div class="${ratingClasses.AVERAGE_RATING} ${hooks.MEDIA_RATING_AVG}">					<div class="${ratingClasses.CAPTION} ${hooks.MEDIA_CAPTION}"></div> 					<div class="${ratingClasses.STAR_RATING} ${hooks.MEDIA_RATING_STAR}"></div>					(<div class="${ratingClasses.NUM_OF_VOTES} ${hooks.MEDIA_VOTES}"></div>)				</div>				<div class="${ratingClasses.MY_RATING} ${hooks.MEDIA_RATING_MY}">					<div class="${ratingClasses.CAPTION} ${hooks.MEDIA_CAPTION}"></div> 					<div class="${ratingClasses.STAR_RATING} ${hooks.MEDIA_RATING_STAR}"></div>					<br/><div>						${templates.getAverageVotesText(\'<div class="\'+templates.getVotesText()+\'"></div>\',\'<div class="\'+templates.getRatingText()+\'"></div>\')}					</div>				</div>			</div>			<table class="${classes.WRAPPER}">				<tr>					<td>						<div class="${classes.DATE}">							<div class="${classes.LABEL}">${templates.getDateLabel()}</div>							<div class="${classes.VALUE}">${blog.uploadedDate|date}</div>						</div>					</td>					<td>					{if !blog.hiddenAuthor}						<div class="${classes.AUTHOR} ${hooks.MEDIA_AUTHOR}">						 	<div class="${classes.LABEL}">${templates.getAuthorLabel()}</div>						 	<div class="${classes.VALUE}">${blog.author}</div>						 </div>					{else}						<div/>					{/if}					</td>				</tr>			</table>			<div class="${classes.CATEGORIES}">			{if blog.category}				<div class="${classes.LABEL}">${templates.getCategoryLabel()}</div>				<div class="${classes.VALUE}"><a class="${classes.CATEGORY} ${hooks.MEDIA_CATEGORY}" href="javascript:void(0)">${blog.category}</a></div>			{/if}			</div>			<div class="${classes.TAG_LIST}">			{if hasTags}				<div class="${classes.LABEL}">${templates.getTagsLabel()}</div>				<div class="${classes.VALUE}">				{for tag in blog.tags}{if tag_index > 0}${", "}{/if}<a class="${classes.TAG}{if _MODIFIERS.active(tag)} ${classes.ACTIVE}{/if} ${hooks.MEDIA_TAG}" href="javascript:void(0)">${tag}</a>{/for}				</div>			{/if}			</div>			<div class="${classes.THUMB} ${hooks.MEDIA_THUMB}"></div>			<div class="${classes.DESCRIPTION}">				<div class="${classes.FULL}">${blog.description}</div>				<div class="${classes.SHORT}">${shortDescription}</div>				{if hasMore}					<div class="${classes.MORE} ${hooks.MEDIA_MORE}">${templates.getMoreText()}</div> | 				{/if}				<div class="hdCommentsButton ${hooks.MEDIA_COMMENTS_BTN}">					${templates.getCommentsText(blog.numberOfComments)}				</div>			</div>			{if config.embedShare}				${shareWidget|html}			{/if}			{if config.embedSendFriend}				${sendFriendWidget|html}			{/if}		</div>'
};
(function () {
    HD.community.Blog.hooks = HD.clone(HD.community.Media.hooks)
})();
HD.community.Blog.prototype = {
    getHtml: function (C, B) {
        var F = this.data;
        if (F == null) {
            return ""
        }
        this.loadTemplates(HD.community.Blog.templates, HD.community.Blog.hooks, {
            config: C,
            templates: "blogTemplates",
            hooks: "blogHooks"
        });
        var E = B.filters && B.filters.tags ? B.filters.tags.slice(0) : [];
        var D = F.description;
        var G = false;
        if (HD.util.Common.hasValue(D)) {
            var A = HD.util.Common.stripHtmlTags(D);
            if (A.length > C.previewLength) {
                D = HD.util.Common.ellipseText(D, C.previewLength, true);
                G = true
            } else {
                D = HD.util.Common.stripHtmlTags(D, true)
            }
        }
        if (C.embedShare) {
            this.shareWidget = new HD.ShareWidget(HD.merge(C.shareConfig, {
                embedMode: true
            }))
        }
        if (C.embedSendFriend) {
            this.sendFriendWidget = new HD.SendFriendWidget(HD.merge(C.sendFriendConfig, {
                embedMode: true
            }))
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            blog: F,
            config: C,
            shortDescription: D,
            hasMore: G,
            shareWidget: this.shareWidget || null,
            sendFriendWidget: this.sendFriendWidget || null,
            hasTags: F.tags && F.tags.length > 0,
            ratingClasses: HD.util.StarRating.CSS_CLASSES,
            _MODIFIERS: {
                active: function (H) {
                    var J = false;
                    for (var I = E.length - 1;
                    I >= 0;
                    I--) {
                        if (E[I] == H) {
                            J = true;
                            E.splice(I, 1);
                            break
                        }
                    }
                    return J
                },
                html: function (H) {
                    return H.getHtml(F)
                }
            }
        })
    },
    destroy: function () {
        if (this.tooltip) {
            this.tooltip.destroy();
            delete this.tooltip
        }
    },
    setListener: function (L, J) {
        var a = HD.CSS_CLASSES;
        var d = HD.util.StarRating.CSS_CLASSES;
        var f = this.data;
        if (f == null) {
            return ""
        }
        var T = this;
        var Z = f;
        var g = J.config;
        var S = function () {
            J.notifyObservers.call(J, "itemSelected", Z);
            J.model.setActiveItem.call(J.model, Z)
        };
        if (J.config.type == "hd_gallery_widget") {
            var E = J.config.showMatrix ? L : HD.getByClass(this.config.hooks.MEDIA_TITLE, "*", L)[0];
            if (E) {
                E.onclick = S
            }
        }
        var D = HD.getByClass(this.config.hooks.MEDIA_COMMENTS_BTN, "*", L)[0];
        if (D) {
            D.onclick = S
        }
        var h = HD.getByClass(this.config.hooks.MEDIA_MORE, "*", L, function (i) {
            i.onclick = S
        });
        var C = HD.getByClass(this.config.hooks.MEDIA_THUMB, "*", L)[0];
        var P = f.description.match(/\<img.+?\>/);
        if (C && f.url.indexOf("videos") > 0 || f.url.indexOf("VIDEO") > 0) {
            var U = new HD.util.Player({
                parent: C,
                width: g.playerWidth || 400,
                height: g.playerHeight || 300,
                parentWidget: this,
                templates: g.playerTemplates || {},
                hooks: g.playerHooks || {}
            });
            U.view.render({
                videoUrl: f.url,
                thumbUrl: f.largeThumbUrl || f.thumbUrl,
                media: f
            });
            window.playerTest = U
        } else {
            if (C && P && P[0]) {
                var N = P[0].match(/src=["'](.+?)["']/);
                if (N && N[1]) {
                    var c = new Image();
                    c.src = N[1];
                    C.appendChild(c)
                }
            }
        }
        if ( !! f.category) {
            var b = HD.getByClass(this.config.hooks.MEDIA_CATEGORY, "*", L);
            if (b[0]) {
                b[0].onclick = function () {
                    J.model.setCategories([f.category])
                }
            }
        }
        if (f.tags && f.tags.length > 0) {
            var e = HD.getByClass(this.config.hooks.MEDIA_TAG, "*", L);
            for (var V = 0, X = e.length;
            V < X;
            V++) {
                (function () {
                    var i = f.tags[V];
                    e[V].onclick = function () {
                        J.model.setTags([i])
                    }
                })()
            }
        }
        var B = HD.getByClass(this.config.hooks.MEDIA_RATING_MY, "*", L)[0] || null;
        var Y = HD.getByClass(this.config.hooks.MEDIA_RATING_AVG, "*", L)[0] || null;
        var M = {
            update: function (i, k) {
                J.model.rateMedia.call(J.model, Z.mediaId, null, k)
            }
        };
        if (Y) {
            var Q = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", Y)[0] || null;
            var I = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", Y)[0] || null;
            var j = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", Y)[0] || null;
            var K = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", Y)[0] || null;
            if (I) {
                I.onclick = S
            }
            var O = new HD.util.StarRating({
                captionParent: Q,
                textRatingParent: j,
                starRatingParent: I,
                numOfVotesParent: K,
                numOfVotes: f.numberOfVotes,
                averageRating: f.rating,
                isStatic: true,
                itemId: f.mediaId,
                numOfDecimals: 1,
                requiresLogin: g.requiresRatingLogin,
                showRatingHalves: g.showRatingHalves || false,
                showYourRatingText: g.showYourRatingText || false
            });
            this.ratings.push(O)
        }
        if (B) {
            var Q = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", B)[0] || null;
            var I = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", B)[0] || null;
            var j = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", B)[0] || null;
            var K = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", B)[0] || null;
            var G = new HD.util.StarRating({
                captionParent: Q,
                textRatingParent: j,
                starRatingParent: I,
                numOfVotesParent: K,
                numOfVotes: f.numberOfVotes,
                averageRating: f.rating,
                isStatic: false,
                itemId: f.mediaId,
                numOfDecimals: 1,
                requiresLogin: g.requiresRatingLogin,
                showRatingHalves: g.showRatingHalves || false,
                showYourRatingText: g.showYourRatingText || false
            });
            this.ratings.push(G);
            G.addObserver(M)
        }
        J.model.addObserver({
            update: function (i, k) {
                if (i == "rateMedia_Finish") {
                    if (k.mediaId == Z.mediaId) {
                        Z.numberOfVotes = k.numberOfVotes;
                        Z.rating = k.rating;
                        T.updateRatingWidgets.call(T, k)
                    }
                }
            }
        });
        var H = J.model;
        var R = HD.getByClass(this.config.hooks.MEDIA_PREVIOUS, "*", L)[0];
        var A = HD.getByClass(this.config.hooks.MEDIA_NEXT, "*", L)[0];
        if (R) {
            if (H.hasPreviousItem()) {
                R.onclick = function () {
                    J.view.notifyObservers.call(J.view, "itemChange_Start", f);
                    H.getPreviousItem.call(H)
                }
            } else {
                HD.addClass(R, a.HIDDEN)
            }
        }
        if (A) {
            if (H.hasNextItem()) {
                A.onclick = function () {
                    J.view.notifyObservers.call(J.view, "itemChange_Start", f);
                    H.getNextItem.call(H)
                }
            } else {
                HD.addClass(A, a.HIDDEN)
            }
        }
        var W = HD.getByClass(this.config.hooks.MEDIA_AUTHOR, "*", L);
        if (W.length > 0) {
            var F = W[0];
            F.onclick = function () {
                J.notifyObservers.call(J, "authorSelected", Z);
                J.model.getMemberProfile.call(J.model, Z.authorId)
            }
        }
        if (J.config.embedShare && this.shareWidget) {
            this.shareWidget.config.parent = L;
            this.shareWidget.setListeners(f)
        }
        if (J.config.embedSendFriend && this.sendFriendWidget) {
            this.sendFriendWidget.config.parent = L;
            this.sendFriendWidget.setListeners(f)
        }
    }
};
HD.extend(HD.community.Blog, [HD.community.Media]);
HD.register("hd_blog", "HD.community.Blog", {
    version: "1.0",
    build: "1"
});
HD.community.Photo = function (A) {
    this.data = A;
    this.ratings = []
};
HD.community.Photo.templates = {
    authorLabel: "Submitted by: ",
    dateLabel: "",
    tagsLabel: "Tags: ",
    categoryLabel: "Category: ",
    moreText: "Read the Story",
    commentsTextFirst: "Comments ({number})",
    commentsText: "Comments ({number})",
    nextLabel: "Next",
    previousLabel: "Previous",
    averageVotesText: "(Average of ${num_of_votes}&nbsp;ratings:&nbsp;${text_rating}&nbsp;stars)",
    emailText: "Send to a friend",
    getAuthorLabel: function () {
        return this.authorLabel
    },
    getDateLabel: function () {
        return this.dateLabel
    },
    getTagsLabel: function () {
        return this.tagsLabel
    },
    getCategoryLabel: function () {
        return this.categoryLabel
    },
    getMoreText: function () {
        return this.moreText
    },
    getCommentsText: function (A) {
        var B = this.commentsTextFirst.replace(/\{number\}/, A);
        if (A != null && A > 0) {
            B = this.commentsText.replace(/\{number\}/, A)
        }
        return B
    },
    getNextLabel: function () {
        return this.nextLabel
    },
    getPreviousLabel: function () {
        return this.previousLabel
    },
    getAverageVotesText: function (B, A) {
        return this.averageVotesText.replace(/\$\{num_of_votes\}/, B).replace(/\$\{text_rating\}/, A)
    },
    getEmailText: function () {
        return this.emailText
    },
    getHtml: function () {
        return this.html
    },
    getVotesText: function () {
        return HD.util.StarRating.CSS_CLASSES.NUM_OF_VOTES + " " + HD.community.Photo.hooks.MEDIA_VOTES
    },
    getRatingText: function () {
        return HD.util.StarRating.CSS_CLASSES.TEXT_RATING + " " + HD.community.Photo.hooks.MEDIA_RATING_TEXT
    },
    getPhotoDescription: function (A) {
        return A.replace(/(\r\n|[\r\n])/g, "<br />")
    },
    html: '		<div class="${classes.ITEM} ${classes.PHOTO}{if !photo.previous} ${classes.FIRST}{/if}{if !photo.next} ${classes.LAST}{/if} ${hooks.MEDIA_ITEM}">			<div class="${classes.SMALL_THUMB_WRAPPER}">				<div class="${classes.SMALL_THUMB} ${hooks.MEDIA_THUMB}" style="background: transparent url(${photo.thumbUrl}) no-repeat 50% 50%;">					<div class="${classes.THUMB_OVERLAY}"></div>				</div>			</div>			<div class="${classes.LARGE_THUMB_WRAPPER}">				<div class="${classes.LARGE_THUMB}" style="background: transparent url(${photo.url}) no-repeat 50% 50%;"></div>				<div class="${classes.THUMB_OVERLAY}"></div>			</div>			<div class="${classes.LEFT}">				<div class="${classes.TITLE} ${hooks.MEDIA_TITLE}">${photo.title|ellipse:config.titleLength || photo.title.length}</div>				<div class="${classes.CATEGORIES}">				{if photo.category}					<div class="${classes.LABEL}">${templates.getCategoryLabel()}</div>					<div class="${classes.VALUE}"><a class="${classes.CATEGORY} ${hooks.MEDIA_CATEGORY}" href="javascript:void(0)">${photo.category}</a></div>				{/if}				</div>				<div class="${classes.TAG_LIST}">				{if hasTags}					<div class="${classes.LABEL}">${templates.getTagsLabel()}</div>					<div class="${classes.VALUE}">					{for tag in photo.tags}{if tag_index > 0}${", "}{/if}<a class="${classes.TAG} ${hooks.MEDIA_TAG}" href="javascript:void(0)">${tag}</a>{/for}					</div>				{/if}				</div>				<div class="${classes.AUTHOR} ${hooks.MEDIA_AUTHOR}">				{if !photo.hiddenAuthor}					<div class="${classes.LABEL}">${templates.getAuthorLabel()}</div>					<div class="${classes.VALUE}">${photo.author}</div>				{/if}				</div>				<div class="${classes.DATE}">					<div class="${classes.LABEL}">${templates.getDateLabel()}</div>					<div class="${classes.VALUE}">${photo.uploadedDate|date}</div>				</div>				<div class="${classes.RATING}">					<div class="${ratingClasses.AVERAGE_RATING} ${hooks.MEDIA_RATING_AVG}">						<div class="${ratingClasses.STAR_RATING} ${hooks.MEDIA_RATING_STAR}"></div>						<div class="${classes.WRAPPER}">							(<div class="${ratingClasses.NUM_OF_VOTES} ${hooks.MEDIA_VOTES}"></div>)						</div>					</div>					<div class="${ratingClasses.MY_RATING} ${hooks.MEDIA_RATING_MY}">						<div class="${ratingClasses.CAPTION} ${hooks.MEDIA_CAPTION}"></div> 						<div class="${ratingClasses.STAR_RATING}  ${hooks.MEDIA_RATING_STAR}"></div>						<br/><div class="${classes.RATING}Wrapper">							${templates.getAverageVotesText(\'<div class="\'+templates.getVotesText()+\'"></div>\',\'<div class="\'+templates.getRatingText()+\'"></div>\')}						</div>					</div>				</div>			</div>			<div class="${classes.RIGHT}">				<div class="${classes.NAVIGATION}">					<div class="${classes.PREVIOUS} ${hooks.MEDIA_PREVIOUS}">${templates.getPreviousLabel()}</div>					<div class="${classes.NEXT} ${hooks.MEDIA_NEXT}">${templates.getNextLabel()}</div>				</div>				<a class="${classes.COMMENTS}Button ${hooks.MEDIA_COMMENTS_BTN}" id="${commentsButtonId}">${templates.getCommentsText(photo.numberOfComments)}</a>				<div class="${classes.EMAIL}">${templates.getEmailText()}</div>			</div>			<div class="${classes.DESCRIPTION}">				<div>${templates.getPhotoDescription(photo.description)}</div>			</div>			{if config.embedShare}				${shareWidget|html}			{/if}			{if config.embedSendFriend}				${sendFriendWidget|html}			{/if}		</div>'
};
(function () {
    HD.community.Photo.hooks = HD.clone(HD.community.Media.hooks)
})();
HD.community.Photo.prototype = {
    getHtml: function (B) {
        var A = this.data;
        if (A == null) {
            return ""
        }
        this.loadTemplates(HD.community.Photo.templates, HD.community.Photo.hooks, {
            config: B,
            templates: "photoTemplates",
            hooks: "photoHooks"
        });
        this.commentsButtonId = HD.util.Common.generateElementId();
        if (B.embedShare) {
            this.shareWidget = new HD.ShareWidget(HD.merge(B.shareConfig, {
                embedMode: true
            }))
        }
        if (B.embedSendFriend) {
            this.sendFriendWidget = new HD.SendFriendWidget(HD.merge(B.sendFriendConfig, {
                embedMode: true
            }))
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            photo: A,
            config: B,
            shareWidget: this.shareWidget || null,
            sendFriendWidget: this.sendFriendWidget || null,
            commentsButtonId: this.commentsButtonId,
            hasTags: A.tags && A.tags.length > 0,
            ratingClasses: HD.util.StarRating.CSS_CLASSES,
            _MODIFIERS: {
                html: function (C) {
                    return C.getHtml(A)
                }
            }
        })
    },
    destroy: function () {
        if (this.tooltip) {
            this.tooltip.destroy();
            delete this.tooltip
        }
    },
    setListener: function (X, I) {
        var E = this.data;
        if (E == null) {
            return ""
        }
        var W = HD.CSS_CLASSES;
        var Z = HD.util.StarRating.CSS_CLASSES;
        var b = I.config;
        var H = b.type.match(/^(hd_gallery_widget|hd_carousel_widget)$/);
        if (H) {
            X.onclick = function () {
                I.notifyObservers.call(I, "itemSelected", E);
                I.model.setActiveItem.call(I.model, E)
            }
        }
        var O = HD.getByClass(this.config.hooks.MEDIA_THUMB, "*", X);
        if (O.length > 0) {
            var B = O[0];
            if (!H) {
                B.onclick = function () {
                    I.notifyObservers.call(I, "itemSelected", E);
                    I.model.setActiveItem.call(I.model, E)
                }
            }
            if (b.isShowPopups) {
                this.tooltip = new YAHOO.widget.Tooltip(HD.util.Common.generateElementId(), {
                    context: B,
                    text: '<div class="' + HD.CSS_CLASSES.TOOL_TIP + '">' + E.description.substring(0, 200) + "</div>",
                    autodismissdelay: 60000
                })
            }
        }
        var S = this;
        I.model.addObserver({
            update: function (e, f) {
                if (e == "submitComment_Finish" || e == "getComments_Finish") {
                    if (f.mediaId == E.mediaId) {
                        S.data = f;
                        var d = HD.get(S.commentsButtonId);
                        if (d != null) {
                            d.innerHTML = HD.community.Photo.templates.getCommentsText(f.numberOfComments)
                        }
                    }
                }
            }
        });
        if ( !! E.category) {
            var Y = HD.getByClass(this.config.hooks.MEDIA_CATEGORY, "*", X);
            if (Y[0]) {
                Y[0].onclick = function () {
                    I.model.setCategories([E.category])
                }
            }
        }
        if (E.tags && E.tags.length > 0) {
            var a = HD.getByClass(this.config.hooks.MEDIA_TAG, "*", X);
            for (var T = 0, U = a.length;
            T < U;
            T++) {
                (function () {
                    var d = E.tags[T];
                    a[T].onclick = function () {
                        I.model.setTags([d])
                    }
                })()
            }
        }
        var C = HD.getByClass(this.config.hooks.MEDIA_RATING_MY, "*", X)[0] || null;
        var V = HD.getByClass(this.config.hooks.MEDIA_RATING_AVG, "*", X)[0] || null;
        var K = {
            update: function (d, e) {
                I.model.rateMedia.call(I.model, E.mediaId, E.contentType, e)
            }
        };
        var M = E.currentUserRating > 0;
        var P = null;
        if (M) {
            P = parseInt(E.currentUserRating)
        }
        if (V) {
            var N = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", V)[0] || null;
            var G = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", V)[0] || null;
            var c = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", V)[0] || null;
            var J = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", V)[0] || null;
            var L = new HD.util.StarRating({
                captionParent: N,
                textRatingParent: c,
                starRatingParent: G,
                numOfVotesParent: J,
                numOfVotes: E.numberOfVotes,
                averageRating: E.rating,
                isStatic: true,
                itemId: E.mediaId,
                myRating: P,
                isRated: M,
                numOfDecimals: 1,
                requiresLogin: b.requiresRatingLogin,
                showRatingHalves: b.showRatingHalves || false,
                showYourRatingText: b.showYourRatingText || false
            });
            this.ratings.push(L)
        }
        if (C) {
            var N = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", C)[0] || null;
            var G = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", C)[0] || null;
            var c = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", C)[0] || null;
            var J = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", C)[0] || null;
            var D = new HD.util.StarRating({
                captionParent: N,
                textRatingParent: c,
                starRatingParent: G,
                numOfVotesParent: J,
                numOfVotes: E.numberOfVotes,
                averageRating: E.rating,
                isStatic: false,
                itemId: E.mediaId,
                myRating: P,
                isRated: M,
                numOfDecimals: 1,
                requiresLogin: b.requiresRatingLogin,
                showRatingHalves: b.showRatingHalves || false,
                showYourRatingText: b.showYourRatingText || false
            });
            this.ratings.push(D);
            D.addObserver(K)
        }
        I.model.addObserver({
            update: function (d, e) {
                if (d == "rateMedia_Finish") {
                    if (e.mediaId == E.mediaId) {
                        E.numberOfVotes = e.numberOfVotes;
                        E.rating = e.rating;
                        S.updateRatingWidgets.call(S, e)
                    }
                }
            }
        });
        var F = I.model;
        var Q = HD.getByClass(this.config.hooks.MEDIA_PREVIOUS, "*", X)[0];
        var A = HD.getByClass(this.config.hooks.MEDIA_NEXT, "*", X)[0];
        if (Q) {
            if (F.hasPreviousItem()) {
                Q.onclick = function () {
                    I.view.notifyObservers.call(I.view, "itemChange_Start", E);
                    F.getPreviousItem.call(F)
                }
            } else {
                HD.addClass(Q, W.HIDDEN)
            }
        }
        if (A) {
            if (F.hasNextItem()) {
                A.onclick = function () {
                    I.view.notifyObservers.call(I.view, "itemChange_Start", E);
                    F.getNextItem.call(F)
                }
            } else {
                HD.addClass(A, W.HIDDEN)
            }
        }
        var R = HD.get(S.commentsButtonId);
        if (R) {
            R.onclick = function () {
                var d = HD.get("commentsDiv");
                if (d != null) {
                    HD.util.Common.scrollTo(d)
                }
            }
        }
        if (I.config.embedShare && this.shareWidget) {
            this.shareWidget.config.parent = X;
            this.shareWidget.setListeners(E)
        }
        if (I.config.embedSendFriend && this.sendFriendWidget) {
            this.sendFriendWidget.config.parent = X;
            this.sendFriendWidget.setListeners(E)
        }
    }
};
HD.extend(HD.community.Photo, [HD.community.Media]);
HD.register("hd_photo", "HD.community.Photo", {
    version: "1.0",
    build: "1"
});
HD.community.Video = function (A) {
    this.data = A;
    this.ratings = []
};
HD.community.Video.templates = {
    authorLabel: "Submitted by: ",
    dateLabel: "",
    tagsLabel: "Tags: ",
    categoryLabel: "Category: ",
    moreText: "Watch Video",
    commentsTextFirst: "Comments ({number})",
    commentsText: "Comments ({number})",
    nextLabel: "Next",
    previousLabel: "Previous",
    averageVotesText: "(Average of ${num_of_votes}&nbsp;ratings:&nbsp;${text_rating}&nbsp;stars)",
    emailText: "Send to a friend",
    getAuthorLabel: function () {
        return this.authorLabel
    },
    getDateLabel: function () {
        return this.dateLabel
    },
    getTagsLabel: function () {
        return this.tagsLabel
    },
    getCategoryLabel: function () {
        return this.categoryLabel
    },
    getMoreText: function () {
        return this.moreText
    },
    getCommentsText: function (A) {
        var B = this.commentsTextFirst.replace(/\{number\}/, A);
        if (A != null && A > 0) {
            B = this.commentsText.replace(/\{number\}/, A)
        }
        return B
    },
    getNextLabel: function () {
        return this.nextLabel
    },
    getPreviousLabel: function () {
        return this.previousLabel
    },
    getAverageVotesText: function (B, A) {
        return this.averageVotesText.replace(/\$\{num_of_votes\}/, B).replace(/\$\{text_rating\}/, A)
    },
    getEmailText: function () {
        return this.emailText
    },
    getHtml: function () {
        return this.html
    },
    getVotesText: function () {
        return HD.util.StarRating.CSS_CLASSES.NUM_OF_VOTES + " " + HD.community.Video.hooks.MEDIA_VOTES
    },
    getRatingText: function () {
        return HD.util.StarRating.CSS_CLASSES.TEXT_RATING + " " + HD.community.Video.hooks.MEDIA_RATING_TEXT
    },
    getVideoDescription: function (A) {
        return A.replace(/(\r\n|[\r\n])/g, "<br />")
    },
    html: '		<div class="${classes.ITEM} ${classes.VIDEO}{if !video.previous} ${classes.FIRST}{/if}{if !video.next} ${classes.LAST}{/if} ${hooks.MEDIA_ITEM}">			<div class="${classes.SMALL_THUMB_WRAPPER}">				<div class="${classes.SMALL_THUMB} ${hooks.MEDIA_THUMB}" style="background: transparent url(${video.thumbUrl}) no-repeat 50% 50%;">					<div class="${classes.THUMB_OVERLAY}"></div>				</div>			</div>			<div class="${classes.LARGE_THUMB_WRAPPER}">				<div class="${classes.LARGE_THUMB} ${hooks.MEDIA_THUMB_LG}"></div>			</div>			<div class="${classes.LEFT}">				<div class="${classes.TITLE} ${hooks.MEDIA_TITLE}">${video.title|ellipse:config.titleLength || video.title.length}</div>				<div class="${classes.CATEGORIES}">				{if video.category}					<div class="${classes.LABEL}">${templates.getCategoryLabel()}</div>					<div class="${classes.VALUE}"><a class="${classes.CATEGORY} ${hooks.MEDIA_CATEGORY}" href="javascript:void(0)">${video.category}</a></div>				{/if}				</div>				<div class="${classes.TAG_LIST}">				{if hasTags}					<div class="${classes.LABEL}">${templates.getTagsLabel()}</div>					<div class="${classes.VALUE}">					{for tag in video.tags}{if tag_index > 0}${", "}{/if}<a class="${classes.TAG} ${hooks.MEDIA_TAG}" href="javascript:void(0)">${tag}</a>{/for}					</div>				{/if}				</div>				<div class="${classes.AUTHOR} ${hooks.MEDIA_AUTHOR}">				{if !video.hiddenAuthor}					<div class="${classes.LABEL}">${templates.getAuthorLabel()}</div>					<div class="${classes.VALUE}">${video.author}</div>				{/if}				</div>				<div class="${classes.DATE}">					<div class="${classes.LABEL}">${templates.getDateLabel()}</div>					<div class="${classes.VALUE}">${video.uploadedDate|date}</div>				</div>				<div class="${classes.RATING}">					<div class="${ratingClasses.AVERAGE_RATING} ${hooks.MEDIA_RATING_AVG}">						<div class="${ratingClasses.STAR_RATING} ${hooks.MEDIA_RATING_STAR}"></div>						<div class="${classes.WRAPPER}">							(<div class="${ratingClasses.NUM_OF_VOTES} ${hooks.MEDIA_VOTES}"></div>)						</div>					</div>					<div class="${ratingClasses.MY_RATING} ${hooks.MEDIA_RATING_MY}">						<div class="${ratingClasses.CAPTION} ${hooks.MEDIA_CAPTION}"></div> 						<div class="${ratingClasses.STAR_RATING} ${hooks.MEDIA_RATING_STAR}"></div>						<br/><div class="${classes.RATING}Wrapper">							${templates.getAverageVotesText(\'<div class="\'+templates.getVotesText()+\'"></div>\',\'<div class="\'+templates.getRatingText()+\'"></div>\')}						</div>					</div>				</div>			</div>			<div class="${classes.RIGHT}">				<div class="${classes.NAVIGATION}">					<div class="${classes.PREVIOUS} ${hooks.MEDIA_PREVIOUS}">${templates.getPreviousLabel()}</div>					<div class="${classes.NEXT} ${hooks.MEDIA_NEXT}">${templates.getNextLabel()}</div>				</div>				<a class="${classes.COMMENTS}Button ${hooks.MEDIA_COMMENTS_BTN}" id="${commentsButtonId}">${templates.getCommentsText(video.numberOfComments)}</a>				<div class="${classes.EMAIL}">${templates.getEmailText()}</div>			</div>			<div class="${classes.DESCRIPTION}">				<div>${templates.getVideoDescription(video.description)}</div>			</div>			{if config.embedShare}				${shareWidget|html}			{/if}			{if config.embedSendFriend}				${sendFriendWidget|html}			{/if}		</div>'
};
(function () {
    HD.community.Video.hooks = HD.clone(HD.community.Media.hooks)
})();
HD.community.Video.prototype = {
    getHtml: function (A) {
        var B = this.data;
        if (B == null) {
            return ""
        }
        this.loadTemplates(HD.community.Video.templates, HD.community.Video.hooks, {
            config: A,
            templates: "videoTemplates",
            hooks: "videoHooks"
        });
        this.commentsButtonId = HD.util.Common.generateElementId();
        if (A.embedShare) {
            this.shareWidget = new HD.ShareWidget(HD.merge(A.shareConfig, {
                embedMode: true
            }))
        }
        if (A.embedSendFriend) {
            this.sendFriendWidget = new HD.SendFriendWidget(HD.merge(A.sendFriendConfig, {
                embedMode: true
            }))
        }
        return this.processTemplate(this.config.templates.getHtml(), {
            video: B,
            config: A,
            shareWidget: this.shareWidget || null,
            sendFriendWidget: this.sendFriendWidget || null,
            commentsButtonId: this.commentsButtonId,
            hasTags: B.tags && B.tags.length > 0,
            ratingClasses: HD.util.StarRating.CSS_CLASSES,
            _MODIFIERS: {
                html: function (C) {
                    return C.getHtml(B)
                }
            }
        })
    },
    destroy: function () {
        if (this.tooltip) {
            this.tooltip.destroy();
            delete this.tooltip
        }
    },
    setListener: function (B, H) {
        var X = this.data;
        if (X == null) {
            return ""
        }
        var Z = HD.CSS_CLASSES;
        var b = HD.util.StarRating.CSS_CLASSES;
        var d = H.config;
        var G = d.type.match(/^(hd_gallery_widget|hd_carousel_widget)$/);
        var N = HD.getByClass(this.config.hooks.MEDIA_THUMB, "*", B)[0];
        if (G) {
            B.onclick = function () {
                H.notifyObservers.call(H, "itemSelected", X);
                H.model.setActiveItem.call(H.model, X)
            }
        } else {
            if (N) {
                N.onclick = function () {
                    H.notifyObservers.call(H, "itemSelected", X);
                    H.model.setActiveItem.call(H.model, X)
                }
            }
        }
        if (d.isShowPopups) {
            this.tooltip = new YAHOO.widget.Tooltip(HD.util.Common.generateElementId(), {
                context: N,
                text: '<div class="' + HD.CSS_CLASSES.TOOL_TIP + '">' + X.description.substring(0, 200) + "</div>",
                autodismissdelay: 60000
            })
        }
        var P = HD.getByClass(this.config.hooks.MEDIA_THUMB_LG, "*", B)[0];
        if (P) {
            var U = new HD.util.Player({
                parent: P,
                width: d.playerWidth || 400,
                height: d.playerHeight || 300,
                parentWidget: this,
                templates: d.playerTemplates || {},
                hooks: d.playerHooks || {}
            });
            var J = X.viewUrl;
            U.view.render({
                videoUrl: J,
                thumbUrl: X.largeThumbUrl || X.thumbUrl,
                media: X
            })
        }
        var T = this;
        H.model.addObserver({
            update: function (g, h) {
                if (g == "submitComment_Finish" || g == "getComments_Finish") {
                    if (h.mediaId == X.mediaId) {
                        T.data = h;
                        var f = HD.get(T.commentsButtonId);
                        if (f != null) {
                            f.innerHTML = HD.community.Video.templates.getCommentsText(h.numberOfComments)
                        }
                    }
                }
            }
        });
        if ( !! X.category) {
            var a = HD.getByClass(this.config.hooks.MEDIA_CATEGORY, "*", B);
            if (a[0]) {
                a[0].onclick = function () {
                    H.model.setCategories([X.category])
                }
            }
        }
        if (X.tags && X.tags.length > 0) {
            var c = HD.getByClass(this.config.hooks.MEDIA_TAG, "*", B);
            for (var V = 0, W = c.length;
            V < W;
            V++) {
                (function () {
                    var f = X.tags[V];
                    c[V].onclick = function () {
                        H.model.setTags([f])
                    }
                })()
            }
        }
        var C = HD.getByClass(this.config.hooks.MEDIA_RATING_MY, "*", B)[0] || null;
        var Y = HD.getByClass(this.config.hooks.MEDIA_RATING_AVG, "*", B)[0] || null;
        var K = {
            update: function (f, g) {
                H.model.rateMedia.call(H.model, X.mediaId, X.contentType, g)
            }
        };
        var M = X.currentUserRating > 0;
        var Q = null;
        if (M) {
            Q = parseInt(X.currentUserRating)
        }
        if (Y) {
            var O = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", Y)[0] || null;
            var F = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", Y)[0] || null;
            var e = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", Y)[0] || null;
            var I = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", Y)[0] || null;
            var L = new HD.util.StarRating({
                captionParent: O,
                textRatingParent: e,
                starRatingParent: F,
                numOfVotesParent: I,
                numOfVotes: X.numberOfVotes,
                averageRating: X.rating,
                isStatic: true,
                itemId: X.mediaId,
                myRating: Q,
                isRated: M,
                numOfDecimals: 1,
                requiresLogin: d.requiresRatingLogin,
                showRatingHalves: d.showRatingHalves || false,
                showYourRatingText: d.showYourRatingText || false
            });
            this.ratings.push(L)
        }
        if (C) {
            var O = HD.getByClass(this.config.hooks.MEDIA_CAPTION, "*", C)[0] || null;
            var F = HD.getByClass(this.config.hooks.MEDIA_RATING_STAR, "*", C)[0] || null;
            var e = HD.getByClass(this.config.hooks.MEDIA_RATING_TEXT, "*", C)[0] || null;
            var I = HD.getByClass(this.config.hooks.MEDIA_VOTES, "*", C)[0] || null;
            var D = new HD.util.StarRating({
                captionParent: O,
                textRatingParent: e,
                starRatingParent: F,
                numOfVotesParent: I,
                numOfVotes: X.numberOfVotes,
                averageRating: X.rating,
                isStatic: false,
                itemId: X.mediaId,
                myRating: Q,
                isRated: M,
                numOfDecimals: 1,
                requiresLogin: d.requiresRatingLogin,
                showRatingHalves: d.showRatingHalves || false,
                showYourRatingText: d.showYourRatingText || false
            });
            this.ratings.push(D);
            D.addObserver(K)
        }
        H.model.addObserver({
            update: function (f, g) {
                if (f == "rateMedia_Finish") {
                    if (g.mediaId == X.mediaId) {
                        X.numberOfVotes = g.numberOfVotes;
                        X.rating = g.rating;
                        T.updateRatingWidgets.call(T, g)
                    }
                }
            }
        });
        var E = H.model;
        var R = HD.getByClass(this.config.hooks.MEDIA_PREVIOUS, "*", B)[0];
        var A = HD.getByClass(this.config.hooks.MEDIA_NEXT, "*", B)[0];
        if (R) {
            if (E.hasPreviousItem()) {
                R.onclick = function () {
                    H.view.notifyObservers.call(H.view, "itemChange_Start", X);
                    E.getPreviousItem.call(E)
                }
            } else {
                HD.addClass(R, Z.HIDDEN)
            }
        }
        if (A) {
            if (E.hasNextItem()) {
                A.onclick = function () {
                    H.view.notifyObservers.call(H.view, "itemChange_Start", X);
                    E.getNextItem.call(E)
                }
            } else {
                HD.addClass(A, Z.HIDDEN)
            }
        }
        var S = HD.get(T.commentsButtonId);
        if (S) {
            S.onclick = function () {
                var f = HD.get("commentsDiv");
                if (f != null) {
                    HD.util.Common.scrollTo(f)
                }
            }
        }
        if (H.config.embedShare && this.shareWidget) {
            this.shareWidget.config.parent = B;
            this.shareWidget.setListeners(X)
        }
        if (H.config.embedSendFriend && this.sendFriendWidget) {
            this.sendFriendWidget.config.parent = B;
            this.sendFriendWidget.setListeners(X)
        }
    }
};
HD.extend(HD.community.Video, [HD.community.Media]);
HD.register("hd_video", "HD.community.Video", {
    version: "1.0",
    build: "1"
});
HD.util.RSS = {
    _injectValue: function (A, C, B) {
        if (!A[C]) {
            A[C] = []
        }
        A[C].push(B)
    },
    _parseNode: function (D) {
        var C = {};
        for (var B = 0, A = D.childNodes.length;
        B < A;
        B++) {
            var F = D.childNodes[B].nodeName.replace(/[:]/g, "__");
            if (F != "#text" && D.childNodes[B].childNodes.length > 0) {
                this._injectValue(C, F, this._parseNode(D.childNodes[B]))
            } else {
                if (F == "#text") {
                    var E = null;
                    if (typeof D.childNodes[B].textContent != "undefined") {
                        E = D.childNodes[B].textContent || null
                    } else {
                        E = D.childNodes[B].nodeValue || null
                    }
                    return E
                } else {
                    this._injectValue(C, F, D.childNodes[B].textContent || null)
                }
            }
        }
        return C
    },
    _parseFeed: function (E, F) {
        var D = {
            channel: []
        };
        var A = E.responseXML.getElementsByTagName("channel");
        for (var C = 0, B = A.length;
        C < B;
        C++) {
            this._injectValue(D, "channel", this._parseNode(A[C]))
        }
        F(D)
    },
    getFeed: function (B, C, D) {
        var A = this;
        YAHOO.util.Connect.asyncRequest("GET", comSvcBaseUrl + "/hd/hd_rss/assets/proxy.jsp?feed=" + B + "&params=" + C, {
            success: function (E) {
                A._parseFeed(E, D)
            },
            failure: function (E) {
                D(false)
            }
        })
    },
    getRidePlannerFeed: function (A, B) {
        this.getFeed("rideplanner", A, B)
    }
};
HD.register("hd_rss", HD.util.RSS, {
    version: "1.0",
    build: "1"
});
if (typeof _hbPageView == "undefined" || !_hbPageView) {
    function _hbPageView() {}
}
if (typeof HDSocial == "undefined" || !HDSocial) {
    var HDSocial = {
        hasAnalytics: function () {
            return !!HD && !! HD.util && !! HD.util.Analytics
        },
        pageLink: function (D, A, C, B) {
            var E = window.open(D, A, C);
            if (!E) {
                HDSocial.getSwf(B).openWindowFromSwf(D)
            } else {
                E.focus()
            }
        },
        getSwf: function (A) {
            if (navigator.appName.indexOf("Microsoft") != -1) {
                return window[A]
            } else {
                return document[A]
            }
        },
        hdSocialShare: function (E, C, G, B, H, F, A, D) {
            switch (E) {
            case "facebook":
                HDSocial.hdFbShare(C, G, F, A, D);
                break;
            case "myspace":
                HDSocial.hdMSShare(C, G, B, F, A, D);
                break;
            case "digg":
                HDSocial.hdDiggShare(C, G, B, F, A, D);
                break;
            case "twitter":
                HDSocial.hdTShare(B, F, A, D);
                break;
            case "wordpress":
            case "blogger":
                HDSocial.hdBlogShare(C, G, B, H, F, A, E, D);
                break
            }
        },
        hdFbShare: function (B, F, G, C, A) {
            var H = B;
            var I = F;
            var D = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(H) + "&t=" + encodeURIComponent(I);
            var E = "toolbar=0,status=0,width=626,height=436";
            HDSocial.pageLink(D, "Facebook", E, C);
            if (this.hasAnalytics()) {
                HD.util.Analytics.track(this.analyticsFacebookString(A))
            } else {
                _hbPageView("Facebook", G)
            }
        },
        hdTShare: function (E, G, B, F) {
            var D = E;
            var A = "http://twitter.com/home?status=" + encodeURIComponent(D);
            var C = "toolbar=0,status=0,width=790,height=436";
            HDSocial.pageLink(A, "Twitter", C, B);
            if (this.hasAnalytics()) {
                HD.util.Analytics.track(this.analyticsTwitterString(F))
            } else {
                _hbPageView("Twitter", G)
            }
        },
        hdMSShare: function (E, J, L, K, H, B) {
            var F = J;
            var A = L;
            var D = E;
            var G = "http://www.myspace.com/index.cfm?fuseaction=postto&t=" + encodeURIComponent(F) + "&c=" + encodeURIComponent(A) + "&u=" + encodeURIComponent(D);
            var I = "width=1024,height=768,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no";
            HDSocial.pageLink(G, "MySpace", I, H);
            if (this.hasAnalytics()) {
                HD.util.Analytics.track(this.analyticsMyspaceString(B))
            } else {
                _hbPageView("MySpace", K)
            }
        },
        hdDiggShare: function (E, H, D, G, B, F) {
            var A = "http://digg.com/submit/?url=" + E + "&title=" + H + "&bodytext=" + D;
            var C = "width=1024,height=768,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no";
            HDSocial.pageLink(A, "Digg", C, B);
            if (this.hasAnalytics()) {
                HD.util.Analytics.track(this.analyticsDiggString(F))
            } else {
                _hbPageView("Digg", G)
            }
        },
        hdBlogShare: function (Q, R, J, F, E, M, P, D) {
            var H = "0";
            var C = Q;
            var L = "_blank";
            var G = "8";
            var O = R.replace(/['"]/g, "");
            var N = "left";
            var I = F;
            var A = "";
            var B = R;
            var K = '<div id="HDSocialBlogPost">';
            K += '<div class="dblRuleBtm">';
            K += '  <div class="head">POST TO YOUR BLOG</div>';
            K += "</div>";
            K += '<div class="hdwcMedPadBtm">';
            K += '<div id="hdwcInstructions">Copy and paste the embed code below and post it to your blog:</div>';
            K += "</div>";
            K += '<div id="hdwcBody" class="wrap">';
            K += '<div class="htmlEmbedCode hdwcSmlPadBtm">';
            K += "	<h2>Embed Code</h2>";
            K += '  <textarea name="copyText" id="copyText" >';
            K += '<a href="' + C + '"  target="' + L + '"><img src="' + I + '" align="' + N + '" alt="' + O + '" hspace="' + G + '" border="' + H + '"/></a>';
            K += J + '<br/>Check it out at <a href="' + C + '" target="' + L + '">' + B + "</a>";
            K += "</textarea>";
            K += "</div>";
            K += '<div class="btnOrange"><a href="javascript: void(0);" id="hdSocial-closebtn">Close</a></div>';
            K += "</div>";
            K += "</div>";
            HDSocial.showOverlay(K, B, 586, 254, false);
            if (this.hasAnalytics()) {
                if (P == "wordpress") {
                    HD.util.Analytics.track(this.analyticsWordpressString(D))
                } else {
                    if (P == "blogger") {
                        HD.util.Analytics.track(this.analyticsBloggerString(D))
                    }
                }
            } else {
                _hbPageView(P || "Blog", E)
            }
        },
        showOverlay: function (K, N, D, O, G) {
            var I = YAHOO.util.Dom.get("hdwcOverlay");
            if (I) {
                this.hideOverlay()
            }
            var B = 540 > YAHOO.util.Dom.getViewportHeight() && parseInt(O, 10) > 450;
            if (B) {
                O = YAHOO.util.Dom.getViewportHeight() - 40
            }
            var C = (YAHOO.util.Dom.getViewportWidth() / 2) - (D / 2);
            var J = YAHOO.util.Dom.getDocumentScrollTop();
            var A = ((YAHOO.util.Dom.getViewportHeight() + J) / 2) - (O / 2);
            C = Math.round(C);
            A = Math.round(A);
            var E = {
                constraintoviewport: true,
                close: true,
                draggable: true,
                zindex: 100000,
                modal: true,
                visible: false,
                iframe: true,
                underlay: "shadow",
                x: C,
                y: A,
                height: typeof O == "number" ? O + "px" : O || null,
                width: typeof D == "number" ? D + "px" : D || null
            };
            if (G == true) {
                K = "<iframe class='hdwcOverlayIframe' src='" + K + "' frameBorder='0' height='" + O + "' width='" + D + "' scrolling='no' allowTransparency='true'></iframe>"
            }
            var F = new YAHOO.widget.Panel("hdwcOverlay", E);
            F.setBody(K);
            F.render(document.body);
            F.show();
            if (YAHOO.env.ua.ie > 0) {
                YAHOO.util.Dom.setStyle("hdwcOverlay_c", "top", A);
                YAHOO.util.Dom.setStyle("hdwcOverlay_c", "left", C)
            }
            var M = function () {
                HDSocial.hideOverlay()
            };
            var P = YAHOO.util.Dom.getElementsByClassName("container-close", "a", I);
            P.push(document.getElementById("hdSocial-closebtn"));
            for (var H = 0, L = P.length;
            H < L;
            H++) {
                (function () {
                    P[H].onclick = M
                })()
            }
            if (B) {
                YAHOO.util.Event.onContentReady("hdwcBody", function () {
                    var R = YAHOO.util.Dom.get("hdwcBody");
                    var Q = YAHOO.util.Dom.get("scrollableDiv");
                    if (R) {
                        R.style.height = (parseInt(O, 10) - 65) + "px"
                    }
                    if (Q) {
                        Q.style.height = (parseInt(O, 10) - 90) + "px"
                    }
                })
            }
            this.overlay = F;
            return I
        },
        hideOverlay: function () {
            if (this.overlay != null) {
                this.overlay.hide();
                this.overlay.destroy()
            }
        },
        analyticsFacebookString: function () {
            return "default_analyticsFacebookString"
        },
        analyticsTwitterString: function () {
            return "default_analyticsTwitterString"
        },
        analyticsMyspaceString: function () {
            return "default_analyticsMyspaceString"
        },
        analyticsBloggerString: function () {
            return "default_analyticsBloggerString"
        },
        analyticsWordpressString: function () {
            return "default_analyticsWordpressString"
        },
        analyticsDiggString: function () {
            return "default_analyticsDiggString"
        }
    }
};
HD.util.Queue = function () {
    this.items = []
};
HD.util.Queue.prototype = {
    add: function (A) {
        this.items.push(A)
    },
    remove: function (E) {
        var B = [];
        var C = this.items;
        for (var D = 0, A = C.length;
        D < A;
        D++) {
            var F = C[D];
            if (F != E) {
                B.push(F)
            }
        }
        this.items = B
    },
    execute: function () {
        var A = this.items;
        for (var B = A.length - 1;
        B > -1;
        B--) {
            A[B]()
        }
        this.clear()
    },
    clear: function () {
        this.items = []
    },
    contains: function (D) {
        var B = this.items;
        for (var C = 0, A = B.length;
        C < A;
        C++) {
            var E = B[C];
            if (E == D) {
                return true
            }
        }
        return false
    }
};
HD.register("hd_queue", HD.util.Queue, {
    version: "1.0",
    build: "1"
});
HD.AuthorWidget = function (A) {
    this.config = A;
    this.config.renderMode = this.config.renderMode || "list" || "select";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.AuthorWidget.templates = {
    defaultSelectLabel: "By author",
    getDefaultSelectLabel: function () {
        return this.defaultSelectLabel
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.AUTHOR_BREAKDOWN} ${classes.WIDGET}">		{if config.renderMode == "list"}			{for item in items}				{if item }					<div>						<span class="${classes.TITLE} ${classes.CONTROL} ${hooks.ITEM}">${item.userName}</span>						<span class="${classes.VALUE}"> (${item.itemCount})</span>					</div>				{/if}			{/for}		{elseif config.renderMode == "select"}			<select class="${hooks.LIST}">			<option class="${hooks.ITEM}" value="" selected="selected">${templates.getDefaultSelectLabel()}</option>			{for item in items}				{if item}					<option class="${hooks.ITEM}" value="${item.userName}">${item.userName}</option>				{/if}			{/for}			</select>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.AuthorWidget.hooks = {
        ITEM: A.ITEM,
        LIST: A.LIST
    }
})();
HD.AuthorWidget.prototype = {
    setListeners: function (F) {
        var C = this.getParent();
        var G = F;
        if (this.config.renderMode == "list") {
            var B = HD.getByClass(this.config.hooks.ITEM, "*", C);
            var E = 0;
            for (var D in G) {
                if (B[E]) {
                    this.setListener(B[E], D)
                }
                E++
            }
        } else {
            if (this.config.renderMode == "select") {
                var A = this;
                HD.getByClass(this.config.hooks.LIST, "*", C, function (H) {
                    H.onchange = function () {
                        var I = H.options[H.selectedIndex].value;
                        if (I != "") {
                            A.model.setAuthor.call(A.model, F[I])
                        }
                    }
                })
            }
        }
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        if (D != "") {
            C.onclick = function () {
                var E = B;
                A.model.setAuthor.call(A.model, E)
            }
        }
    },
    update: function (A, B) {
        if (A == "getAllBlogAuthors_Finish") {
            this.loading(false);
            this.render(B)
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            items: (A) || []
        })
    }
};
HD.extend(HD.AuthorWidget, [HD.Widget]);
HD.register("hd_author_widget", "HD.AuthorWidget", {
    version: "1.0",
    build: "1"
});
HD.ContextWidget = function (A) {
    this.config = A;
    this.config.dateFormat = this.config.dateFormat || "mmm yyyy";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.ContextWidget.templates = {
    defaultText: "Blog",
    tagsText: "Posts tagged ${filter}",
    authorText: "Posts by ${filter}",
    dateText: "Posts from ${filter}",
    backText: "&#60;&#60; Blog",
    getBackText: function () {
        return this.backText
    },
    getContextText: function (B, A) {
        if (B.tags != null && B.tags.length > 0) {
            return this.tagsText.replace(/\$\{filter\}/, B.tags[0])
        } else {
            if (B.author != null && B.author.length > 0) {
                return this.authorText.replace(/\$\{filter\}/, B.author)
            } else {
                if (B.startDate != null) {
                    return this.dateText.replace(/\$\{filter\}/, HD.util.Date.format(B.startDate, A))
                } else {
                    return this.defaultText
                }
            }
        }
    },
    getHtml: function () {
        return this.html
    },
    html: '		{if data}			<div class="${classes.CONTEXT} ${classes.WIDGET}">				{if filters.tags != null || filters.author != null || filters.startDate != null}					<div class="${classes.BACK} ${hooks.BACK}">					<h2><a href="javascript: void(0);">${templates.getBackText(filters, dateFormat)}</a></h2>					</div>				{/if}				<div class="${classes.TITLE}">				<h1>${templates.getContextText(filters, dateFormat)}</h1>				</div>			</div>		{/if}'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.ContextWidget.hooks = {
        BACK: A.BACK + "-context"
    }
})();
HD.ContextWidget.prototype = {
    setListeners: function (C) {
        var D = HD.getByClass(this.config.hooks.BACK, "*", this.getParent())[0];
        if (D) {
            var A = this.model;
            var B = this;
            D.onclick = function () {
                A.clearDateRange(true);
                A.clearAuthor(true);
                A.clearTags()
            }
        }
    },
    update: function (A, B) {
        if (A == "getMedia_Start") {
            this.loading(true)
        } else {
            if (A == "getMedia_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        this.filters = this.model.filters;
        this.dateFormat = this.config.dateFormat;
        return this.processTemplate(this.config.templates.getHtml(), {
            data: A,
            filters: this.filters,
            dateFormat: this.dateFormat
        })
    },
    analyticsString: function (A) {
        return "default_analyticsDetailString"
    }
};
HD.extend(HD.ContextWidget, [HD.Widget]);
HD.register("hd_context_widget", "HD.ContextWidget", {
    version: "1.0",
    build: "1"
});
HD.FacebookAttendeesWidget = function (A) {
    this.config = A;
    this.config.dateFormat = this.config.dateFormat || "d mmm yyyy 'at' hh:MM tt";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.FacebookAttendeesWidget.templates = {
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.FACEBOOK_ATTENDEES} ${classes.WIDGET}">		{for attendee in attendees}			<div class="${classes.ITEM}">				<div class="${classes.SMALL_THUMB}">				  <img src=${attendee.pic_small} >				</div>				<div class="${classes.THUMB}">				  <img src=${attendee.pic} >				</div>				<div class="${classes.LARGE_THUMB}">				  <img src=${attendee.pic_big} >				</div>				<div class="${classes.TITLE}">					${attendee.name}				</div>			</div>			<div class="${classes.SEPARATOR}"></div>		{/for}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.FacebookAttendeesWidget.hooks = {
        EVENT: A.EVENT
    }
})();
HD.FacebookAttendeesWidget.prototype = {
    setListeners: function (D) {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.EVENT, "*", C)
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        C.onclick = function () {
            A.model.setActiveItem.call(A.model, B);
            A.notifyObservers.call(A, "itemSelected", B)
        }
    },
    update: function (A, B) {
        if (A == "getFacebookAttendeesForEvent_Start") {
            this.loading(true)
        } else {
            if (A == "getFacebookAttendeesForEvent_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            attendees: (A) || []
        })
    }
};
HD.extend(HD.FacebookAttendeesWidget, [HD.Widget]);
HD.register("hd_facebook_attendees_widget", "HD.FacebookAttendeesWidget", {
    version: "1.0",
    build: "1"
});
HD.FacebookEventsWidget = function (A) {
    this.config = A;
    this.config.dateFormat = this.config.dateFormat || "d mmm yyyy 'at' hh:MM tt";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.FacebookEventsWidget.templates = {
    rsvpText: "RSVP",
    hostLabel: "HOSTED BY:",
    noneLabel: "No Events at this Time",
    typeLabel: "TYPE:",
    whereLabel: "WHERE:",
    whenLabel: "WHEN:",
    facebookURL: "http://www.facebook.com/darkcustom?v=app_2344061033&viewas=500036834",
    facebookLinkText: '<a href="${facebookURL}" target="_blank">See more events on our Facebook page</a>',
    getFacebookLinkText: function () {
        return this.facebookLinkText.replace(/\$\{facebookURL\}/, this.getFacebookURL())
    },
    getRsvpText: function () {
        return this.rsvpText
    },
    getHostLabel: function () {
        return this.hostLabel
    },
    getNoneLabel: function () {
        return this.noneLabel
    },
    getTypeLabel: function () {
        return this.typeLabel
    },
    getWhereLabel: function () {
        return this.whereLabel
    },
    getWhenLabel: function () {
        return this.whenLabel
    },
    getFacebookURL: function () {
        return this.facebookURL
    },
    getFacebookTime: function (B) {
        var F = "";
        if (B) {
            var E = B.getUTCFullYear();
            var C = B.getUTCDate();
            var G = B.getUTCMonth();
            var A = B.getUTCHours();
            var D = B.getUTCMinutes();
            F = new Date();
            F.setFullYear(E, G, C);
            F.setHours(A, D, 0, 0)
        }
        return F
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.FACEBOOK_EVENTS} ${classes.WIDGET}">		{if events.length == 0}			<div class="${classes.TITLE}">				${templates.getNoneLabel()}			</div>		{else}			{for event in events}				<div class="${classes.ITEM}">					<div class="${classes.SMALL_THUMB}">					  {if event.pic != ""}						<img src="${event.pic}">					  {/if}				    </div>				    <div class="${classes.EVENT_RSVP}"><a href="${event.eventLink}" target="_blank">${templates.getRsvpText()}</a></div>				    <div class="${classes.DETAIL}">					<div class="${classes.TITLE}">						<a href="${event.eventLink}" target="_blank">${event.name}</a>					</div>					<div class="${classes.DESCRIPTION}">						${event.tagline}					</div>					<div class="${classes.AUTHOR}">						<div class="${classes.LABEL}">${templates.getHostLabel()}</div>						<div class="${classes.VALUE}">${event.host}</div>					</div>					<div class="hdType">						<div class="${classes.LABEL}">${templates.getTypeLabel()}</div>						<div class="${classes.VALUE}">${event.eventType}</div>					</div>					<div class="hdLocation">						<div class="${classes.LABEL}">${templates.getWhereLabel()}</div>						<div class="${classes.VALUE}">${event.location}</div>					</div>					<div class="hdDate">						<div class="${classes.LABEL}">${templates.getWhenLabel()}</div>						<div class="${classes.VALUE}">${templates.getFacebookTime(event.startTime)|date} until ${templates.getFacebookTime(event.endTime)|date}</div>					</div>				</div>				<div class="${classes.SEPARATOR}"></div>			</div>			{/for}			<div class="${classes.VIEW_ALL}">${templates.getFacebookLinkText()}</div>		{/if}		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.FacebookEventsWidget.hooks = {
        EVENT: A.EVENT
    }
})();
HD.FacebookEventsWidget.prototype = {
    setListeners: function (D) {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.EVENT, "*", C)
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        C.onclick = function () {
            A.model.setActiveItem.call(A.model, B);
            A.notifyObservers.call(A, "itemSelected", B)
        }
    },
    update: function (A, B) {
        if ((A == "getFacebookEvents_Start") || (A == "getFutureFacebookEvents_Start")) {
            this.loading(true)
        } else {
            if ((A == "getFacebookEvents_Finish") || (A == "getFutureFacebookEvents_Finish")) {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            events: (A) || []
        })
    }
};
HD.extend(HD.FacebookEventsWidget, [HD.Widget]);
HD.register("hd_facebook_events_widget", "HD.FacebookEventsWidget", {
    version: "1.0",
    build: "1"
});
HD.TwitterFeedWidget = function (A) {
    this.config = A;
    this.config.dateFormat = this.config.dateFormat || "d mmm yyyy 'at' hh:MM tt";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.TwitterFeedWidget.templates = {
    twitterLabel: "TWEETS @ DARKCUSTOM",
    twitterViewText: "VIEW",
    twitterReplyText: "REPLY",
    twitterReTweetText: "RT",
    twitterViewURL: "http://twitter.com/${tweetAUTHOR}/statuses/${tweetID}",
    twitterReplyURL: "http://twitter.com/home?status=%40${tweetAUTHOR}&in_reply_to_status_id=${tweetID}&in_reply_to=${tweetAUTHOR}",
    twitterReTweetURL: "http://twitter.com/home?status=RT+%40${tweetAUTHOR}:${tweetTEXT}",
    twitterFollowText: '<a href="${twitterFollowURL}" target="_blank">Follow Dark Custom on Twitter</a>',
    twitterFollowURL: "http://twitter.com/darkcustom",
    getTwitterLabel: function () {
        return this.twitterLabel
    },
    getTwitterViewText: function () {
        return this.twitterViewText
    },
    getTwitterReplyText: function () {
        return this.twitterReplyText
    },
    getTwitterReTweetText: function () {
        return this.twitterReTweetText
    },
    getTwitterFollowText: function (A) {
        return this.twitterFollowText.replace(/\$\{twitterFollowURL\}/, this.getTwitterFollowURL())
    },
    getTwitterViewURL: function (B) {
        var A = this.twitterViewURL.replace(/\$\{tweetAUTHOR\}/, B.fromScreenName);
        return A.replace(/\$\{tweetID\}/, B.id)
    },
    getTwitterReplyURL: function (B) {
        var A = this.twitterReplyURL.replace(/\$\{tweetAUTHOR\}/g, B.fromScreenName);
        return A.replace(/\$\{tweetID\}/, B.id)
    },
    getTwitterReTweetURL: function (B) {
        var A = this.twitterReTweetURL.replace(/\$\{tweetAUTHOR\}/, B.fromScreenName);
        return A.replace(/\$\{tweetTEXT\}/, encodeURIComponent(B.text))
    },
    getTwitterFollowURL: function () {
        return this.twitterFollowURL
    },
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.TWITTER_TWEET} ${classes.WIDGET}">			<div class="${classes.TITLE}">${templates.getTwitterLabel()}</div>			{var postIndex = 0}			{for tweet in tweets}				{eval}				postIndex++;				{/eval} 				{if postIndex % 2 == 0}					<div class="${classes.TWEET} ${classes.ACTIVE}">				{else}					<div class="${classes.TWEET}">				{/if}					<div class="${classes.AUTHOR}">			          ${tweet.fromScreenName}			        </div>					<div class="${classes.DESCRIPTION}">			          ${tweet.text}			        </div>					<div class="${classes.DATE}">						${tweet.createdAt|date}					</div>					<div class="${classes.WRAPPER}">						<div class="${classes.VIEW}">							<a href="${templates.getTwitterViewURL(tweet)}" target="_blank">${templates.getTwitterViewText()}</a>						</div>						<div class="${classes.REPLY}">							<a href="${templates.getTwitterReplyURL(tweet)}" target="_blank">${templates.getTwitterReplyText()}</a>						</div>						<div class="${classes.RETWEET}">							<a href="${templates.getTwitterReTweetURL(tweet)}" target="_blank">${templates.getTwitterReTweetText()}</a>						</div>					</div>					<div class="${classes.SEPARATOR}"></div>				</div>			{/for}			<div class="${classes.SUBSCRIBE}">				${templates.getTwitterFollowText()}			</div>			<div class="${classes.SEPARATOR}"></div>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.TwitterFeedWidget.hooks = {
        EVENT: A.EVENT
    }
})();
HD.TwitterFeedWidget.prototype = {
    setListeners: function (D) {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.EVENT, "*", C)
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        C.onclick = function () {
            A.model.setActiveItem.call(A.model, B);
            A.notifyObservers.call(A, "itemSelected", B)
        }
    },
    update: function (A, B) {
        if (A == "getTwitterFeed_Start") {
            this.loading(true)
        } else {
            if (A == "getTwitterFeed_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            tweets: (A) || []
        })
    }
};
HD.extend(HD.TwitterFeedWidget, [HD.Widget]);
HD.register("hd_twitter_feed_widget", "HD.TwitterFeedWidget", {
    version: "1.0",
    build: "1"
});
HD.YoutubeWidget = function (A) {
    this.config = A;
    this.config.dateFormat = this.config.dateFormat || "d mmm yyyy 'at' hh:MM tt";
    this.observers = [];
    this.loadTemplates(arguments.callee)
};
HD.YoutubeWidget.templates = {
    youtubeLabel: "Youtube",
    getHtml: function () {
        return this.html
    },
    html: '		<div class="${classes.YOUTUBE} ${classes.WIDGET}">		  {for youtubeMedia in youtubeMedias}		  <div class="${classes.TITLE}">${youtubeMedia.title}</div>				<div class="${classes.YOUTUBE_VIDEO}">					<div class="${classes.AUTHOR}">			          <BR>uploader: ${youtubeMedia.uploader}			          <BR>description: ${youtubeMedia.description}			          <BR>uploadedDate: ${youtubeMedia.uploadedDate}			          <BR>duration: ${youtubeMedia.duration}			          <BR>type: ${youtubeMedia.type}			          <BR>mediaUrl: ${youtubeMedia.mediaUrl}			          <BR>playerUrl: ${youtubeMedia.playerUrl}			          <BR>thumbnailUrl: ${youtubeMedia.thumbnailUrl}			          <BR>height: ${youtubeMedia.thumbnailHeight}			          <BR>width: ${youtubeMedia.thumbnailWidth}			        </div>				</div>			{/for}			<div class="${classes.SEPARATOR}"></div>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.YoutubeWidget.hooks = {
        EVENT: A.EVENT
    }
})();
HD.YoutubeWidget.prototype = {
    setListeners: function (D) {
        var B = HD.CSS_CLASSES;
        var C = this.getParent();
        var A = HD.getByClass(this.config.hooks.EVENT, "*", C)
    },
    setListener: function (C, D) {
        if (C == null || D == null) {
            return
        }
        var A = this;
        var B = D;
        C.onclick = function () {
            A.model.setActiveItem.call(A.model, B);
            A.notifyObservers.call(A, "itemSelected", B)
        }
    },
    update: function (A, B) {
        if (A == "getYoutube_Start") {
            this.loading(true)
        } else {
            if (A == "getYoutube_Finish") {
                this.loading(false);
                this.render(B)
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml(), {
            youtubeMedias: (A) || []
        })
    }
};
HD.extend(HD.YoutubeWidget, [HD.Widget]);
HD.register("hd_youtube_widget", "HD.YoutubeWidget", {
    version: "1.0",
    build: "1"
});
if (!HD) {
    var HD = {
        util: {}
    }
} else {
    if (!HD.util) {
        HD.util = {}
    }
}
if(typeof HD.util.Analytics == "undefined" || !HD.util.Analytics){
	HD.util.Analytics = {
		track: function (A) {}
	};
}
HD.RidePlannerWidget = function (A) {
    A = A || {};
    var B = HD.util.Common.hasValue;
    if (!B(A.type)) {
        A.type = "hd_ride_planner_widget"
    }
    if (!B(A.zoomLevel)) {
        A.zoomLevel = 10
    }
    this.config = A || {};
    this.config.ridePlannerURL = this.config.ridePlannerURL || "http://rideplanner.harley-davidson.com/rideplanner/ridePlanner.jsp";
    this.observers = [];
    this.loadTemplates(arguments.callee);
    this.geocoder = new HD.util.Geocoder();
    this.geocoder.addObserver(this)
};
HD.RidePlannerWidget.templates = {
    ridePlannerLabel: "Look for Rides in Your Area",
    buttonText: "Go",
    inputText: "address, city, state or zip",
    invalidLocationText: "Please enter a valid location",
    geocodeErrorText: "Could not resolve location ",
    getLabelText: function () {
        return this.ridePlannerLabel
    },
    getButtonText: function () {
        return this.buttonText
    },
    getInputText: function () {
        return this.inputText
    },
    getInvalidLocationErrorMessage: function () {
        return this.invalidLocationText
    },
    getGeocodeErrorMessage: function (A) {
        return this.geocodeErrorText + A
    },
    getDisambiguateHtml: function () {
        return this.disambiguateHtml
    },
    getHtml: function () {
        return this.html
    },
    disambiguateHtml: '		{for geocode in geocodes}			<a href="javascript:void();" class="${classes.ITEM} ${hooks.AMBIGLINK}">${geocode.name}</a><br/>		{/for}',
    html: '		<div class="${classes.RIDE_PLANNER} ${classes.WIDGET}">       	 	<form class="${hooks.LOCATIONFORM}">       	 		<div class="${classes.LABEL}">${templates.getLabelText()}</div>       	 		<div class="${classes.ERROR} ${hooks.ERROR}"></div>       	 		<input class="${classes.VALUE} ${hooks.LOCATIONINPUT}" value="${templates.getInputText()}"/>       	 		<input class="${classes.SUBMIT} ${hooks.LOCATIONBUTTON}" value="${templates.getButtonText()}" type="submit"/>       	 		<div class="${classes.MORE} ${classes.HIDDEN} ${hooks.MORE}"></div>       	 	</form>		</div>'
};
(function () {
    var A = HD.CSS_CLASSES;
    HD.RidePlannerWidget.hooks = {
        LOCATIONFORM: A.RIDE_PLANNER + "-locform",
        LOCATIONINPUT: A.RIDE_PLANNER + "-locinput",
        LOCATIONBUTTON: A.RIDE_PLANNER + "-locbutton",
        ERROR: A.RIDE_PLANNER + "-error",
        MORE: A.RIDE_PLANNER + "-more",
        AMBIGLINK: A.RIDE_PLANNER + "-ambilink"
    }
})();
HD.RidePlannerWidget.prototype = {
    setListeners: function (E) {
        var D = this.getParent();
        var G = HD.getByClass(this.config.hooks.LOCATIONINPUT, "*", D)[0];
        var C = HD.getByClass(this.config.hooks.LOCATIONFORM, "*", D)[0];
        var B = HD.RidePlannerWidget.templates.getInputText();
        var F = this.geocoder;
        G.onfocus = function () {
            if (this.value == B) {
                this.value = ""
            }
        };
        G.onblur = function () {
            if (this.value == "") {
                this.value = B
            }
        };
        var A = this;
        C.onsubmit = function () {
            A.clearDisambiguate.call(A);
            A.clearError.call(A);
            var H = HD.util.Common.stripHtmlTags(G.value);
            if (!A.isValidLocation.call(A, H)) {
                A.showError.call(A, HD.RidePlannerWidget.templates.getInvalidLocationErrorMessage());
                return false
            }
            F.geocode.call(F, H);
            return false
        }
    },
    isValidLocation: function (A) {
        if (!HD.util.Common.hasValue(A)) {
            return false
        }
        if (A == HD.RidePlannerWidget.templates.getInputText()) {
            return false
        }
        if (!A.match(/[\d\w]+/)) {
            return false
        }
        return true
    },
    update: function (A, B) {
        if (A == "geocode_Start") {
            this.clearError();
            this.loading(true)
        } else {
            if (A == "geocode_Finish") {
                this.loading(false);
                this.clearError();
                this.renderResults(B.geocodes)
            } else {
                if (A == "geocode_Error") {
                    this.loading(false);
                    this.showError(HD.RidePlannerWidget.templates.getGeocodeErrorMessage(B.location))
                }
            }
        }
    },
    getHtml: function (A) {
        return this.processTemplate(this.config.templates.getHtml())
    },
    analyticsString: function (A) {
        return "default_analyticsRidePlannerWidgetString"
    },
    renderResults: function (D) {
        var A = HD.CSS_CLASSES;
        var C = this.getParent();
        var E = HD.getByClass(this.config.hooks.LOCATIONINPUT, "*", C)[0];
        if (D.length == 1) {
            var B = D[0];
            E.value = B.name;
            this.openRidePlanner(B.latLon)
        } else {
            this.showDisambiguate(D)
        }
    },
    openRidePlanner: function (A) {
        this.clearDisambiguate();
        var C = this.config;
        var D = "";
        if (C.showUserRoads) {
            D += "&showUserRoads=true"
        }
        if (C.showGreatRoads) {
            D += "&showGreatRoads=true"
        }
        var B = this.config.ridePlannerURL + "?latitude=" + A.latitude + "&longitude=" + A.longitude + "&zoomLevel=" + C.zoomLevel + D;
        window.open(B, "", "scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no")
    },
    showError: function (A) {
        var B = this.getParent();
        var C = HD.getByClass(this.config.hooks.ERROR, "*", B)[0];
        C.innerHTML = A
    },
    clearError: function () {
        var A = this.getParent();
        var B = HD.getByClass(this.config.hooks.ERROR, "*", A)[0];
        B.innerHTML = ""
    },
    showDisambiguate: function (F) {
        var E = this.getParent();
        var D = HD.CSS_CLASSES;
        var H = HD.getByClass(this.config.hooks.MORE, "*", E)[0];
        HD.removeClass(H, D.HIDDEN);
        H.innerHTML = this.processTemplate(this.config.templates.getDisambiguateHtml(), {
            geocodes: F
        });
        var B = this;
        var G = HD.getByClass(this.config.hooks.AMBIGLINK, "*", E);
        for (var C = 0, A = F.length;
        C < A;
        C++) {
            (function () {
                var I = F[C];
                G[C].onclick = function () {
                    B.clearDisambiguate.call(B);
                    B.renderResults.call(B, [I])
                }
            }())
        }
    },
    clearDisambiguate: function () {
        var B = this.getParent();
        var A = HD.CSS_CLASSES;
        var C = HD.getByClass(this.config.hooks.MORE, "*", B)[0];
        HD.addClass(C, A.HIDDEN);
        C.innerHTML = ""
    }
};
HD.extend(HD.RidePlannerWidget, [HD.Widget]);
HD.register("hd_ride_planner_widget", "HD.RidePlannerWidget", {
    version: "1.0",
    build: "1"
});
HD.util.Geocoder = function (A) {
    this.config = A || {};
    this.observers = []
};
HD.util.Geocoder.prototype = {
    geocode: function (B) {
        this.notifyObservers("geocode_Start");
        var A = this;
        var D = {
            location: B
        };
        var C = {
            callback: function (E) {
                var F = E.success && E.geocodes != null ? "geocode_Finish" : "geocode_Error";
                A.notifyObservers.call(A, F, E)
            }
        };
        GeocoderService.geocode(D, C)
    }
};
HD.extend(HD.util.Geocoder, [HD.util.Observable]);
HD.register("hd_geocoder", "HD.util.Geocoder", {
    version: "1.0",
    build: "1"
});
