//MooTools More 1.2.4.4 w/ Fx.Elements

// MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.

MooTools.More={version:"1.2.4.4",build:"6f6057dc645fdb7547689183b2311063bd653ddf"};Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(b,a){this.elements=this.subject=$$(b);
this.parent(a);},compute:function(g,h,j){var c={};for(var d in g){var a=g[d],e=h[d],f=c[d]={};for(var b in a){f[b]=this.parent(a[b],e[b],j);}}return c;
},set:function(b){for(var c in b){var a=b[c];for(var d in a){this.render(this.elements[c],d,a[d],this.options.unit);}}return this;},start:function(c){if(!this.check(c)){return this;
}var h={},j={};for(var d in c){var f=c[d],a=h[d]={},g=j[d]={};for(var b in f){var e=this.prepare(this.elements[d],b,f[b]);a[b]=e.from;g[b]=e.to;}}return this.parent(h,j);
}});




window.addEvent('domready', function() {

	hideIntro();
	hideSectors();
	hideLoaders();

	// kwicks stuff...
	
	var szNormal = 32, szSmall = 32, szFull = 330, posNormal = 0, posUp = -40;
	 
	var items = $$("#items li");
	
	var fx = new Fx.Elements(items, {wait: false, duration: 500, transition: Fx.Transitions.Circ.easeInOut});
	var fx2 = new Fx.Elements(items, {wait: false, duration: 100, transition: Fx.Transitions.linear});
	
	items.each(function(item, i) {
		item.addEvent('click', function(event) {
			var o = {};
			o[i] = {width: [item.getStyle("width").toInt(), szFull]}
			
			items.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall]};
				}
			});
			
			fx.start(o);
			
			(function() {
				hideSectors();
			}).delay(250);
			
			items.each(function(e) {
				e.removeEvents();
			});
			
			hideReds();
			hideNames();
			$('item' + (i + 1)).getFirst().fade('out'); // grey sliver and canvas relection
			loadSector(i + 1);
			
		});
		
		item.addEvent('mouseenter', function(event) {
			var o = {};
			o[i] = {marginTop: [item.getStyle("margin-top").toInt(), posUp]}
			
			items.each(function(other, j) {
				if(i != j) {
					var mt = other.getStyle("margin-top").toInt();
					if(mt != posNormal) o[j] = {marginTop: [mt, posNormal]};
				}
			});
			
			fx2.start(o);
			$('sector' + (i + 1)).fade('in');
		});
		
		item.addEvent('mouseleave', function(event) {
			var o = {};
			o[i] = {marginTop: [item.getStyle("margin-top").toInt(), posNormal]}
			
			items.each(function(other, j) {
				if(i != j) {
					var mt = other.getStyle("margin-top").toInt();
					if(mt != posNormal) o[j] = {marginTop: [mt, posNormal]};
				}
			});
			
			fx2.start(o);
			$('sector' + (i + 1)).fade('out');
		});
		
	});
	
	(function() {
		$('loaded').setStyle('display', 'block');
	}).delay(300);
	
	// load sequence...
	
	(function() {
		$('intro-logo').fade('in');
	}).delay(500);
	
	(function() {
		$('intro-welcome').fade('in');
	}).delay(1000);
	
	(function() {
		$('architects').fade('in');
	}).delay(1500);
	(function() {
		$('engineers').fade('in');
	}).delay(1800);
	(function() {
		$('planners').fade('in');
	}).delay(2100);
	
	(function() {
		$('architects').fade('out');
		$('engineers').fade('out');
		$('planners').fade('out');
	}).delay(4000);
	
	
	(function() {
		$('intro-text').setStyle('display', 'none');
		animate(1, 0);
	}).delay(4500);
	
	(function() {
		animate(2, 33);
	}).delay(4700);
	
	(function() {
		animate(3, 66);
	}).delay(4900);
	
	(function() {
		animate(4, 99);
	}).delay(5100);
	
	(function() {
		animate(5, 132);
	}).delay(5300);
	
	(function() {
		animate(6, 165);
	}).delay(5500);
	
	(function() {
		animate(7, 198);
	}).delay(5700);
	
	(function() {
		animate(8, 231);
	}).delay(5900);
	
	
	(function() {
		$('intro').setStyle('display', 'none');
		$('themask').setStyle('display', 'none');
		$('intro-masks').fade('out');
	}).delay(6950);
	
	(function() {
		$('intro-masks').setStyle('display', 'none');
	}).delay(7500);

});

