// Functions to show and hide the categories in the left hand navigation
// Used jQuery - DO NOT UNINSTLL JQUERY PLEASE!
// Ben Major - LincWeb Design - www.lincweb-design.com

$(function() {
    // Handle when they click on ".parentitem":
    $('.parentitem').click(function() {
        var the_cat_id = $(this).attr('data-catid');
        var the_child  = $('#sub_' + the_cat_id);
        
        if(the_child.is(':visible'))
        {
            return true;
        }
        else
        {
            the_child.slideDown('fast');
            return false;
        }
    });
});

// Function to handle the changing of VAT using the settings at the top:
$(function() {
    
    $('input[name="pricetype"]').change(function() {
        
        var the_value = $(this).val();
        $.ajax({
            url:  '/ben/scripts/price.ajax.php',
            data: 'value=' + the_value
        });
        
        switch(the_value)
        {
            case 'incvat':
                $('span.price.exvat').fadeOut('fast', function() { $('span.price.incvat').fadeIn('fast'); });
                break;
            
            case 'exvat':
                $('span.price.incvat').fadeOut('fast', function() { $('span.price.exvat').fadeIn('fast'); });
                break;
        }
        
    });
    
});
