//-----------------------------------------------------------------------------------------------------------------------------
//: Acme
//-----------------------------------------------------------------------------------------------------------------------------
wfx.Acme = {
	PawPrintsStartAt:2000,
	PawPrintsRepeatEvery:8000,
	PawPrintsStayVisible:1500,
	PawPrintsFade:2000,
	PawPrintsSpacing:200,
	PawPrintsRepeat:10,
	PawPrintRepeatsCompleted:0,

	ChangeFeatureRate:10000,
	CurrentTestimonial:0,
	CurrentSnapshot:0,

	LastFeatureType:0,

	//-----------------------------------------------------------------------------------------------------------------------------
	//:: Init
	//-----------------------------------------------------------------------------------------------------------------------------
	Init: function(re) {
		////wfx.log("wfx.Acme.Init");

		if($('home')) {
			wfx.Acme.PawPrintsSetup();
			setTimeout(wfx.Acme.PawPrints, wfx.Acme.PawPrintsStartAt);
		}
		else {
			var lightbox = new Lightbox({relString:'snapshots'});

			// randomize start
			wfx.Acme.CurrentTestimonial = Math.round(Math.random() * wfx.Acme.Testimonials.length);
			wfx.Acme.CurrentSnapshot = Math.round(Math.random() * $$('.featuredpet').length);

			wfx.Acme.ChooseFeature();
			//wfx.Acme.ShowSnapshot();
		}
	},

	//-----------------------------------------------------------------------------------------------------------------------------
	//:: PawPrintsSetup
	//-----------------------------------------------------------------------------------------------------------------------------
	PawPrintsSetup: function() {
		////wfx.log("wfx.Acme.PawPrintsSetup");
		//wfx.Acme.pp1 = $('pawprint1');

		wfx.Acme.pp1 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp1);
		wfx.Acme.pp1.setProperty('class', 'pawprint');
		wfx.Acme.pp1.setStyles({left:'52px', top:'621px'});

		wfx.Acme.pp2 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp2);
		wfx.Acme.pp2.setProperty('class', 'pawprint');
		wfx.Acme.pp2.setStyles({left:'186px', top:'589px'});

		wfx.Acme.pp3 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp3);
		wfx.Acme.pp3.setProperty('class', 'pawprint');
		wfx.Acme.pp3.setStyles({left:'343px', top:'420px'});

		wfx.Acme.pp4 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp4);
		wfx.Acme.pp4.setProperty('class', 'pawprint');
		wfx.Acme.pp4.setStyles({left:'342px', top:'314px'});

		wfx.Acme.pp5 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp5);
		wfx.Acme.pp5.setProperty('class', 'pawprint');
		wfx.Acme.pp5.setStyles({left:'486px', top:'297px'});

		wfx.Acme.pp6 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp6);
		wfx.Acme.pp6.setProperty('class', 'pawprint');
		wfx.Acme.pp6.setStyles({left:'512px', top:'193px'});

		wfx.Acme.pp7 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp7);
		wfx.Acme.pp7.setProperty('class', 'pawprint');
		wfx.Acme.pp7.setStyles({left:'653px', top:'191px'});

		wfx.Acme.pp8 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp8);
		wfx.Acme.pp8.setProperty('class', 'pawprint');
		wfx.Acme.pp8.setStyles({left:'694px', top:'74px'});

		wfx.Acme.pp9 = $(document.createElement('div'));
		$('page').appendChild(wfx.Acme.pp9);
		wfx.Acme.pp9.setProperty('class', 'pawprint');
		wfx.Acme.pp9.setStyles({left:'659px', top:'-30px'});
	},

	//-----------------------------------------------------------------------------------------------------------------------------
	//:: PawPrints
	//-----------------------------------------------------------------------------------------------------------------------------
	PawPrints: function() {
		////wfx.log("wfx.Acme.PawPrints");

		var offset = wfx.Acme.PawPrintsSpacing;
		wfx.Acme.DoPawPrint(wfx.Acme.pp1);

		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp2); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp3); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp4); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp5); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp6); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp7); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp8); }, offset);

		offset += wfx.Acme.PawPrintsSpacing;
		setTimeout(function() { wfx.Acme.DoPawPrint(wfx.Acme.pp9); }, offset);


		wfx.Acme.PawPrintRepeatsCompleted++;
		if(wfx.Acme.PawPrintRepeatsCompleted <= wfx.Acme.PawPrintsRepeat) {
			setTimeout(wfx.Acme.PawPrints, wfx.Acme.PawPrintsRepeatEvery);
		}
	},

	//-----------------------------------------------------------------------------------------------------------------------------
	//:: DoPawPrint
	//-----------------------------------------------------------------------------------------------------------------------------
	DoPawPrint: function(p) {
		p.fade('show');
		//p.fade('out');
		setTimeout(function() {
			p.set('tween', {duration:wfx.Acme.PawPrintsFade});
			p.tween('opacity', 0);
			//wfx.Acme.DoPawPrint(p);
		}, wfx.Acme.PawPrintsStayVisible);
	},

	//-----------------------------------------------------------------------------------------------------------------------------
	//:: ChooseFeature
	//-----------------------------------------------------------------------------------------------------------------------------
	ChooseFeature: function() {
		////wfx.log("wfx.Acme.ChooseFeature");

		//var rand = Math.round(Math.random());// - 0.25);
		////wfx.log(rand);
		if(wfx.Acme.LastFeatureType == 0) {
			wfx.Acme.ShowSnapshot();
			wfx.Acme.LastFeatureType = 1;
		}
		else {
			wfx.Acme.ShowTestimonial();
			wfx.Acme.LastFeatureType = 0;
		}

		setTimeout(wfx.Acme.ChooseFeature, wfx.Acme.ChangeFeatureRate);
	},
	//-----------------------------------------------------------------------------------------------------------------------------
	//:: Testimonials
	//-----------------------------------------------------------------------------------------------------------------------------
	Testimonials: [],
	//-----------------------------------------------------------------------------------------------------------------------------
	//:: ShowTestimonial
	//-----------------------------------------------------------------------------------------------------------------------------
	ShowTestimonial: function() {
		////wfx.log("wfx.Acme.ShowTestimonial");

		if($('main_feature')) {
			$('main_feature').setProperty('class', 'stickynote');
			$('stickynote').show();
			$('snapshot').hide();

			if($('testimonial') &&  wfx.Acme.Testimonials.length) {
				if(wfx.Acme.CurrentTestimonial >= wfx.Acme.Testimonials.length) wfx.Acme.CurrentTestimonial = 0;
				var t =  wfx.Acme.Testimonials[wfx.Acme.CurrentTestimonial];//.getRandom();//
				$('testimonial').innerHTML = t.text;

				var link = $('testimonial').getProperty('href');

				var x = link.indexOf("#");
				if(x > 0) {
					link = link.substring(0, x);
				}
				link += "#"+t.id;
				$('testimonial').setProperty('href', link);
				wfx.Acme.CurrentTestimonial++;
			}
		}

	},
	//-----------------------------------------------------------------------------------------------------------------------------
	//:: Snapshots
	//-----------------------------------------------------------------------------------------------------------------------------
	Snapshots: [],
	//-----------------------------------------------------------------------------------------------------------------------------
	//:: ShowSnapshot
	//-----------------------------------------------------------------------------------------------------------------------------
	ShowSnapshot: function() {
		////wfx.log("wfx.Acme.ShowSnapshot");

		if($('main_feature')) {
			$('main_feature').setProperty('class', 'snapshot');
			$('stickynote').hide();
			$('snapshot').show();

			var featured = $$('.featuredpet');
			featured.setStyle('display', 'none');
			if(wfx.Acme.CurrentSnapshot >= featured.length) wfx.Acme.CurrentSnapshot = 0;
			var snap = featured[wfx.Acme.CurrentSnapshot];//.getRandom();
			snap.setStyle('display', 'block');
			wfx.Acme.CurrentSnapshot++;
		}
	}

}; // Acme

