$(document).ready(function(){
    
        if($('.offers-card-pane').length >= parseInt($('#pageCount').val())){
                                    $('.view-block').addClass('hide');
                                }
                                
        
        
        $(".view-more").on('click',function(){
                var pageID = parseInt($('#pageID').val())+1;
                
				var offerSort =   $('#offerSort').val();
				offerSort = 'sort_priority';
                $.ajax({
                type: "GET",
                url: GLOBAL_BASE_PATH+"/specialoffers/ajaxgetofferslist/sort/"+offerSort+"/page/"+pageID+"/",
                success: function (data) { 
                    if(data != '')
                    { //offers-card
                        $('.special-offers-listing').append(data);
                                $('#pageID').val(pageID);
                                if($('.offers-card-pane').length >= parseInt($('#pageCount').val())){
                                    $('.view-block').addClass('hide');
                                    return false;
                                }
                    }else{
                        $('.view-block').addClass('hide');
                                    return false;
                    }
                        }
                })
        })
        $('#offerSort').change(function(){
             var offertypeid =   $('#offerTypeID').val();
            if(offertypeid == '' || offertypeid == undefined)
                offertypeid = 0;
            var offerSort =   $('#offerSort').val();
            if(offerSort == '' || offerSort == undefined)
                offerSort = 'sort_priority';
            $.ajax({
                        type: "GET",
                        url:GLOBAL_BASE_PATH+"/offergroup/ajaxgetofferslist/id/"+offertypeid+"/sort/"+offerSort+"/gid/"+$('#groupID').val()+"/page/1",
                        success: function(msg){
                            $('.special-offers-listing').html(msg);
                            $('#pageID').val(1);
                            if($('.offers-card-pane').length >= parseInt($('#pageCount').val())){
                                    $('.view-block').addClass('hide');
                                }else{
                                    $('.view-block').removeClass('hide');
                                }
                        }
                 });
        });
});