var introImages = new Array(
	'images/uploads/intro/intro_01.jpg',
	'images/uploads/intro/intro_02.jpg',
	'images/uploads/intro/intro_03.jpg',
	'images/uploads/intro/intro_04.jpg',
	'images/uploads/intro/intro_05.jpg',
	'images/uploads/intro/intro_06.jpg',
	'images/uploads/intro/intro_07.jpg',
	'images/uploads/intro/intro_08.jpg',
	'images/uploads/intro/intro_09.jpg',
	'images/uploads/intro/intro_10.jpg',
	'images/uploads/intro/intro_11.jpg',
	'images/uploads/intro/intro_12.jpg',
	'images/uploads/intro/intro_13.jpg',
	'images/uploads/intro/intro_14.jpg',
	'images/uploads/intro/intro_15.jpg',
	'images/uploads/intro/intro_16.jpg',
	'images/uploads/intro/intro_17.jpg',
	'images/uploads/intro/intro_18.jpg',
	'images/uploads/intro/intro_19.jpg',
	'images/uploads/intro/intro_20.jpg'
);

var locked = true;
var keylocked = false;

document.addEvent('mousewheel', function(e) {
	myEvent = new Event(e);
	
	if (myEvent.wheel > 0) {
		next();
	} else if (myEvent.wheel < 0) {
		previous();
	}
	myEvent.stopPropagation();
	if(myEvent.preventDefault)
		myEvent.preventDefault();
	e.stop();
	new Fx.Scroll(document).start(0,0);
});

if(window.opera || (navigator.userAgent && navigator.userAgent.indexOf('Firefox') != -1))
	document.addEvent('keypress', function(e) { key(e) });
else
	document.addEvent('keydown', function(e) { key(e) });

function key(e) {
	switch(e.key) {
		case '!':
		case 'up':
			if(!keylocked) {
				next();
				myEvent = new Event(e);
				myEvent.stopPropagation();
				if(myEvent.preventDefault)
					myEvent.preventDefault();
				e.stop();
				new Fx.Scroll(document).start(0,0);
				return false;
			}
			break;
		case 'left':
			if(!keylocked) {
				currentImageSwitch(false);
				myEvent = new Event(e);
				myEvent.stopPropagation();
				if(myEvent.preventDefault)
					myEvent.preventDefault();
				e.stop();
				new Fx.Scroll(document).start(0,0);
				return false;
			}
			break;
		case 'right':
			if(!keylocked) {
				currentImageSwitch(true);
				myEvent = new Event(e);
				myEvent.stopPropagation();
				if(myEvent.preventDefault)
					myEvent.preventDefault();
				e.stop();
				new Fx.Scroll(document).start(0,0);
				return false;
			}
			break;
		case '"':
		case 'down':
			if(!keylocked) {
				previous();
				myEvent = new Event(e);
				myEvent.stopPropagation();
				if(myEvent.preventDefault)
					myEvent.preventDefault();
				e.stop();
				new Fx.Scroll(document).start(0,0);
				return false;
			}
			break;
		case '$':
		case '#':
			if(!keylocked) {
				myEvent = new Event(e);
				myEvent.stopPropagation();
				if(myEvent.preventDefault)
					myEvent.preventDefault();
				e.stop();
				new Fx.Scroll(document).start(0,0);
				return false;
			}
			break;
	}
}

