window.onload = function(){
	externalLinks();
	try	{if(fadeImageContainer){fadeImageContainer = fadeImageContainer} }
	catch(err){	fadeImageContainer = false; }
	if(fadeImageContainer){
		new FadeImage().startAnimation();
	}
}

var FadeImage = Class.create();


FadeImage.prototype = {
	initialize: function(listItem) {
		this.imagepool = fadeImagePool;
		this._currentnode = 0;
		this._totalnodes = fadeImagePool.length;
		this.sizes = fadeImageSize;
		this.bg = fadeImageBg;
		this.nodename = fadeImageContainer
		this.fadespeed = fadeImageSpeed/1000
		this.delay = fadeImageDelay
		this.node = $(fadeImageContainer);
		this.setsize();
		this.setbg();
		this.createnodes();
	},
	setsize: function(){
		this.node.style.width = this.sizes.width+"px";
		this.node.style.height = this.sizes.height+"px";	
	},
	setbg: function(){
		this.node.style.background = this.bg
	},
	createnodes: function(){
		for(var t=0; t<this.imagepool.length; t++){
			var _node = document.createElement("img");
			_node.num = t
			_node.id = this.nodename+"_"+t
			_node.src = this.imagepool[t];
			this.node.appendChild(_node)
		}
	},
	startAnimation: function(){
		this.hideall()
		var _current = $(this.nodename+"_"+this._currentnode)
		this.toggle(_current);
	},
	toggle: function(_elem){
		//	alert(_elem)
		var _trans = this;
		this.hideall()
		new Effect.Appear(_elem,{duration:this.fadespeed});
		this._currentnode++
		if(this._currentnode==this.imagepool.length){
			this._currentnode = 0;
		}		
		_show_header_image = window.setTimeout(function(){_trans.toggle($(_trans.nodename+"_"+_trans._currentnode))},	_trans.delay);
	},
	hideall: function(){
		for(var t=0; t<this.imagepool.length; t++){
			$(this.nodename+"_"+t).style.display = "none";
		}
	}
}
