
function narrow_search_by_brand1(myBrand) {
    var form=document.getElementById('form-filter');
    form.Brand.value=add_remove_filter(form.Brand.value.split(","), "$"+myBrand+"$");
    form.submit();
}
function narrow_search_by_cat1(myCat) {
    var form=document.getElementById('form-filter');
    form.SubCatID.value=add_remove_filter(form.SubCatID.value.split(","), myCat);
    form.submit();
}
function narrow_search_by_price1(myPriceFrom, myPriceTo) {
    var form=document.getElementById('form-filter');
    if (myPriceTo=="") {
        var tmp=myPriceFrom.split(":");
        myPriceFrom=tmp[0];
        myPriceTo=tmp[1];
    }
    form.price_from.value=myPriceFrom;
    form.price_to.value=myPriceTo;
    form.submit();
}
function narrow_search_by_price_add(price) {
    add_to_filter('price_'+price);
}
function narrow_search_by_price_remove(price) {
    remove_from_filter('price_'+price);
}
function add_to_filter(val) {
    var form=document.getElementById('form-filter');
    form.filters.value=form.filters.value+","+val;
    form.submit();
}
function remove_from_filter(val) {
    var form=document.getElementById('form-filter');
    form.rfilters.value=val;
    form.submit();
}
function add_rebate(val) {
    var form=document.getElementById('form-filter');
    form.rebate.value=val;
    form.submit();
}

function add_freeshipping(val) {
    var form=document.getElementById('form-filter');
    form.free_shipping.value=val;
    form.submit();
}
function sort_by(val) {
    var form=document.getElementById('form-filter');
    form.OrderList.value=val;
    form.submit();
}
function add_remove_filter(extsarr, findfilter) {
    var tmp="";
    var found=0;
    for (var i=0; i<extsarr.length; i++) {
        if (findfilter==extsarr[i]) {
            extsarr[i]="";
            found=1;
            break;
        }
    }
    for (i=0; i<extsarr.length; i++) {
        if (extsarr[i]!="") {
            tmp=tmp+extsarr[i]+",";
        }
    }
    if (found==0) {
        tmp=tmp+findfilter+",";
    }
    if (tmp!="") {
        tmp=tmp.substr(0, tmp.length-1);
    }
    return tmp;
}
