<!--
// Home Page Featured Videos
function show_feature_video(video_num) {

    document.getElementById('feature_video[1]').style.display = 'none';
    document.getElementById('feature_video[2]').style.display = 'none';
    document.getElementById('feature_video[3]').style.display = 'none';
    
    document.getElementById('video_widget_thumb[1]').className='video_widget_td';
    document.getElementById('video_widget_thumb[2]').className='video_widget_td';
    document.getElementById('video_widget_thumb[3]').className='video_widget_td';
    
    document.getElementById('video_widget_thumb[' + video_num + ']').className='video_widget_td_active';

    document.getElementById('feature_video[' + video_num + ']').style.display = 'block';
}
      
// Collapse JS
function Cookie_custom(name) {
    this.setValue = function (value, hours, bridge) {
        var cookieString, date;
        cookieString = name + "=" + escape(value);
        if (hours) {
            date = new Date();
            date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
            cookieString += "; expires=" + date.toGMTString();
        }
        cookieString += "; path=/";
        document.cookie = cookieString;
        if (bridge) {
            // send cookie info to check in
            cookiesForBridge.push(cookieString);
        }
    };
    
    this.getValue = function () {
        var results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
        return results ? unescape(results[2]) : null;
    };
    
    this.remove = function () {
        this.setValue("", -1);
    };
}

function getElementsByClassName_custom(obj, theClass, theTag) {
    var allTagsWithClass = [],
        thisTag, i;
    
    for (i = 0; (thisTag = obj.getElementsByTagName(theTag ? theTag : '*')[i]); i++) {
        if (thisTag.className === theClass) {
            allTagsWithClass.push(thisTag);
        }
    }
    return allTagsWithClass;
}

function custom_collapse() {
    var lastHash, containers, page, cookie, checkHash, eventOverOut, eventClick, qNaCurrent, valCollapse, i, objectList, cookieVal, num;
    lastHash = null;
    containers = [];
    page = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1);
    cookie = new Cookie_custom(page);

    // Check if we need to follow an anchor
    checkHash = function () {
        return function () {
            var sectionToDisplay;
            if (document.location.hash && lastHash !== document.location.hash) {
                lastHash = document.location.hash;
                sectionToDisplay = document.getElementById(document.location.hash.split('#')[1]);
                if (sectionToDisplay && sectionToDisplay.className === 'collapse_tab_block hide_block') {
                    sectionToDisplay.className = sectionToDisplay.className.replace(new RegExp(" hide_block\\b"), "");
                }
            }
        };
    };
    
    // returns an event handler for collapse mouse over and out events
    eventOverOut = function () {
        return function (e) {
            if (this.className === 'collapse_title') {
                this.className += ' collapse_over';
            } else {
                this.className = this.className.replace(new RegExp(" collapse_over\\b"), "");
            }
        };
    };
    
    // returns an event handler for collapse click
    eventClick = function () {
        return function (e) {
            var i, newValue;
            if (this.parentNode.className === 'collapse_tab_block') {
                this.parentNode.className += ' hide_block';
                if (document.location.hash) {
                    if (this.parentNode.id === document.location.hash.split("#")[1]) {
                        document.location.hash = '';
                    }
                }
            } else {
                this.parentNode.className = this.parentNode.className.replace(new RegExp(" hide_block\\b"), "");
            }
            
            // sets a cookie to tell us which qna's were open
            newValue = '|';
            for (i = 0; i < containers.length; i += 1) {
                if (containers[i].className === 'collapse_tab_block') {
                    if (i < 10) {
                        newValue += '0';
                    }
                    newValue += i + '|';
                }
            }
            cookie.setValue(newValue);
        };
    };
    
    // init this thing
    objectList = document.getElementById('collapse_main_box');
    if (objectList) {
        containers = getElementsByClassName_custom(objectList, 'collapse_tab_block', 'div');
        containers = containers.concat(getElementsByClassName_custom(objectList, 'collapse_tab_block', 'span'));
        if (containers.length > 0) {
            // checks cookie to see which qna's were left open last time they were on this page
            cookieVal = cookie.getValue();
            for (i = 0; i < containers.length; i += 1) {
                qNaCurrent = containers[i];
                if (cookieVal) {
                    num = (i < 10) ? '0' + i : i;
                    qNaCurrent.className += (cookieVal.match(num)) ? '' : ' hide_block';
                } else {
                    qNaCurrent.className += ' hide_block';
                }
                
                valCollapse = getElementsByClassName_custom(qNaCurrent, 'collapse_title', 'div');
                if (valCollapse.length > 0) {
                    valCollapse = valCollapse[0];
                    valCollapse.innerHTML = valCollapse.innerHTML.replace("<span>", "").replace("</span>", ""); // temp fix for Chrome
                    valCollapse.onmouseover = eventOverOut();
                    valCollapse.onmouseout = eventOverOut();
                    valCollapse.onclick = eventClick();
                }
            }
            window.setInterval(checkHash(), 200);
        }
    }
}
// Eof Collapse JS

