$(document).ready(function(){
        var text_waiting = 'Loading filler rate';
        var div_waiting = '<div id="sh_initialLoading" style="margin: 10px auto; background-image: url(https://www.nextinsure.com/ListingDisplay/Images/300x137_loading_bg.gif); text-align: center; width: 300px; height: 137px; font-family: Arial; font-weight: bold; color: rgb(51, 51, 51); background-repeat: no-repeat; font-size: 16px; padding-top: 30px;">'+text_waiting+'<br/><img src="https://www.nextinsure.com/ListingDisplay/Images/thumper.gif" style="border: 0pt none ; width: 35px; height: 35px; margin-top: 5px;"/></div>'
        //get val ni_rp, ni_amt, ni_rpt from rate-table.tpl, products.tpl
        var rp = ni_rp;
        var amount = ni_amt;
        var rateterm = ni_rpt;

        //load filler rate in rate-table.tpl, products.tpl
        function loadFillerRate(rp, amount, rateterm) {
            var filler_url = '/filler_rate.php?rp='+rp+'&amount='+amount+'&rateterm='+rateterm;

            $.get(filler_url, function(data){
                $('#filler_rate').html(data);
                $('#filler_rate').append('<a href="#fill-table" class="see-toprates" style="font-size: 1.2em; text-decoration:underline;font-weight:bold; padding-left:5px; display:none; ">See top rates</a>');
            },'html');
        }

        $('#filler_rate').html(div_waiting);
        loadFillerRate(rp, amount, rateterm);

        //reload filler rate when change params rp, amount, rateterm
        $('#updateResultsCell img').click(function (){
            $('#filler_rate').html(div_waiting);
            rp = $('#sh_rpFilter').val();
            amount = $('#sh_amtFilter').val();
            rateterm = $('#sh_rtFilter').val();
            if(rp == '' || amount == '')
                $('#filler_rate').html("No result;");
            else
                loadFillerRate(rp, amount, rateterm);
        });

});