var HomeBanner = new Class({

	/* initialize needed methods
	 ======================================================================= */
	initialize: function() {
		if(!$chk($('banner-fade'))) return false;
		
		this.imgs 		= new Array(),
		this.zInterval 	= null,
		this.Current 	= 0,
		this.pause 		= false;
				
		this.start();
	},

	/* attach events and add the initially fired methods
	 ======================================================================= */
	start: function() {	
		$$('#banner-fade .imageElement').each(function(item) {
			item.setStyle('display', 'none');
		});
		
		this.soInit();
	},
	
	soInit: function() {
		this.imgs = $$('#banner-fade div');
		this.imgs.each(function(img) {
			if(img.hasClass('imageElement')) img.xOpacity = 0;
		});

		this.imgs[0].setStyle('display', 'block');
		this.imgs[0].xOpacity = 1.0;

		this.soXfade.delay((window.ie6 ? 999999999 : 6000), this);

		$$('#banner-fade .hidden').each(function(item) {
			item.removeClass('hidden');
		});

		$('banner-fade').setStyle('background', 'none');
	},
	
	soXfade: function() {
		cOpacity = this.imgs[this.Current].xOpacity;
		nIndex = this.imgs[this.Current+1]?this.Current+1:0;

		nOpacity = this.imgs[nIndex].xOpacity;

		cOpacity-=.05; 
		nOpacity+=.05;

		this.imgs[nIndex].setStyle('display', 'block');
		this.imgs[this.Current].xOpacity = cOpacity;
		this.imgs[nIndex].xOpacity = nOpacity;

		setOpacity(this.imgs[this.Current]); 
		setOpacity(this.imgs[nIndex]);

		if(cOpacity<=0) {
			this.imgs[this.Current].setStyle('display', 'none');
			this.Current = nIndex;
			this.soXfade.delay(6000, this);
		} else {
			this.soXfade.delay(50, this);
		}

		function setOpacity(obj) {
			if(obj.xOpacity>1.0) {
				obj.xOpacity = 1.0;
				return;
			}

			obj.setStyle('opacity', obj.xOpacity);
		}
	}
});
