jQuery(document).ajaxSend(function(r,s){
    jQuery("#section02").html("");
    jQuery("#section02").addClass("dynamicPopulate_Updating");
});

function updateResultsList(value) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/GetProdList",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
} 
function filterByKeyword(value) { 
    var j = document.getElementsByName('collapsiblePanelCustomSearchText');
    var regex = /^([\w\.]|\s){0,255}/;
    for (var i=0; i< j.length; i++){
        value = j[i].value;
    }
    if (value == ''){
        alert('A value is required.');
    }else if(!value.match(regex)){
        alert('Only Alpha and Numeric characters are allowed.');
    }else{
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/FilterByKeyword",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
    }
}
function filterByPercentage(value) { 
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/FilterByPercentage",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}
function filterByPrice(value) { 
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/FilterByPrice",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}
function filterByBrand(value) { 
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/FilterByBrand",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}

function removeFilter(value) { 
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/RemoveFilter",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}

function setSortBy(value){   
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/SetSortBy",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}

function setPerPage(value){
    jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "AjaxWS.asmx/SetPerPageCount",
        data: "{ 'contextKey' :  '" + value + "' }",
        dataType: "json",
        async: true,
        success: function(result) {
            var htmlResult = result.d;
            jQuery("#section02").removeClass("dynamicPopulate_Updating");
            jQuery("#section02").html(htmlResult);
            setDefaultFontSize();
        }
    });
}
function OpenReviewWindow(ASID) {
    window.open("http://www.midwayusa.com/eproductreview.exe/GetReviews?productid=" + ASID, 'ReadReviews', 'statusbar=false,toolbar=false,scrollbars=yes,resizable=yes,width=425,height=300');
}