function getIEVersion() {
    var version = -1, usrAgt, regExp;
    if (navigator.appName === 'Microsoft Internet Explorer') {
        usrAgt = navigator.userAgent;
        regExp = new RegExp('MSIE ([0-9]{1,}[.0-9]{0,})');
        if (regExp.exec(usrAgt) !== null) {
            version = parseFloat(regExp.exec(usrAgt)[1]);
        }
    }
    return version;
}

// returns an array of all tags of a certain class
function getElementsByClassName(obj, theClass, theTag) {
    var allTagsWithClass = [],
        thisTag, i;
    
    for (i = 0; (thisTag = obj.getElementsByTagName(theTag ? theTag : '*')[i]); i++) {
        if (thisTag.className === theClass) {
            allTagsWithClass.push(thisTag);
        }
    }
    return allTagsWithClass;
}

function AlphaList(id, hideable) {
    var linksContainer, alphaLinks, i, showList, allLists, alphaLists = [], liWidths = [], lastCols = [], liLinks, j, windowResize, lastWindowWidth = 0, colsHeight = [], createCols, colsTotalWidth = [], colsList = [], slideMe, slideInt = null, slideCount = 1, slideAmt, heightDiff =  0, maxCols = [], maxWidth, numCols = [], lastShown = null, titleList = [], title = [], k,  noTitleList = false, seeAll, showAll, clearDiv,
    container = document.getElementById(id),
    ieVersion = getIEVersion();
    
    slideMe = function (closeMe, list, cols) {
        return function () {
            if (closeMe) {
                if (slideCount < 9) {
                    colsList[list][cols].style.height = colsList[list][cols].offsetHeight - slideAmt + 'px';
                    slideCount++;
                } else {
                    colsList[list][cols].style.height = '0px';
                    alphaLists[list].className = 'shop-by-lists';
                    window.clearInterval(slideInt);
                    slideInt = null;
                }
            } else {
                if (slideCount > 2) {
                    colsList[list][cols].style.height = colsList[list][cols].offsetHeight + slideAmt + 'px';
                    slideCount--;
                } else {
                    colsList[list][cols].style.height = colsHeight[list][cols] + 'px';
                    colsList[list][cols].className = '';
                    window.clearInterval(slideInt);
                    slideInt = null;
                }
            }
        };
    };
    
    windowResize = function () {
        return function () {
            if (lastWindowWidth !== document.body.offsetWidth) {
                lastWindowWidth = document.body.offsetWidth;
                if (lastShown !== null) {
                    for (i = maxCols[lastShown] - 1; i > -1; i--) {
                        if (colsTotalWidth[lastShown][i] < container.offsetWidth) {
                            numCols[lastShown] = i;
                            break;
                        }
                    }
                    if (numCols[lastShown] !== lastCols[lastShown]) {
                        colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                        colsList[lastShown][numCols[lastShown]].style.height = colsHeight[lastShown][numCols[lastShown]] + 'px';
                        colsList[lastShown][numCols[lastShown]].className = '';
                        alphaLists[lastShown].removeChild(colsList[lastShown][lastCols[lastShown]]);
                        alphaLists[lastShown].appendChild(colsList[lastShown][numCols[lastShown]]);
                        lastCols[lastShown] = numCols[lastShown];
                    }
                } else if (!hideable || seeAll.innerHTML.match('hide all')) {
                    for (i = 0; i < alphaLists.length; i++) {
                        for (j = maxCols[i]; j > -1; j--) {
                            if (colsTotalWidth[i][j] < container.offsetWidth) {
                                numCols[i] = j;
                                break;
                            }
                        }
                        if (numCols[i] !== lastCols[i]) {
                            alphaLists[i].removeChild(colsList[i][lastCols[i]]);
                            alphaLists[i].appendChild(colsList[i][numCols[i]]);
                            lastCols[i] = numCols[i];
                        }
                        if (hideable) {
                            colsList[i][numCols[i]].style.height = '';
                            colsList[i][numCols[i]].style.paddingTop = '20px';
                            if (i > 0) {
                                colsList[i][numCols[i]].style.borderTop = '1px solid #ccc';
                            }
                        }
                    }
                }
            }
        };
    };
    
    createCols = function (num) {
        var listItems, rows, start, end, list, k, rowsHeight;
        colsTotalWidth[num] = [];
        colsList[num] = [];
        colsHeight[num] = [];
        listItems = alphaLists[num].getElementsByTagName('a');
        maxCols[num] = 11;
        for (i = 1; i < maxCols[num]; i++) {
            rows = Math.ceil(listItems.length / i);
            if (i > 1 && rows < 3) {
                maxCols[num] = i - 1;
                break;
            }
            if (!noTitleList) {
                colsTotalWidth[num][i] = (hideable) ? 80 : 130;
            } else {
                colsTotalWidth[num][i] = 0;
            }
            start = 0;
            end = rows;
            colsList[num][i] = document.createElement('li');
            rowsHeight = rows * 18;
            colsHeight[num][i] = (rowsHeight > 63) ? rowsHeight : 63;
            if (hideable) {
                colsList[num][i].style.height = '0px';
            }
            if (!noTitleList) {
                colsList[num][i].appendChild(title[num].cloneNode(true));
            }
            for (j = 0; j < i; j++) {
                if (listItems[start]) {
                    list = document.createElement('ul');
                    maxWidth = 0;
                    for (k = start; k < end; k++) {
                        if (listItems[k]) {
                            list.appendChild(listItems[k].parentNode.cloneNode(true));
                            if (liWidths[num][k] > maxWidth) {
                                maxWidth = liWidths[num][k];
                            }
                        }
                    }
                    if (hideable) {
                        maxWidth += 20;
                    } else {
                        maxWidth += 50;
                    }
                    colsTotalWidth[num][i] += maxWidth;
                    if (ieVersion === 6) {
                        list.style.width = maxWidth - 30 + 'px';
                    }
                    start += rows;
                    end += rows;
                    colsList[num][i].appendChild(list);
                }
            }
        }
    };
    
    showList = function (num) {
        return function () {
            this.blur();
            if (slideInt !== null) {
                return false;
            }
            if (!colsList[num]) {
                createCols(num);
            }
            for (i = maxCols[num]; i > -1; i--) {
                if (colsTotalWidth[num][i] < container.offsetWidth) {
                    numCols[num] = i;
                    break;
                }
            }
            if (lastShown !== null) {
                alphaLinks[lastShown].className = '';
                if (lastShown === num) {
                    colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                    slideCount = 1;
                    slideAmt = colsHeight[lastShown][numCols[lastShown]] / 10;
                    slideAmt = (ieVersion > 0) ? Math.floor(slideAmt) : slideAmt;
                    slideInt = window.setInterval(slideMe(true, lastShown, numCols[lastShown]), 25);
                    lastShown = null;
                    return false;
                }
                heightDiff = colsHeight[num][numCols[num]] - colsHeight[lastShown][lastCols[lastShown]];
                colsList[num][numCols[num]].style.height = colsList[lastShown][lastCols[lastShown]].offsetHeight + 'px';
                colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                colsList[lastShown][lastCols[lastShown]].style.height = '0px';
                alphaLists[lastShown].className = 'shop-by-lists';
                if (heightDiff === 0) {
                    alphaLinks[num].className = 'shop-by-alpha-letter-selected';
                    alphaLists[num].className += ' show-list';
                    colsList[num][numCols[num]].className = '';
                    if (numCols[num] !== lastCols[num]) {
                        alphaLists[num].innerHTML = '';
                        alphaLists[num].appendChild(colsList[num][numCols[num]]);
                        lastCols[num] = numCols[num];
                    }
                    lastShown = num;
                    return false;
                }
            }
            if (numCols[num] !== lastCols[num]) {
                alphaLists[num].innerHTML = '';
                alphaLists[num].appendChild(colsList[num][numCols[num]]);
                lastCols[num] = numCols[num];
            }
            alphaLinks[num].className = 'shop-by-alpha-letter-selected';
            alphaLists[num].className += ' show-list';
            slideCount = 10;
            slideAmt = (heightDiff !== 0) ? heightDiff / 10 : colsHeight[num][numCols[num]] / 10;
            slideAmt = (ieVersion > 0) ? Math.floor(slideAmt) : slideAmt;
            colsList[num][numCols[num]].className = 'hide-lists';
            slideInt = window.setInterval(slideMe(false, num, numCols[num]), 25);
            lastShown = num;
            heightDiff = 0;
            return false;
        };
    };
    
    showAll = function () {
        return function () {
            if (seeAll.innerHTML === '+ show all') {
                for (k = 0; k < alphaLinks.length; k++) {
                    alphaLists[k].className = alphaLists[k].className.replace(new RegExp(' show-list\\b'), '');
                    alphaLinks[k].onclick = null;
                    alphaLists[k].className += ' show-list';
                    alphaLinks[k].className = '';
                    
                    if (!colsList[k]) {
                        createCols(k);
                    }
                    for (i = maxCols[k]; i > -1; i--) {
                        if (colsTotalWidth[k][i] < container.offsetWidth) {
                            numCols[k] = i;
                            break;
                        }
                    }
                    if (numCols[k] !== lastCols[k]) {
                        alphaLists[k].innerHTML = '';
                        alphaLists[k].appendChild(colsList[k][numCols[k]]);
                        lastCols[k] = numCols[k];
                    }
                    colsList[k][numCols[k]].style.height = '';
                    colsList[k][numCols[k]].style.padding = '10px 0';
                    if (k > 0) {
                        colsList[k][numCols[k]].style.borderTop = '1px solid #ccc';
                    }
                }
                lastShown = null;
                seeAll.innerHTML = '&mdash; hide all';
            } else {
                for (k = 0; k < alphaLinks.length; k++) {
                    alphaLinks[k].onclick = showList(k);
                    alphaLists[k].className = alphaLists[k].className.replace(new RegExp(' show-list\\b'), '');
                    colsList[k][numCols[k]].style.height = '0px';
                    colsList[k][numCols[k]].style.padding = '';
                    if (k > 0) {
                        colsList[k][numCols[k]].style.borderTop = '';
                    }
                }
                seeAll.innerHTML = '+ show all';
            }
            return false;
        };
    };
    
    // init
    if (container) {
        if (hideable) {
            linksContainer = getElementsByClassName(container, 'shop-by-alpha-links', 'span')[0];
            alphaLinks = linksContainer.getElementsByTagName('a');
            for (i = 0; i < alphaLinks.length; i++) {
                alphaLinks[i].onclick = showList(i);
            }
            seeAll = document.createElement('a');
            seeAll.innerHTML = '+ show all';
            seeAll.href = '#';
            seeAll.onclick = showAll();
            seeAll.id = 'shop-by-show-all';
            linksContainer.parentNode.insertBefore(seeAll, linksContainer);
            clearDiv = document.createElement('div');
            clearDiv.style.clear = 'both';
            container.appendChild(clearDiv);
        }
        allLists = getElementsByClassName(container, 'shop-by-lists', 'ul');
        for (k = 0; k < allLists.length; k++) {
            alphaLists[k] = allLists[k];
            liWidths[k] = [];
            lastCols[k] = -1;
            liLinks = alphaLists[k].getElementsByTagName('a');
            for (j = 0; j < liLinks.length; j++) {
                liWidths[k][j] = liLinks[j].offsetWidth;
            }
            titleList[k] = allLists[k].getElementsByTagName('ul')[0];
            if (titleList[k].getElementsByTagName('li')[0].className === 'shop-by-pic-link' || titleList[k].getElementsByTagName('li')[0].className === 'shop-by-big-letter') {
                title[k] = titleList[k].cloneNode(true);
                alphaLists[k].getElementsByTagName('li')[0].removeChild(titleList[k]);
            } else {
                noTitleList = true;
            }
            if (!hideable) {
                alphaLists[k].className += ' show-list';
                createCols(k);
                alphaLists[k].innerHTML = '';
                alphaLists[k].appendChild(colsList[k][1]);
                lastCols[k] = 1;
            }
        }
        window.setInterval(windowResize(), 200);
        container.className += ' shop-by-script';
    }
}

