﻿
$(document).ready(function () {

    // getAgendaItems(0);
    $(".tb_bachonly").click(function () {
        getAgendaItems(0);
    });
});


function getAgendaItems($pageNum) {
  
    var allchecked = '';
    var comma = '';

    $('.tb_plaats').each(function (index) {
          allchecked += "&tb_plaats=" + this.value;
      });
      $('.tb_bachonly').each(function (index) {
          if ($(this).find("input").attr('checked')) {
              allchecked += "&tb_bachonly=yep";
          }

      });
      $('.tb_componist').each(function (index) {
          allchecked += "&tb_componist=" + this.value;
      });
      $('.tb_werk').each(function (index) {
          allchecked += "&tb_werk=" + this.value;
      });
      $('.tb_uitvoerende').each(function (index) {
          allchecked += "&tb_uitvoerende=" + this.value;
      });
      $('.tb_locatie').each(function (index) {
          allchecked += "&tb_locatie=" + this.value;
      });
      $('.tb_trefwoord').each(function (index) {
          allchecked += "&tb_trefwoord=" + this.value;
      });

      $('.sb_month').each(function (index) {
          allchecked += "&sb_month=" + this.value;
      });
      allchecked = "Page=" + $pageNum + '&1=1' + allchecked

      allchecked = encodeURI(allchecked + '&1=1' + getUrlVars());

    $.ajax({
        type: "GET",
        url: "agendaitems.aspx?" + allchecked,
        success: function (data) {
            $("#agendaitems").html(data);

        },
        error: function (msg, s, d) {
            //alert('ajax error' + msg);
        }
    });
   
    return true;

};

function getUrlVars() {
    var vars = [], hash;
    var strVars;
    strVars = '';
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
        strVars += '&' + hash[0] + '=' + hash[1];
    }
    return strVars;
}

