﻿$(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');

	//Focus on the search box on page load
    $("#header #txtSearch").focus();


    // 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 runSearch()
    {
        var strURL = '/search/results.aspx?cx=008112444754083711906:oq92vhwimh0&cof=FORID:9&ie=UTF-8&q=';
        var strSearch = document.getElementById('txtSearch').value;

        if (strSearch != '') 
        {
            strURL += strSearch;
            // go to search
            window.location = strURL;
        }
    }
    
    // run search on enter
    function detectEnter(e) 
    {
        var keynum;

        if (window.event) // IE
            keynum = e.keyCode;
        else if (e.which) // Netscape/Firefox/Opera
            keynum = e.which;

        if (keynum == 13)
            runSearch();

        return keynum != 13;
    }

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");
	});
}


