jQuery(document).ready(function($){
    function count_price() {
        var price = 0.00;
            
        $("[type=radio]:checked").each(function(index) {
            var id = $(this).attr('id');
            var value = $(this).attr('value');  
            var class = $(this).attr('class');
            if(class == 'price' && value != 2) {
                if(id == 'price_0_1') {
                    var quantity  = $('#counter_0_1').val();
                    price += (parseInt(quantity)*parseInt($(this).attr('price')));
                } else if (id == 'price_0_0') {
                    var quantity  = $('#counter_0_0').val();
                    price += (parseInt(quantity)*parseInt($(this).attr('price')));
                } else {
                    price += parseInt($(this).attr('price'));
                }
            }
        })

        $("#price_total").html('Price Total: &pound;'+price);
    }
    
    $("[type=radio]").click(function(){ 
        count_price();    
    }); 
    
    $("select").change(function(){
        count_price();
    }); 
    
    if($('#paypal-autosubmit').length) {
        $('#paypal-autosubmit').submit();
    }
});
