(function( $ ){

  $.fn.jFloater = function( options ) {  
	
	var topPos;
	var leftPos;
	var rightPos;
	var bottomPos;
    var settings = {
	  'position': 'fixed',
      'width'	: null,
	  'height'	: null,
	  'top'		: null,
      'left'	: null,
	  'right'	: null,
	  'bottom'	: null
    };

    return this.each(function() {        
		// If options exist, lets merge them
		// with our default settings
		if ( options ) { 
		$.extend( settings, options );
		}
		
		$(this).css("position", settings.position);
		
		if(settings.width != null)
			$(this).css("width", settings.width);
		
		if(settings.height != null)
			$(this).css("height", settings.height);
		
		if(settings.top == true)
		{
			topPos = 0;
			bottomPos = null;
		}
		else if(settings.top == null && settings.bottom == null)
		{
			topPos = 0;
			bottomPos = null;
		}
		else if(settings.top != null && settings.bottom != null)
		{
			topPos = settings.top;	
			bottomPos = null;
		}
		else if(settings.bottom == true)
		{
			bottomPos = 0;
			topPos = null;
		}
		else
		{
			topPos = settings.top;
			bottomPos = settings.bottom;
		}
		
		
		if(settings.left == true)
		{
			leftPos = 0;
			rightPos = null;
		}
		else if(settings.left == null && settings.right == null)
		{
			leftPos = 0;
			rightPos = null;
		}
		else if(settings.left != null && settings.right != null)
		{
			leftPos = settings.left;	
			rightPos = null;
		}
		else if(settings.right == true)
		{
			rightPos = 0;
			leftPos = null;
		}
		else
		{
			leftPos = settings.left;
			rightPos = settings.right;
		}
		
		if(topPos != null)
		{
			$(this).css("top", topPos);
		}
		
		if(bottomPos != null)
		{
			$(this).css("bottom", bottomPos);
		}
		
		if(leftPos != null)
		{
			$(this).css("left", leftPos);
		}
		
		if(rightPos != null)
		{
			$(this).css("right", rightPos);
		}
    });

  };
})( jQuery );
