$(document).ready(function () {


	//MENU

	/*

	$('#menu a').hover(

		function() { 

			$('span',this).stop(1,1).fadeIn(200);

		},

		function() {

			if ( !$(this).hasClass('active') )

				$('span',this).fadeOut(600);

		}

	);

	*/

	$('#menu li').hover(

		function() { 

			$(this).children('ul').stop(1,1).slideDown(200);

		},

		function() {

			$(this).children('ul').fadeOut(400);

		}

	);

	$("#menu").lavaLamp({ fx: "easeOutBack", speed: 400 })

	

	// HOME

	$('#home .home-project img').css({opacity:1 });

	$('#home .home-project img').hover(

		function() { 

			$(this).stop(1,1).animate({ opacity:.6 }, 200);

		},

		function() { 

			$(this).animate({ opacity:1 }, 600);

		}

	);

	$('#home-slider .inner').cycle({ 

		fx: 'turnDown',

		speed:    1500, 

		timeout:  6000,

		easing: 'easeOutBounce'

	});



	// ABOUT

	$('.toggle').show();

	$('#about-accordian .wrap').hide();

	$('#about-accordian .wrap .wrap').show();

	$('#about-accordian .wrap').eq(0).show();

	$('#about-accordian .tab a').click (function() {

		if ($(this).parent('.tab').parent('li').children('.wrap').is(':visible')) 

			{ $(this).html('click to read') }

		else 

			{ $(this).html('click to close') }

		$(this).parent('.tab').parent('li').children('.wrap').stop(1,1).slideToggle(400);

		return false;

	});

	$('#about-accordian .tab a').localScroll()

	$('#steps li').hide();

	$('#steps').css({overflow:'visible'});

	$('#steps li').eq(0).show();

	$('#process a').click( function() {

		var dex = $('#process a').index(this);

		if ($.browser.msie && $.browser.version.substr(0,1)<8) {

		}

		else {

			$('#overlay').stop(1,1).css({top:122}).show();

			$('#steps li').eq(dex).show();

			$('#overlay').animate({top:310}, 600)

		}

		$('#steps li').hide();

		$('#steps li').eq(dex).show();

	});

	

	$(window).load( function() {
		$('#work-cycle li').each( function() {
			var height = $(this).height();
			if (height>335) {
				var offset = ((height-335)/2)*(-1);
				$('img',this).css({top:offset})
			}
		});
		$('#work-cycle li').eq(0).animate({opacity:1}, 400).fadeIn(1000)
	});

	// WORK

	$('#work-cycle').cycle({ 

		fx: 'cover',

		speed:    300, 

		timeout:  0,

		next: '#controls .next',

	});


	$('#work-items a').hover(

		function() {

			$('span',this).show();								   

		},

		function() {

			$('span',this).hide();								   

		}

	);

	

	$('#more-info').hide();

	$('#case-study a').click( function() {

		if ($('#more-info').is(':visible')) 

			{ $(this).html('click to read') }

		else 

			{ $(this).html('click to close') }

		$('#more-info').slideToggle(400);

		return false;		

	});

		

	// FOOTER

	var bqs = $('#quotes blockquote').size()-1;

	var bqc = 0;

	nextQuote()

	function nextQuote() {

		$('#quotes blockquote').hide();

		$('#quotes blockquote').eq(bqc).fadeIn(600);

		if (bqc<bqs) { ++bqc }

		else {bqc = 0}

		quoteTimer()

		

	}

	function quoteTimer() {

		$('#copy').animate({opacity:1}, 6000, function() {
			nextQuote()
		})	

	}



});