(function( $ ){

  var methods = {
    init : function( options ) { 
  
      return this.each(function() {   
  
        var $this = $(this);
        
        var dir = options.dir;
        
        $(this).prepend(
            $(document.createElement('div'))
            .addClass("gator-header")
            .css("z-index", 100)
            .append(
                $(document.createElement('img'))
                .attr({ src : 'images/gator-header-' + dir + '.png' })
            )
        );
        
        if ('right' == dir)
        {
            var animation = {
              right : options.distance
            }  
            $('.gator-header').css("right", '90%');
        } else {
            var animation = {
              left : options.distance
            }
            $('.gator-header').css("left", '80%');
        }
        
        $('.gator-header').animate(animation, {
                duration: 500,
                specialEasing: {
                    width: 'easeOutBounce'
                },
                complete: function() {
                    if (options.top)
                    {
                        $('#page-wrapper').prepend(
                            $(document.createElement('div'))
                            .addClass("gator-body")
                            .css("top", options.top)
                            .append(
                                $(document.createElement('img'))
                                .attr({ src : 'images/gator-body-left.png' })
                            )
                        );
                    }
                }
           }
        );
        
      });
    
    },
    other: function() {}
  };
  
  $.fn.gator = 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 on jQuery.tooltip' );
    }    
  
  };
})( jQuery );
