﻿
var address = 'Themes/DarrahJane/Content/Images1/';
var Page = new Class({
	sectionImages: [],
	sectionPieces: [],
	sectionImagesLoaded: [],
	sectionImagesToLoad: [],
	sectionBackgroundImages: [],
	Extends: BasePage,
	initialize: function () {
		this.parent();
		window.addEvent('domready', this.load.bind(this));
	},
	load: function () {
		var pageLoader = new PageLoader({ defaultAnimLength: 300, defaultAnimOffset: 100 });
		pageLoader.addSection('Header', '#LogoImg, #HeaderDiv ul li img.Over, #ContactTabDiv', [{ id: 'ContactTabDiv', src: '/Themes/DarrahJane/Content/Images/contactInfoTab.gif'}]);
		pageLoader.addSection('BodyLeft', '#ThoughtBubblesDiv img, #ThoughtBubbleCopyDiv, #PostItsDiv img');
		pageLoader.addSection('BodyRight', '#BlogPostsHeaderBottomImg, #BlogPostsHeaderTopImg, .BlogPostDiv');
		pageLoader.addSection('Footer', '#FooterDividerImg, #FollowMeImg, #SiteCreditsDiv, #SocialNetworkingLinksDiv img, #NewsletterSignupLabelDiv, #NewsletterSignupTextBoxDiv, #NewsletterSubmitDiv',
											[{ id: 'NewsletterSignupTextBoxDiv', src: '/Themes/DarrahJane/Content/Images/subscribeTextBoxBack.gif' },
											 { id: 'NewsletterSubmitDiv', src: '/Themes/DarrahJane/Content/Images/subscribeSubmitButtonRightBack.gif'}]);

		$('RootDiv').setStyle('visibility', 'visible');
	   
		this.animateNavAndPostIts.delay(2200, this);
	},
	animateNavAndPostIts: function () {
		this.flashPostIts();
	},
	flashPostIts: function () {
		$$('#PostItsDiv a img').set('opacity', 1).setStyle('visibility', 'visible');

		leftPostItWidth = $('PostItLeftImgOverDiv').getSize().x;
		centerPostItLeft = $('PostItCenterImgOverDiv').getStyle('left').removePx();
		rightPostItWidth = $('PostItRightImgOverTopDiv').getSize().x;
		rightPostItLeft = $('PostItRightImgOverTopDiv').getStyle('left').removePx();

		$$('#PostItLeftImgOverDiv, #PostItLeftImgOverImg').set('tween', { duration: 900, transition: 'quad:out' });
		$$('#PostItLeftImgOverDiv').set('morph', { transition: 'quad:in' });

		//Left Post-it Animation Sequence
		$('PostItLeftImgOverDiv').setStyle('width', 0).setStyle('visibility', 'visible');

		$('PostItLeftImgOverDiv').tween('width', 0, leftPostItWidth).get('tween').chain(function () {
			$('PostItLeftImgOverDiv').set('tween', { duration: 200 }).tween('opacity', 1, .2).get('tween').chain(function () {
				$('PostItLeftImgOverDiv').set('tween', { duration: 300 }).tween('opacity', .2, 1);
			});
		});

		//Center Post-it Animation Sequence
		$$('#PostItCenterImgOverDiv, #PostItCenterImgOverDiv2, #PostItCenterImgOverDiv3').set('opacity', 0).setStyle('visibility', 'visible');
		$$('#PostItCenterImgOverDiv, #PostItCenterImgOverDiv2, #PostItCenterImgOverDiv3').set('morph', { duration: 800, transition: 'quad:out' });

		$('PostItCenterImgOverDiv').morph({
			'opacity': [0, 1],
			'left': [centerPostItLeft - 100, centerPostItLeft]
		}).get('morph').chain(function () {
			this.element.set('morph', { duration: 600, transition: 'quad:out' }).morph({
				'left': [centerPostItLeft, centerPostItLeft]
			});
		});

		(function () {
			$('PostItCenterImgOverDiv2').morph({
				'opacity': [0, 1],
				'left': [centerPostItLeft - 100, centerPostItLeft]
			}).get('morph').chain(function () {
				this.element.set('morph', { duration: 600, transition: 'quad:out' }).morph({
					'left': [centerPostItLeft, centerPostItLeft]
				});
			});
		}).delay(200);

		(function () {
			$('PostItCenterImgOverDiv3').morph({
				'opacity': [0, 1],
				'left': [centerPostItLeft - 100, centerPostItLeft]
			}).get('morph').chain(function () {
				this.element.set('morph', { duration: 600, transition: 'quad:out' }).morph({
					'left': [centerPostItLeft, centerPostItLeft]
				});
			});
		}).delay(300);

		//Right Post-it Animation Sequence
		$('PostItRightImgOverTopDiv').setStyle('height', 0).setStyle('visibility', 'visible');
		$('PostItRightImgOverBottomDiv').setStyle('width', 0).setStyle('visibility', 'visible');

		$('PostItRightImgOverTopDiv').set('tween', { duration: 1000, transition: 'quad:in' }).tween('height', 0, 45).get('tween').chain(function () {
			$('PostItRightImgOverBottomDiv').set('tween', { duration: 900, transition: 'quad:out' }).tween('width', 0, rightPostItWidth);
		});
	}
});

new Page();
