(function($) {
  $.fn.njBar = function(options) {
		var opts = $.extend({}, $.fn.njBar.defaults, options);
		var $obj = $(this);
		if ($obj.size()==0) {
			alert('njBar : Aucun "'+$obj.selector+'" trouve');
			return;
		}
		if ($obj.size()!=1) {
			alert('njBar : Plusieurs "'+$obj.selector+'" trouves');
			return;
		}
		$obj.css({
			display:'block',
			position:'fixed',
			'text-align':'right',
			padding:'10px 0 0',
			bottom:'0px',
			background:opts.fondBackground,
			width:'100%',
			height:'37px',
			'border-top':'#7f9958 1px solid'
		});
		$obj.children('.njTitre').css({
			color:opts.couleurTitre,
			height:'0',
			padding:'71px 0 0',
			margin:'0',
			width:opts.titreWidth,
			background:opts.titreBackground,
			position:'absolute',
			top:47-opts.titreHeight,
			cursor:"pointer"
		}).click(function() {
			window.location.href='http://www.netJuggler.net';
		});
		$obj.children('.njBox').css({
			display:'inline-block',
			padding:'0',
			margin:'0'
		})
		.children('.njTitre').css({
			display:'inline-block',
			background:opts.boutonBackground,
			border:'#393939 1px solid',
			height:'19px',
			'font-size':'12px',
			'line-height':'12px',
			'text-shadow':'none',
			'font-weight':'normal',
			padding:'2px 6px 0 '+opts.boutonMarge+'px',
			'border-radius':'3px',
			margin:'0 7px 0 0',
			color:'#9C9C9C'
		}).append('<span class="njFleche"></span>')
		.children('.njFleche')
		.css({
			display:'inline-block',
			width:13,
			height:7,
			margin:'0 0 0 8px',
			background:'url(http://medias.netjuggler.net/barImages/fleche.jpg)'
		});
		
		var $ul=$obj.children('.njBox').children('ul');
		
		$ul.each(function(i) {
			$ul.eq(i).css({
				position:'absolute',
				top:-$ul.eq(i).innerHeight()-20,
				width:$ul.eq(i).parent().children('.njTitre').innerWidth()-10,
				border:'#393939 1px solid',
				'border-radius':'3px',
				margin:'0',
				background:'#272727',
				padding:'5px'
			}).children('li').css({'list-style':'none'}).children('a').css({color:'#9C9C9C','text-decoration':'none'});
		}).hide();
		
		$('body').append('<div id="njVideBlock"></div>');
		$('#njVideBlock').css({height:opts.titreHeight});
		
		$obj.children('.njBox').hover(function() {
			$(this).children('ul').css({
				top:-$(this).children('ul').innerHeight()+4,
			}).stop(true,true).fadeIn(300);
		},function() {
			$(this).children('ul').stop(true,true).fadeOut();
		});
		
		$ul.children('li').children('a').hover(function() {
			$(this).css({color:'#FFF'});
		},function() {
			$(this).css({color:'#9C9C9C'});
		});		
	}
	$.fn.njBar.defaults={
		fondBackground:'url(http://medias.netjuggler.net/barImages/fond.jpg) #272727',
		titreBackground:'url(http://medias.netjuggler.net/barImages/titre.png)',
		titreWidth:190,
		titreHeight:71,
		boutonBackground:'url(http://medias.netjuggler.net/barImages/mini_tete.png) no-repeat #272727',
		boutonMarge:83
	};
})(jQuery);
