function AdViewer() {
	$('.main_ad').mouseenter( function() {
			$('#ad_viewer_bar').stop().fadeTo(600, 0.5);
		});
	$('.main_ad').mouseleave( function(e) {
			$('#ad_viewer_bar').stop().fadeTo(600, 0.0);
		});
	$('#ad_viewer_bar').mouseover( function() {
			$('#ad_viewer_bar').stop().fadeTo(600, 1.0);
		});
	$('#ad_viewer_bar').mouseout( function() {
			$('#ad_viewer_bar').stop().fadeTo(600, 0.0);
		});
	this.vCurrentAd = 0;
	this.vInterval = 0;
	this.play = function() {
		var me = this; // to fix scope issue with setInterval
		if (!me.vInterval) { me.vInterval = setInterval(function() { me.rotate_next(); }, 10000); }
	};
	this.pause = function() {
		if (this.vInterval) {
			clearInterval(this.vInterval);
			this.vInterval = 0;
		}
	};
	this.show = function() {
		$('#main_ad_' + this.vCurrentAd).css({visibility: "visible",display: "none"}).fadeIn(600);
	};
	this.rotate_next = function() {
		$('#main_ad_' + this.vCurrentAd).fadeOut(600);
		do {
			this.vCurrentAd = (this.vCurrentAd + 1)%5;
		} while( !$('#main_ad_' + this.vCurrentAd).html() )
		this.show();
		this.pause();
		this.play();
	};
	this.rotate_previous = function() {
		$('#main_ad_' + this.vCurrentAd).fadeOut(600);
		do {
			this.vCurrentAd = (this.vCurrentAd + 4)%5;
		} while( !$('#main_ad_' + this.vCurrentAd).html() )
		this.show();
		this.pause();
		this.play();
	};
}


