FlashGamePromotion = function( options ) {
	this.init( options );
}

FlashGamePromotion.prototype = {
	firstPopup : true,
	options : null,
	Promos : null,
	NextPromo : 0,
	TotalPromos : 0,
	init: function( options ) {
		this.options = options;
/*		// Set promotion size
		var promotionContainer = jQuery( '.promotion-container' );
		promotionContainer.css( 'height', options.PromotionHeight + 'px' );
		promotionContainer.css( 'margin-top', '-' + options.PromotionHeight / 2 + 'px' );
		promotionContainer.css( 'width', options.PromotionWidth + 'px' );
		promotionContainer.css( 'margin-left', '-' + options.PromotionWidth / 2 + 'px' );
*/

		this.Promos = jQuery('#flash-game-promos > div');
		//this.GameToplist = jQuery('#FlashGameToplist');
		this.NextPromo = 0;
		this.TotalPromos = this.Promos.length;
	},

	start: function() {
		this.promotionPopup();
	},

	promotionPopup: function() {
		
		var self = this, docBody=document.body.id?document.body.id:'';
		jQuery( '#FlashGameOverlay' ).hide();
		//jQuery( '#FlashGameToplist' ).hide();
		docBody=='GameTrainerPage-page'?jQuery('#FlashGameOverlay > #flash-game-promos').css('margin-top','-265px').css('margin-left','-215px'): '' ;
                docBody=='FlashGamePage-page'?jQuery('#FlashGameOverlay > #flash-game-promos').css('top','25%'): '' ;

		var callBack = function() {
                        jQuery('#button-close').attr('href', window.location.pathname+'#');
			jQuery( '#FlashGameOverlay' ).show();
		//	jQuery( '#FlashGameToplist' ).show();
                        self.Promos.hide();
                        $( self.Promos[ self.NextPromo ] ).show();
                        self.NextPromo = self.NextPromo + 1 < self.TotalPromos ? self.NextPromo + 1 : 0;
						//self.GameToplist.hide();
		}

		setTimeout( callBack, this.getInterval() );
	},

	getInterval: function() {
		var interval = this.firstPopup ? this.options.FirstInterval : this.options.SecondInterval;
		this.firstPopup = false;
		return interval;
	}
};
