// JavaScript Document

	var loginFrmVisible = false;
	var logoutFrmVisible = false;
	var statusFrmVisible = false;

	function flBoxShow(el) {
		if (typeof(Effect)=='undefined') {
			el.style.display="block";
		} else {
			Effect.BlindUp(el, {scaleX:true, scaleY:true, duration:0.2});
		}
		return true;
	}
	function flBoxHide(el) {
		if (typeof(Effect)=='undefined') {
			el.style.display="none";
		} else {
			Effect.BlindDown(el, {scaleX:true, scaleY:true, duration:0.2});
		}
		return true;
	}

	// ### LOGIN ### //
	function flLoginDiv() {
		var el = getEl("loginDiv");
		if (el) {
			if (loginFrmVisible) {
				if (flBoxShow(el)) loginFrmVisible = false;
				
			} else {
				if (flBoxHide(el)) loginFrmVisible = true;
			}
		} else {
			var html = "";
			html += '<form action="/Uzytkownicy/logga_in.php" method="post">';
			html += '<div>';
			html += 'Email:<br />';
			html += '<input type="text" name="email" style="width:238px; margin-top:2px; margin-bottom:5px;" /><br />';
			html += 'Hasło:<br />';
			html += '<input type="password" name="password" style="width:238px; margin-top:2px; margin-bottom:5px;" />';
			html += '</div>';
			html += '<div style="margin-top:5px; margin-bottom:10px;">';
			html += '<input name="store_validation" type="checkbox" id="store_validation" value="1" style="margin:0px; margin-right:5px;" />';
			html += '<label for="store_validation">Zaznacz by logować się automatycznie</label>';
			html += '</div>';
			html += '<input name="screen" type="hidden" id="screen" value="' + screen.width + 'x' + screen.height + '">';
			html += '<input name="depth" type="hidden" id="depth" value="' + screen.colorDepth + '">';
			html += '<input name="referer" type="hidden" id="referer" value="' + flSessionParams.uri + '">';
			
			html += '<input name="login" type="submit" id="login" value="Zaloguj" />';
			html += '<input type="button" value="Anuluj" style="margin-left:5px; margin-right:5px;" onclick="flLoginDiv();" />';
			html += '<a href="/Uzytkownicy/logga_in.php">Więcej...</a>';
			html += '</form>';
			
			
			var loginLnkEl = getEl('homelinks_logout');
			var loginLnkWdth = loginLnkEl.offsetWidth;
			var maincontentLeft = findPosX(loginLnkEl)+loginLnkWdth-270; 
			var maincontentTop = findPosY(loginLnkEl)+loginLnkEl.offsetHeight+4;
			var msgLeft = maincontentLeft;
			var msgTop = maincontentTop;
			
			var outerdiv = document.createElement('div');
			outerdiv.id = 'loginDiv';
			Element.setStyle(outerdiv, { position:'absolute',
										 zIndex:'100',	
										 left:msgLeft + 'px',
										 top:msgTop + 'px',
										 backgroundColor:'#FFFFFF',
										 padding:'1px',
										 borderColor:'#CCCCFF',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'270px',
										 display:'none'} );
			
			var innerdiv = outerdiv.appendChild(document.createElement('div'));
			Element.setStyle(innerdiv, { padding:'10px',
										 borderColor:'#999999',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'248px',
										 textAlign:'left'} );
			innerdiv.align = 'left';
			innerdiv.innerHTML = html;
			document.body.appendChild(outerdiv);
			
			if (typeof(Effect)=='undefined') {
				outerdiv.style.display="block";
			} else {
				Effect.BlindDown(outerdiv, {scaleX:true, scaleY:true, duration:0.2});
			}
			loginFrmVisible = true;
		}
		return false;
	}
	
	
	
	
	// ### LOGOUT ### //
	function flLogoutDiv() {
		var el = getEl("logoutDiv");
		if (el) {
			if (logoutFrmVisible) {
				flBoxShow(el);
				logoutFrmVisible = false;
			} else {
				flBoxHide(el);
				logoutFrmVisible = true;
			}
		} else {
			var html = "";
			html += '<form action="/Uzytkownicy/logga_ut.php" method="post">';
			html += '<div style="margin-top:5px; margin-bottom:5px; text-align:center;">';
			if (readCookie('familjeliv_userid')) {
				html += '<div align="center">';
				html += '<input name="remove_validation" type="checkbox" id="remove_validation" value="1" style="margin:0px; margin-right:5px;" />';
				html += '<label for="remove_validation">Wyłącz automatyczne logowanie</label>';
				html += '</div">';
			}
			html += '<div align="center" style="margin-top:5px;">';
			html += '<input name="logout" type="submit" id="logout" value="Wyloguj się" style="margin-left:5px; width:155px;" />';
			html += '<input type="button" value="Anuluj" style="margin-left:5px; margin-right:5px;" onclick="flLogoutDiv();" />';
			html += '</div">';
			html += '</div>';
			html += '</form>';
			
			
			var loginLnkEl = getEl('homelinks_logout');
			var loginLnkWdth = loginLnkEl.offsetWidth;
			var maincontentLeft = findPosX(loginLnkEl)+loginLnkWdth-270; 
			var maincontentTop = findPosY(loginLnkEl)+loginLnkEl.offsetHeight+4;
			var msgLeft = maincontentLeft;
			var msgTop = maincontentTop;
			
			var outerdiv = document.createElement('div');
			outerdiv.id = 'logoutDiv';
			Element.setStyle(outerdiv, { position:'absolute',
										 left:msgLeft + 'px',
										 top:msgTop + 'px',
										 backgroundColor:'#FFFFFF',
										 padding:'1px',
										 borderColor:'#CCCCFF',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'270px',
										 display:'none'} );
			
			var innerdiv = outerdiv.appendChild(document.createElement('div'));
			Element.setStyle(innerdiv, { padding:'10px',
										 borderColor:'#999999',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'248px',
										 textAlign:'center'} );
			innerdiv.align = 'left';
			innerdiv.innerHTML = html;
			document.body.appendChild(outerdiv);
			
			if (typeof(Effect)=='undefined') {
				outerdiv.style.display="block";
			} else {
				Effect.BlindDown(outerdiv, {scaleX:true, scaleY:true, duration:0.2});
			}
			logoutFrmVisible = true;
		}
		return false;
	}
	
	
	
	
	// ### STATUS ### //
	function flStatusDiv() {
		var el = getEl("statusDiv");
		if (el) {
			if (statusFrmVisible) {
				flBoxShow(el);
				statusFrmVisible = false;
			} else {
				flBoxHide(el);
				statusFrmVisible = true;
			}
		} else {
			var html = "";
			html += '<form name="updateuserstatus" id="updateuserstatus" action="/Uzytkownicy/update_status.php" method="post">';
			html += '<div style="text-align:left; margin:0px; margin-bottom:5px;">';
			html += '<input type="text" name="user_status" style="width:238px; margin:0px" ';
			
			html += 'value="' + flSessionParams.usrStatus + '" maxlength="160" />';
			
			
			html += '<input type="hidden" name="ref" value="' + flSessionParams.uri + '" />';
			html += '</div>';
			html += '<div style="text-align:left">';
			html += '<input type="submit" name="update" value="Zmień mój status" style="width:150px;" />';
			html += '<input type="button" value="Anuluj" style="margin-left:5px;" onClick="flStatusDiv()" />';
			html += '</div>';
			html += '</form>';
			
			var statusLnkEl = getEl('homelinks_logout'); 
			var loginLnkWdth = statusLnkEl.offsetWidth;
			var maincontentLeft = findPosX(statusLnkEl)+loginLnkWdth-270; 
			var maincontentTop = findPosY(statusLnkEl) + statusLnkEl.offsetHeight + 4;
			var msgLeft = maincontentLeft;
			var msgTop = maincontentTop;
			
			var outerdiv = document.createElement('div');
			outerdiv.id = 'statusDiv';
			Element.setStyle(outerdiv, { position:'absolute',
										 left:msgLeft + 'px',
										 top:msgTop + 'px',
										 backgroundColor:'#FFFFFF',
										 padding:'1px',
										 borderColor:'#CCCCFF',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'270px',
										 display:'none'} );

			var innerdiv = outerdiv.appendChild(document.createElement('div'));
			Element.setStyle(innerdiv, { padding:'10px',
										 borderColor:'#999999',
										 borderStyle:'solid',
										 borderWidth:'1px',
										 width:'248px',
										 textAlign:'left'} );

			innerdiv.align = 'left';
			innerdiv.innerHTML = html;
			document.body.appendChild(outerdiv);
			
			if (typeof(Effect)=='undefined') {
				outerdiv.style.display="block";
			} else {
				Effect.BlindDown(outerdiv, {scaleX:true, scaleY:true, duration:0.2});
			}
			statusFrmVisible = true;
		}
		return false;
	}