
// This function randomly selects among masthead images

function chooseMastImg () {
	var bkg = new Array ();
	var imgDir = '/rmtp/wp-content/themes/Ramblemuse_SW/images/';
	var ix, masthead;

	bkg[0] = 'utah_viewpoint_pan_en_720.jpg';
	bkg[1] = 'wheeler_ridge_pan_720.jpg';
	bkg[2] = 'utah_redrock_snow_720.jpg';

	ix = Math.round((bkg.length-1)*Math.random());
	if ( document.getElementById ) {
	   masthead = document.getElementById('masthead');
	   masthead.style.backgroundImage = 'url(' + imgDir + bkg[ix] + ')';
	}
}


/*

  Script for using Javascript target attribute to replace the use of
  the depricated HTML target attribute of the <a> tag. The target
  attribute is replace with the attribute 'rel="external"'. This allows
  opening a link in a new window while maintaining valid XHTML. The
  DOM is a separate specification in which the target attribute
  is not deprecated. If Javascript is not enabled or the browser
  is not DOM aware, then the link will occur in the current window.

  Keven Yank: 2003. New-Window Links in a Standards-Compliant World.
  March 4th. <http://www.sitepoint.com/print/standards-compliant-world>

*/

function externalLinks() {

  // Check whether the browser supports the DOM
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
        anchor.getAttribute("rel") == "external") {
      anchor.target = "_blank";
    }
  }
}


window.onload = function () {
	chooseMastImg();
	externalLinks();
}
