function addLoadEvent(func) {
	var ssArray = "";
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

var ubImageArray = new Array();
var ubImageIterator = new imageIterator();

function showImages(ubImageObject) {
	ubImageId = 'ubPhoto';
	ubImage = document.getElementById(ubImageId);
	ubImage.style.visibility = 'visible';
	ubImage.setAttribute("src", ubImageObject.image.src);
	
	setOpacity(ubImage, 0);

	fadeIn(ubImageId, 0);
	
	document.getElementById("ubImageHREF").setAttribute("href", ubImageObject.href);
}
	
function fadeIn(objId1 ,opacity) {
	if (document.getElementById) {
		obj1 = document.getElementById(objId1);
		if (opacity > 101) {
			document.getElementById("ubImageContainer").style.backgroundImage = "url(" + obj1.getAttribute('src') + ")";
		}
		if (opacity <= 100) {
			setOpacity(obj1, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId1+"', "+opacity+")", 50);
		}
	}
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function imageObject(s,h,c) {
	this.src = s;
	this.href = h;
	this.caption = c;
	var i = new Image();
	this.image = i;
	this.image.src = s;
}

function imageIterator(_imageArray) {
	this.iterator = 0;
	this.array = _imageArray;
	this.increment = function() { this.iterator = (this.iterator == (this.array.length - 1)) ? 0 : this.iterator+1; };
	this.decrement = function() { this.iterator = (this.iterator == 0) ? (this.array.length - 1) : this.iterator-1; };
	this.getNext = function() { this.increment(); next = this.array[this.iterator];  return next; };
	this.getPrevious = function() { this.decrement(); previous = this.array[this.iterator];  return previous; };
}

function executeInterval() {
	showImages(ubImageIterator.getNext());
}

addLoadEvent( function() {
	if (document.getElementById('ubPhoto')) { 
		showImages(ubImageArray[0]);
		showtime = setInterval("executeInterval()", 6000);
	}
} );