function AlphaListTags(id, hideable) {
    var linksContainer, alphaLinks, i, showList, allLists, alphaLists = [], liWidths = [], lastCols = [], liLinks, j, windowResize, lastWindowWidth = 0, colsHeight = [], createCols, colsTotalWidth = [], colsList = [], slideMe, slideInt = null, slideCount = 1, slideAmt, heightDiff =  0, maxCols = [], maxWidth, numCols = [], lastShown = null, titleList = [], title = [], k,  noTitleList = false, seeAll, showAll, clearDiv,
    container = document.getElementById(id),
    ieVersion = getIEVersion();
    
    slideMe = function (closeMe, list, cols) {
        return function () {
            if (closeMe) {
                if (slideCount < 9) {
                    colsList[list][cols].style.height = colsList[list][cols].offsetHeight - slideAmt + 'px';
                    slideCount++;
                } else {
                    colsList[list][cols].style.height = '0px';
                    alphaLists[list].className = 'shop-by-lists';
                    window.clearInterval(slideInt);
                    slideInt = null;
                }
            } else {
                if (slideCount > 2) {
                    colsList[list][cols].style.height = colsList[list][cols].offsetHeight + slideAmt + 'px';
                    slideCount--;
                } else {
                    colsList[list][cols].style.height = colsHeight[list][cols] + 'px';
                    colsList[list][cols].className = '';
                    window.clearInterval(slideInt);
                    slideInt = null;
                }
            }
        };
    };
    
    windowResize = function () {
        return function () {
            if (lastWindowWidth !== document.body.offsetWidth) {
                lastWindowWidth = document.body.offsetWidth;
                if (lastShown !== null) {
                    for (i = maxCols[lastShown] - 1; i > -1; i--) {
                        if (colsTotalWidth[lastShown][i] < container.offsetWidth) {
                            numCols[lastShown] = i;
                            break;
                        }
                    }
                    if (numCols[lastShown] !== lastCols[lastShown]) {
                        colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                        colsList[lastShown][numCols[lastShown]].style.height = colsHeight[lastShown][numCols[lastShown]] + 'px';
                        colsList[lastShown][numCols[lastShown]].className = '';
                        alphaLists[lastShown].removeChild(colsList[lastShown][lastCols[lastShown]]);
                        alphaLists[lastShown].appendChild(colsList[lastShown][numCols[lastShown]]);
                        lastCols[lastShown] = numCols[lastShown];
                    }
                } else if (!hideable || seeAll.innerHTML.match('hide all')) {
                    for (i = 0; i < alphaLists.length; i++) {
                        for (j = maxCols[i]; j > -1; j--) {
                            if (colsTotalWidth[i][j] < container.offsetWidth) {
                                numCols[i] = j;
                                break;
                            }
                        }
                        if (numCols[i] !== lastCols[i]) {
                            alphaLists[i].removeChild(colsList[i][lastCols[i]]);
                            alphaLists[i].appendChild(colsList[i][numCols[i]]);
                            lastCols[i] = numCols[i];
                        }
                        if (hideable) {
                            colsList[i][numCols[i]].style.height = '';
                            colsList[i][numCols[i]].style.paddingTop = '20px';
                            if (i > 0) {
                                colsList[i][numCols[i]].style.borderTop = '1px solid #ccc';
                            }
                        }
                    }
                }
            }
        };
    };
    
    createCols = function (num) {
        var listItems, rows, start, end, list, k, rowsHeight;
        colsTotalWidth[num] = [];
        colsList[num] = [];
        colsHeight[num] = [];
        listItems = alphaLists[num].getElementsByTagName('a');
        maxCols[num] = 11;
        for (i = 1; i < maxCols[num]; i++) {
            rows = Math.ceil(listItems.length / i);
            if (i > 1 && rows < 3) {
                maxCols[num] = i - 1;
                break;
            }
            if (!noTitleList) {
                colsTotalWidth[num][i] = (hideable) ? 80 : 130;
            } else {
                colsTotalWidth[num][i] = 0;
            }
            start = 0;
            end = rows;
            colsList[num][i] = document.createElement('li');
            rowsHeight = rows * 18;
            colsHeight[num][i] = (rowsHeight > 63) ? rowsHeight : 63;
            if (hideable) {
                colsList[num][i].style.height = '0px';
            }
            if (!noTitleList) {
                colsList[num][i].appendChild(title[num].cloneNode(true));
            }
            for (j = 0; j < i; j++) {
                if (listItems[start]) {
                    list = document.createElement('ul');
                    maxWidth = 0;
                    for (k = start; k < end; k++) {
                        if (listItems[k]) {
                            list.appendChild(listItems[k].parentNode.cloneNode(true));
                            if (liWidths[num][k] > maxWidth) {
                                maxWidth = liWidths[num][k];
                            }
                        }
                    }
                    if (hideable) {
                        maxWidth += 20;
                    } else {
                        maxWidth += 50;
                    }
                    colsTotalWidth[num][i] += maxWidth;
                    if (ieVersion === 6) {
                        list.style.width = maxWidth - 30 + 'px';
                    }
                    start += rows;
                    end += rows;
                    colsList[num][i].appendChild(list);
                }
            }
        }
    };
    
    showList = function (num) {
        return function () {
            this.blur();
            if (slideInt !== null) {
                return false;
            }
            if (!colsList[num]) {
                createCols(num);
            }
            for (i = maxCols[num]; i > -1; i--) {
                if (colsTotalWidth[num][i] < container.offsetWidth) {
                    numCols[num] = i;
                    break;
                }
            }
            if (lastShown !== null) {
                alphaLinks[lastShown].className = '';
                if (lastShown === num) {
                    colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                    slideCount = 1;
                    slideAmt = colsHeight[lastShown][numCols[lastShown]] / 10;
                    slideAmt = (ieVersion > 0) ? Math.floor(slideAmt) : slideAmt;
                    slideInt = window.setInterval(slideMe(true, lastShown, numCols[lastShown]), 25);
                    lastShown = null;
                    return false;
                }
                heightDiff = colsHeight[num][numCols[num]] - colsHeight[lastShown][lastCols[lastShown]];
                colsList[num][numCols[num]].style.height = colsList[lastShown][lastCols[lastShown]].offsetHeight + 'px';
                colsList[lastShown][lastCols[lastShown]].className = 'hide-lists';
                colsList[lastShown][lastCols[lastShown]].style.height = '0px';
                alphaLists[lastShown].className = 'shop-by-lists';
                if (heightDiff === 0) {
                    alphaLinks[num].className = 'shop-by-alpha-letter-selected';
                    alphaLists[num].className += ' show-list';
                    colsList[num][numCols[num]].className = '';
                    if (numCols[num] !== lastCols[num]) {
                        alphaLists[num].innerHTML = '';
                        alphaLists[num].appendChild(colsList[num][numCols[num]]);
                        lastCols[num] = numCols[num];
                    }
                    lastShown = num;
                    return false;
                }
            }
            if (numCols[num] !== lastCols[num]) {
                alphaLists[num].innerHTML = '';
                alphaLists[num].appendChild(colsList[num][numCols[num]]);
                lastCols[num] = numCols[num];
            }
            alphaLinks[num].className = 'shop-by-alpha-letter-selected';
            alphaLists[num].className += ' show-list';
            slideCount = 10;
            slideAmt = (heightDiff !== 0) ? heightDiff / 10 : colsHeight[num][numCols[num]] / 10;
            slideAmt = (ieVersion > 0) ? Math.floor(slideAmt) : slideAmt;
            colsList[num][numCols[num]].className = 'hide-lists';
            slideInt = window.setInterval(slideMe(false, num, numCols[num]), 25);
            lastShown = num;
            heightDiff = 0;
            return false;
        };
    };
    
    showAll = function () {
        return function () {
            if (seeAll.innerHTML === '+ show all') {
                for (k = 0; k < alphaLinks.length; k++) {
                    alphaLists[k].className = alphaLists[k].className.replace(new RegExp(' show-list\\b'), '');
                    alphaLinks[k].onclick = null;
                    alphaLists[k].className += ' show-list';
                    alphaLinks[k].className = '';
                    
                    if (!colsList[k]) {
                        createCols(k);
                    }
                    for (i = maxCols[k]; i > -1; i--) {
                        if (colsTotalWidth[k][i] < container.offsetWidth) {
                            numCols[k] = i;
                            break;
                        }
                    }
                    if (numCols[k] !== lastCols[k]) {
                        alphaLists[k].innerHTML = '';
                        alphaLists[k].appendChild(colsList[k][numCols[k]]);
                        lastCols[k] = numCols[k];
                    }
                    colsList[k][numCols[k]].style.height = '';
                    colsList[k][numCols[k]].style.padding = '10px 0';
                    if (k > 0) {
                        colsList[k][numCols[k]].style.borderTop = '1px solid #ccc';
                    }
                }
                lastShown = null;
                seeAll.innerHTML = '&mdash; hide all';
            } else {
                for (k = 0; k < alphaLinks.length; k++) {
                    alphaLinks[k].onclick = showList(k);
                    alphaLists[k].className = alphaLists[k].className.replace(new RegExp(' show-list\\b'), '');
                    colsList[k][numCols[k]].style.height = '0px';
                    colsList[k][numCols[k]].style.padding = '';
                    if (k > 0) {
                        colsList[k][numCols[k]].style.borderTop = '';
                    }
                }
                seeAll.innerHTML = '+ show all';
            }
            return false;
        };
    };
    
    // init
    if (container) {
        if (hideable) {
            linksContainer = getElementsByClassName(container, 'shop-by-alpha-links', 'span')[0];
            alphaLinks = linksContainer.getElementsByTagName('a');
            for (i = 0; i < alphaLinks.length; i++) {
                alphaLinks[i].onclick = showList(i);
            }
            seeAll = document.createElement('a');
            seeAll.innerHTML = '+ show all';
            seeAll.href = '#';
            seeAll.onclick = showAll();
            seeAll.id = 'shop-by-show-all';
            linksContainer.parentNode.insertBefore(seeAll, linksContainer);
            clearDiv = document.createElement('div');
            clearDiv.style.clear = 'both';
            container.appendChild(clearDiv);
        }
        allLists = getElementsByClassName(container, 'shop-by-lists', 'ul');
        for (k = 0; k < allLists.length; k++) {
            alphaLists[k] = allLists[k];
            liWidths[k] = [];
            lastCols[k] = -1;
            liLinks = alphaLists[k].getElementsByTagName('a');
            for (j = 0; j < liLinks.length; j++) {
                liWidths[k][j] = liLinks[j].offsetWidth;
            }
            titleList[k] = allLists[k].getElementsByTagName('ul')[0];
            if (titleList[k].getElementsByTagName('li')[0].className === 'shop-by-pic-link' || titleList[k].getElementsByTagName('li')[0].className === 'shop-by-big-letter') {
                title[k] = titleList[k].cloneNode(true);
                alphaLists[k].getElementsByTagName('li')[0].removeChild(titleList[k]);
            } else {
                noTitleList = true;
            }
            if (!hideable) {
                alphaLists[k].className += ' show-list';
                createCols(k);
                alphaLists[k].innerHTML = '';
                alphaLists[k].appendChild(colsList[k][1]);
                lastCols[k] = 1;
            }
        }
        window.setInterval(windowResize(), 200);
        container.className += ' shop-by-script';
    }
}

