jQuery.noConflict();

jQuery(document).ready(function(){
	try {
		if (jQuery("input[name='tx_indexedsearch[sword]']").val().length == 0) {
			jQuery("input[name='tx_indexedsearch[sword]']").val('Szukaj');
		}
		jQuery("input[name='tx_indexedsearch[sword]']").focus(makeFocus);
		jQuery("input[name='tx_indexedsearch[sword]']").blur(makeBlur);
	}
	catch(e) {}
	jQuery('#menu > div').hover(showMenu, hideMenu);
	resizeMenu();
	resizeMenu2();
});

function makeFocus() {
	if (jQuery(this).val() == 'Szukaj')
		jQuery(this).val('');
}

function makeBlur() {
	if (jQuery(this).val().length == 0)
		jQuery(this).val('Szukaj');
}

function resizeMenu() {
	var totalWidth = jQuery('#menu .menu_item_a').width();
	var count;
	if (totalWidth > 0)
		count = 1;
	else
		count = 0;
	jQuery('#menu .menu_item').each(function() {
		totalWidth += jQuery(this).width();
		count++;
	});
	if (totalWidth >= 990)
		return;
	var space = Math.floor((1000 - totalWidth) / count); 
	jQuery('#menu .menu_item').css('margin', '0 ' + space + 'px 0 0');
	jQuery('#menu .menu_item:last').css('margin', 0);
	jQuery('#menu .menu_item_a').css('margin', '0 ' + space + 'px 0 0');
	
}

function resizeMenu2() {
	var totalWidth = 0;
	var count = -1;		// bo jest li clear
	jQuery('#menu2 ul li').each(function(){
		totalWidth += jQuery(this).width() + 20;
		count++;
	});
	if (totalWidth >= 960)
		return;
	var space = Math.floor((1000 - totalWidth) / (count));
	jQuery('#menu2 ul li').css('margin', '0 ' + space + 'px 0 0');
	jQuery("#menu2 ul li[class!='clear']:last").css('margin', 0);
}

function showMenu() {
	jQuery(this).find('.submenu_top').show();
	jQuery(this).find('.l').addClass('la');
	jQuery(this).find('.r').addClass('ra');
	jQuery(this).find('.menu').addClass('menu_a');
}

function hideMenu() {
	jQuery(this).find('.submenu_top').hide();
	jQuery(this).find('.l').removeClass('la');
	jQuery(this).find('.r').removeClass('ra');
	jQuery(this).find('.menu').removeClass('menu_a');
}


