function FindPrevious(url) {
    var yearDoc = document.getElementById('YearFrom');
    var monthDoc = document.getElementById('MonthFrom');
    var yearDocTo = document.getElementById('YearTo');
    var monthDocTo = document.getElementById('MonthTo');
    var yearVal = "";
    var monthVal = "";
    var yearValTo = "";
    var monthValTo = "";
    var companyFilterVal = document.getElementById('CompanyFilter').value;
    var countryFilterVal = document.getElementById('CountryFilter').value;
    var customCategories = GetCategories();
    if (yearDoc != null && yearDoc != 'undefined') yearVal = yearDoc.value;
    if (monthDoc != null && monthDoc != 'undefined') monthVal = monthDoc.value;
    if (yearDocTo != null && yearDocTo != 'undefined') yearValTo = yearDocTo.value;
    if (monthDocTo != null && monthDocTo != 'undefined') monthValTo = monthDocTo.value;
    location = url + "&yearfrom=" + yearVal + "&monthfrom=" + monthVal + 
        "&CustomCategories=" + customCategories + "&monthto=" + monthValTo + "&yearto=" + yearValTo +
        "&companyFilter=" + companyFilterVal + "&countryFilter=" + countryFilterVal;
}

function GetCategories() {
    var allcategories = document.getElementById('CustomCategoriesID').value.split(",");
    var result = "";
    for (var i = 0; i < allcategories.length; i++) {
        var check = document.getElementById("CustomCategory" + allcategories[i]);
        if (check.checked) result += check.value + ",";
    }
    return result;
}
