<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/star-rating.js"></script>
<script src="js/MyJs.js"></script>
<script>
    jQuery(document).ready(function () {
        $("input:radio[name=product_imp]").click(function () {
            var value = $(this).val();
            if (value == "Yes") {
                $('#email').prop('required', true);
            } else {
                $('#email').prop('required', false);
            }
        });
        $("#input-21f").rating({
            starCaptions: function (val) {
                if (val < 3) {
                    return val;
                } else {
                    return 'high';
                }
            },
            starCaptionClasses: function (val) {
                if (val < 3) {
                    return 'label label-danger';
                } else {
                    return 'label label-success';
                }
            },
            hoverOnClear: false
        });
        var $inp = $('#rating-input');

        $inp.rating({
            min: 0,
            max: 5,
            step: 1,
            size: 'lg',
            showClear: false
        });

        $('#btn-rating-input').on('click', function () {
            $inp.rating('refresh', {
                showClear: true,
                disabled: !$inp.attr('disabled')
            });
        });


        $('.btn-danger').on('click', function () {
            $("#kartik").rating('destroy');
        });

        $('.btn-success').on('click', function () {
            $("#kartik").rating('create');
        });

        $inp.on('rating.change', function () {
            alert($('#rating-input').val());
        });


        $('.rb-rating').rating({
            'showCaption': true,
            'stars': '3',
            'min': '0',
            'max': '3',
            'step': '1',
            'size': 'xs',
            'starCaptions': {0: 'status:nix', 1: 'status:wackelt', 2: 'status:geht', 3: 'status:laeuft'}
        });
        $("#input-21c").rating({
            min: 0, max: 8, step: 0.5, size: "xl", stars: "8"
        });
    });



    jQuery(document).ready(function () {
        $("#question_1").hide();
        $("input:radio[name=rebate]").click(function () {
            var value = $(this).val();
            if (value == "No") {
                $('#r_name').prop('required', true);
                $('#r_address').prop('required', true);
                $('#r_city').prop('required', true);
                $('#r_state').prop('required', true);
				$('#r_Zip').prop('required', true);
				
<?php if (!empty($_SESSION['amazon_order_id'])) { ?>
                    $.get('function.php?action=customer_details&code=<?php echo $_SESSION['amazon_order_id'] ?>', function (data) {
                        var data = jQuery.parseJSON(data);
                        $("#r_name").val(data.customer_name);
                        $("#r_address").val(data.address);
                        $("#r_city").val(data.city);
                        $("#r_state").val(data.state);
						$('#r_Zip').val(data.zip);
                    });
<?php } ?>

                $("#question_1").show();
                $("#charity_list").hide();
            } else {
				$('#r_name').prop('required', false);
                $('#r_address').prop('required', false);
                $('#r_city').prop('required', false);
                $('#r_state').prop('required', false);
				$('#r_Zip').prop('required', false);
                $("#question_1").hide();
				
                $("#charity_list").show();
            }
        });
    });
</script>