
/******************** Ukrywany element *********************/
// rok w ms -> 365 dni x 24 h x 60 min x 60 s x 1000 ms
// tydzien w ms -> 7 dni x 24 h x 60 min x 60 s x 1000 ms

var COOKIE_EXPIRATION = new Date(7*24*60*60*1000 + new Date().getTime());

function hideOrShow(oEvent) {
		var oEventSrc = getEventSrc(oEvent);
		var oStyle = oEventSrc.oElemToHide.style;
		if(oStyle.display == "none" || oEventSrc.bOnlyShow) {
			oStyle.display = "block";
			oEventSrc.className = oEventSrc.sClassHide;
			if(oEventSrc.bUseCookie)
				setCookie("HIDE_" + oEventSrc.oElemToHide.id, 0, COOKIE_EXPIRATION);
			if(oEventSrc.funFunction)
				oEventSrc.funFunction(false);
		}
		else {
			oStyle.display = "none";
			oEventSrc.className = oEventSrc.sClassShow;
			if(oEventSrc.bUseCookie)
				setCookie("HIDE_" + oEventSrc.oElemToHide.id, 1, COOKIE_EXPIRATION);
			if(oEventSrc.funFunction)
				oEventSrc.funFunction(true);
		}
		if(oEventSrc.bPreventDefault)
			preventDefaultEvent(oEvent);
}

function showElement(oElement, oElemToChange, bOnlyCookie) {
	if(!bOnlyCookie) {
		oElement.style.display = "block";
		if(oElemToChange)
			oElemToChange.className = oElemToChange.sClassHide;
	}
	setCookie("HIDE_" + oElement.id, 0, COOKIE_EXPIRATION);
}

function hideElement(oElement, oElemToChange) {
	oElement.style.display = "none";
	if(oElemToChange)
		oElemToChange.className = oElemToChange.sClassShow;
	setCookie("HIDE_" + oElement.id, 1, COOKIE_EXPIRATION);
}

// Uzycie: activateElementHidding("boxJakisDoUkrycia", "przycisk", "klasaPrzyciskZwin", "klasaPrzyciskRozwin", false, false, false, false, modifyTextLink) 
// sElemToHideId - blok do ukrycia
// sButtonId - id przycisku / linku
// sClassHide - przycisku / linku ukrywajacego
// sClassShow - przycisku / linku pokazujacego
// bUseCookie - uzyc cookie lub nie
// bHidden - jezeli nie uzyto cookie - czy ukryc
// bPreventDefault - czy zablokowac standardowa akcje
// bOnlyShow - czy zwijac z powrotem
// funFunction - funcja wywolywana przy pokazywaniu lub ukrywaniu, do ktorej przekazywane
//			jest true jezeli blok jest ukrywany lub false jezeli jest pokazywany

function activateElementHidding(sElemToHideId, sButtonId, sClassHide, sClassShow, bUseCookie, bHidden, bPreventDefault, bOnlyShow, funFunction) {
	var oButton = document.getElementById(sButtonId);
	oButton.oElemToHide = document.getElementById(sElemToHideId);
	oButton.sClassHide = sClassHide;
	oButton.sClassShow = sClassShow;
	oButton.bUseCookie = bUseCookie;
	oButton.bPreventDefault = bPreventDefault;
	oButton.bOnlyShow = bOnlyShow;
	oButton.funFunction = funFunction;

	if(bUseCookie && (getCookie("HIDE_" + oButton.oElemToHide.id) == 1) || !bUseCookie && bHidden) 	{
		oButton.oElemToHide.style.display = "none";
		oButton.className = sClassShow;
		if(funFunction)
			funFunction(true);
	}	
	else {
		oButton.oElemToHide.style.display = "block";
		oButton.className = sClassHide;
		if(funFunction)
			funFunction(false);
	}

	addEventHandler(oButton, "click", hideOrShow);
}
/******************** Ukrywany element KONIEC *********************/

