﻿// jQuery calls

$(document).ready(function() {   
    //columnizer puts the categories on the homepage into 3 columns
    $('.main-content .categories').makeacolumnlists({ cols: 3, colWidth: 0, equalHeight: 'ul', startN: 1 });

    //alternating row colors
    doRowAlterations();

    //might use this to equalize the column height, causes some problems when doing an ajax call with the height / looking for another solution
    //   var highestCol = Math.max($('.main-content').height(),$('.sidebar').height());
    //  $('.sidebar').height(highestCol);
    //  $('.main-content').height(highestCol);

});

function doRowAlterations() {
    $(".list-row:odd").addClass("odd-bg");
    $(".list-row:even").addClass("even-bg");
    $(".list-row:first").css("margin-top", "10px");
    $(".list-row:last").css("margin-bottom", "10px");
}

function DoBreadCrumbAsCat(linkText, categoryId, categoryName) {
    if (linkText == 'Search') {
        var term = document.getElementById('searchBox').value.replace(' ', '_');
        if (term.length > 0) {
            var link = '<a onclick="loadView(\'/Search/?searchBox=' + term + '\', \'donothing\', \'doRowAlterations()\')">> "' + document.getElementById('searchBox').value + '"</a>';
            if (categoryId > 0) {
                link = '<a onclick="loadView(\'/Search/?categoryId=' + categoryId + '\', \'donothing\', \'doRowAlterations()\')">> "' + categoryName + '"</a>';
            }
            document.getElementById('navSearchTerm').innerHTML = link;
        }
    } else {
        document.getElementById('navSearchTerm').innerHTML = '';
    }
    document.getElementById('navSearchType').innerHTML = linkText;
    if (linkText == 'Search' || linkText == 'My Items' || linkText == 'My Purchases') {
        $('.breadcrumb').show();
    } else {
        $('.breadcrumb').hide();
    }

}
function DoBreadCrumb(linkText) {
    DoBreadCrumbAsCat(linkText, 0, '');
} 
