﻿$(function() {
    $('#navWrap ul').superfish();    // Enable Superfish Menus with HoverIntent delay

    // add first and last classes to the appropriate LI's
    $('#navWrap ul li:first-child').addClass('first');
    $('#navWrap ul li:last-child').addClass('last');


    // add first and last classes to the appropriate LI's
    $('.breadcrumbWrap ul li:first-child').addClass('first');
    $('.breadcrumbWrap ul li:last-child').addClass('last');


    // remove the a tag from the last li if it exists
    var liLast = $('.breadcrumbWrap ul li:last-child');

    if ($('a', liLast).length == 1)
        liLast.html('<span style="display:none;">A tag removed by /js/mojoJs/navAndSearch.js</span>' + $('a', liLast).html());


    // add the altRow styling to any table that needs it
		altItem("table tbody","tr"); // class is added to odd rows
		altItem("table:not(:has(thead)) tbody","tr", "even"); // class is added to even rows
    
    /* 
    **** Implement as needed ****
    
    $('#brandProductSubCats').superfish();    // Enable Superfish Menus with HoverIntent delay
    $('h1 + h2').addClass("firstH2");

    // For search on keypress 'Enter'
    $("#query2").keypress(function(e)
    {
        if (e.which == 13) searchPico();
    });
    */
});

/*
function searchPico()
{
    searchStr = $("#query2").val();
    newForm = "<div class=\"Searching\"><form id=\"searchForm\" name=\"frmSearch\" action=\"/products/search.aspx\" method=\"post\"><input type=\"hidden\" name=\"index2\" value=\"205096\" /><input type=\"query2\" name=\"query2\" value=\"" + searchStr + "\" /></form><h1>Searching...</h1></div>";
    $("body").html(newForm).find("form").submit();
}
*/

function altItem(p,c,e) {
	// p: jQuery selector statement for container of altItems; ie. "table"
	// c: jQuery selector statement of altItems via .find() prototype; ie. "tr"
	// e: Determines if altItems are odd or even; ie. ("odd" | "even") optional
	// examples:  altItem("table", "tr"); altItem(".sidebar > ul", "li", "even");
	e = (!e ? "odd" : e);
	$(p).each(function() {
		$(this).find(c).removeClass("altItem").filter(":visible:"+e).addClass("altItem");
	});
}
