(function($) {
	
	//Global Vars *****************************
	
	//Methods *****************************
	var methods = 
	{
		//INIT *****************************	
		init: function(parameters)
		{
			
			$('#content').bind('touchstart', methods.iconMouseClick);
			$('#content').bind('mouseenter', methods.iconMouseEnter);
			$('#content').bind('mouseleave', methods.iconMouseLeave);

			$('#current-status-button').bind('click', methods.showCurrentStatus);
				
		},

		iconMouseClick: function(e)
		{	
			$(this).toggleClass('active');
		},

		iconMouseEnter: function(e)
		{
			$(this).addClass('active');
		},

		iconMouseLeave: function(e)
		{
			$(this).removeClass('active');	
		},

		showCurrentStatus: function(e)
		{
			e.preventDefault();

			$('#current-status-wrapper').toggleClass('show');	
		},

		getCurrentStatus: function()
		{
			$.getJSON('/stage/current-status/api/?count=3&page=1', function(data){
				
				methods.updateCurrentStatus(data);

			});
		},

		updateCurrentStatus: function(theJSON)
		{
			var currentStatus = $('#current-status');
			var currentStatusWrapper = $('#current-status-wrapper');
			
			for(post in theJSON['posts'])
			{
				var thePost = $('<li/>');
				var theContent = '<span>' + theJSON['posts'][post]['date'] + ' /*</span>' + theJSON['posts'][post]['content'];
				
				thePost.append(theContent);
				currentStatus.append(thePost);
			}

			setTimeout(function(){
				currentStatusWrapper.css('margin-bottom', -currentStatus.outerHeight() + 'px');
			}, 1500);
		}
			
	}//END methods

	$.fn.adam_putinski = function(method)
	{
		if(methods[method]) {
			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
		}
		else if (typeof method === 'object' || !method) {
			return methods.init.apply(this, arguments);
		}
		else {
			$.error('Method ' + method + ' does not exist');
		}
	}

})(jQuery);

$(document).ready(function(){
	
	//Init the plugin, passing in the current page
	$.fn.adam_putinski();
					
});

$(window).load(function(){
	
	//Init the plugin, passing in the current page
	$.fn.adam_putinski('getCurrentStatus');
					
});

