$(document).ready(function() {
  $("label img").bind("click", function() {
    $(this).parent().click();
  });
});

/* A TARGET */
(function($) {
  $.fn.target = function() {
    return this.each(function(index, elm) {
      if (substr($(this).attr("class"), 0, 7) == 'target-') {
        $(this).attr("target", substr($(this).attr("class"), 7));
      }
    });
  }
})(jQuery);

$(document).ready(function() {
  $("a").target();

  $('div.messages').jScrollPane({showArrows:true});

  if ($.browser.msie) {
    $("div.menu_container div.left").children("div").eq(0).css("margin-top", "-1px");
    $("ul.menu li ul").css("left", "-4px");
  }

  $("ul.menu li ul").find("li:last").addClass("last");
  
  /* Hoogte van schaduw berekenen */
  $("div.container div.banner div.shadow").height($("div.banner").height() + $("div.content").height() + $("div.menu_container").height() + 60 + 10);
  $("div.container div.banner div.shadow div").height($("div.banner").height() + $("div.content").height() + $("div.menu_container").height() + 10);

  /* PNG FIX */
  $('img[@src$=.png]').pngfix({
		imageFixSrc: "/images/pixel.gif"
	});

	$('div.container div.top div.bg').pngfix({
		imageFixSrc: "/images/pixel.gif"
	});

	/* SITE MENU */
	$("div.sites").children("ul").eq(0).children("li:first-child").bind("click", function() {
    siteMenu();
	});

	$("div.sites").children("ul").eq(0).children("li").not("li:first-child").children("a").each(function() {
	  $(this).bind("click", function() {
	    $("div.sites").children("ul").eq(0).children("li:first-child").html($(this).html());

      siteMenu();
	  });
	});

	function siteMenu() {
    var top = $("div.sites").children("ul").eq(0).children("li:first-child").next();

	  if ($(top).css('display') == 'list-item' || $(top).css('display') == 'block') {
	    $("div.sites").children("ul").eq(0).children("li").not("li:first-child").hide();
	  } else {
	    $("div.sites").children("ul").eq(0).children("li").not("li:first-child").show();
	  }
	}

	$("div.language").children("div").each(function() {
    $(this).bind("click", function() {
      $.POST(window.location.href, {sl_id : $(this).attr("id").replace('lang_', '')});
    });
  });

//	$("div.language").hide();
	
	$("input[name='search_query']").bind("focus", function() {
		if ($(this).val() == 'Zoeken') {
			$(this).val('');
		}
	});
	
	$("input[name='search_query']").bind("keyup", function(e) {
		if (e.keyCode == 13 && $("input[name='search_query']").val().length > 0 ) {
			window.location.href = '/search/' + $("input[name='search_query']").val() + '/';
		}
	});
	
	
	// TIJDELIJKE SITE UITSCHAKELING
	$("div.sites").children("ul").children("li").each(function() {		
		if ($(this).attr("id").length == 0 || ($(this).attr("id").length > 0 && $(this).attr("id") == 'site_6')) {
			//do nothing
		} else {
			$(this).remove();
		}
	});
	
	

});

