/*
    Product compare functions needed for pages with comparable items and for
    the compare pop-up window.
    Copyright (C) 2000-2008 Kohler Company.    All Rights Reserved.
    Author: Dennis Spaag
    Date Created: 01/29/08
 */
function compareArrayContainsValue(s) {
    var inCompareArray =  getCompareArray();
    var result = false;
    if (inCompareArray.length > 0) {
        result = arrayContains(inCompareArray,s);
    }
    return result;
}
function getCompareArray() {
    var inCompare = $.cookie('cnrw_compare');
    var result = [];
    if (inCompare != null && inCompare.length > 0) {
        result = inCompare.split('|');
    }
    return result;
}
function setCompareCookie(items) {
    var value = arrayUnique(items).join('|');
    if (value.indexOf("|")==0) { value = value.replace('|',''); }
    $.cookie('cnrw_compare', value, { path: '/' });
}
function updateCompareCookie(items) {
    var a2 = items.join('|').split('|'); // duplicate array - don't change original
    var result = $.merge( a2, getCompareArray() );
    setCompareCookie(result);
}