$(document).ready(function(){
	if($("#profil").attr('class') != "dontHideProfile") {
		if($("#profil h2#hook").attr('class') != "dontHideProfile")
		{
		$("#profil .box-profil h2#hook").after('<a href="#" class="ukryj">ukryj <img alt="ukryj" id="strzalkaUkryj" src="/css/images/next.png" /></a>');
		var c = readCookie('hideProfile');
		if (c) 
		{
		profileHide();
		$("#profil a.ukryj").toggle( function() {
			profileShow()
			return false
			}, function() {
			profileHide()
			return false
			});
		}
		else
		{
		$("#profil a.ukryj").toggle( function() {
			profileHide()
			return false
			}, function() {
			profileShow()
			return false
			});
		}
	}
}
$("form#szukaj input#query").val("szukane wyrażenie");
$("form#szukaj input#query").focus(function(){
		if($(this).val() == "szukane wyrażenie"){
		$(this).val("");
		}
		});
$("form#szukaj input#query").blur(function(){
		if($(this).val() == ""){
		$(this).val("szukane wyrażenie");
		}
		});
$(".message").animate({opacity:"0" }, 1, "linear", function(){
		$(this).fadeTo(1000, 1);
		});
$(".message").wrapInner("<span></span>");
$(".message span").append('<a href="#" id="closeMessage">[Ukryj]</a>');
$(".message #closeMessage").click( function() {
		$(".message").hide(1000);
		return false;
		});
});
function profileHide()
{
	$("#profil").width("20px");
	$("#czescGlowna").width("853px");
	$("#trescStrony").width("661px");
	$("#profil .box-profil a.ukryj").html('<img alt="pokaż" id="strzalkaPokaz" src="/css/images/prev.png" />');
	createCookie('hideProfile', 1, 365);
	return false;
}
function profileShow()
{
	$("#profil .box-profil a.ukryj").html('ukryj <img alt="ukryj" id="strzalkaUkryj" src="/css/images/next.png" />');
	$("#profil").width("233px");
	$("#czescGlowna").width("653px");
	$("#trescStrony").width("461px");
	eraseCookie('hideProfile');	
	return false;
}
// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions
