jQuery(document).ready(function () {
    filterSelectSubmit();
    miniCartToggle();
    leftNav();
});

function filterSelectSubmit() {
    jQuery('#filterForm select').change(function () {
        jQuery('#filterForm').submit();
    });
};

function miniCartToggle() {
    jQuery('#viewCart').click(function () {
        jQuery('#miniCart').slideToggle('medium');
    });
};
function leftNav() {
    jQuery('.menuToggle ~ li').hide();
    jQuery('#leftNav .viewMore').show();
    jQuery('#leftNav .viewMore').toggle(function () {
        jQuery(this).children('a').text('View Less');
        jQuery(this).siblings('.menuToggle ~ li').show('fast');

    }, function () {
        jQuery(this).children('a').text('View More');
        jQuery(this).siblings('.menuToggle ~ li').hide('fast');

    });
}

jQuery(function ($) {

    // Places text from a title attribute into an input
    jQuery.fn.hint = function () {
        return this.each(function () {
            var t = $(this);
            var title = t.attr('title');

            if (title) {
                t.focus(function () {
                    if (t.val() == title) {
                        t.val('');
                        t.removeClass('blur');
                    }
                })

                t.blur(function () {
                    if (t.val() == '') {
                        t.val(title);
                        t.addClass('blur');
                    }
                })

                t.parents('form:first').submit(function () {
                    if (t.val() == title) {
                        t.val('');
                        t.removeClass('blur');
                    }
                });

                t.blur();
            }
        })
    }

    // drops a hint in input fields
    $('input:text').hint();
});
