/*
 * Ścieżka do plików obrazów
 * Jeśli zmieniona zostanie ścieżka do plików obrazów proszę eytować tylko tą zmienną.
 */
var image_path = "img/";

/*
 * Po załadowaniu obiektu DOM
 */
$(function() {
	main_menu_notlogged();
	main_menu_loggedin();
	login_label();
	search_label();
	newsletter_label();
	widget_menu();
});

/*
 * Po załadowaniu i wyświetleniu wszystkich elementów
 */
$(window).load(function() {
	
});

function main_menu_notlogged() {
	$('.main-menu-notlogged-link').hover(function() {
		var rel = $(this).children('img').attr('rel');
		$(this).children('img').attr('src', image_path + 'main-menu-notlogged/hover/' + rel + '.gif');
	}, function() {
		var rel = $(this).children('img').attr('rel');
		$(this).children('img').attr('src', image_path + 'main-menu-notlogged/item/' + rel + '.gif');
	});
}

function main_menu_loggedin() {
	$('.main-menu-loggedin-link').hover(function() {
		var rel = $(this).children('img').attr('rel');
		$(this).children('img').attr('src', image_path + 'main-menu-loggedin/hover/' + rel + '.gif');
	}, function() {
		var rel = $(this).children('img').attr('rel');
		$(this).children('img').attr('src', image_path + 'main-menu-loggedin/item/' + rel + '.gif');
	});
}

function login_label() {
	$('LABEL.login, LABEL.password').click(function() {
		$(this).hide();
	});
}

function search_label() {
	$('LABEL.search').click(function() {
		$(this).hide();
	});
}

function newsletter_label() {
	$('LABEL.newsletter').click(function() {
		$(this).hide();
	});
}

function widget_menu() {
	$('.item-developed .widget-menu-item-title, .item-collapsed .widget-menu-item-title').click(function() {
		var parent = $(this).parent('.widget-menu-item');
		if($(parent).hasClass('.item-developed')) {
			$(parent).removeClass('item-developed').addClass('item-collapsed');
		} else {
			$(parent).removeClass('item-collapsed').addClass('item-developed');
		}
	});
	$('.widget-menu-list-item SPAN').click(function() {
		var parent = $(this).parent('.widget-menu-list-item');
		if($(parent).hasClass('.list-developed')) {
			$(parent).removeClass('list-developed').addClass('list-collapsed');
		} else {
			$(parent).removeClass('list-collapsed').addClass('list-developed');
		}
	});
}