Event.onDOMReady( function() {

  /* Replace subtitles */
  $A(['white', 'blue', 'red']).each( function(color) {
    $$("h2."+color, ".fg-"+color+" h2", "h3."+color, ".fg-"+color+" h3").each( function(element) {
      setPNGbackground(element, getSubtitleURL(element, color));
      Element.setStyle(element, { textIndent: "-2000px" });
    } );
  } );

} );

function getSubtitleURL(element, state) {
  var text = (element.childNodes[0]) ? element.childNodes[0].nodeValue : "";
  var dynimage = (element.tagName.toUpperCase() == "H2") ? "subtitle" : "subtitle2";
  state = (state) ? "-" + state : "";
  var size;
       if (element.up("td.column-colspan-2")) size = "520x40";
  else if (element.up("td.column-colspan-3")) size = "780x40";
  else                                        size = "260x40";
  state += "-" + size;
  var url = "/images/"+dynimage+"/"+escape(text)+escape(state)+".png";
  return url;
}

/* Set a PNG as a background images */
function setPNGbackground(element, url) {
  if (pngSupport()) {
    Element.setStyle( element, { backgroundImage: "url('"+url+"')" } );
  }else{
    Element.setStyle( element, { filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"', sizingMethod='crop')" } );
  }
}

function pngSupport() {
  /*@cc_on
    @if (@_win32)
      return (@_jscript_version > 5.6);
    @end
  @*/
  return true;
}

function writeEmail(a) {
  //var h=location.host.replace(/^.*(?:^|\.)([^\.]+)\.([^\.]+)$/, "$1.$2");
  var h=location.host.match(/[^\.]+\.[^\.]+$/);
  var e=a+'&#X40;'+h;
  document.write('<a href="mailto:'+e+'">'+e+'</a>');
}
