$(document).ready(function(){

  //external window
  $('a[class="external"]').click(function(){
    this.target = "_blank";
  });
  
  //popup window
  $('a[class="popup"]').click(function(){
    window.open(this.href, 'Popup', 'height=580,width=400,scrollTo,resizable=0,scrollbars=0,location=0,left=50,top=50', 'false');
    return false;
  });
  
  //close popup window link
  $('a[class="popup_close"]').click(function(){
    window.close();
    return false;
  });
  
  //print link
  $('a[class="print"]').click(function(){
    window.print();
    return false;
  });
  
  //confirm link
  $('a[class="confirm"]').click(function(){
    return confirm(this.title);
  });
  
  //bookmark link 
  $("a.bookmark").click(function(event){
    event.preventDefault();
    var url = this.href;
    var title = this.title;
    if (window.sidebar) {
      window.sidebar.addPanel(title, url, "");
    }
    else 
      if (window.external) {
        window.external.AddFavorite(url, title);
      }
      else {
        alert('Uw browser ondersteunt helaas niet deze optie.');
      }
  });
  
  //iframe replacement
  $('a[class="iframe"]').each(function(i){
    $(this).replaceWith("<iframe src='" + this.getAttribute("href") + "' frameborder='0' scrolling='no' width='934' height='600'></iframe>");
  });
  
  //image rollover
  $("img.rollover").hover(function(){
    this.src = this.src.replace("_off.", "_on.");
  }, function(){
    this.src = this.src.replace("_on.", "_off.");
  });
  
  //forms - focus
  $("input[type=password], input[type=text], textarea").focus(function(){
    $(this).addClass("focus");
  });
  $("input[type=password], input[type=text], textarea").blur(function(){
    if ($(this).find(".focus")) {
      $(this).removeClass("focus");
    }
  });
  
  //forms - hover
  $("input.submit").hover(function(){
    $(this).addClass("hover");
  }, function(){
    $(this).removeClass("hover");
  });
  
  //forms - select all
  //$("input[@name=select_deselect]").click(function(){
  //  var checked_status = this.checked;
  //  $("input[@class=check_me]").each(function(){
  //    this.checked = checked_status;
  //  });
  //});
  
  //forms - hover
  $("input.submit").hover(function(){
    $(this).addClass("hover");
  }, function(){
    $(this).removeClass("hover");
  });
  
  //forms - multi select transfer
  $('a#add').click(function(){
    return !$('select#select1 option:selected').remove().appendTo('#select2');
  });
  $('a#remove').click(function(){
    return !$('select#select2 option:selected').remove().appendTo('#select1');
  });
  
  //forms - toggle visibility information
  $('p.more_info').hide();
  $('.toggle_info input[type=radio]').click(function(){
    ($(this).val() == 'Yes') ? $('p.more_info').show() : $('p.more_info').hide();
  });
  
  //forms - auto submit
  $(".auto_submit").change(function(){
    $(this.form).submit();
  });
  
  //forms - no javascript button
  $('input.no_javascript').hide();
  
  //$('h2.flash').sifr({
  //  font: '/uploads/flash/compacta_reg.swf',
  //  fontSize: '32',
  //  version: 3,
  //  build: '419'
  //});
  
  //FAQ - toggle
  $("dd.content").hide();
  $("dt.toggle a").click(function(){
    $(this).parent().next("dd").toggle();
    return false;
  });
  
  //dropdown menu - hover IE6
  $('div#footer ul li').hover(function(){
    $(this).addClass('hover');
  }, function(){
    $(this).removeClass('hover');
  });
  
  //forms - autoclear
  $('form#form_search input[type="text"]').attr({
    value: 'Zoek'
  }).focus(function(){
    if ($(this).val() == "Zoek") {
      $(this).val("");
    }
  }).blur(function(){
    if ($(this).val() == "") {
      $(this).val("Zoek");
    }
  });
  
  //tabs
  $(".tab_content").hide();
  $("ul.tabs li:first").addClass("active").show();
  $(".tab_content:first").show();
  $("ul.tabs li").click(function(){
    $("ul.tabs li").removeClass("active");
    $(this).addClass("active");
    $(".tab_content").hide();
    var activeTab = $(this).find("a").attr("href");
    $(activeTab).show();
    return false;
  });

});
