function format_links(){
  $("a[rel='external']").attr("target","_blank");
  $("a.xhr_popup").click( xhr_popup );

}

function xhr_popup(e){
  var target_url = $(this).attr("href") + "&xhr";
  $("<div></div>").addClass("popup").hide().load( target_url, addButton ).css("left",  $(window).width()/2-250 + "px").css("top", $(this).offset().top + "px").prependTo(document.body).fadeIn();

  function addButton(){
    $("<button></button>").html(" X ").css("float","right").click( function(){$( this.parentNode).fadeOut() } ).prependTo(this);
  }

  return false;
}




function googleMap(){
  var staticMap = document.getElementById('staticMap');
  if(!staticMap)
    return;
  var mapDiv=staticMap.parentNode;
  mapDiv.removeChild(staticMap);
  var gFrame=document.createElement('iframe');
  gFrame.setAttribute('src','http://www.maricopa.edu/map/small_gmap.php');
  gFrame.setAttribute('border','0');
  gFrame.setAttribute('width','700px');
  gFrame.setAttribute('height','500px');
  gFrame.setAttribute('scrolling','no');
  mapDiv.appendChild(gFrame);
}



$(format_links);
$(googleMap);