/*
	Lusk Architecture Landing Page

	17 may 2011: created; started on logos
	18 may 2011: added placeholders, slides, and news
	19 may 2011: no longer centering slides; cycle
		plugin overrides my changes anyway
	20 may 2011: tweaked speed on slides and logos
		per client's request
*/

var lusk =
{
	initialize: function()
	{
		lusk.placeholders.initialize();
		lusk.slides.initialize();
		lusk.logos.initialize();
		lusk.news.initialize();
	},
	middle: function(a, b)
	{
		return (Math.round((a - b)  / 2) + 'px');
	},
	placeholders:
	{
		initialize: function()
		{	// add js placeholders for older browsers
			$(':input[placeholder]').placeholder();
		}
	},
	slides:
	{
		initialize: function()
		{	// make slides dynamic
			$('#slides').cycle(
			{
				fx:      'fade',
				pause:   true,
				speed:   2000,
				timeout: 6000
			});
		}
	},
	logos:
	{
		initialize: function()
		{	// center logos vertically
			var $logos = $('#logos');
			var logosh = $logos.height();
			$logos.find('.logo').each(function()
			{
				var $logo = $(this);
				$logo.css(
				{
					'margin-top': lusk.middle(logosh, $logo.height()) / 2
				});
			});
			// make logos scroll horizontally
			$logos.scrollElements(
			{
				interval: 30,
				speed:    100
			});
		}
	},
	news:
	{
		initialize: function()
		{	// make news items dynamic
			$('#news-items').cycle(
			{
				fx:      'fade',
				pause:   true,
				speed:   1000,
				timeout: 6000
			});

			//add click event to cycle to the next news article
			$('#next-news-item').click(function(){
				$('#news-items').cycle('next');
				return false;
			});
		}
	}
};

$(lusk.initialize);


