(function(){
	jQuery.fn.iTab = function(opt){
		opt = jQuery.extend({
			scrollToTop: false
		}, opt);
		
		var target = this.find('a');
		target.unbind( 'click' );
		target.click(function(){
			var href = jQuery(this).attr( 'href' );
			if ( href.indexOf( '#' ) == 0 ) {
				target.each(function(){
					var href = jQuery(this).attr( 'href' );
					if ( href.indexOf( '#' ) == 0 ) {
						jQuery(href).hide();
					}
				});
				jQuery(href).fadeIn();
			}
			return false;
		});
		
		target.each(function(){
			var href = jQuery(this).attr( 'href' );
			if ( href.indexOf( '#' ) == 0 ) {
				jQuery(href).hide();
			}
		});
		if( window.location.hash && target.filter('a[@href="' + window.location.hash + '"]' ).length ){
			jQuery( window.location.hash ).fadeIn();
			if ( opt.scrollToTop ) {
				jQuery(window).scrollTop(0);
			} else {
				var position = target.eq(0).position();
				jQuery(window).scrollTop(position.top);
			}
		} else {
			jQuery( target.eq(0).attr( 'href' ) ).show();
		}
		
	};
})(jQuery);


