function changeUrl() {
    if(periodtype == 'day') {
        var newlocation = window.location.pathname + '?period=' + $("#years").val() + '-' + $("#months").val() + '-' + $("#days").val();
//        alert(newlocation);
        window.location = newlocation;
    }
/*
    if(periodtype == 'week') {
        window.location = window.location.pathname + '?period=' + 
    }
*/
    if(periodtype == 'month') {
        var newlocation = window.location.pathname + '?period=' + $("#years").val() + $("#months").val();
//        alert(newlocation);
        window.location = newlocation;
    }
    if(periodtype == 'year') {
        var newlocation = window.location.pathname + '?period=' + $("#years").val();
//        alert(newlocation);
        window.location = newlocation;
    }
}

$(document).ready(function(){

    $("#years").change( function () {
//        alert('Year is changed, ' + periodtype + ', ' + window.location.pathname);
        changeUrl();
    });

    $("#months").change( function () {
//        alert('Month is changed, ' + periodtype);
        changeUrl();
    });

    $("#days").change( function () {
//        alert('Day is changed, ' + periodtype);
        changeUrl();
    });

});