// onload...

function hideIntro() {
	$('intro-logo').fade('hide');
	$('intro-welcome').fade('hide');
	$('architects').fade('hide');
	$('engineers').fade('hide');
	$('planners').fade('hide');
	
	var introdivs = $$('#intro div');
	
	introdivs.each(function(e) {
		e.fade('hide');
	});
	
	var maskimgs = $$('#intro-masks img');
	
	maskimgs.each(function(e) {
		e.fade('hide');
	});
	
}

function hideSectors() {
	var sectorimgs = $$('#sectors img');
	
	sectorimgs.each(function(e) {
		e.fade('hide');
	});
}

function hideLoaders() {
	$$('#square1, #loader1').fade('hide');
	$$('#square2, #loader2').fade('hide');
	$$('#square3, #loader3').fade('hide');
	$$('#square4, #loader4').fade('hide');
	$$('#square5, #loader5').fade('hide');
	$$('#square6, #loader6').fade('hide');
	$$('#square7, #loader7').fade('hide');
	$$('#square8, #loader8').fade('hide');
}

// onclick...

function hideNames() {
	var txtdivs = $$('#items li div.vertical');
	
	txtdivs.each(function(e) {
		e.fade('out');
	});
}

function hideReds() {
	var lis = $$('#items li');
	
	lis.each(function(e) {
		e.getFirst().getNext().fade('out');
	});
}

function loadSector(x) {
	$('square' + x).fade('in');
	
	(function() {
		var morphsquare = new Fx.Morph($('square' + x), {duration: 'short'});
		
		morphsquare.start({
    		'left': [0, 33],
    		'width': [32, 263]
		});
	}).delay(400);
	
	(function() {
		$('loader' + x).fade('show');
	}).delay(700);
	
	(function() {
		$('blink' + x).fade('hide');
	}).delay(700);
	(function() {
		$('blink' + x).fade('show');
	}).delay(850);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(1000);
	(function() {
		$('blink' + x).fade('show');
	}).delay(1150);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(1300);
	(function() {
		$('blink' + x).fade('show');
	}).delay(1450);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(1600);
	(function() {
		$('blink' + x).fade('show');
	}).delay(1750);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(1900);
	(function() {
		$('blink' + x).fade('show');
	}).delay(2050);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(2200);
	(function() {
		$('blink' + x).fade('show');
	}).delay(2350);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(2500);
	(function() {
		$('blink' + x).fade('show');
	}).delay(2650);
	(function() {
		$('blink' + x).fade('hide');
	}).delay(2800);
	(function() {
		$('blink' + x).fade('show');
	}).delay(2950);
	
	(function() {
		if (x == 1) {
			document.location = '/federal-military-facilities/';
		}
		if (x == 2) {
			document.location = '/aviation/';
		}
		if (x == 3) {
			document.location = '/fueling/';
		}
		if (x == 4) {
			document.location = '/public-safety-civic-education-facilities/';
		}
		if (x == 5) {
			document.location = '/transportation/';
		}
		if (x == 6) {
			document.location = '/landscape-architecture-planning-urban-design/';
		}
		if (x == 7) {
			document.location = '/municipal-infrastructure/';
		}
		if (x == 8) {
			document.location = '/green/';
		}	
	}).delay(3100);
}

/* opening slide-in animations */

function animate(x, z) {

	$('anim' + x).fade('in');
	
	var morph1 = new Fx.Morph($('anim' + x), {duration: 150});
	var morph2 = new Fx.Morph($('anim' + x), {duration: 50});
	
	(function() {
		morph1.start({
    		'left': [581, z],
    		'width': [32, 263]
		});
	}).delay(200);
	
	(function() {
		morph2.start({
    		'width': [263, 32]
		});
	}).delay(350);
	
	(function() {
		$('mask' + x).fade('in');
		$('ref' + x).fade('in');
	}).delay(500);

}



