var adtheox = $.Class.create({

	ad: null,

	slide1: null,
	cups: null,
	spots: null,
	spot1: null,
	spot2: null,
	spot3: null,

	slide2: null,
	logo: null,
	theox: null,

	initialize: function (node) {

		this.ad = node;

		this.slide1 = this.ad.children('#slide1');
		this.cups = this.slide1.children('.cups');
		this.spots = this.slide1.children('.spots');
		this.spot1 = this.slide1.children('.spots').children('#spot1');
		this.spot2 = this.slide1.children('.spots').children('#spot2');
		this.spot3 = this.slide1.children('.spots').children('#spot3');

		this.slide2 = this.ad.children('#slide2');
		this.logo = this.slide2.children('.logo');
		this.theox = this.slide2.children('.theox');

	},

	start: function (ads, index) {

		var mthis = this;
		var next = 0;

		if (ads.length > 1) {

			next = Math.floor(Math.random() * ads.length);

			while (index === next) {

				next = Math.floor(Math.random() * ads.length);

			}

		}

		mthis.slide1.hide();
		mthis.cups.hide();
		mthis.spots.hide();
		mthis.spot1.hide();
		mthis.spot2.hide();
		mthis.spot3.hide();

		//mthis.transition.css('backgroundPosition', '849px');

		mthis.slide2.hide();
		mthis.logo.hide();
		mthis.theox.hide();

		mthis.animate(ads, next);

	},

/*
	animate: function ( ads, next ) {

		var mthis = this;

		mthis.ad.fadeIn(1000, function () {

			mthis.slide1.fadeIn(1000, function () {});

			mthis.cups.fadeIn(3000, function () {

				mthis.spots.fadeIn(1000, function () {});

				mthis.spot1.fadeIn(2000, function () {

					mthis.spot2.fadeIn(2000, function () {

						mthis.spot3.fadeIn(2000, function () {

							mthis.transition.animate({backgroundPosition:'2px center'}, 2000, function () {

								mthis.slide1.fadeOut(500, function () {

									mthis.slide2.fadeIn(500, function () {

										mthis.logo.fadeIn(3000, function () {});
										mthis.theox.fadeIn(5000, function () {});

										mthis.transition.animate({backgroundPosition:'420px center'}, 2000, function () {

											setTimeout(function () {

												mthis.theox.fadeOut(1000, function () {});

												mthis.ad.fadeOut(1000, function () {

													ads[next].start(ads, next);

												});

											}, 3000);

										});

									});


								});

							});

						});

					});

				});

			});

		});

	}
*/

	animate: function ( ads, next ) {

		var mthis = this;

		mthis.ad.fadeIn(1000, function () {

			mthis.slide1.fadeIn(1000);

			mthis.cups.fadeIn(3000, function () {

				mthis.spots.fadeIn(1000, function () {

    				mthis.spot1.fadeIn(2000, function () {
    
    					mthis.spot2.fadeIn(2000, function () {
    
    						mthis.spot3.fadeIn(2000, function () {

mthis.cups.fadeOut(1000, function () {});
    
    							mthis.slide1.fadeOut(2000, function () {
    
    								mthis.slide2.fadeIn(1000, function () {
    
    									mthis.logo.fadeIn(3000);
    									mthis.theox.fadeIn(3000);
    
    									setTimeout(function () {
    
    										mthis.theox.fadeOut(1000);
    
    										mthis.ad.fadeOut(1000, function () {
    
    											ads[next].start(ads, next);
    
    										});
    
    									}, 4000);
    
    								});
    
    
    							});

    
    						});
    
    					});
    
    				});

                });

			});

		});

	}

});
