$(document).ready(function(){
  $("#bpostcode, #huisnummer").bind("click", function(){
    alert('click');

    $.ajax({
      url: 'http://api.art4m.nl/lookup/5427bd/28',
      dataType: 'json',
      data: data,
      success: function(){
        alert('SUCCESS');
      }
    });

    $.getJSON("http://api.art4m.nl/lookup/5427bd/28", function(json) {
       alert("JSON Data: " + json.users[3].name);
     });
  });

  $("#hps a").bind("click", function(){

    // get id of selected hp
    var hp = $(this).attr('rel');
    var parent = $(this).parent();

    // remove selected advertorials class
    $("#hps.advertorials .col").each(function() {
        $(this).removeClass('selected');
    });

    // hide each advertorial content + toggle chosen advertorial
    $(".hp").each(function() {
      if ($(this).attr('id') == hp)
      {
        $(this).toggle();

        if (($(this).attr('style') == 'DISPLAY: none') || ($(this).attr('style') == 'display: none;'))
        {
          parent.removeClass('selected');
        }
        else
        {
          parent.addClass('selected');
        }
      }
      else
      {
        $(this).hide();
      }
    });

    return false;
  });

  $("#tools a").bind("click", function(){

    // get id of selected hp
    var tool = $(this).attr('rel');
    var parent = $(this).parent();

    // remove selected advertorials class
    $("#tools.advertorials .col").each(function() {
      $(this).removeClass('selected');
    });

    // add selected advertorial
    $(this).parent().addClass('selected');

    // hide each advertorial content + toggle chosen advertorial
    $(".tool").each(function() {
      if ($(this).attr('id') == tool)
      {
        $(this).toggle();

        if (($(this).attr('style') == 'DISPLAY: none') || ($(this).attr('style') == 'display: none;'))
        {
          parent.removeClass('selected');
        }
        else
        {
          parent.addClass('selected');
        }
      }
      else
      {
        $(this).hide();
      }
    });

    return false;
  });
});
