
var rr_addedToCartItemIds;
function rr_parseQueryValue(a) {
    var b = location.href.indexOf(a);
    var c;
    if (b != -1) {
        var d = location.href.indexOf("&", b);
        if (d != -1) {
            c = location.href.substring(b + a.length + 1, d)
        } else {
            c = location.href.substring(b + a.length + 1, location.href.length)
        }
    } else {
        c = ''
    }
    return c
}
function rr_addStrategy(a) {
    if (typeof this.forcedStrategies == 'undefined') {
        this.forcedStrategies = ''
    }
    this.forcedStrategies += '|' + a
}
function rr_addPlacementType(a) {
    if (typeof this.placementTypes == 'undefined') {
        this.placementTypes = ''
    }
    this.placementTypes += '|' + a
}
function rr_blockItemId(a) {
    if (typeof this.blockeditemIds == 'undefined') {
        this.blockeditemIds = ''
    }
    this.blockeditemIds += '|' + a
}
function rr_addItemId(a) {
    if (typeof this.itemIds == 'undefined') {
        this.itemIds = ''
    }
    this.itemIds += '|' + a
}
function rr_addItemIdDollarsAndCentsQuantity(a, b, c) {
    if (typeof this.itemIds == 'undefined') {
        this.itemIds = ''
    }
    this.itemIds += '|' + a;
    if (typeof this.purchasesDollarsAndCents == 'undefined') {
        this.purchasesDollarsAndCents = ''
    }
    if (typeof b == 'undefined') {
        b = 0
    }
    this.purchasesDollarsAndCents += '|' + b;
    if (typeof this.quantities == 'undefined') {
        this.quantities = ''
    }
    if (typeof c == 'undefined') {
        c = -1
    }
    c = c + '';
    if (c.indexOf('.') != -1) {
        c = c.substring(0, c.indexOf('.'))
    }
    this.quantities += '|' + c
}
function rr_addItemIdCentsQuantity(a, b, c) {
    if (typeof this.itemIds == 'undefined') {
        this.itemIds = ''
    }
    this.itemIds += '|' + a;
    if (typeof this.purchasesCents == 'undefined') {
        this.purchasesCents = ''
    }
    if (typeof b == 'undefined') {
        b = 0
    }
    this.purchasesCents += '|' + b;
    if (typeof this.quantities == 'undefined') {
        this.quantities = ''
    }
    if (typeof c == 'undefined') {
        c = -1
    }
    c = c + '';
    if (c.indexOf('.') != -1) {
        c = c.substring(0, c.indexOf('.'))
    }
    this.quantities += '|' + c
}
function rr_addItemIdPriceQuantity(a, b, c) {
    if (typeof this.itemIds == 'undefined') {
        this.itemIds = ''
    }
    this.itemIds += '|' + a;
    if (typeof this.purchasesPrice == 'undefined') {
        this.purchasesPrice = ''
    }
    if (typeof b == 'undefined') {
        b = 0
    }
    this.purchasesPrice += '|' + b;
    if (typeof this.quantities == 'undefined') {
        this.quantities = ''
    }
    if (typeof c == 'undefined') {
        c = -1
    }
    c = c + '';
    if (c.indexOf('.') != -1) {
        c = c.substring(0, c.indexOf('.'))
    }
    this.quantities += '|' + c
}
function rr_addAttribute(a, b) {
    if (typeof this.attributes == 'undefined') {
        this.attributes = ''
    }
    this.attributes += '|' + a + ':' + b
}
function rr_addRefinement(a, b) {
    if (typeof this.refinements == 'undefined') {
        this.refinements = ''
    }
    this.refinements += '|' + a + ':' + b
}
function rr_addCategory(a, b) {
    if (typeof this.categories == 'undefined') {
        this.categories = ''
    }
    if (typeof b == 'undefined') {
        b = a
    }
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.categories += '|' + a + ':' + b
}
function rr_addCategoryId(a) {
    if (typeof this.categoryIds == 'undefined') {
        this.categoryIds = ''
    }
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.categoryIds += '|' + a
}
function rr_addCategoryHintId(a) {
    if (typeof this.categoryHintIds == 'undefined') {
        this.categoryHintIds = ''
    }
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.categoryHintIds += '|' + a
}
function rr_addItemIdToCart(a) {
    if (typeof rr_addedToCartItemIds == 'undefined') {
        rr_addedToCartItemIds = ''
    }
    rr_addedToCartItemIds += '|' + a
}
function rr_setOrderNumber(a) {
    this.orderNumber = a
}
function rr_setBaseUrl(a) {
    if ('http://media.richrelevance.com/rrserver/' == a) {
        a = 'http://recs.richrelevance.com/rrserver/'
    }
    if ('https://media.richrelevance.com/rrserver/' == a) {
        a = 'https://recs.richrelevance.com/rrserver/'
    }
    this.baseUrl = a
}
function rr_addClickthruParams(a, b) {
    if (typeof this.clickthruParams == 'undefined') {
        this.clickthruParams = ''
    }
    this.clickthruParams += '|' + encodeURIComponent(a) + ':' + encodeURIComponent(b)
}
function rr_setClickthruServer(a) {
    this.clickthruServer = a
}
function rr_setImageServer(a) {
    this.imageServer = a
}
function rr_setJsFileName(a) {
    this.jsFileName = a
}
function rr_setApiKey(a) {
    this.apiKey = a
}
function rr_setLocale(a) {
    this.locale = a
}
function rr_enableJson() {
    this.jsonEnabled = 't'
}
function rr_setUserId(a) {
    this.userId = a
}
function rr_setSessionId(a) {
    this.sessionId = a
}
function rr_setForcedTreatment(a) {
    this.forcedTreatment = a
}
function rr_setTopLevelGenre(a) {
    this.topLevelGenre = a
}
function rr_setId(a) {
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.id = a
}
function rr_setName(a) {
    this.name = a
}
function rr_setDescription(a) {
    this.description = a
}
function rr_setImageId(a) {
    this.imageId = a
}
function rr_setReleaseDate(a) {
    this.releaseDate = a
}
function rr_setDollarsAndCents(a) {
    this.dollarsAndCents = a
}
function rr_setCents(a) {
    this.cents = a
}
function rr_setSaleDollarsAndCents(a) {
    this.saleDollarsAndCents = a
}
function rr_setSaleCents(a) {
    this.saleCents = a
}
function rr_setPrice(a) {
    this.price = a
}
function rr_setSalePrice(a) {
    this.salePrice = a
}
function rr_setLinkId(a) {
    this.linkId = a
}
function rr_setEndDate(a) {
    this.endDate = a
}
function rr_setRating(a) {
    this.rating = a
}
function rr_setBrand(a) {
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.brand = a
}
function rr_setRecommendable(a) {
    this.recommendable = a
}
function rr_setParentId(a) {
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.parentId = a
}
function rr_setTopName(a) {
    this.topName = a
}
function rr_setTerms(a) {
    this.terms = a
}
function rr_setClearancePage(a) {
    this.clearancePage = a
}
function rr_forceListenMode() {
    this.listenModeForced = 't'
}
function rr_forceDisplayMode() {
    this.displayModeForced = 't'
}
function rr_forceDevMode() {
    this.devModeForced = 't'
}
function rr_useDummyData() {
    this.dummyDataUsed = 't';
    this.displayModeForced = 't'
}
function rr_addForcedTemplate(a) {
    if (typeof this.forcedTemplates == 'undefined') {
        this.forcedTemplates = ''
    }
    this.forcedTemplates += '|' + a
}
function rr_addForcedPoolItem(a) {
    if (typeof this.forcedPoolItems == 'undefined') {
        this.forcedPoolItems = ''
    }
    this.forcedPoolItems += '|' + a
}
function rr_addFilterBrand(a) {
    if (typeof this.filterBrands == 'undefined') {
        this.filterBrands = ''
    }
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.filterBrands += '|' + a
}
function rr_setFilterBrandsIncludeMatchingElements(a) {
    this.filterBrandsInclude = a
}
function rr_addFilterCategory(a) {
    if (typeof this.filterCategories == 'undefined') {
        this.filterCategories = ''
    }
    if (a.indexOf('&amp;') > -1) {
        a = a.replace(/&amp;/g, "&")
    }
    if (a.indexOf('&#039;') > -1) {
        a = a.replace(/&#039;/g, "'")
    }
    this.filterCategories += '|' + a
}
function rr_setFilterCategoriesIncludeMatchingElements(a) {
    this.filterCategoriesInclude = a
}
function rr_setFilterPriceCentsMin(a) {
    this.filterPriceCentsMin = a
}
function rr_setFilterPriceCentsMax(a) {
    this.filterPriceCentsMax = a
}
function rr_setFilterPriceMin(a) {
    this.filterPriceMin = a
}
function rr_setFilterPriceMax(a) {
    this.filterPriceMax = a
}
function rr_setFilterPriceIncludeMatchingElements(a) {
    this.filterPriceInclude = a
}
function rr_setRegionId(a) {
    this.regionId = a
}
function rr_setInStock(a) {
    this.inStock = a
}
function rr_addFilter(a) {
    if (typeof this.filters == 'undefined') {
        this.filters = ''
    }
    this.filters += '|' + a
}

function rr_createItemScript(a, b) {
    if (a.topLevelGenre) {
        b += '&tg=' + encodeURIComponent(a.topLevelGenre)
    }
    if (a.categories) {
        b += '&cs=' + encodeURIComponent(a.categories)
    }
    if (a.categoryIds) {
        b += '&cis=' + encodeURIComponent(a.categoryIds)
    }
    if (a.id) {
        b += '&p=' + encodeURIComponent(a.id)
    }
    if (a.name) {
        b += '&n=' + encodeURIComponent(a.name)
    }
    if (a.description) {
        b += '&d=' + encodeURIComponent(a.description)
    }
    if (a.imageId) {
        b += '&ii=' + encodeURIComponent(a.imageId)
    }
    if (a.linkId) {
        b += '&li=' + encodeURIComponent(a.linkId)
    }
    if (a.releaseDate) {
        b += '&rd=' + encodeURIComponent(a.releaseDate)
    }
    if (a.dollarsAndCents) {
        b += '&np=' + encodeURIComponent(a.dollarsAndCents)
    }
    if (a.cents) {
        b += '&npc=' + encodeURIComponent(a.cents)
    }
    if (a.saleDollarsAndCents) {
        b += '&sp=' + encodeURIComponent(a.saleDollarsAndCents)
    }
    if (a.saleCents) {
        b += '&spc=' + encodeURIComponent(a.saleCents)
    }
    if (a.price) {
        b += '&np=' + encodeURIComponent(a.price)
    }
    if (a.salePrice) {
        b += '&sp=' + encodeURIComponent(a.salePrice)
    }
    if (a.endDate) {
        b += '&ed=' + encodeURIComponent(a.endDate)
    }
    if (a.rating) {
        b += '&r=' + encodeURIComponent(a.rating)
    }
    if (typeof a.recommendable != 'undefined') {
        b += '&re=' + encodeURIComponent(a.recommendable)
    }
    if (a.brand) {
        b += '&b=' + encodeURIComponent(a.brand)
    }
    if (a.attributes) {
        b += '&at=' + encodeURIComponent(a.attributes)
    }
    if (a.blockeditemIds) {
        b += '&bi=' + encodeURIComponent(a.blockeditemIds)
    }
    if (typeof a.inStock != 'undefined') {
        b += '&ins=' + encodeURIComponent(a.inStock)
    }
    return b
}
function rr_createCategoryScript(a, b) {
    if (a.topLevelGenre) {
        b += '&tg=' + encodeURIComponent(a.topLevelGenre)
    }
    if (a.name) {
        b += '&cn=' + encodeURIComponent(a.name)
    }
    if (a.id) {
        b += '&c=' + encodeURIComponent(a.id)
    }
    if (a.parentId) {
        b += '&pc=' + encodeURIComponent(a.parentId)
    }
    if (a.topName) {
        b += '&tcn=' + encodeURIComponent(a.topName)
    }
    if (a.brand) {
        b += '&b=' + encodeURIComponent(a.brand)
    }
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    return b
}
function rr_createCartScript(a, b) {
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    if (a.purchasesCents) {
        b += '&ppc=' + encodeURIComponent(a.purchasesCents)
    }
    if (a.purchasesDollarsAndCents) {
        b += '&pp=' + encodeURIComponent(a.purchasesDollarsAndCents)
    }
    if (a.quantities) {
        b += '&q=' + encodeURIComponent(a.quantities)
    }
    if (a.purchasesPrice) {
        b += '&pp=' + encodeURIComponent(a.purchasesPrice)
    }
    return b
}
function rr_createAddToCartScript(a, b) {
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    if (a.purchasesCents) {
        b += '&ppc=' + encodeURIComponent(a.purchasesCents)
    }
    if (a.purchasesDollarsAndCents) {
        b += '&pp=' + encodeURIComponent(a.purchasesDollarsAndCents)
    }
    if (a.quantities) {
        b += '&q=' + encodeURIComponent(a.quantities)
    }
    if (a.purchasesPrice) {
        b += '&pp=' + encodeURIComponent(a.purchasesPrice)
    }
    return b
}
function rr_createPurchasedScript(a, b) {
    if (a.orderNumber) {
        b += '&o=' + encodeURIComponent(a.orderNumber)
    }
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    if (a.purchasesCents) {
        b += '&ppc=' + encodeURIComponent(a.purchasesCents)
    }
    if (a.purchasesDollarsAndCents) {
        b += '&pp=' + encodeURIComponent(a.purchasesDollarsAndCents)
    }
    if (a.quantities) {
        b += '&q=' + encodeURIComponent(a.quantities)
    }
    if (a.purchasesPrice) {
        b += '&pp=' + encodeURIComponent(a.purchasesPrice)
    }
    return b
}
function rr_createSearchScript(a, b) {
    if (a.terms) {
        b += '&st=' + encodeURIComponent(a.terms)
    }
    if (a.brand) {
        b += '&b=' + encodeURIComponent(a.brand)
    }
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    return b
}
function rr_createHomeScript(a, b) {
    return b
}
function rr_createErrorScript(a, b) {
    return b
}
function rr_createMyRecsScript(a, b) {
    return b
}
function rr_createWishlistScript(a, b) {
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    return b
}
function rr_createGenericScript(a, b) {
    if (a.itemIds) {
        b += '&p=' + encodeURIComponent(a.itemIds)
    }
    return b
}
function rr_reach(a, b) {
    setTimeout('rr_reachLoad(\'' + a + '\')', b)
}
function rr_reachLoad(a) {
    var b = document.createElement('div');
    b.innerHTML = (a);
    document.body.appendChild(b)
}
function r3_common() {
    this.auctionID = '';	
    this.baseUrl = '';
    this.jsFileName = '';
    this.setBaseUrl = rr_setBaseUrl;
    this.setClickthruServer = rr_setClickthruServer;
    this.setImageServer = rr_setImageServer;
    this.setJsFileName = rr_setJsFileName;
    this.setApiKey = rr_setApiKey;
    this.setLocale = rr_setLocale;
    this.setPageBrand = rr_setBrand;
    this.enableJson = rr_enableJson;
    this.setUserId = rr_setUserId;
    this.setSessionId = rr_setSessionId;
    this.addStrategy = rr_addStrategy;
    this.addPlacementType = rr_addPlacementType;
    this.addItemIdToCart = rr_addItemIdToCart;
    this.setForcedTreatment = rr_setForcedTreatment;
    this.setClearancePage = rr_setClearancePage;
    this.forceListenMode = rr_forceListenMode;
    this.forceDisplayMode = rr_forceDisplayMode;
    this.forceDevMode = rr_forceDevMode;
    this.useDummyData = rr_useDummyData;
    this.addForcedTemplate = rr_addForcedTemplate;
    this.addForcedPoolItem = rr_addForcedPoolItem;
    this.addCategoryHintId = rr_addCategoryHintId;
    this.addClickthruParams = rr_addClickthruParams;
    this.addFilterBrand = rr_addFilterBrand;
    this.setFilterBrandsIncludeMatchingElements = rr_setFilterBrandsIncludeMatchingElements;
    this.addFilterCategory = rr_addFilterCategory;
    this.setFilterCategoriesIncludeMatchingElements = rr_setFilterCategoriesIncludeMatchingElements;
    this.setFilterPriceCentsMin = rr_setFilterPriceCentsMin;
    this.setFilterPriceCentsMax = rr_setFilterPriceCentsMax;
    this.setFilterPriceMin = rr_setFilterPriceMin;
    this.setFilterPriceMax = rr_setFilterPriceMax;
    this.setFilterPriceIncludeMatchingElements = rr_setFilterPriceIncludeMatchingElements;
    this.addFilter = rr_addFilter;
    this.setRegionId = rr_setRegionId;
    this.addRefinement = rr_addRefinement
}
function r3_item() {
    this.setTopLevelGenre = rr_setTopLevelGenre;
    this.addCategory = rr_addCategory;
    this.addCategoryId = rr_addCategoryId;
    this.setId = rr_setId;
    this.setName = rr_setName;
    this.setDescription = rr_setDescription;
    this.setImageId = rr_setImageId;
    this.setReleaseDate = rr_setReleaseDate;
    this.setDollarsAndCents = rr_setDollarsAndCents;
    this.setCents = rr_setCents;
    this.setSaleDollarsAndCents = rr_setSaleDollarsAndCents;
    this.setSaleCents = rr_setSaleCents;
    this.setPrice = rr_setPrice;
    this.setSalePrice = rr_setSalePrice;
    this.setBrand = rr_setBrand;
    this.setRecommendable = rr_setRecommendable;
    this.setLinkId = rr_setLinkId;
    this.setEndDate = rr_setEndDate;
    this.setRating = rr_setRating;
    this.addAttribute = rr_addAttribute;
    this.blockItemId = rr_blockItemId;
    this.setInStock = rr_setInStock
}
function r3_category() {
    this.setTopLevelGenre = rr_setTopLevelGenre;
    this.setName = rr_setName;
    this.setId = rr_setId;
    this.setParentId = rr_setParentId;
    this.setTopName = rr_setTopName;
    this.setBrand = rr_setBrand;
    this.addItemId = rr_addItemId
}
function r3_cart() {
    this.addItemId = rr_addItemId;
    this.addItemIdDollarsAndCentsQuantity = rr_addItemIdDollarsAndCentsQuantity;
    this.addItemIdCentsQuantity = rr_addItemIdCentsQuantity;
    this.addItemIdPriceQuantity = rr_addItemIdPriceQuantity
}
function r3_addtocart() {
    this.addItemIdToCart = rr_addItemIdToCart
}
function r3_purchased() {
    this.setOrderNumber = rr_setOrderNumber;
    this.addItemIdDollarsAndCentsQuantity = rr_addItemIdDollarsAndCentsQuantity;
    this.addItemIdCentsQuantity = rr_addItemIdCentsQuantity;
    this.addItemIdPriceQuantity = rr_addItemIdPriceQuantity;
    this.addItemId = rr_addItemIdCentsQuantity
}
function r3_search() {
    this.setTerms = rr_setTerms;
    this.setBrand = rr_setBrand;
    this.addItemId = rr_addItemId
}
function r3_home() {}
function r3_error() {}
function r3_myrecs() {}
function r3_wishlist() {
    this.addItemId = rr_addItemId
}
function r3_generic() {
    this.addItemId = rr_addItemId
}
var rr_placement_place_holders = new Array();
function r3_placement(a) {
    document.write('<div id="rr_placement_' + rr_placement_place_holders.length + '"></div>');
    rr_placement_place_holders[rr_placement_place_holders.length] = a
}
function r3_getRecs() {
    return false
}
var rr_placements = new Array();
function rr_append_parsed_element(a, b) {
    var c = a.cloneNode(false);
    if (c.nodeName == 'SCRIPT') {
        c.text = a.innerHTML;
        b.appendChild(c)
    } else if (c.nodeName == '#text') {
        b.appendChild(c)
    } else {
        b.appendChild(c);
        for (var i = 0, len = a.childNodes.length; i < len; i++) {
            rr_append_parsed_element(a.childNodes[i], c)
        }
    }
}
function rr_scroll(a, b) {
    var c;
    var d = eval('rr_cells[' + a + ']');
    var e = eval('rr_showing[' + a + ']');
    var f = eval('rr_display_count[' + a + ']');
    if (f >= d.length) {
        var g = document.getElementById('rr_scroller' + a);
        if (g) {
            g.parentNode.removeChild(g)
        }
        var h = document.getElementById('rr_prev' + a);
        if (h) {
            h.parentNode.removeChild(h)
        }
        var j = document.getElementById('rr_next' + a);
        if (j) {
            j.parentNode.removeChild(j)
        }
        f = d.length
    }
    if (e.length === 0) {
        c = 0
    } else if (b < 0) {
        var k = e[0];
        c = k - f;
        if (c < 0) {
            c = d.length + c
        }
    } else {
        var l = e[e.length - 1];
        c = l + 1;
        if (c > d.length - 1) {
            c = c - d.length
        }
    }
    var m = c;
    for (var i = 0; i < f; i++) {
        if (document.getElementById('rr_cell' + a + '_' + i)) {
            document.getElementById('rr_cell' + a + '_' + i).innerHTML = d[m];
            e[i] = m;
            m++;
            if (m == d.length) {
                m = 0
            }
        }
    }
}
var rr_cells = new Array();
var rr_showing = new Array();
function rr_addCell(a, b) {
    if (typeof rr_cells[a] == 'undefined') {
        rr_cells[a] = new Array();
        rr_showing[a] = new Array()
    }
    rr_cells[a][rr_cells[a].length] = b
}
var rr_display_count = new Array();
function rr_setDisplayCount(a, b) {
    rr_display_count[a] = b
}
function rr_insert_placement(a, b) {
    for (var i = 0; i < rr_placements.length; i++) {
        if (rr_placements[i][0] === 0 && rr_placements[i][1] == b) {
            rr_placements[i][0] = 1;
            if (rr_placements[i][2].indexOf('<script') == -1) {
                a.innerHTML = rr_placements[i][2]
            } else if (document.implementation.hasFeature('Range', '2.0')) {
                var c = document.createRange();
                c.selectNodeContents(a);
                var e = c.createContextualFragment(rr_placements[i][2]);
                a.appendChild(e);
                c.detach()
            } else {
                var d = document.createElement('div');
                d.innerHTML = rr_placements[i][2];
                for (var j = 0, len = d.childNodes.length; j < len; j++) {
                    rr_append_parsed_element(d.childNodes[j], a)
                }
            }
            return
        }
    }
    return
}
var rr_onload_called = false;
function rr_flush() {}
function rr_flush_onload() {
    if (!rr_onload_called) {
        rr_onload_called = true;
        rr_flush()
    }
}
function rr_addLoadEvent(a) {
    var b = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = a
    } else {
        window.onload = function() {
            b();
            a()
        }
    }
}
var RR = {
    jsonCallback: function(a) {},
    onloadCalled: false,
    useJsonRecs: function() {},
    useJsonRecsOnload: function() {
        if (!RR.onloadCalled) {
            RR.onloadCalled = true;
            RR.useJsonRecs()
        }
    }
};
rr_addLoadEvent(rr_flush_onload);
rr_addLoadEvent(RR.useJsonRecsOnload);
var p13nGeneratedScriptSrc;
function rr_create_script(a) {
    var b = document.createElement('script');
    b.type = 'text/javascript';
    b.src = a;
    document.getElementsByTagName('head')[0].appendChild(b)
}
function rr_create_inline_style(a) {
    var b = document.createElement('style');
    b.type = 'text/css';
    b.innerHTML = a;
    document.getElementsByTagName('head')[0].appendChild(b)
}
function r3(a, b) {
    var c = false;
    if (typeof(b) == 'undefined' || !b) {
        if (typeof R3_COMMON != 'undefined' && location.href.indexOf('r3_forceDisplay=true') != -1) {
            R3_COMMON.debugMode = true;
            R3_COMMON.displayModeForced = 't'
        }
        if (location.href.indexOf('r3_forceDev=true') != -1) {
            R3_COMMON.debugMode = true;
            R3_COMMON.devModeForced = 't'
        }
        if (location.href.indexOf('r3_debugMode=true') != -1) {
            c = true
        } else if (location.href.indexOf('r3_debugMode=false') != -1) {
            c = false
        } else if (typeof(a) != 'undefined' && a) {
            c = a
        }
        if (location.href.indexOf('r3_useDummyData=true') != -1) {
            R3_COMMON.debugMode = true;
            R3_COMMON.dummyDataUsed = 't';
            R3_COMMON.displayModeForced = 't'
        }
        var e = rr_parseQueryValue('r3_addTemplates');
        if (e !== '') {
            R3_COMMON.debugMode = true;
            if (typeof R3_COMMON.forcedTemplates == 'undefined') {
                R3_COMMON.forcedTemplates = ''
            }
            R3_COMMON.forcedTemplates += e
        }
        var f = rr_parseQueryValue('r3_addPoolItems');
        if (f !== '') {
            R3_COMMON.debugMode = true;
            if (typeof R3_COMMON.forcedPoolItems == 'undefined') {
                R3_COMMON.forcedPoolItems = ''
            }
            R3_COMMON.forcedPoolItems += f
        }
        var g = rr_parseQueryValue('r3_forcedTreatment');
        if (g && g != '') {
            R3_COMMON.forcedTreatment = g
        }
        var h = rr_parseQueryValue('r3_ftp');
        if (h && h != '') {
            R3_COMMON.forcedFtp = h
        }
        if (location.href.indexOf('vg=') != -1) {
            R3_COMMON.viewGuid = rr_parseQueryValue('vg')
        }
        if (location.href.indexOf('rm=') != -1) {
            R3_COMMON.fromRichMail = rr_parseQueryValue('rm')
        }
    }
    if (typeof R3_COMMON != 'undefined') {
	if (R3_COMMON.baseUrl) {
            var i = R3_COMMON.baseUrl + R3_COMMON.jsFileName + '?a=' + R3_COMMON.apiKey;
            p13nGeneratedScriptSrc = i;
            setTimeout('rr_create_script(p13nGeneratedScriptSrc)', 10)
        }
    } else {
        if (c) {
            alert("Carousel has not been defined")
        }
    }
}

