$(document).ready(function(){
	
	// TopMenu Hover
	$("div.TopMenu").mouseover(function(){
		if ($(this).find("div.TopMenuEx").length)
		{
			$(this).removeClass("TopMenu").addClass("TopMenuActiveEx").before('<div class="TopMenuActiveLeftEx">&nbsp;</div>').after('<div class="TopMenuActiveRightEx">&nbsp;</div>');
			$(this).find("div.TopMenuEx").css('visibility', 'visible');
		}
		else
		{	
			$(this).removeClass("TopMenu").addClass("TopMenuActive").before('<div class="TopMenuActiveLeft">&nbsp;</div>').after('<div class="TopMenuActiveRight">&nbsp;</div>');
		}
	}).mouseout(function(){
		$(this).find("div.TopMenuEx:first").css('visibility', 'hidden');
		$(this).removeClass("TopMenuActiveEx TopMenuActive").addClass("TopMenu");		
		$(this).prev("div.TopMenuActiveLeftEx:first").remove();
		$(this).next("div.TopMenuActiveRightEx:first").remove();
		$(this).next("div.TopMenuActiveRight:first").remove();
		$(this).prev("div.TopMenuActiveLeft:first").remove();
	});
	$("div.TopMenuActive").mouseover(function(){
		if ($(this).find("div.TopMenuEx").length)
		{
			$(this).removeClass("TopMenuActive").addClass("TopMenuActiveEx");
			$(this).prev("div.TopMenuActiveLeft:first").removeClass("TopMenuActiveLeft").addClass("TopMenuActiveLeftEx");
			$(this).next("div.TopMenuActiveRight:first").removeClass("TopMenuActiveRight").addClass("TopMenuActiveRightEx");
			$(this).find("div.TopMenuEx").css('visibility', 'visible');
		}
	}).mouseout(function(){
		if ($(this).find("div.TopMenuEx").length)
		{
			$(this).removeClass("TopMenuActiveEx").addClass("TopMenuActive");
			$(this).prev("div.TopMenuActiveLeftEx:first").removeClass("TopMenuActiveLeftEx").addClass("TopMenuActiveLeft");
			$(this).next("div.TopMenuActiveRightEx:first").removeClass("TopMenuActiveRightEx").addClass("TopMenuActiveRight");
			$(this).find("div.TopMenuEx").css('visibility', 'hidden');
		}
	});
	
	
	// Login
	$("#link_Login").attr("href", "#").click(function(){
		$("#Main").append('<div id="LoginForm"><div id="LoginFormClose"><img src="gfx/ico/cross-small.png" alt="" /></div><form method="post" action="/logowanie"><input type="hidden" name="akcja" value="Zaloguj" /><h2>Logowanie</h2><strong>Nazwa użytkownika</strong><div><input type="text" name="NazwaUzytkownika" maxlength="45" /></div><strong>Hasło</strong><div><input type="password" name="Haslo" maxlength="45" /> <a href="/logowanie">przypomnienie hasła</a></div><div><input type="checkbox" name="Zapamietaj" value="1" /> zapamiętaj mnie</div><div><input type="submit" name="Zaloguj" value="" /></div>Nie masz jeszcze konta? <a href="/rejestracja">Załóż je!</a></form></div>');	
		$("#LoginForm").css('visibility', 'visible');
		$("input[name='NazwaUzytkownika']").focus();
		$("#LoginFormClose").click(function() { $("#LoginForm").remove(); });		
	});
	
	
	
	/* otwieranie linków w nowym oknie */
	$('a.blank').click(function(){
        window.open(this.href);
        return false;
    });
	
	
		
});
