jQuery.fn.alphaRotate = function() {
  return this.each(function(){
	activeOpacity = {
		'-ms-filter': "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)",
		'filter': 'alpha(opacity=50)', 
		'opacity': '0.5'
	}
	
	inActiveOpacity = {
		'-ms-filter': "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)",
		'filter': 'alpha(opacity=20)', 
		'opacity': '0.2'
	}
	
	
	function init () {
		//for image rotation
		$(object).css('position', 'relative').height($(object).children().height()).width($(object).children().width());
		$(object).children('img').css('position', 'absolute').css('z-index', '1');
		$(object).children('img.alpha').addClass('active');
		
		//for indication
		$(object).append('<div id="indication"></div>');
		for (var i=0; i < $(object).children('img').length; i++) {
			$(object).children('#indication').append('<span>·</span>');
		};
		$(object).children('#indication').css({
			'font-size': '100px',
			'position': 'absolute',
			'z-index': '100',
			'line-height': '30px',
			'letter-spacing': '-10px',
			'margin-right': '5px',
			'margin-bottom': '-5px',
			'bottom': '0',
			'right': '0'
		});
		
		if ($.browser.webkit || ($.browser.msie && $.browser.version < 8.0)) {
			$(object).children('#indication').css('margin-bottom', '-25px');
		};
		
		if ($.browser.msie && $.browser.version < 8.0) {
			$(object).children('#indication').children('span').css('margin-right', '-10px');
		};
		
		$(object).children('#indication').children('span').css(inActiveOpacity).eq(0).addClass('alpha').addClass('active').css(activeOpacity);
		$(object).children('#indication').children('span').eq(-1).addClass('omega');
	}
	
	
	object = this;
	
	init();
	
	setInterval(function() {
		currentImage = $(object).children('img.active');
		currentIndicator = $(object).children('#indication').children('span.active');
		
		if( currentImage.hasClass('omega') ){
			nextImage = $(object).children('img.alpha');
		}
		else{
			nextImage = currentImage.next('img');
		}
		
		if( currentIndicator.hasClass('omega') ){
			nextIndicator = $(object).children('#indication').children('span.alpha');
		}
		else{
			nextIndicator = currentIndicator.next('span');
			asdf = 1;
		}
		
		nextImage.css('z-index', '10').fadeIn('slow', function(){
			currentImage.hide().css('z-index', '1').removeClass('active');
			nextImage.addClass('active').css('z-index', '1');
		});
		
		nextIndicator.css(activeOpacity).addClass('active');
		currentIndicator.css(inActiveOpacity).removeClass('active');
		/*.animate(
			{ 'opacity', '0.5' },
			{
				duration: 'slow',
				complete: function(){
					currentIndicator.css('opacity', '0.2').removeClass('active');
					nextIndicator.addClass('active');
				}
			} );*/
			
			
		}, 5000 );
  });
};

