jQuery(function() {

	$("#newsnav li a[id]").click(function() {
		$("div#news div").hide();
		$("div#news div." + $(this).attr("id")).show();
		$("#newsnav li a").removeClass("active");
		$(this).addClass("active");
	});

	$("#newsnav li a[id=all]").click(function() {
		$("div#news div").show();
	});

  $(".dialog").each(function(){

    var myTitle = $(this).attr("title");
    var myClass = $(this).attr("id");

    $.ajax({
      type: "get",
      url: $(this).attr("href"),
      success: function(data) {
        $("<div class='" + myClass + "'/>").append(data).dialog({
          autoOpen: false,
          modal: true,
          title: myTitle,
          width: 650,
          height: 'auto'
        }).children("div").append("<div class='close' style='margin-top: 1em'><a href='#' class='close'>Close this window</a></div>");  
        $(".close a").click(function(){
          $(".ui-dialog-content").dialog("close");
          return false;
        });   
      }
    });
  }).click(function(){
    $(".ui-dialog-content." + $(this).attr("id")).dialog("open");
    return false;
  });

});