window.addEvent('domready', function() {
	var links = $$('a');
	for(var i=0; i<links.length; i++) {
		if(links[i].href.indexOf('#') == -1 && links[i].href != '' && links[i].href.indexOf('javascript:') == -1 && links[i].href.indexOf('mailto:') == -1 && links[i].target != '_blank')
			links[i].onclick = function() {return waitUnload(this)};
	}
});
var timer, loadedImages = [];
function introImage(index) {
	if(index == loadedImages.length - 1) {
		loadedImages[index].inject($('intro'));
		addObject(loadedImages[index]);
		setTimeout(function() {
			new Fx.Morph($('intro'), {duration:1000}).start({ 'opacity' : [1, 0] }).chain(function() {
				locked = false;
				$('intro').setStyle('display', 'none');
				$('current').addEvent('click', function(e) { currentClick(e); });
				$('left_arrow').addEvent('mouseenter', function() { prevArrowOver(); });
				$('left_arrow').addEvent('mouseleave', function() { prevArrowOut(); });
				$('left_arrow').addEvent('click', function() { currentImageSwitch(false) });
				$('right_arrow').addEvent('mouseenter', function() { nextArrowOver();});
				$('right_arrow').addEvent('mouseleave', function() { nextArrowOut(); });
				$('right_arrow').addEvent('click', function() { currentImageSwitch(true) });
				$('next_link').addEvent('mouseenter', function() { showNext();});
				$('next_link').addEvent('mouseleave', function() { hideNext();});
				$('next_link').addEvent('click', function() { next(); });
				$('prev_link').addEvent('mouseenter', function() { showPrevious();});
				$('prev_link').addEvent('mouseleave', function() { hidePrevious();});
				$('prev_link').addEvent('click', function() { previous(); });
				$('next').addEvent('mouseenter', function() { showNext();});
				$('next').addEvent('mouseleave', function() { hideNext();});
				$('next').addEvent('click', function() { next(); });
				$('previous').addEvent('mouseenter', function() { showPrevious();});
				$('previous').addEvent('mouseleave', function() { hidePrevious();});
				$('previous').addEvent('click', function() { previous(); });
				$('current').addEvent('mousemove', function(e) { currentHover(e);});
				$('current').addEvent('mouseleave', function(e) { currentOut(); });
			});
		}, 2000);
	} else {
		loadedImages[index].inject($('intro'));
		addObject(loadedImages[index]);
		setTimeout("introImage("+(index + 1)+")", 110);
	}
}
var numLoaded = 0;
window.addEvent('load', function() {
	if(pagename == "index") {
		//new Fx.Morph('logo', {duration:3500}).start({ 'opacity' : [0, 1] });
		new Asset.images(introImages, {
			onProgress: function(i) {
				this.setStyles({
					'position': 'absolute',
					'opacity': 1,
					'left': 245,
					'top': 87
				});
				loadedImages[i] = this;
				numLoaded++;
				$('intro_progress_bar').setStyle('height', 1);
				$('intro_progress').setStyle('width', (numLoaded / introImages.length * 340) * ratio);
				$$('#intro_percent span')[0].innerHTML = 100 * numLoaded / introImages.length;
				$('intro_percent').setStyle('left', (229 + numLoaded / introImages.length * 340) * ratio);
				updateObjectValue($('intro_progress'), 'width', numLoaded / introImages.length * 340);
				updateObjectValue($('intro_percent'), 'left', 229 + numLoaded / introImages.length * 340);
			},
			onComplete: function() {
				new Group(
					new Fx.Morph('intro_progress_bar', { duration:1000 }).start({ 'opacity' : 0 }),
					new Fx.Morph('intro_percent', { duration:1000 }).start({ 'opacity' : 0 })
				).addEvent('complete', function() {
					loadedImages.sort(function(a, b) {
						return (a.src < b.src) ? -1 : (a.src > b.src) ? 1 : 0;
					});
					introImage(0);
				});
			}
		}); 
		
	} else {
		new Group(
			new Fx.Morph('topbox', {fps : 24}).start({ 'opacity' : [1, 0] }),
			new Fx.Morph('bottombox', {fps : 24}).start({ 'opacity' : [1, 0] }),
			new Fx.Morph('previous', {fps : 24, duration:125}).start({ 'opacity' : [0, .5] }),
			new Fx.Morph($$('#current div.inner')[0], {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
			new Fx.Morph('next', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
			new Fx.Morph('next_link', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
			new Fx.Morph('prev_link', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
			new Fx.Morph('filter', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] })
		).addEvent('complete', function() {
			locked = false;
			$('current').addEvent('click', function(e) { currentClick(e); });
			$('left_arrow').addEvent('mouseenter', function() { prevArrowOver(); });
			$('left_arrow').addEvent('mouseleave', function() { prevArrowOut(); });
			$('left_arrow').addEvent('click', function() { currentImageSwitch(false) });
			$('right_arrow').addEvent('mouseenter', function() { nextArrowOver(); });
			$('right_arrow').addEvent('mouseleave', function() { nextArrowOut(); });
			$('right_arrow').addEvent('click', function() { currentImageSwitch(true) });
			$('next_link').addEvent('mouseenter', function() { showNext();});
			$('next_link').addEvent('mouseleave', function() { hideNext();});
			$('next_link').addEvent('click', function() { next(); });
			$('prev_link').addEvent('mouseenter', function() { showPrevious();});
			$('prev_link').addEvent('mouseleave', function() { hidePrevious();});
			$('prev_link').addEvent('click', function() { previous(); });
			$('next').addEvent('mouseenter', function() { showNext();});
			$('next').addEvent('mouseleave', function() { hideNext();});
			$('next').addEvent('click', function() { next(); });
			$('previous').addEvent('mouseenter', function() { showPrevious();});
			$('previous').addEvent('mouseleave', function() { hidePrevious();});
			$('previous').addEvent('click', function() { previous(); });
			
			$('shadow2').addEvent('mouseenter', function() { showNext();});
			$('shadow2').addEvent('mouseleave', function() { hideNext();});
			$('shadow2').addEvent('click', function() { next(); });
			$('shadow4').addEvent('mouseenter', function() { showPrevious();});
			$('shadow4').addEvent('mouseleave', function() { hidePrevious();});
			$('shadow4').addEvent('click', function() { previous(); });
			
			$('current').addEvent('mousemove', function(e) { currentHover(e);});
			$('current').addEvent('mouseleave', function(e) { currentOut(); });
		});
	}
});
function waitUnload(ele) {
	var url = ele.href;
	ele.blur();
	if(playing)
		lightsOn();
	$('project_bottom_bar').setStyle('display', 'none');
	$('play').setStyle('display', 'none');
	new Group(
		new Fx.Morph('previous', {fps : 24, duration:125}).start({ 'opacity' : [.5, 0] }),
		new Fx.Morph($$('#current div.inner')[0], {fps : 24, duration:125}).start({ 'opacity' : [1, 0] }),
		new Fx.Morph('next', {fps : 24, duration:125}).start({ 'opacity' : [1, 0] }),
		new Fx.Morph('next_link', {fps : 24, duration:125}).start({ 'opacity' : [1, 0] }),
		new Fx.Morph('prev_link', {fps : 24, duration:125}).start({ 'opacity' : [1, 0] }),
		new Fx.Morph('topbox', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
		new Fx.Morph('bottombox', {fps : 24, duration:125}).start({ 'opacity' : [0, 1] }),
		new Fx.Morph('filter', {fps : 24, duration:125}).start({ 'opacity' : [1, 0] }),
		new Fx.Morph('credits', {fps : 24, duration:125}).start({ 'opacity' : 0 }),
		new Fx.Morph('loading', {fps : 24, duration:125}).start({ 'opacity' : 1 })
	).addEvent('complete', function() {
//		$('loading').setStyle('opacity', 1);
		window.location.href = url;
	});
	return false;
}
function next() {
	hideNext();
	creditsMorph.cancel();
	$('credits').setStyle('opacity', 0);
	if(!locked) {
		locked = true;
		if(playing)
			stopMovie(true);
		keyboardMorph.cancel();
		keyboardMorph.start({ 'opacity' : 0 });
//		slideNumberMorph.cancel();
//		slideNumberMorph.set({'opacity' : 0});
		bottomBarMorph.cancel();
		bottomBarMorph.set({'opacity' : 0});
		hidePlayButton(false);
		$('current').removeEvents('click');
		$('current').removeEvents('mouseenter');
		$('current').removeEvents('mousemove');
		$('current').removeEvents('mouseleave');
		$('previous').removeEvents('click');
		$('previous').removeEvents('mouseenter');
		$('previous').removeEvents('mouseleave');
		$('next').removeEvents('click');
		$('next').removeEvents('mouseenter');
		$('next').removeEvents('mouseleave');
		// Handle Mouseover
			nextOver = false;
			prevOver = false;
			$('prev_link').setStyle('color', '');
			/*
			$('previous').setStyle('top', 0);
			$('prev_link').setStyle('top', 568*ratio);
			$('next_link').setStyle('color', '');
			$('next').setStyle('position', 'relative');
			$('next').setStyle('top', 0);
			$('next_link').setStyle('top', 23*ratio);
			$('current').setStyle('margin-top', 0);
			*/
		//
		var top = parseFloat($('main').getStyle('top').split('px')[0]);
		var nextProject = getNewNext();
		
		var newProject = new Element('div', {
			id : 'temp',
			'class' : 'project',
			styles : {'opacity' : 0}
		});
		var newInner = new Element('div', {
			'class' : 'inner'
		});
		new Element('div', {
			'class' : 'project_image',
			html : '<img src="'+nextProject.images[nextProject.currentIndex]+'" width="750" height="500" alt="'+nextProject.name+'" />',
			styles : {'visibility' : 'hidden'}
		}).inject(newInner);
		switch(nextProject.colorScheme) {
			case 'white':
				var h1Color = '#fff';
				var h2Color = '#bcbec0';
				var pColor = '#bcbec0';
				break;
			default:
				var h1Color = '#231f20';
				var h2Color = '#808285';
				var pColor = '#808285';
		}
		
		h1Color = (nextProject.colors[0] != '') ? nextProject.colors[0] : h1Color;
		h2Color = (nextProject.colors[1] != '') ? nextProject.colors[1] : h2Color;
		pColor = (nextProject.colors[2] != '') ? nextProject.colors[2] : pColor;
				
		var types = '';
		for(var i=0; i<nextProject.type.length; i++)
			types += ((i != 0 && nextProject.type[i] != '') ? ', ' : '') + nextProject.type[i];
		new Element('div', {
			'class' : 'content',
			styles : {
				'visibility' : 'hidden'
			},
			html : ((nextProject.currentIndex == 0)
					?
						'<h1 style="color: '+h1Color+'">'+nextProject.name+'</h1><h2 style="color: '+h2Color+'">'+types+'</h2><p style="color: '+pColor+'">'+nextProject.description+'</p>'
					:
						'')
		}).inject(newInner);
		
		newInner.inject(newProject);
		newProject.inject('main', 'top');
		addObject(newProject);
		
		$('main').setStyle('top', top - 536 * ratio + 'px');
		top -= 536 * ratio;
		$('temp_prev_link').setStyles({'opacity' : 1 , 'top' : 568 * ratio}).innerHTML = $('prev_link').innerHTML;
		$('temp_next_link').setStyles({'opacity' : 1 , 'top' : 23 * ratio}).innerHTML = $('next_link').innerHTML;
		$('prev_link').setStyle('opacity', 0).innerHTML = display[((index==0) ? display.length - 1 : index - 1)].name;
		$('next_link').setStyle('opacity', 0).innerHTML = nextProject.name;
		
		new Group(
			new Fx.Morph('next', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : 1}),
			new Fx.Morph('current', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : .5}),
			new Fx.Morph('previous', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : 0}),
			new Fx.Morph('temp', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : .5}),
			new Fx.Morph('main', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'top' : top + (536 * ratio)}),
			new Fx.Morph('next_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [-513 * ratio, 23 * ratio],
				'opacity' : [0,1] }),
			new Fx.Morph('temp_next_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [23 * ratio, 559 * ratio],
				'opacity' : [1,0] }),
			new Fx.Morph('prev_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [32 * ratio, 568 * ratio],
				'opacity' : [0,1] }),
			new Fx.Morph('temp_prev_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [568 * ratio, 1164 * ratio],
				'opacity' : [1,0] }),
			new Fx.Morph($$('#next div.content')[0], {duration: 1000}).start({'opacity' : [0, 1]}),
			new Fx.Morph($$('#current div.content')[0], {duration: 1000}).start({'opacity' : [1, 0]}),
			new Fx.Morph($$('#current div.project_image')[0], {duration: 1000}).start({'opacity' : [1, 0]}),
			new Fx.Morph($$('#next div.project_image')[0], {duration: 1000}).start({'opacity' : [0, 1]})/*,
			new Fx.Morph($$('#current div.content')[0], {duration: 1000}).start({'top' : 53 * ratio})*/
		).addEvent('complete', function() {
//			bottomBarMorph.start({ 'opacity' : 1 }).chain(function () { if(display[index].currentIndex != 0) bottomBarMorph.start({ 'opacity' : 0.01 }); });
			if(display[index].currentIndex == 0)
				pulse();
			else
				pulseMorph.cancel();
			prevImage = new Asset.image(display[index].images[((display[index].currentIndex == 0) ? display[index].images.length - 1 : display[index].currentIndex - 1)], {
				width: 750,
				height: 500,
				alt: ''
			});
			nextImage = new Asset.image(display[index].images[((display[index].currentIndex == display[index].images.length - 1) ? 0 : display[index].currentIndex + 1)], {
				width: 750,
				height: 500,
				alt: ''
			});
			//prevImage = new Image(750, 500);
			//prevImage.src = display[index].images[((display[index].currentIndex == 0) ? display[index].images.length - 1 : display[index].currentIndex - 1)];
			//nextImage = new Image(750, 500);
			//nextImage.src = display[index].images[((display[index].currentIndex == display[index].images.length - 1) ? 0 : display[index].currentIndex + 1)];
			updateObjectValue($$('#current div.content')[0], 'top', 0);
			deleteObject($('previous'));
			$('previous').dispose();
			$('current').id = 'previous';
			$('next').id = 'current';
			$('temp').id = 'next';
			$('next').setStyle('cursor', '');
			$('previous').setStyle('cursor', '');	
			if(display[index].images.length == 1) {
				$('current').setStyle('cursor', 'auto');
				$('left_arrow').setStyle('cursor', 'auto');
				$('right_arrow').setStyle('cursor', 'auto');
			} else {
				$('current').setStyle('cursor', '');
				$('left_arrow').setStyle('cursor', '');
				$('right_arrow').setStyle('cursor', '');
			}
			$('current').addEvent('click', function(e) { currentClick(e); });
			$('next').addEvent('mouseenter', function() { showNext();});
			$('next').addEvent('mouseleave', function() { hideNext();});
			$('next').addEvent('click', function() { next(); });
			$('previous').addEvent('mouseenter', function() { showPrevious();});
			$('previous').addEvent('mouseleave', function() { hidePrevious();});
			$('previous').addEvent('click', function() { previous(); });
			$('current').addEvent('mousemove', function(e) { currentHover(e);});
			$('current').addEvent('mouseleave', function(e) { currentOut(); });
			
			updatePlayButton(false);
			$('slide_numbers').innerHTML = (display[index].currentIndex + 1) + '|' + (display[index].images.length);
			bottomBarMorph.cancel();
			bottomBarMorph.start({ 'opacity' : 1 });
			updateBottomBar();
			locked = false;
		});
	}
}
var mouseTimeout;
var nextOver = false;
var prevOver = false;
var bounce1, bounce2;
function showNext() {
	$('next_link').setStyle('color', '#000');
	/*
	if(mouseTimeout != null)
		clearTimeout(mouseTimeout);
	if(!locked && !nextOver) {
		nextOver = true;
		$('next_link').setStyle('color', '#000');
		$('next').setStyle('position', 'absolute');
		bounce1 = new Fx.Morph('next', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [0, 7*ratio] });
		bounce2 = new Fx.Morph('next_link', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [23*ratio, 30*ratio] });
		$('current').setStyle('margin-top', 536*ratio+'px');
	}
	*/
	return;
}
function showPrevious() {
	$('prev_link').setStyle('color', '#000');
	/*
	if(mouseTimeout != null)
		clearTimeout(mouseTimeout);
	if(!locked && !prevOver) {
		prevOver = true;
		bounce1 = new Fx.Morph('previous', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [0, -7*ratio] });
		bounce2 = new Fx.Morph('prev_link', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [568*ratio, 561*ratio] });
	}
	*/
	return;
}
function hideNext() {
	$('next_link').setStyle('color', '');
	/*
	if(mouseTimeout != null)
		clearTimeout(mouseTimeout);
	mouseTimeout = setTimeout(function() {
		if(!locked && nextOver) {
			clearTimeout(mouseTimeout);
			nextOver = false;
			$('next').setStyle('position', 'relative');
			bounce1 = new Fx.Morph('next', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [7*ratio, 0] });
			bounce2 = new Fx.Morph('next_link', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [30*ratio, 23*ratio] });
			$('current').setStyle('margin-top', 0);
		}
	}, 50);
	*/
	return;
}
function hidePrevious() {
	$('prev_link').setStyle('color', '');
	/*
	if(mouseTimeout != null)
		clearTimeout(mouseTimeout);
	mouseTimeout = setTimeout(function() {
		if(!locked && prevOver) {
			clearTimeout(mouseTimeout);
			prevOver = false;
			bounce1 = new Fx.Morph('previous', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [-7*ratio, 0] });
			bounce2 = new Fx.Morph('prev_link', { duration: 'short', transition: Fx.Transitions.Quad.easeOut }).start({'top' : [561*ratio, 568*ratio] });
		}
	}, 50);
	*/
	return;
}
function previous() {
	if(!locked) {
		locked = true;
		creditsMorph.cancel();
		$('credits').setStyle('opacity', 0);
		if(playing)
			stopMovie(true);
		hidePrevious();
		keyboardMorph.cancel();
		keyboardMorph.start({ 'opacity' : 0 });
//		slideNumberMorph.cancel()
//		slideNumberMorph.set({'opacity' : 0});
		bottomBarMorph.cancel();
		bottomBarMorph.set({'opacity' : 0.01});
		hidePlayButton(false);
		$('current').removeEvents('click');
		$('current').removeEvents('mouseenter');
		$('current').removeEvents('mousemove');
		$('current').removeEvents('mouseleave');
		$('previous').removeEvents('click');
		$('previous').removeEvents('mouseenter');
		$('previous').removeEvents('mouseleave');
		$('next').removeEvents('click');
		$('next').removeEvents('mouseenter');
		$('next').removeEvents('mouseleave');
		// Handle Mouseover
			nextOver = false;
			prevOver = false;
			$('prev_link').setStyle('color', '');
			/*
			$('previous').setStyle('top', 0);
			$('prev_link').setStyle('top', 568*ratio);
			$('next_link').setStyle('color', '');
			$('next').setStyle('position', 'relative');
			$('next').setStyle('top', 0);
			$('next_link').setStyle('top', 23*ratio);
			$('current').setStyle('margin-top', 0);*/
		//
		var top = parseFloat($('main').getStyle('top').split('px')[0]);
		var nextProject = getNewPrevious();
		var newProject = new Element('div', {
			id : 'temp',
			'class' : 'project',
			styles : {
				'visibility' : 'hidden'
			}
		});
		var newInner = new Element('div', {
			'class' : 'inner'
		});
		new Element('div', {
			'class' : 'project_image',
			styles : {
				'opacity' : 0
			},
			html : '<img src="'+nextProject.images[nextProject.currentIndex]+'" width="750" height="500" alt="'+nextProject.name+'" />'
		}).inject(newInner);
		switch(nextProject.colorScheme) {
			case 'white':
				var h1Color = '#fff';
				var h2Color = '#bcbec0';
				var pColor = '#bcbec0';
				break;
			default:
				var h1Color = '#231f20';
				var h2Color = '#808285';
				var pColor = '#808285';
		}
		
		h1Color = (nextProject.colors[0] != '') ? nextProject.colors[0] : h1Color;
		h2Color = (nextProject.colors[1] != '') ? nextProject.colors[1] : h2Color;
		pColor = (nextProject.colors[2] != '') ? nextProject.colors[2] : pColor;
		
		var types = '';
		for(var i=0; i<nextProject.type.length; i++)
			types += ((i != 0 && nextProject.type[i] != '') ? ', ' : '') + nextProject.type[i];
		new Element('div', {
			'class' : 'content',
			styles : {
				'width' : 314,
				'visibility' : 'hidden'/*,
				'top' : 53*/
			},
			html : ((nextProject.currentIndex == 0)
					?
						'<h1 style="color: '+h1Color+'">'+nextProject.name+'</h1><h2 style="color: '+h2Color+'">'+types+'</h2><p style="color: '+pColor+'">'+nextProject.description+'</p>'
					:
						'')
		}).inject(newInner);
		newInner.inject(newProject);
		newProject.inject('main', 'bottom');
		addObject(newProject);
		$('temp_prev_link').setStyles({'opacity' : 1 , 'top' : 568 * ratio}).innerHTML = $('prev_link').innerHTML;
		$('temp_next_link').setStyles({'opacity' : 1 , 'top' : 23 * ratio}).innerHTML = $('next_link').innerHTML;
		$('prev_link').setStyle('opacity', 0).innerHTML = nextProject.name;
		$('next_link').setStyle('opacity', 0).innerHTML = display[((index==display.length - 1) ? 0 : index + 1)].name;
		
		new Group(
			new Fx.Morph('previous', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : 1}),
			new Fx.Morph('current', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : .5}),
			new Fx.Morph('next', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : 0}),
			new Fx.Morph('temp', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'opacity' : .5}),
			new Fx.Morph('main', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({'top' : top - (536 * ratio)}),
			new Fx.Morph('temp_next_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [23 * ratio, -513 * ratio],
				'opacity' : [1,0] }),
			new Fx.Morph('next_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [559 * ratio, 23 * ratio],
				'opacity' : [0,1] }),
			new Fx.Morph('temp_prev_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [568 * ratio, 32 * ratio],
				'opacity' : [1,0] }),
			new Fx.Morph('prev_link', {duration: 1000, transition: Fx.Transitions.Quad.easeOut}).start({
				'top' : [1164 * ratio, 568 * ratio],
				'opacity' : [0,1] }),
			new Fx.Morph($$('#previous div.content')[0], {duration: 1000}).start({'opacity' : [0, 1]}),
			new Fx.Morph($$('#current div.content')[0], {duration: 1000}).start({'opacity' : [1, 0]}),
			new Fx.Morph($$('#previous div.project_image')[0], {duration: 1000}).start({'opacity' : [0, 1]}),
			new Fx.Morph($$('#temp div.project_image')[0], {duration: 1000}).start({'opacity' : 0}),
			/*new Fx.Morph($$('#previous div.content')[0], {duration: 1000}).start({'top' : 0}),*/
			new Fx.Morph($$('#current div.project_image')[0], {duration: 1000}).start({'opacity' : [1, 0]})
		).addEvent('complete', function() {
//			bottomBarMorph.start({ 'opacity' : 1 }).chain(function () { if(display[index].currentIndex != 0) bottomBarMorph.start({ 'opacity' : 0.01 }); });
			if(display[index].currentIndex == 0)
				pulse();
			else
				pulseMorph.cancel();
			prevImage = new Asset.image(display[index].images[((display[index].currentIndex == 0) ? display[index].images.length - 1 : display[index].currentIndex - 1)], {
				width: 750,
				height: 500,
				alt: ''
			});
			nextImage = new Asset.image(display[index].images[((display[index].currentIndex == display[index].images.length - 1) ? 0 : display[index].currentIndex + 1)], {
				width: 750,
				height: 500,
				alt: ''
			});
			//prevImage = new Image(750, 500);
			//prevImage.src = display[index].images[((display[index].currentIndex == 0) ? display[index].images.length - 1 : display[index].currentIndex - 1)];
			//nextImage = new Image(750, 500);
			//nextImage.src = display[index].images[((display[index].currentIndex == display[index].images.length - 1) ? 0 : display[index].currentIndex + 1)];
			$('main').setStyle('top', top + 'px');
			updateObject($$('#previous div.content')[0], 'top');
			deleteObject($('next'));
			$('next').dispose();
			$('current').id = 'next';
			$('previous').id = 'current';
			$('temp').id = 'previous';
			$('next').setStyle('cursor', '');
			$('previous').setStyle('cursor', '');	
			if(display[index].images.length == 1) {
				$('current').setStyle('cursor', 'auto');
				$('left_arrow').setStyle('cursor', 'auto');
				$('right_arrow').setStyle('cursor', 'auto');
			} else {
				$('current').setStyle('cursor', '');
				$('left_arrow').setStyle('cursor', '');
				$('right_arrow').setStyle('cursor', '');
			}
			$('current').addEvent('click', function(e) { currentClick(e); });
			$('next').addEvent('mouseenter', function() { showNext();});
			$('next').addEvent('mouseleave', function() { hideNext();});
			$('next').addEvent('click', function() { next(); });
			$('previous').addEvent('mouseenter', function() { showPrevious();});
			$('previous').addEvent('mouseleave', function() { hidePrevious();});
			$('previous').addEvent('click', function() { previous(); });
			$('current').addEvent('mousemove', function(e) { currentHover(e);});
			$('current').addEvent('mouseleave', function(e) { currentOut(); });
			$('slide_numbers').innerHTML = (display[index].currentIndex + 1) + '|' + (display[index].images.length);
			bottomBarMorph.cancel();
			bottomBarMorph.start({ 'opacity' : 1 });
			updateBottomBar();
			updatePlayButton(false);
			locked = false;
		});
	}
}