
jQuery(document).ready(function() {
	plank.global();
});

// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern
var plank = (function($) {
	return {
		// Start It
		global: function() {
			for (var i in plank.init) {
				plank.init[i]();
			}
		},



		init: {
			
			
			button_hover: function() 
			{
			
				$('.hoverfade').hover(function(){
					$(this).stop().animate({
						opacity: 0.6
					}, 500);
				
				}, function(){
					$(this).stop().animate({
						opacity: 1.0
					}, 500);
				})
			
			
			
			},
			
			
			
			home_news: function()
			{
				$('#news_scroller').innerfade({
					animationtype: 'fade',
					speed: 1000,
					timeout: 6000,
					type: 'sequence',
					containerheight: '70px'
				});
			
			},
			
			
			
			
			
			lightbox: function()
			{		
				$("ul.project_gallery a").fancybox({
				    'transitionIn'	:	'elastic',
				    'transitionOut'	:	'elastic',
				    'speedIn'		:	600, 
				    'speedOut'		:	200, 
				    'overlayShow'	:	true
				});               
			},
			
			
			
			launch_video: function()
			{
			
				$('a.launch_video').click(function()
				{
					// Get title
					var title = $(this).attr('title');
					var video = $(this).attr('rel');
				
				
					// Prepare the modal
					plank.prepare_modal(title);
					
					var embed = '<object width="760" height="430"><param name="movie" value="http://www.youtube.com/v/'+ video +'&hl=en&fs=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+ video +'&hl=en&fs=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="760" height="430"></embed></object>';
			
					$('#modal-content').html(embed);
								
					$('html, body').animate({scrollTop:0}, 'slow');
					$('.overlay').fadeIn('slow');
					
				});
			
			
			
			}
					
			
		
		
		},
		
		
		
		
			
		prepare_modal: function(title)
		{
			// create the overlay
			var height = $(document).height();
			var overlay = '<div class="overlay" style="height: '+height+'px;"></div>';
			$('body').append(overlay);
			
			
			var inner = '<div id="modal"><h1 class="tag">'+title+'</h1><a href="javascript:;" class="close" onclick="plank.modal_close();"><img src="/assets/img/close.png"></a><div class="clear"></div><div id="modal-content"></div></div>';
			$('.overlay').append(inner);
			$('html,body').animate({ scrollTop: $('body').offset().top }, { duration: 'slow'});

			
		

		
		},
		
		
		
		
		modal_close: function()
		{
		   $('.overlay').fadeOut('Slow', function(){
		       $('.overlay').remove();
		   });
		    		
		}
		
		
		
	};
// Pass in jQuery ref.
})(jQuery, this);






