var menulink = new Array(false,false,false,false,false);
var menu = new Array(false,false,false,false,false);
var bmenulink = new Array(false,false,false,false,false);
var bmenu = new Array(false,false,false,false,false);
var bubble_backgrounds = new Array(0,254,252,344,297,262);
$(document).ready(function(){
	
	$('.delete').click(function(e){
		if(confirm('Na pewno usunąć?'))
		{}
		else
		{
			e.preventDefault();
		}
		
	});
	
	$('#menu .menu-items').hide();
	
	$('.menu-parent').click(function(e){
		e.preventDefault();
	});
	
	$('.menu-parent').hover(function(e){
		menulink[parseInt($(this).attr('id').substr(5))] = true;
		$(this).parent().find('div').slideDown(150);
		
	},function(e){
		menulink[parseInt($(this).attr('id').substr(5))] = false;
		$(this).parent().find('.menu-items').oneTime('0.1s',hideMenu,0);
		
	});
	
	$('#menu .menu-items').hover(function(e){
		menu[parseInt($(this).parent().find('a').attr('id').substr(5))] = true;
		$(this).slideDown(150);
		
	},function(e){
		menu[parseInt($(this).parent().find('a').attr('id').substr(5))] = false;
		$(this).oneTime('0.1s',hideMenu,0);
	});
	
	
	$('#bubble-container .menu-items').hide();
	
	$('.bubble-area').click(function(e){
		var number = $(this).attr('id').substr(12);
		$('#bubble-menu-'+number).fadeIn(150);
		e.preventDefault();
	});
	
	$('.bubble-area').hover(function(e){
		var number = $(this).attr('id').substr(12);
		$('#bmaster'+number).css('z-index','2');
		$('#bmaster'+number).css('background-position','0px 0px');
		bmenulink[parseInt(number)] = true;
	},function(e){
		var number = $(this).attr('id').substr(12);
		$('#bmaster'+number).oneTime('0.1s',function(){ if (!bmenu[parseInt(number)]) {
			$(this).css('z-index','1');
			$(this).css('background-position','0px '+bubble_backgrounds[parseInt(number)]+'px');
			$('#bubble-menu-'+number).oneTime('0.1s',hidebMenu,0);
		}},0);
		bmenulink[parseInt(number)] = false;
		
		
	});
	
	$('#bubble-container .menu-items').hover(function(e){
		var number = $(this).attr('id').substr(12);
		bmenu[parseInt(number)] = true;
		$(this).slideDown(150);
		
	},function(e){var number = $(this).attr('id').substr(12);
		bmenu[parseInt(number)] = false;
		$(this).oneTime('0.1s',hidebMenu,0);
		$('#bmaster'+number).oneTime('0.1s',function(){ if (!bmenu[parseInt(number)]) {
			$(this).css('z-index','1');
			$(this).css('background-position','0px '+bubble_backgrounds[parseInt(number)]+'px');
		}},0);
	});
	

	$('.content-menu-items').hide();
	
	$('.cmenu').click(function(e){
		var show = true;
		var number = $(this).attr('id').substr(13);
		if ($('#cmi'+number).is(':visible')) show = false;
		$('.content-menu-items').slideUp(100);
		if (show) $('#cmi'+number).oneTime('0.15s',function(){$(this).slideDown(200);},0);
		e.preventDefault();
	});
	
	$('.xbubble').click(function(e){
		location.href = $(this).attr('href');
		e.preventDefault();
	});
	
});

function hidebMenu()
{
	if (!bmenulink[parseInt($(this).parent().find('a').attr('id').substr(5))] && !bmenu[parseInt($(this).parent().find('a').attr('id').substr(5))]) $(this).fadeOut(150);
	
}

function hideMenu()
{
	if (!menulink[parseInt($(this).parent().find('a').attr('id').substr(5))] && !menu[parseInt($(this).parent().find('a').attr('id').substr(5))]) $(this).slideUp(150);
	
}