function cnCarousel(thisCarIn, jsonArray, optionsIn) {
    //instance args
    var data = jsonArray ? jsonArray: {};
    var thisCar = thisCarIn;
    //Overwrite options in third argument with an object hash like so: var aNewCarousel = new cnCarousel($('#id_of_carousel_window'),recs.placements[0],{ horizontal:false, itemsMoved:2 })
    var options = {
        horizontal: true,
        itemsMoved: 1,
        //enter 'page' for full page of items.
        loadAhead: 1,
        //enter 'page' for one page ahead.
        marginSpace: 5,
        //minimum space on either side of item divs inside carousel
        sleeper: false,
        //horizontal list of items that becomes a carousel if enough items are present.
        sleeperMax: 8,
        //# of items to exceed for carousel interaction to kick in - default set for softline prod. page swatches
        newMax: 0,
        //assigned to data.maxItems if it's lower and not 0.
        minWidth: 168,
        // width of whatever item is in the LI - it's assumed these are already set in the CSS
        minHeight: 240,
        // height of item in the LI - it's assumed these are already set in the CSS
        buttonWidth: 23,
        // inside the carousel_window container - it's assumed width is set in the CSS.
        buttonsBegone: false,
        killContainer: $(thisCar),
        //specify the container that gets toggled on/off whether items are present.
        slideButtons: true //sets whether button image changes when no more items can be scrolled from a direction - must have a sprite-style horizontal slider with off btn to the right.
    }

    for (x in optionsIn) {
        options[x] = optionsIn[x];
    }

    var updates = {
        itemFit: function() {
            var itemSpace = options.horizontal ? $(thisCar).width() - (options.buttonWidth * 2) : $(thisCar).outerHeight() - 49;
            var minSpace = options.horizontal ? options.minWidth + (2 * options.marginSpace) : options.minHeight;
            return (Math.floor(itemSpace / minSpace));
        },
        itemsLoaded: 0,
        remainingItems: 0,
        totalMoves: 0,
        //This is actually somewhat counterintuitively negative when you'd expect positive,
        overMax: false,
        setLiWidth: function() {
            if (options.horizontal && !options.sleeper) {
                //var fitItems = (data.maxItems >= updates.itemFit()) ? updates.itemFit():data.maxItems;
                if (data.maxItems >= updates.itemFit()) {
                    var fitItems = updates.itemFit();
                    updates.overMax = false;
                }
                else {
                    var fitItems = data.maxItems;
                    updates.overMax = true;
                }
                if (updates.overMax && updates.buttonsBegone) {
                    var newMargin = ($(thisCar).width() - (fitItems * options.minWidth)) / 2 + 'px';
                    $(thisCar).find('ul').css('left-margin', newMargin);
                    $(thisCar).find('ul li').css('width', options.minWidth + (options.marginSpace * 2) + 'px');
                }
                var liWidth = (100 / fitItems) - ((((options.buttonWidth * 2) / $(thisCar).width()) * 100) / fitItems);
                liWidth = liWidth * ($(thisCar).width() / $(thisCar).find('ul').width());
                $(thisCar).find('ul li').css('width', liWidth + '%');
            }
        },
        moveInc: 0,
        buttonCheck: function() {
            if (options.slideButtons) {
                if (updates.totalMoves == 0) {
                    $(thisCar).find('.back_btn_slider').css('background-position', ( - 1 * options.buttonWidth) + 'px 0px');
                }
                else {
                    $(thisCar).find('.back_btn_slider').css('background-position', '0px 0px');
                }
                if (updates.itemFit() - updates.totalMoves >= data.maxItems) {
                    $(thisCar).find('.forward_btn_slider').css('background-position', ( - 1 * options.buttonWidth) + 'px 0px');
                }
                else {
                    $(thisCar).find('.forward_btn_slider').css('background-position', '0px 0px');
                }
            }
        }
    }

    this.initialize = function() {
        if (jsonArray && jsonArray.items) { //looks redundant but in some cases RR passes an empty object - other times it's undefined
            if (!data.maxItems || (data.maxItems > data.items.length)) {
                data.maxItems = data.items.length
            }
            if ((options.newMax > 0) && (options.newMax < data.maxItems)) {
                $(data.items).each(function(i) {
                    if (i > options.newMax) {
                        delete data.items[i]
                    }
                });
                data.maxItems = options.newMax;
            }
            if (options.loadAhead == 'page') {
                var loadIn = updates.itemFit()
            }
            else {
                var loadIn = options.loadAhead;
            }
            $(thisCar).find('h2').html(data.strategy);
        }
        else {
            data.maxItems = $(thisCar).find('ul li').size();
            data.items = $(thisCar).find('ul li .item').get();
        }
        if (options.sleeper) {
            $(thisCar).css('width', (options.minWidth * options.sleeperMax) + (2 * options.buttonWidth) + 1 + 'px');
            $(thisCar).find('.carousel_btn').css('display', (options.sleeperMax > data.maxItems) ? 'none': 'block');
        }
        updates.setLiWidth();
        updates.remainingItems = data.maxItems > updates.itemFit() ? data.maxItems - updates.itemFit() : 0;
        $(thisCar).find('.carousel_btn').unbind().click(function(e) {
            moveItems(e);
        });
        updates.buttonCheck();
        if (options.horizontal && !options.sleeper) {
            $(window).resize(function() {
                if (options.loadAhead == 'page') {
                    loadIn = updates.itemFit();
                }
                if (data.maxItems > updates.itemsLoaded) {
                    itemBuild(data.items, updates.itemsLoaded, (updates.itemFit() + loadIn));
                }
                updates.setLiWidth();
                if (updates.itemFit() >= data.maxItems) {
                    if (options.buttonsBegone) {
                        $(thisCar).find('.carousel_btn').css('display', 'none');
                        $(thisCar).find('ul').css('margin-left', '0px').css('margin-right', options.buttonWidth + 'px');
                    }
                    $(thisCar).find('ul').css('left', '0px');
                    updates.totalMoves = 0;
                }
                else {
                    if (options.buttonsBegone) {
                        $(thisCar).find('.carousel_btn').css('display', 'block');
                        $(thisCar).find('ul').css('margin-right', '0px').css('margin-left', options.buttonWidth + 'px');
                    }
                    var leftShift = (updates.itemFit() - updates.totalMoves) - data.maxItems;
                    if (leftShift > 0) {
                        updates.totalMoves += leftShift;
                    }
                    $(thisCar).find('ul').css('left', updates.totalMoves * $(thisCar).find('ul li').width() + 'px');
                }
                updates.buttonCheck();
            });
        }
        if (jsonArray) {
            itemBuild(data.items, 0, (updates.itemFit() + loadIn));
        }
        $(document).ready(function() {
            if ($(thisCar).hasClass('carouselNew') && $(thisCar).hasClass('carousel_window')) {
                $(options.killContainer).css('display', 'block')
            } else {
                if ($(thisCar).hasClass('carouselNew') && $(thisCar).hasClass('carousel_window')) {
                    $(options.killContainer).css('display', 'block')
                } else {
                    $(thisCar).find('ul li').size() > 0 ? $(options.killContainer).css('display', 'block') : $(options.killContainer).css('display', 'none');
                }
            }
        });
    }

    function moveItems(e) {
        if (options.itemsMoved == 'page') {
            var moves = updates.itemFit();
        }
        else {
            var moves = options.itemsMoved;
        }
        if ((e.target.className.match(/forward/)) || (e.target.className.match(/down/))) {
            var forwardBtn = true;
            moves = (moves * -1);
            var availMove = (( - 1 * updates.totalMoves) + updates.itemFit()) - data.maxItems;
            if (updates.itemFit() >= data.maxItems) {
                availMove = 0;
            }
        }
        else {
            var availMove = Math.abs(updates.totalMoves);
        }
        updates.moveInc = options.horizontal ? $(thisCar).find('ul li').width() : $(thisCar).find('ul li').outerHeight();
        (Math.abs(moves) > Math.abs(availMove)) ? updates.totalMoves += availMove: updates.totalMoves += moves;
        var carUl = $(thisCar).find('ul');
        var Direction = (updates.moveInc * updates.totalMoves) + 'px';
        if (options.loadAhead == 'page') {
            var loadIn = updates.itemFit()
        }
        else {
            var loadIn = options.loadAhead;
        }
        var buildAndUpdate = function() {
            itemBuild(data.items, updates.itemsLoaded, updates.itemsLoaded + loadIn);
            if (options.horizontal) {
                updates.buttonCheck();
            }
        }
        if (options.horizontal) { (forwardBtn) ? carUl.animate({
                left: Direction
            },
            {
                complete: buildAndUpdate
            }) : carUl.animate({
                left: Direction
            },
            {
                complete: updates.buttonCheck
            });
        }
        else { (forwardBtn) ? carUl.animate({
                top: Direction
            },
            {
                complete: buildAndUpdate
            }) : carUl.animate({
                top: Direction
            });
        }
    }

    var itemBuild = function(itemData, itemStart, itemEnd) {
        options.killContainer.css('display', itemData.length == 0 ? 'none': 'block');
        var html_element = '';
        var itemsToAdd = $(itemData).slice(itemStart, itemEnd);
        $(itemsToAdd).each(function(i) {
            if (i >= itemsToAdd.length || (updates.itemsLoaded >= data.maxItems)) {
                return false;
            }
            var arrayIndex = itemStart + i;
            html_element += "<li>";
            html_element += "<div class=\"" + (itemData[arrayIndex].type ? itemData[arrayIndex].type: "item normal") + "\">";
            html_element += "<h4><a href=\"" + (itemData[arrayIndex].url ? itemData[arrayIndex].url: "javascript:;") + "\">" + (itemData[arrayIndex].name.length > 40 ? itemData[arrayIndex].name.substr(0, 40) + "...": itemData[arrayIndex].name) + "</a></h4> ";
            html_element += "<p class=\"placeimage\"><a href=\"" + ((itemData[arrayIndex].url) ? itemData[arrayIndex].url: "javascript:;") + "\"><img height=\"100\" width=\"100\" src=\"" + itemData[arrayIndex].image + "&qlt=75" + "\" alt=\"" + itemData[arrayIndex].name + "\" style=\"margin-left:20px;\" /></a></p>";
            //i18n changes
            if (isI18NConvReq()) {
                html_element += "<div class=\"saveStory\">" + fnConSSfly(itemData[arrayIndex].attr_savestory) + "</div>"
            } else {
                html_element += "<div class=\"saveStory\">" + itemData[arrayIndex].attr_savestory + "</div>"
            }
            html_element += "<a class=\"view_more_btn\" href=\"" + ((itemData[arrayIndex].url) ? itemData[arrayIndex].url: "javascript:;") + "\"></a></div>";
            html_element += "</li>";
            updates.itemsLoaded++;
        });
        $(thisCar).find('ul').append(html_element);
        if (options.horizontal) {
            updates.setLiWidth();
        }
    }
    this.initialize();
}

cnCarousel.setCarousels = function(car_windows, jsonObj, optionsIn) {
    var carousels = {};
    $(car_windows).each(function(i) {
        carousels['carousel_' + i] = new cnCarousel($(car_windows[i]), jsonObj[i], optionsIn);
        carousels['carousel_' + i].onLoad = function() {
            $("a.mapLink").click(function() {
                mapClick(this)
            });
        }
    });
}
