var Header = {
	images : null,
	currentIndex : 0,
	
	init : function() {
        $(document).ready(Header._init);
    },
	
	_init : function() {
		Header.images = $('#imageDisplay a');
		
		if (!Header.images) return false;
		
		Header.images.each(function(index) {
			if (index != 0)
				$(this).css({display : 'block'}).fadeOut(0);
			
			$(this).css({position: 'absolute', top :'0px', left: '0px'});
			this.index = index;
		});
		
		if (Header.images.length > 1)	
			$("#imageDisplay").everyTime(5000,Header.autoPlay);
	},
	
	autoPlay : function() {
		var current = Header.currentIndex;
		var next = (Header.currentIndex + 1) == Header.images.length?0:Header.currentIndex + 1;
		
		$(Header.images[next]).fadeIn(2500);
		$(Header.images[current]).fadeOut(2000);
		
		Header.currentIndex = next;
	},
	pause : function() {
		$("#imageDisplay").stopTime();
	},
	resume : function() {
		if (Header.images.length > 1)	
			$("#imageDisplay").everyTime(5000,Header.autoPlay);
	}
}

Header.init();
