function getElementsByClassName(classname) {
  var rl = new Array();
  var re = new RegExp('(^| )'+classname+'( |$)');
  var ael = document.getElementsByTagName('*');
  var op = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
  if (document.all && !op) ael = document.all;
  for (i=0, j=0; i<ael.length; i++) {
    if (re.test(ael[i].className)) {
      rl[j]=ael[i];
      j++;
    }
  }
  return rl;
}

function attachExternals() {
  if (document.getElementsByTagName('a')) {
    as = document.getElementsByTagName('a');
    for (var i=0; i<as.length; i++) {
      if (as[i].className.indexOf('external') >= 0) {
        as[i].target = '_blank';
      }
    }
  }
}

function init() {
  attachExternals();
}

window.onresize = init;


function randomImage() {
  
	if (document.getElementById('banner')) {

		var theImages = new Array()
		theImages[0] = '1.jpg';
		theImages[1] = '2.jpg';
		theImages[2] = '3.jpg';
		theImages[3] = '4.jpg';
		theImages[4] = '5.jpg';
		theImages[5] = '6.jpg';
		theImages[6] = '7.jpg';

		var j = 0;
		var p = theImages.length;
		var preBuffer = new Array();
		for (i = 0; i < p; i++) {
 			preBuffer[i] = new Image();
   			preBuffer[i].src = theImages[i];
		}
		var whichImage = Math.round(Math.random()*(p-1));

		var banner = document.getElementById('banner');
		var myImage = theImages[whichImage];
		//banner.style.background="#fff url(/_images/'+myImage+') no-repeat";
		banner.style.background="#fff url('/_images/" + myImage + "') no-repeat";

	} else {
		return false;
	}

}
