﻿var jSING = { utils: { getTargetID: function(item) { var href = item.attr("href"), bits = href.split(/\//), id = bits[bits.length - 1]; if (id.charAt(0) == "#") { return id } else { return null } } }, navigation: { superfish: function() {
    var path = "current"; var navContainer = $("ul#site_nav"); if (navContainer.length) {
        var current_nav = navContainer.attr("class").match(/nav_[a-z]*/); if (current_nav == null || current_nav[0] == "nav_") { $("ul#site_nav li#nav_news").addClass(path) } else { $("ul#site_nav li#" + current_nav[0]).addClass(path); $("ul#site_nav li#" + current_nav[0] + " > ul.secondary_nav").css("display", "block") } $("ul#site_nav").superfish({ pathClass: path, hoverClass: "hover", pathLevels: 2, delay: 1500, speed: "fastest", autoArrows: true, dropShadows: false })
    } 
}, navPosition: function() { var wrapper_offset = $("#page_wrapper").offset(), nav_offset = 844 + wrapper_offset.left; $("ul.tertiary_nav").each(function() { var offset = $(this).offset(); if (offset.left > nav_offset) { $(this).addClass("shift_left") } }); $("ul.quaternary_nav").each(function() { var offset = $(this).offset(); if (offset.left > nav_offset) { $(this).addClass("pop_left") } }) }, init: function() { this.navPosition(); this.superfish() } 
}, carousels: { utils: { pauseAutoScrollOnHover: function(carousel) { carousel.clip.hover(function() { carousel.stopAuto() }, function() { carousel.startAuto() }) } }, alertBarCarousel: { doAlertBarCarousel: function(carousel) {
    var controls = "<div id='alert_bar_controls'><a href='#alert_bar_carousel' class='alert_bar_control alert_bar_prev'>Previous</a><div id='alert_bar_counter'><span id='alert_bar_counter_current'>1</span> of <span id='alert_bar_counter_total'>" + carousel.size() + "</span></div><a href='#alert_bar_carousel' class='alert_bar_control alert_bar_next'>Next</a></div>";
    $("#alert_bar_clipper").prepend(controls); $("#alert_bar_controls a.alert_bar_prev").bind("click", function() { carousel.prev(); carousel.startAuto(0); return false }); $("#alert_bar_controls a.alert_bar_next").bind("click", function() { carousel.next(); carousel.startAuto(0); return false }); jSING.carousels.utils.pauseAutoScrollOnHover(carousel)
}, alertBarOnSlide: function(carousel, item, current_page, state) { $("#alert_bar_counter_current").text(current_page) }, init: function() {
    var alertBar = $("#alert_bar_carousel"); if (alertBar.children().size() > 1) {
        alertBar.jcarousel({ vertical: true, auto: 6, animation: 250, easing: "swing", scroll: 1, wrap: "both", initCallback: this.doAlertBarCarousel, itemFirstInCallback: this.alertBarOnSlide, buttonNextHTML: null, buttonPrevHTML: null })
    } 
} 
}, skyboxCarousel: { doSkyboxCarousel: function(carousel) {
    var pages = $("#skybox_carousel").children().size(); var controls_list = $("#skybox_controls ul"), controls = "<a href='#skybox_carousel' class='carousel_control carousel_prev' title='See previous group of skyboxes'>Previous</a><a href='#skybox_carousel' class='carousel_control carousel_next' title='See next group of skyboxes'>Next</a>"; controls_list.after(controls); for (i = 1; i <= pages; i++) { controls_list.append("<li><a href='#skybox_wrapper' id='page" + i + "' title='Jump to Skybox page " + i + "'>" + i + "</a></li>") } $("#skybox_controls ul li:first-child").addClass("current");
    $("#skybox_controls li").bind("click", function() { carousel.scroll($.jcarousel.intval($(this).text())); $("#skybox_controls li").each(function() { if ($(this).hasClass("current")) { $(this).removeClass("current") } }); $(this).toggleClass("current"); return false }); $("#skybox_controls .carousel_next").bind("click", function() { carousel.next(); jSING.apptap.execAppTapEvent(this, "Event64", false); return false }); $("#skybox_controls .carousel_prev").bind("click", function() { carousel.prev(); jSING.apptap.execAppTapEvent(this, "Event64", false); return false })
}, skyboxOnSlide: function(carousel, item, current_page, state) {
    $("#skybox_controls ul li a").each(function() {
        if ($(this).attr("id") == "page" + current_page) {
            $(this).parent().addClass("current")
        } else { $(this).parent().removeClass("current") } 
    })
}, init: function() { var skyboxes = $("#skybox_carousel"); if (skyboxes.length) { skyboxes.jcarousel({ initCallback: this.doSkyboxCarousel, scroll: 1, wrap: "both", buttonNextHTML: null, buttonPrevHTML: null, itemFirstInCallback: this.skyboxOnSlide }) } } 
}, posterCarousel: { doPosterCarousel: function(carousel) {
    var pages = $("#poster").children().size(), controls_list = $("#poster_controls ul"), controls = "<a href='#poster' class='carousel_control carousel_prev' title='See previous poster content'>Previous</a><a href='#poster' class='carousel_control carousel_next' title='See next poster content'>Next</a>";
    controls_list.after(controls); for (i = 1; i <= pages; i++) { controls_list.append("<li><a href='#poster' id='page" + i + "' + title='See poster page: " + i + "'>" + i + "</a></li>") } $("#poster_controls ul li:first-child").addClass("current"); $("#poster_controls li").bind("click", function() { carousel.scroll($.jcarousel.intval($(this).text())); $("#poster_controls li").each(function() { if ($(this).hasClass("current")) { $(this).removeClass("current") } }); $(this).toggleClass("current"); carousel.startAuto(0); return false }); $("#poster_controls a.carousel_prev").bind("click", function() {
        carousel.prev(); carousel.startAuto(0); jSING.apptap.execAppTapEvent(this, "Event65", false);
        return false
    }); $("#poster_controls a.carousel_next").bind("click", function() { carousel.next(); carousel.startAuto(0); jSING.apptap.execAppTapEvent(this, "Event65", false); return false }); jSING.carousels.utils.pauseAutoScrollOnHover(carousel)
}, posterOnSlide: function(carousel, item, current_page, state) { $("#poster_controls ul li a").each(function() { if ($(this).attr("id") == "page" + current_page) { $(this).parent().addClass("current") } else { $(this).parent().removeClass("current") } }) }, init: function() {
    var poster = $("#poster"); if (poster.children().size() > 1) {
        poster.jcarousel({ auto: 8, animation: 250, easing: "linear", scroll: 1, wrap: "both", initCallback: this.doPosterCarousel, itemFirstInCallback: this.posterOnSlide, buttonNextHTML: null, buttonPrevHTML: null })
    } 
} 
}, inlineCarousels: { doInlineGalleries: function(carousel) {
    var re = /\d+/, photoGallery = carousel.container.parent(".inline_carousel_wrapper"), photoGalleryWrapper = photoGallery.parents(".inline_carousel").eq(0), photoGalleryUL = photoGallery.find("ul.story_gallery").eq(0), photoGalleryItemsTotal = photoGalleryUL.children().size(); id = re.exec(photoGallery.attr("id"))[0]; if (photoGallery.hasClass("fullwidth")) {
        var inlineControls = "<div class='gallery_controls'><a href='#'	 id='gallery_" + id + "_prev' class='carousel_control carousel_prev'>Previous</a><a href='#' id='gallery_" + id + "_next' class='carousel_control carousel_next'>Next</a></div>", inlineControlsPredecessor = photoGalleryWrapper.find("h4").eq(0)
    } else { var inlineControls = "<div class='controls_wrapper'><div class='gallery_controls_sidebar'><a href='#'	 id='gallery_" + id + "_prev' class='carousel_control carousel_prev'>Previous</a> <span class='gallery_index'><span class='gallery_index_current'>1</span> of <span class='gallery_index_total'>" + photoGalleryItemsTotal + "</span></span> <a href='#' id='gallery_" + id + "_next' class='carousel_control carousel_next'>Next</a></div></div>", inlineControlsPredecessor = photoGalleryUL } inlineControlsPredecessor.after(inlineControls); $("a#gallery_" + id + "_next").bind("click", function() {
        carousel.next(); return false
    }); $("a#gallery_" + id + "_prev").bind("click", function() { carousel.prev(); return false })
}, inlineGalleryFirstInCallback: function(carousel, item, idx, state) { if (!carousel.container.parent(".inline_carousel_wrapper").hasClass("fullwidth")) { carousel.container.find(".gallery_index_current").eq(0).html(idx) } }, init: function() {
    var inlineCarousels = $(".inline_carousel"); if (inlineCarousels.length) {
        $(".inline_carousel_wrapper ul.story_gallery").jcarousel({ initCallback: this.doInlineGalleries, animation: "fast", easing: "linear", scroll: 1, wrap: "both", itemFirstInCallback: this.inlineGalleryFirstInCallback, buttonNextHTML: null, buttonPrevHTML: null })
    } 
} 
}, init: function() { var self = this; self.alertBarCarousel.init(); self.skyboxCarousel.init(); self.posterCarousel.init(); self.inlineCarousels.init() } 
}, tabs: { doTabs: function() { $(".tab_wrapper").tabs() }, init: function() { this.doTabs() } }, ajax: { createQuery: function(selectField) { var query = ""; selectField.each(function(i) { if ($(this).val() != "") { query += $(this).attr("name") + "=" + $(this).val() + "&" } }); return query.substring(0, query.length - 1) }, searchFilter: function(url) {
    var self = this; $("input#search_button").remove(); var selectField = $("#browse_search_form .vSelectField"), loadingDiv = $("#main_loader"), pageLinks = $("#results_list li ul.paginated_arrows li a");
    loadingDiv.ajaxStart(function() { $(this).show().next().fadeTo("medium", 0.25) }); loadingDiv.ajaxStop(function() { $(this).hide().next().fadeTo("medium", 1) }); self.createQuery(selectField); selectField.change(function() { var query = self.createQuery(selectField); $.ajax({ type: "GET", url: url, data: query, dataType: "html", success: function(results) { $("ul#results_list.browse_list").html(results) } }) }); pageLinks.live("click", function() {
        var query = self.createQuery(selectField); query += "&page=" + $(this).attr("id"); $.ajax({ type: "GET", url: url, data: query, dataType: "html", success: function(results) {
            $("ul#results_list.browse_list").html(results)
        } 
        }); return false
    })
} 
}, calendars: { config: { ajaxMonthURL: "/calendar/event/_async_month_calendar/" }, ajaxRequest: function(url, query, resultsSelector, callback) { var self = this, callback = callback || function() { return null }; $.ajax({ type: "GET", url: url, data: query, dataType: "html", success: function(results) { $(resultsSelector).html(results); callback() } }) }, monthNav: function(resultsSelector) { var self = this; $("td.month_nav a").click(function() { query = $(this).attr("value"); self.ajaxRequest(self.config.ajaxMonthURL, query, resultsSelector, function() { self.monthNav(resultsSelector) }); return false }) }, calTabsSecondary: function(containerSelector, resultsSelector) {
    var self = this, query = "";
    containerSelector = containerSelector || "#sidebar_events", resultsSelector = resultsSelector || "#calendar_results", loader = $(containerSelector + "_loader"); $(containerSelector + " li.cal_tab_last a").click(function() { loader.ajaxStart(function() { $(this).show(); $(resultsSelector).fadeTo("medium", 0.25) }); loader.ajaxStop(function() { $(this).hide(); $(resultsSelector).fadeTo("medium", 1) }); $(this).parent().siblings().removeClass("ui-tabs-selected"); $(this).parent().addClass("ui-tabs-selected"); self.ajaxRequest(self.config.ajaxMonthURL, "", resultsSelector, function() { self.monthNav(resultsSelector) }); return false })
}, filterQuery: function() {
    var query = "";
    var date = $("#events_browse ul.cal_tab_header li.ui-tabs-selected:first").eq(0).children("a:first").attr("value"); $("#browse_search_form .vSelectField").each(function(i) { var field = $(this), fieldVal = field.val(); if (fieldVal != "") { if (query != "") { query += "&" } query += field.attr("name") + "=" + fieldVal } }); return query + "&start_date=" + date
}, handleCalendarSelect: function() {
    var self = this; $("#browse_search_form .vSelectField").change(function() {
        $("#filter_load").ajaxStart(function() { $(this).show(); $(this).next().fadeTo("medium", 0.25) }); $("#filter_load").ajaxStop(function() {
            $(this).hide(); $(this).next().fadeTo("medium", 1)
        }); query = self.filterQuery() + "&framing=event_filter_list"; self.ajaxRequest("/events/", query, "ul.browse_list")
    })
}, calTabsPrimary: function() {
    var self = this, resultsSelector = "#events_browse .search_results_wrapper"; var query; $("input#search_button").remove(); $("#events_browse ul.cal_tab_header li a").click(function() {
        $("#events_browse .ajax_loader").ajaxStart(function() { $(this).show(); $(this).next().fadeTo("medium", 0.25) }); $("#events_browse .ajax_loader").ajaxStop(function() { $(this).hide(); $(this).next().fadeTo("medium", 1) }); $(this).parent().siblings().removeClass("ui-tabs-selected"); $(this).parent().addClass("ui-tabs-selected");
        if ($(this).hasClass("browse_cal")) { self.ajaxRequest(self.config.ajaxMonthURL, query, resultsSelector, function() { self.monthNav(resultsSelector) }) } else { query = "start_date=" + $(this).attr("value") + "&framing=event_day_list"; self.ajaxRequest("/events/", query, "#events_browse .search_results_wrapper", function() { self.handleCalendarSelect(); $("input#search_button").remove() }) } return false
    }); self.handleCalendarSelect()
}, init: function() { jSING.calendars.calTabsSecondary() } 
}, comments: { config: function() { if (typeof jSINGCommentsConfig !== "undefined") { return jSINGCommentsConfig } return null }, loadComments: function(baseurl, page, comment) {
    var self = this, conf = self.config(), getComment = comment || 0, getPage = page || 0, getURL = baseurl + getPage + "/", loaderElement = '<div id="filter_load" class="ajax_loader" style="display: block;"><img src="' + conf.loadImgURL + '" alt="Loading content" /><p>&nbsp;&nbsp;&nbsp;Loading...</p></div>', jcomments = $("#comments_container"), d = {};
    jcomments.html(loaderElement); if (getComment != 0) { d.comments_id = getComment } else { if (window.location.hash && conf.firstCommentsLoad) { var re_exec = /c[\d]+/.exec(window.location.hash); if (re_exec) { d.comments_id = re_exec[0].replace("c", "") } } } $.get(getURL, d, function(data) { jcomments.html(data); self.handleCommentsLinks(); self.initNonPublicCommentLinks(); self.updateCommentCounts(".dynamic_comment_count"); if (d.comments_id && conf.firstCommentsLoad) { $.scrollTo($("#c" + d.comments_id.toString())) } conf.firstCommentsLoad = false; jSINGCommentsConfig.firstCommentsLoad = false })
}, revealComment: function(element) {
    var comment = $("#ccr" + element), warning = $("#cch" + element);
    if (comment.length > 0 && warning.length > 0) { comment.show(); warning.hide() } 
}, writeCommentCookie: function(action) { document.cookie = "hidecomments=" + encodeURIComponent(action) + "; path=/; max-age=" + (60 * 60 * 24 * 365) }, toggleComments: function(toggleLink, commentsDiv) { var self = this, conf = self.config(); if (toggleLink.text() == "Hide") { commentsDiv.hide(); toggleLink.text("Show"); self.writeCommentCookie("out") } else { self.loadComments(conf.commentsURL, 0, 0); commentsDiv.show(); toggleLink.text("Hide"); self.writeCommentCookie("in") } }, handleCommentsLinks: function() {
    var self = this, conf = self.config(); $(".comments_prev").click(function(event) {
        event.preventDefault();
        $.scrollTo($("#comments")); self.loadComments(conf.commentsURL, conf.commentsPreviousPage, 0)
    }); $(".comments_next").click(function(event) { event.preventDefault(); $.scrollTo($("#comments")); self.loadComments(conf.commentsURL, conf.commentsNextPage, 0) }); $("select.comments_pages_select").change(function() { $.scrollTo($("#comments")); var selectedOption = $(this).children("option:selected"), re = /\d+/; newIndex = re.exec(selectedOption.attr("class"))[0] * 1; self.loadComments(conf.commentsURL, newIndex, 0) })
}, updateCommentCounts: function(destinationSelector) {
    var re = /\d+/, commentCount = re.exec($("#comment_wrapper .comment_list_wrapper:first").attr("id"))[0] * 1;
    if ($("#titlebar_comment_count").length == 0) { var titlebarCommentCount = ' <span id="titlebar_comment_count">&raquo; <span class="' + destinationSelector.replace(".", "") + '"></span></span>'; $("#comments .titlebar:first h3:first").append(titlebarCommentCount) } $(destinationSelector).each(function() { $(this).text(commentCount) })
}, initNonPublicCommentLinks: function() { $("p.comment-not-public-warning a").click(function(event) { event.preventDefault(); var link = $(this), href = jSING.utils.getTargetID(link), commentDiv = $(href); link.parent().fadeOut("fast", function() { commentDiv.fadeIn() }) }) }, init: function() {
    var self = this, conf = self.config(), commentsDiv = $("#comments"), toggleDiv = $("#comment_wrapper");
    if (conf != null && commentsDiv.length > 0) {
        if (conf.hideComments == true) { toggleDiv.hide(); var toggleText = "Show" } else { var toggleText = "Hide" } var toggleUL = '<ul class="deeplinks"><li><a href="#comments" id="comments_toggle">' + toggleText + "</a></li></ul>", commentsTitlebar = $("#comments .titlebar:first"); commentsTitlebar.append(toggleUL); $("#comments_toggle").click(function(event) { event.preventDefault(); self.toggleComments($(this), toggleDiv) }); self.handleCommentsLinks(); self.initNonPublicCommentLinks(); if (conf.loadCommentsData.url) {
            self.loadComments(conf.loadCommentsData.url, conf.loadCommentsData.page, conf.loadCommentsData.comment)
        } 
    } 
} 
}, maps: { handleStaticMaps: function() { var self = this, staticMaps = $(".mapwindow_static"), re = /\d+/; if (staticMaps.length) { staticMaps.each(function() { var staticMap = $(this), mapID = re.exec(staticMap.attr("id"))[0], yahooMapInfo = jSINGconf.maps.yahooMapList[mapID]; self.yahooMap(yahooMapInfo.id, yahooMapInfo.lat, yahooMapInfo["long"], yahooMapInfo.name, yahooMapInfo.address, yahooMapInfo.city, yahooMapInfo.state, yahooMapInfo.width, yahooMapInfo.height) }) } }, handleMapLinks: function() {
    var self = this, mapLinks = $(".browse_list_maplink"), loaderImage = jSINGconf.ajax.loaderImageURL, loader = $('<div class="ajax_loader" style="display: block; height: 32px;"><img src="' + loaderImage + '" alt="Loading map" width="32" height="32" /></div>'), re = /\d+/;
    mapLinks.live("click", function(e) { e.preventDefault(); var mapLink = $(this), mapID = re.exec(mapLink.attr("id"))[0]; var yahooMapDiv = $("#mapwindow_" + mapID); if (!yahooMapDiv.length) { var yahooMapLink = jSINGconf.maps.yahooMapList[mapID], yahooMapDiv = $('<div id="mapwindow_' + mapID + '" class="list_map"></div>'); yahooMapDiv.append(loader); mapLink.after(yahooMapDiv); self.yahooMap(yahooMapLink.id, yahooMapLink.lat, yahooMapLink["long"], yahooMapLink.name, yahooMapLink.address, yahooMapLink.city, yahooMapLink.state, yahooMapLink.width, yahooMapLink.height); loader.remove() } yahooMapDiv.slideToggle() })
}, yahooMap: function(id, latitude, longitude, name, address, city, zip, width, height) {
    var mapsize = new YSize(width, height), mapDiv = document.getElementById("mapwindow_" + id), map = new YMap(mapDiv, YAHOO_MAP_REG, mapsize);
    map.addZoomShort(); map.disableKeyControls(); map.removeZoomScale(); var geopoint = new YGeoPoint(latitude, longitude), newMarker = new YMarker(geopoint); var markerMarkup = "<div style='padding: 3px 7px; font-family: Verdana; font-size: 0.8em; width: 175px;'><strong>" + name + "</strong><br/>" + address + "<br/>" + city + " " + zip + "</div>"; YEvent.Capture(newMarker, EventsList.MouseClick, function() { newMarker.openSmartWindow(markerMarkup) }); map.addOverlay(newMarker); map.drawZoomAndCenter(geopoint, 5)
}, init: function() { var self = this; self.handleStaticMaps(); self.handleMapLinks() } 
}, reordering: { config: { reorderableItemsSelector: "", adIndex: 0, adSelector: "", reorderCookieName: "", containerSelector: "" }, getNormalizedHeight: function(item, margin) {
    var h1 = item.outerHeight(true), h2 = item.outerHeight(false);
    if (h1 == h2) { return h1 + margin } return h1
}, showReorder: function() {
    if (!preventReorder) {
        margin = 21; itemA = $(this); itemAID = itemA.attr("id"); itemAIndex = reorderableItems.index(itemA); itemAHeight = jSING.reordering.getNormalizedHeight(itemA, margin); itemAName = itemA.find(".titlebar h3").eq(0).text(); function reorderItems(thisLink, direction) {
            preventReorder = true; function swap(itemA, direction) {
                adCheck = 0; switch (direction) {
                    case "up": itemBIndex = itemAIndex - 1; itemB = $(reorderableItems.get(itemBIndex)); itemBYModifier = "+="; itemAYModifier = "-="; if (adIndex > 0) { adCheck = adIndex } break; case "down": itemBIndex = itemAIndex + 1; itemB = $(reorderableItems.get(itemBIndex));
                        itemBYModifier = "-="; itemAYModifier = "+="; if (adIndex > 0) { adCheck = adIndex - 1 } break
                } itemBHeight = jSING.reordering.getNormalizedHeight(itemB, margin); adHeight = 0; if (adIndex > 0 && itemAIndex == adCheck) { ad = $(adSelector); if (ad.length) { if (ad.length > 1) { ad = ad.eq(0) } adHeight = jSING.reordering.getNormalizedHeight(ad, margin); adY = ad.offset().top; adModifier = "" } } itemAY2 = itemAYModifier + (itemBHeight + adHeight).toString() + "px"; itemBY2 = itemBYModifier + (itemAHeight + adHeight).toString() + "px"; itemA.animate({ top: itemAY2 }, 400, "swing"); itemB.animate({ top: itemBY2 }, 200, "swing"); if (adHeight) {
                    switch (direction) {
                        case "up": adY2 = itemAHeight - itemBHeight;
                            break; case "down": adY2 = itemBHeight - itemAHeight; break
                    } if (adY2 >= 0) { adModifier = "+=" } else { if (adY2 < 0) { adY2 *= -1; adModifier = "-=" } } adChange = adModifier + adY2.toString() + "px"; ad.animate({ top: adChange }, 300, "swing")
                } reorderableItems[itemAIndex] = itemB[0]; reorderableItems[itemBIndex] = itemA[0]; order = ""; reorderableItems.each(function() { order = order + this.id + "," }); order = order.substring(0, order.length - 1); $.cookie(reorderCookieName, order, { expires: 730 }); preventReorder = false; return reorderableItems
            } itemA.children("a.reorder").remove(); swap(itemA, direction); return reorderableItems
        } function linkHTML(direction, itemAName) {
            return '<a href="#' + itemAID + '" id="reorder_' + direction + "_" + itemAID + '" class="reorder reorder_' + direction + '" title="Click to move ' + itemAName + " " + direction + ' on the page">Move ' + itemAName + " " + direction + "</a>"
        } function initArrow(direction, itemAName) { arrowHTML = linkHTML(direction, itemAName); arrow = $(arrowHTML).css("opacity", "0").click(function(e) { e.preventDefault(); jSING.apptap.execAppTapEvent(this, "Event63", false); reorderItems($(this), direction) }); switch (direction) { case "up": arrow.prependTo(itemA).css("opacity", "1"); break; case "down": arrow.appendTo(itemA).css("opacity", "1"); break } } $("a.reorder").remove(); if (itemAIndex != 0) { initArrow("up", itemAName) } if (itemAIndex != (reorderableItems.length - 1)) { initArrow("down", itemAName) } 
    } preventReorder = false
}, hideReorder: function() {
    preventReorder = false; $(this).children("a.reorder").each(function() {
        reorderLink = $(this);
        reorderLink.animate({ opacity: 0 }, 100, function() { reorderLink.remove() })
    })
}, init: function(reorderableItemsSelector, containerSelector, adSelector, adIndex, reorderCookieName) {
    preventReorder = false; reorderableItemsSelector = reorderableItemsSelector; containerSelector = containerSelector; adSelector = adSelector; adIndex = adIndex; reorderCookieName = reorderCookieName; reorderableItems = $(reorderableItemsSelector); if ($.cookie(reorderCookieName)) {
        var itemIDs = $.cookie(reorderCookieName).split(",") || []; var itemsList = reorderableItems; var itemsContainer = $(containerSelector).eq(0); var itemsLength = itemIDs.length - 1; if (!adIndex) {
            var breakPoint = itemsLength
        } else { var breakPoint = adIndex - 1 } function cookieItemReorder(i, insertion) { var item = $("#" + itemIDs[i]); if (item.length) { switch (insertion) { case "prepend": item.prependTo(itemsContainer); break; case "append": item.appendTo(itemsContainer); break } } } for (var i = breakPoint; i >= 0; i--) { cookieItemReorder(i, "prepend") } if (adIndex) { for (var i = breakPoint + 1; i <= itemsLength; i++) { cookieItemReorder(i, "append") } } reorderableItems = $(reorderableItemsSelector)
    } var hoverConfig = { sensitivity: 15, interval: 0, over: jSING.reordering.showReorder, timeout: 125, out: jSING.reordering.hideReorder }; reorderableItems.hoverIntent(hoverConfig)
} 
}, fonts: { setFontSize: function(fontLinks, fontSizeName, link) {
    fontLinks.filter(".active").removeClass("active");
    var deleteCookie = false, articleBody = $("#article_body"); switch (fontSizeName) { case "small": articleBody.addClass("article_body_small").removeClass("article_body_large"); break; case "large": articleBody.addClass("article_body_large").removeClass("article_body_small"); break; default: articleBody.removeClass("article_body_small article_body_large"); deleteCookie = true } if (link) { link.addClass("active") } else { $("a#font_" + fontSizeName).addClass("active") } if (deleteCookie == true) { $.cookie("storyFontSizeName", null, { path: "/" }) } else { $.cookie("storyFontSizeName", fontSizeName, { expires: 730, path: "/" }) } 
}, init: function() {
    var self = this, fontLinks = $(".story_tools .story_font a");
    if (fontLinks.length > 0) { var fontSizeName = $.cookie("storyFontSizeName") || "default"; self.setFontSize(fontLinks, fontSizeName, null); fontLinks.click(function(event) { event.preventDefault(); var link = $(this), fontSizeName = link.attr("id").split("_")[1]; self.setFontSize(fontLinks, fontSizeName, link) }) } 
} 
}, apptap: { getEventPath: function(trigger) { if (path[-1] != "/") { path += "/" } return path + trigger.attr("href") }, registerAppTapEvent: function(selector, eventName, isMacro) { var self = this; $(selector).click(function() { self.execAppTapEvent(this, eventName, isMacro) }) }, execAppTapEvent: function(trigger, eventName, isMacro) {
    var self = this, trigger = $(trigger), title = trigger.attr("title");
    sendEvent(trigger, eventName, title); if (isMacro) { retarget(self.getEventPath(trigger), title) } 
}, init: function() { var self = this; self.registerAppTapEvent(".macro_tab_header li a", "Event60", true); self.registerAppTapEvent("#content_wrapper :not('#secondary_content') .tab_header:not('.macro_tab_header') li a", "Event61", false); self.registerAppTapEvent("#secondary_content .tab_header li a", "Event62", false); self.registerAppTapEvent("#most_popular a", "Event22", false); self.registerAppTapEvent("a.comment_count", "Event23", false); self.registerAppTapEvent(".quicklinks a", "Event24", false) } 
}, ratings: { ratingSubmit: function(value, link) {
    var self = this, value = value || 0;
    if (value != 0) { var f = $(this.form); if (!f.hasClass("user_rating_form")) { f.addClass("user_rating_form") } } else { var f = cancelThisForm; f.removeClass("user_rating_form") } $.post(f.attr("action"), { rating: value }, function(data, textStatus) { if (value == 0) { newData = eval("(" + data + ")"), newRating = newData.rating, inputs = f.children("input[type=radio].rating-star"), input = inputs.filter("[value=" + newRating + "]"), overallInput = $(input[0]); overallInput.attr("checked", "checked"); inputs.attr("class", "rating-star"); f.find("span.star-rating-control").remove(); self.init(inputs, f) } })
}, init: function(inputObjects, cancelScope) {
    var self = this;
    inputObjects.rating({ callback: self.ratingSubmit }); $(".star-rating-readonly").click(function() { alert("Please login to rate content") }); cancelScope.find("div.rating-cancel a").click(function() { cancelThisForm = $($(this).parents("form")[0]) })
} 
}, cellar: { doCellarLinks: function(dlSelector, promptText, showText, hideText) {
    var dl = $(dlSelector), dtSelector = dlSelector + "_prompt", ddSelector = dlSelector + "_links"; if (dl.length) {
        var dt = $(dtSelector), dd = $(ddSelector); dd.hide(); dt.append('<a href="' + dlSelector + '">' + promptText + "</a>"); var dtToggle = $(dtSelector + " a"); dtToggle.click(function(clickEvent) {
            clickEvent.preventDefault();
            var a = $(this); var t = a.text(); dd.toggle(); if (t.search(showText) >= 0) { a.text(t.replace(" " + showText, " " + hideText)) } else { a.text(t.replace(" " + hideText, " " + showText)) } 
        })
    } 
}, init: function() { var self = this; self.doCellarLinks("#business_directory", " See directory links", "See", "Hide"); self.doCellarLinks("#jobs_by_city", "(click to expand)", "expand", "hide"); self.doCellarLinks("#jobs_by_cat", "(click to expand)", "expand", "hide"); self.doCellarLinks("#jobs_by_popular", "(click to expand)", "expand", "hide") } 
}, mobile: { showMobilePrompt: function(mobileURL, contentURL) {
    var width = jSINGmobile.getBrowserWidth(); if ($.cookie("preventMobileRedirect") && !$.cookie("hideMobilePrompt") && width != 0 && width <= 800) {
        var prompt = '<div id="mobile_prompt" style="width: 994px; height: 60px; margin: 0 auto 10px;line-height: 60px; font-size: 24px;"><a id="visitMobileSite" href="' + mobileURL + contentURL + '" style="margin-left: 15px;">Visit our mobile-optimized site</a><a id="hideMobilePrompt" href="#" style="font-size: 18px; color: #444; margin-left: 15px; text-transform: uppercase">Hide this message</a></div>';
        $("#utilities_wrapper").prepend(prompt); $("#hideMobilePrompt").click(function(e) { e.preventDefault(); $("#mobile_prompt").remove(); $.cookie("hideMobilePrompt", 1, { expires: 365, path: "/" }) }); $("#visitMobileSite").click(function() { $.cookie("preventMobileRedirect", null, { path: "/" }) })
    } 
}, init: function() { this.showMobilePrompt() } 
}, popmenus: { doPlugin: function() {
    $.fn.popmenu = function(options) {
        var defaults = { menu: ".popmenu", activeClass: false, time: 1500, speed: "", effect: "" }; var options = $.extend(defaults, options); var active_menu = null; var timeout; return this.each(function() {
            var button = $(this); var menu = $(this).next();
            button.click(function(e) { clearTimeout(timeout); if (menu.is(":hidden")) { $("" + options.menu + ":visible").each(function() { $(this).hide(options.speed); $(this).prev().removeClass(options.activeClass) }); menu.show(options.speed); if (options.activeClass != false) { button.addClass(options.activeClass) } } else { menu.hide(options.speed); if (options.activeClass != false) { button.removeClass(options.activeClass) } } active_menu = menu.index(menu); return false }); button.mouseover(function() { clearTimeout(timeout); active_menu = menu.index(menu) }); menu.mouseover(function() { clearTimeout(timeout); active_menu = menu.index(menu) }); button.mouseout(function() {
                timeout = setTimeout(function() {
                    if (options.activeClass != false) {
                        button.removeClass(options.activeClass)
                    } menu.hide(options.speed)
                }, options.time); active_menu = null
            }); menu.mouseout(function() { timeout = setTimeout(function() { if (options.activeClass != false) { button.removeClass(options.activeClass) } menu.hide(options.speed) }, options.time); active_menu = null }); $(document).click(function(e) { if (active_menu == null) { $(options.menu + ":visible").each(function() { $(this).hide(options.effect, options.speed); $(this).prev().removeClass(options.activeClass) }) } })
        })
    } 
}, init: function() { var self = this, popMenus = $(".popmenu_button"); if (popMenus.length) { self.doPlugin(); popMenus.popmenu({ activeClass: "active" }) } } 
}, browsers: { zIndexIE: function() {
    if ($.browser.msie) {
        var zIndexNumber = 10000, zList = $("div"), zListLength = zList.length;
        for (var i = 0; i < zListLength; i++) { zList[i].style.zIndex = zIndexNumber; zIndexNumber -= 10 } 
    } 
}, init: function() { this.zIndexIE() } 
}, init: function(pageType) { var self = this; self.navigation.init(); self.tabs.init(); self.carousels.init(); self.comments.init(); self.popmenus.init(); self.calendars.init(); self.maps.init(); self.cellar.init(); self.ratings.init($("input[type=radio].rating-star"), $("form.rating_form")); self.apptap.init(); self.browsers.init() } 
}; jSING.init();