/*
 *
 * jQuery abe Plugins
 * version 0.1
 * Author: Eduards Torba
 * Website: www.fearsomepixels.com
 * 
 * Built on top of the jQuery library
 * http://jquery.com
 * 
 */
 
 
jQuery.fn.extend(
{
	abe_infobar : function(options)
	{
		// Author: Eduards Torba
		// Version: 1.0.0
		var $this = $(this);

		// Default Options
		this.defaultOptions = {
			button: '.infobar_btn',
			easing: 'swing',
			duration: 600,
			visible: true
		};

		// Refreshing Settings
		var settings = $.extend({}, this.defaultOptions, options);
		
		if (!settings.visible) { $this.hide(); }
		
		// Hide infobar if there is no text
		if (settings.text == null || settings.text == "") {
		}

		$this.children().html(settings.text); // Updating infobars text
		
		// Infobar button
		$(settings.button).click(function(e)
		{
			e.preventDefault();
			$this.slideToggle(settings.speed, settings.easing);
		});
	}, // abe_infobar
	abe_backToTop : function(options)
	{
		// Author: Eduards Torba
		// Version: 1.0.0
		var $this = $(this);

		// Default Options
		this.defaultOptions = {
			speed: 1000,
			easing: 'swing'
		};

		// Refreshing Settings
		var settings = $.extend({}, this.defaultOptions, options);

		// Scroll up
		$this.click(function(e)
		{
			e.preventDefault();
			$('body,html').stop(true).animate({scrollTop: 0},settings.speed, settings.easing);
		});
	}, // abe_backToTop
	abe_navFollow : function(options)
	{
		// Author: Eduards Torba
		// Version: 1.0.0
		var $this = $(this);

		// Default Options
		this.defaultOptions = {
			follow: false,
			easing: 'swing',
			speed: 1000,
			lock: false,
			min_window_width: 959
		};

		// Refreshing Settings
		var settings = $.extend({}, this.defaultOptions, options);

		// Lock
		if (settings.lock)
		{
			// Create lock
			$this.prepend('<a class="lock" href=""></a>');

			// Lock Status
			if (settings.follow)
			{
				$(".lock").addClass("unlocked");
			}
			else
			{
				$(".lock").addClass("locked"); 
			}

			// Click
			$(".lock").click(function(e){
				e.preventDefault();
				if (settings.follow)
				{ 
					settings.follow = false;
					$(this).removeClass("unlocked").addClass("locked"); 
				} 
				else
				{ 
					settings.follow = true;
					$(this).removeClass("locked").addClass("unlocked");

					var d = $(window).width();
					if (d > settings.min_window_width)
					{
						$(window).scroll(function()
						{
							if (settings.follow)
							{
								$this.stop(true).animate({"marginTop": $(window).scrollTop() + "px"}, settings.speed, settings.easing);
							}
						});
					}

					// On window resize
					$(window).resize(function()
					{
						var c = $(window).width();
						if (c > settings.min_window_width)
						{
							$(window).scroll(function()
							{
								if (settings.follow)
								{
									$this.stop(true).animate({"marginTop": $(window).scrollTop() + "px"}, settings.speed, settings.easing);
								}
							});
						}
						else
						{
							$this.css({"marginTop": "0px"});
							$(window).scroll(function()
							{
								$this.stop().animate({ marginTop: 0 });
							});
						}
					});
				}
			});
		}
		
		// Follow
		if (settings.follow)
		{
			// Run it on load
			var b = $(window).width();
			if (b > settings.min_window_width)
			{
				$(window).scroll(function()
				{
					if (settings.follow)
					{
						$this.stop(true).animate({"marginTop": $(window).scrollTop() + "px"}, settings.speed, settings.easing);
					}
				});
			}
			
			// On window resize
			$(window).resize(function()
			{
				var c = $(window).width();
				if (c > settings.min_window_width)
				{
					$(window).scroll(function()
					{
						if (settings.follow)
						{
							$this.stop(true).animate({"marginTop": $(window).scrollTop() + "px"}, settings.speed, settings.easing);
						}
					});
				}
				else
				{
					$this.css({"marginTop": "0px"});
					$(window).scroll(function()
					{
						$this.stop().animate({ marginTop: 0 });
					});
				}
			});
		}
	}, // abe_navFollow
	abe_twitter : function(options)
	{
		// Author: Eduards Torba
		// Version: 1.0.0
		var $this = $(this);
		var a = "";

		// Default Options
		this.defaultOptions = {
			username: 'fearsomepixels',
			posts: 3,
			avatar: false,
			loader: false,
			loaderClass: '',
			easing: 'swing',
			duration: 1000
		};

		// Refreshing Settings
		var settings = $.extend({}, this.defaultOptions, options);

		$.getJSON(); //function(data)
	} //abe_twitter
});