function init() { 
if (!document.getElementsByTagName){ 
	return; 
}
var anchors = document.getElementsByTagName("a"); 
	for (i=0; i<anchors.length; i++) { 
	if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") {
	anchors[i].target = "_blank"; 
	anchors[i].title = "This link opens in a new window."
	} 
	}
} 
window.onload = init; 


function get_random(num)
{
    var ranNum= Math.floor(Math.random()*num);
	if (ranNum==0){
		ranNum++;
	}
    return ranNum;
}
function getObj(id){
	if(document.getElementById(id)){
	return document.getElementById(id);
	}
	else if(document.all){
	return document.all[id];
	}
	else if(document.layers){
	return document.layers[id];
	}
}

var DHTML = (document.getElementById || document.all || document.layers);


/*

The following script is only called if DHTML is available to the browser.

first we instantiate starting positions then we check if DHTML available.

*/
var id=0;//start at 0 so that first image ('imageplace1') is rotated first
var nextnum=3;//we start at 3 because first three images are rendered by default .: next image will be 4

if (DHTML){
	
var album = { 

  startup: function() { 
  pe=setInterval(album.cycle,4000);//set the interval to use 1000 = 1 second
  init();//call function to add target _blank to links with rel="external"
  }, 
  
  pause: function() {
	window.clearInterval(pe);

  },
  
  cycle: function() { 
 	id++; //increment the id and nextnum by 1
	nextnum++;
	
	//check to see if the numbers go beyond our range. If they do then reset them.
	if(id>3){
		id=1;
	}
	if(nextnum>9){
		nextnum=1;
	}

	
	getObj('top'+id).style.background='url('+getObj('imageplace'+id).src+')';//set the background image of div wrapping our current image to match the current image source. this ensures a smooth fade.
    new Effect.Fade('imageplace'+id, { 
      duration: 1, 
      fps: 50, 
      afterFinish: function() { //
				
			var next='./siteimages/content/banner0'+nextnum+'.jpg';

	  		getObj('imageplace'+id).src=next;
            new Effect.Appear('imageplace'+id, {
              duration: 1,
              fps: 50,
              queue:'end'
        }) //end afterFinish
      } 
    }) 
  } 
  
} 
 
 
window.onload = album.startup


}