function ShopByScroller(id) {
    var container, boxes, i, totalWidth, scrollInt, scrollBoxes, currentPos = 0, resetSpot, mouseOver, prevBut, nextBut, fastScroll, fastCount, frame, 
    outerDiv = document.getElementById(id);
    
    fastScroll = function (direction) {
        return function () {
            nextBut.onclick = null;
            prevBut.onclick = null;
            container.onmouseover = null;
            if (scrollInt !== null) {
                window.clearInterval(scrollInt);
            }
            fastCount = 0;
            resetSpot += direction;
            scrollInt = window.setInterval(scrollBoxes(direction), 50);
        };
    };
    
    mouseOver = function (over) {
        return function () {
            if (over) {
                if (scrollInt !== null) {
                    window.clearInterval(scrollInt);
                    scrollInt = null;
                }
            } else {
                if (scrollInt === null) {
                    scrollInt = window.setInterval(scrollBoxes(1), 25);
                }
            }
        };
    };
    
    scrollBoxes = function (speed) {
        return function () {
            currentPos -= speed;
            if (speed !== 1) {
                fastCount++;
                if (fastCount === 10) {
                    window.clearInterval(scrollInt);
                    resetSpot = -totalWidth + 2;
                    prevBut.onclick = fastScroll(-20);
                    nextBut.onclick = fastScroll(20);
                    container.onmouseover = mouseOver(true);
                    scrollInt = window.setInterval(scrollBoxes(1), 25);
                }
            }
            if (speed > 0) {
                currentPos = (currentPos < resetSpot) ? 0 : currentPos;
            } else {
                currentPos = (currentPos > -20) ? resetSpot : currentPos;
            }
            container.style.left = currentPos + 'px';
        };
    };
    
    // init
    if (outerDiv) {
        frame = getElementsByClassName(outerDiv, 'shop-by-scroll-frame', 'div')[0];
        frame.className += ' with-script';
        container = getElementsByClassName(frame, 'shop-by-scroll-container', 'div')[0];
        if (container) {
            boxes = getElementsByClassName(container, 'shop-by-scroll-box', 'div');
            totalWidth = boxes.length * 192;
            resetSpot = -totalWidth + 2;
            container.style.width = (totalWidth * 2) + 'px';
            for (i = 0; i < boxes.length; i++) {
                container.appendChild(boxes[i].cloneNode(true));
            }
            container.onmouseover = mouseOver(true);
            container.onmouseout = mouseOver(false);
            prevBut = getElementsByClassName(outerDiv, 'shop-by-scroll-prev', 'div')[0];
            prevBut.className = 'shop-by-scroll-prev-on';
            prevBut.onclick = fastScroll(-20);
            nextBut = getElementsByClassName(outerDiv, 'shop-by-scroll-next', 'div')[0];
            nextBut.className = 'shop-by-scroll-next-on';
            nextBut.onclick = fastScroll(20);
            scrollInt = window.setInterval(scrollBoxes(1), 25);
        }
    }
}

function ucwords(str) {
    // Uppercase the first character of every word in a string  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/ucwords
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Waldo Malqui Silva
    // +   bugfixed by: Onno Marsman
    // +   improved by: Robin
    // *     example 1: ucwords('kevin van zonneveld');
    // *     returns 1: 'Kevin Van Zonneveld'
    // *     example 2: ucwords('HELLO WORLD');
    // *     returns 2: 'HELLO WORLD'
    return (str + '').replace(/^(.)|\s(.)/g, function ($1) {
        return $1.toUpperCase();
    });
}


//--> 
