﻿function materialSelect_change(selectObj) {
    var idx = selectObj.selectedIndex;
    var selectedItem = selectObj.options[idx].value;
    var urlString = document.URL;
    var urlArray = urlString.split("&matrial=");
    window.location = urlArray[0] + "&matrial=" + selectedItem;
}

function showCart() {
    $("#content").hide();
    $("#wrapper").append($("#cartContent"));
    $("#cartContent").show();
}
function showSelect() {
    $("#content").show();
    $("#cartContent").hide();
}

//// Show and Hide Default Text in header search ////
$(function () {
    $('#q').each(function () {
        $.data(this, 'default', this.value);
    }).focus(function () {
        if ($.data(this, 'default') == this.value) {
            this.value = '';
        }
    }).blur(function () {
        if (this.value == '') {
            this.value = $.data(this, 'default');
        }
    });

    /// Home Page Learn More Links ///
    var learnmorelink = $('a.learnmore');

    $("#grid .category a.mainlink:eq(0)").hover(function () {
        $(this).addClass('hover');
        $(this).siblings(learnmorelink).addClass('hover');
    }, function () {
        $(this).removeClass('hover');
        $(this).siblings(learnmorelink).removeClass('hover');
    });

    $(learnmorelink).hover(function () {
        $(this).addClass('hover');
        $(this).siblings("#grid .category a.mainlink").addClass("hover");
    }, function () {
        $(this).removeClass('hover');
        $(this).siblings("#grid .category a.mainlink").removeClass("hover");
    });

    //$('.awesome').corner();

    /// More Info Pages 'Back to Top Links' & Image Dialogs & Read More Links ///
    $(function () {
        try {
            $.expander.defaults.slicePoint = 300;
            $('div.expandable').expander({
                expandEffect: 'slideDown',
                expandSpeed: 800,
                expandText: 'Show More Information &rarr;',
                collapseEffect: 'slideUp',
                collapseSpeed: 800,
                userCollapseText: '&larr; Show Less Information'
            });

            $('a.lightbox').lightBox();

            $('.back-top a').click(function () {
                $('body,html').animate({ scrollTop: 0 }, 800);
                return false;
            });
        }
        catch (err) {
            
        }
    });


    /// Product Page Filtering Options ///
    $(".row:odd").addClass("odd"); // Add ability to 'stripe' rows
    $(".row:even").addClass("even");
    $(".row:last").css("border-bottom", "0");

    $(".row:gt(5):not('.buttons')").css("display", "none"); // Hide all rows after the 6th, except the row that holds the buttons (zero-based)
    $("#more a").live('click', function (e) { // If 'Filter with More Options' is clicked,
        e.preventDefault();
        $(".row:gt(5)").fadeIn(); // fade in the rest of the filtering options,
        $(this).text("Filter with Less Options").addClass('less'); // and change the text and add a new class.
    });
    $("#more a.less").live('click', function (e) { // If 'Filter with Less Options' is clicked,
        e.preventDefault();
        $(".row:gt(5):not('.buttons')").fadeOut('fast'); // hide the previously added filtering options,
        $(this).text("Filter with More Options").removeClass('less'); // and change the text back to it's orignal state.
    });

    //// Stop Highlighting Section Headers in Left Column on Hover ////
    $("ul#prod-list li b").parent().addClass("nohover");

    //// Pop Up Table Striping ////
    $("#pricesgrid tr:odd").addClass("odd"); // Add ability to 'stripe' rows
    $("#pricesgrid tr:even").addClass("even");
});
