(function() {

	var jQ = typeof jQuery == 'function';
	
	function init( p )						
	{
		this.append( $( '<div id=\"button-close\" class=\"button-close png\"><img src=\"images/button-close.png\" width=\"40\" height=\"40\"></div>' ) );
		
		this.find( '.button-close' ).pngFix();
		
		var closeButton = this.find( '.button-close' );
		
		
		return closeButton;
	}

	if (jQ)												
	{
	
		jQuery.fn.ikNav = function( options ) 
		{
			
			if( _buttons == null ) var _buttons = { };
			
  			var props = jQuery.extend(
			{
				name:				"nav",
				buttons:				[ 'closeButton' ],
     			global:		 		false
  			}, 
			options );
		
			
			_buttons[ props.buttons[ 0 ] ] = init.call( this, props )
			
			var methods = jQuery.extend( this, 
			{
				
				ikButton			:	function( button )						
				{
						return _buttons[ button ];
				},
				
				
				ikToggleNav	:	function( button )						
				{
					if( $( _buttons[ button ] ).css( 'visibility' ) == 'hidden' )
					{
						$( _buttons[ button ] ).css( 'visibility', 'visible' );
						$( _buttons[ button ] ).animate(
														   {
															   opacity:	0.9
														   },
														   {
															   duration:		400
														   });
					}
					else
					{
						$( _buttons[ button ] ).animate(
														   {
															   opacity:	0
														   },
														   {
															   duration:		400,
															   complete: function()
															   {
																   $( _buttons[ button ] ).css( 'visibility', 'hidden' );
															   }
														   });
					}
				}
			});
			
			return this;
		}
	}

})();

