/* WWW server*/

// Include
#include "stdint.h"

#include "www.h"
#include "www-konstanty.h"
#include "tcp.h"
#include "http.h"
#include "PIN_config.h"

#include "My_usart.h"
#include "My_adc.h"
#include "My_PWM.h"
#include "My_rtc.h"
#include "planovac.h"
#include "DS18B20.h"			// Knihovna pro praci s teplotnimi cidly DS18B20
#include "server.h"
#include "net.h"
#include "flash_save.h"
#include "stm32f10x_bkp.h"
// Globalni promenne

//#define DEBUG

extern uint8_t TCPEnableGenerateWWW;
extern uint8_t TCPGenerateStatus;
extern uint8_t Server_Freez;
extern uint8_t ServerEnable;

// Exportovane promenne PWM
extern uint16_t PWM_max[5];

// Exportovane promenne ADC (mereni proudu)
extern uint16_t ADC_HodnotyPrumer[6];

// Exportovane promenne planovace
extern uint8_t AutomatickyRezim;

// Exportovane promenne casu
extern uint8_t Time_Hodiny;
extern uint8_t Time_Minuty;
extern uint8_t Time_Vteriny;
extern uint8_t Time_Den;
extern uint8_t Time_Mesic;
extern uint16_t Time_Rok;
extern uint8_t Time_DenVTydnu;
extern const uint8_t JmenaDni3[7][9];

extern uint32_t RunTime;
extern uint32_t LED_Time[6];

// Exportovane promenne serveru
extern uint8_t my_MAC[MAC_ADR_SIZE];						// MAC adresa serveru
extern uint8_t my_IP[IP_ADR_SIZE];							// IP adresa serveru
extern uint8_t my_MASK[IP_ADR_SIZE];						// Maska podsite serveru
extern uint8_t my_GATE[IP_ADR_SIZE];						// Vychozi brana serveru
extern uint16_t my_HTTP_Port;								// Port HTTP serveru
extern uint16_t my_UDP_Port;								// Port UDP serveru
extern uint16_t my_Telnet_Port;								// Port Telnet serveru

// Exportovane promenne teplotnich cidel
extern volatile u8 PocetCidel;								// Pocet teplotnich cidel nalezenych pomoci funkce find sensors
extern int16_t Teplota[MAXSENSORS];								// Teplota ve formatu int -> 25,3 = 253
extern uint8_t gSensorIDs[MAXSENSORS][DS18X20_SP_SIZE];			// Tabulka ROM kodu jednotlivych cidel nactenych pres funkci find sensor
extern uint16_t FLASHSensorIDs[MAXSENSORS][DS18X20_SP_SIZE];	// Tabulka ROM kodu jednotlivych cidel nactenych z emulovane EEPROM pameti
																// FLASHSensorIDs[0][] ... Cidlo na chladici 1 - LED
																// FLASHSensorIDs[1][] ... Cidlo na chladici 2 - Tranzistory
																// FLASHSensorIDs[2][] ... Externi cidlo na kabelu
extern int16_t TeplotaHistorie[MAXSENSORS+1][2];
extern uint8_t PovoleniMeritTeplotu;

extern uint16_t FANtemp[4];
extern uint16_t FANval[4];
extern uint16_t SHUTDOWNtemp;

extern uint8_t	FANmode;

// Exportovane promenne cidla vlhkosti
extern uint8_t Humidity;
extern uint8_t HumidityHistorie[2];
/* --------------------------------------------
 Funkce slouzi k dekodovani requestu
 ------------------------------------------- */
void WWW_ProcessRequest(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint16_t ZacatekRequestu;
	uint8_t Delka;

	if(TCPGenerateStatus==GENERATE_PROGRESS)							// Funkce nesmi byt pri zavolani ve stavu "probihajici prenos"
	{
		TCPGenerateStatus=GENERATE_OFF;
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GEN > Generate=OFF (incorect start)",1);							
			USART1_FreeMUTEX();
		#endif
		return;
	}

	if(TCPGenerateStatus==GENERATE_START)							// Funkce nesmi byt pri zavolani ve stavu "probihajici prenos"
	{
		TCPGenerateStatus=GENERATE_PROGRESS;
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GEN > Generate=PROGRESS",1);							
			USART1_FreeMUTEX();
		#endif
		if(HTTP_GetRequestMetod(RX_Buffer)==HTTP_REQ_METOD_GET)				// Zadost o stranku pomoci metody GET
		{
			Delka=HTTP_GetRequestFromGET(RX_Buffer, &ZacatekRequestu);
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("WWW > Delka req.: ",0);
				USART1_SendNumber(Delka);
				USART1_Send_Enter();
				USART1_FreeMUTEX();
			#endif
			if(Delka==0)
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send(" WWW > Nulova delka -> konec",1);
					USART1_FreeMUTEX();
				#endif
				goto PROCESS_REQUEST_KONEC;
			}
			if((RX_Buffer[ZacatekRequestu+0]=='/') & ((RX_Buffer[ZacatekRequestu+1]==' ') | (RX_Buffer[ZacatekRequestu+1]=='\0')))					// Overeni jestli neni pozadovanym souborem korenovy adresar
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("WWW > Odesilan index",1);
					USART1_FreeMUTEX();
				#endif
				WWW_SendPage(WWW_ID_INDEX,TX_Buffer,RX_Buffer);					// Odeslani souboru Index
			}
			else																// Pozadavek jineho souboru
			{
				if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='1'))
				{
					WWW_SendPage(WWW_ID_INFO,TX_Buffer,RX_Buffer);				// Odeslani souboru Informace o systemu
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='2'))
				{
					WWW_SendPage(WWW_ID_PLANOVANI,TX_Buffer,RX_Buffer);			// Odeslani souboru Planovani
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='3'))
				{
					WWW_SendPage(WWW_ID_NASTAVENI_SYSTEMU,TX_Buffer,RX_Buffer);	// Odeslani souboru Nastaveni systemu
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='4'))
				{
					WWW_SendPage(WWW_ID_NASTAVENI_LED,TX_Buffer,RX_Buffer);		// Odeslani souboru Nastaveni LED
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='5'))
				{
					WWW_SendPage(WWW_ID_NASTAVENI_SITE,TX_Buffer,RX_Buffer);	// Odeslani souboru Nastaveni site
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='6'))
				{
					WWW_SendPage(WWW_ID_PLANOVANI_PRIDAT,TX_Buffer,RX_Buffer);			// Odeslani souboru Planovani - pridat zaznam
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='0') & (RX_Buffer[ZacatekRequestu+2]=='7'))
				{
					WWW_SendPage(WWW_ID_PLANOVANI_EDITOVAT,TX_Buffer,RX_Buffer);			// Odeslani souboru Planovani - editovat zaznam
				}
				else if((RX_Buffer[ZacatekRequestu+1]=='t') & (RX_Buffer[ZacatekRequestu+2]=='a'))
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("WWW > 418 I'm a teapot",1);
						USART1_FreeMUTEX();
					#endif
					WWW_SendErr(HTTP_STATUSCODE_418,TX_Buffer,RX_Buffer);	// Odeslani Err 404
				}
				else
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("WWW > 404 Nenalezeno",1);
						USART1_FreeMUTEX();
					#endif
					WWW_SendErr(HTTP_STATUSCODE_404,TX_Buffer,RX_Buffer);	// Odeslani Err 404
				}
			}
		}
		else if(HTTP_GetRequestMetod(RX_Buffer)==HTTP_REQ_METOD_POST)		// Odeslani parametru formulare
		{
			WWW_SendErr(HTTP_STATUSCODE_400,TX_Buffer,RX_Buffer);
		}
		else
		{
			WWW_SendErr(HTTP_STATUSCODE_400,TX_Buffer,RX_Buffer);
		}
PROCESS_REQUEST_KONEC:
		TCPGenerateStatus=GENERATE_OFF;											// Zastaveni procesu WWW serveru
		Server_Freez=0;															// Povoleni procesu serveru (obsluhy ENC)
		TCPEnableGenerateWWW = 0;												// Zakaze WWW serveru plnit TCP dalsimi daty
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GEN > Generate=OFF",1);
			USART1_Send("GEN > Server freez=OFF",1);
			USART1_Send("GEN > Generate WWW=OFF",1);
			USART1_FreeMUTEX();
		#endif
	}
	return;
}

/* ----------------------------------------------

 --------------------------------------------- */
void WWW_SendPage(uint8_t ID, uint8_t *TX_Buffer, uint8_t *RX_Buffer)
{
	uint8_t temp;
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("WWW > Generuji stranku",1);
		USART1_FreeMUTEX();
	#endif		
	
	if(ID==WWW_ID_INDEX)											// Presmerovani na uvodni stranku s souhrnnymi informacemi o systemu
	{
		ID=WWW_ID_INFO;
	}
	// Vlozeni obsahu
	switch(ID)
	{
		case WWW_ID_INFO:
		{
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Stav systému", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(0, RX_Buffer, TX_Buffer);
			WWW_Generate_StavSystemu(RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_PLANOVANI:
		{
			temp=WWW_GetParametr("2",RX_Buffer);
			Planovac_SmazatZaznam(temp);
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Plánování", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(1, RX_Buffer, TX_Buffer);
			WWW_Generate_Planovani(RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_PLANOVANI_PRIDAT:
		{			
			WWW_DecodeFormGET_Planovani(WWW_PLANOVANI_PRIDAT,RX_Buffer);

			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Plánování - přidat záznam", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(1, RX_Buffer, TX_Buffer);
			WWW_Generate_PlanovaniEditace(0xFF,RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_PLANOVANI_EDITOVAT:
		{	
			temp=WWW_GetParametr("1",RX_Buffer);
			WWW_DecodeFormGET_Planovani(WWW_PLANOVANI_EDITOVAT,RX_Buffer);			

			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Plánování - editovat záznam", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(1, RX_Buffer, TX_Buffer);
			WWW_Generate_PlanovaniEditace(temp,RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_NASTAVENI_SYSTEMU:
		{
			WWW_DecodeFormGET_NastaveniSystemu(RX_Buffer);
			
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Nastavení systému", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(2, RX_Buffer, TX_Buffer);
			WWW_Generate_NastaveniSystemu(RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_NASTAVENI_LED:
		{			
			WWW_DecodeFormGET_NastaveniLED(RX_Buffer);
			
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Nastavení LED", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(3, RX_Buffer, TX_Buffer);
			WWW_Generate_NastaveniLED(RX_Buffer,TX_Buffer);
			break;
		}
		case WWW_ID_NASTAVENI_SITE:
		{
			WWW_DecodeFormGET_NastaveniSite(RX_Buffer);
			
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Nastavení sítě", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(4, RX_Buffer, TX_Buffer);
			WWW_Generate_NastaveniSite(RX_Buffer,TX_Buffer);
			break;
		}
		default:
		{
			HTTP_SetHeader(HTTP_STATUSCODE_200,TX_Buffer,RX_Buffer);		// Nastaveni hlavicky HTTP	
			WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
			TCP_AddDataString("LED System - Chybný požadavek", RX_Buffer, TX_Buffer);		
			WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
			WWW_GenerateLayout1(0, RX_Buffer, TX_Buffer);
			TCP_AddDataString("<h1>Chybný požadavek !</h1>", RX_Buffer, TX_Buffer);
			break;
		}
	}	
	WWW_GenerateLayout2(RX_Buffer, TX_Buffer);
	WWW_InsertFromFLASH(WWW_HTML_Padding,RX_Buffer,TX_Buffer);
	TCP_AddDataChar(0, RX_Buffer, TX_Buffer, 1);						// Odeslani paketu
}
/* ----------------------------------------------
 Funkce odesle chybovy kod klientovy
 --------------------------------------------- */
void WWW_SendErr(uint16_t ID, uint8_t *TX_Buffer, uint8_t *RX_Buffer)
{
	HTTP_SetHeader(ID,TX_Buffer,RX_Buffer);
	// Vlozeni stranky zobrazujici chybu
	WWW_InsertFromFLASH(WWW_HTML_Header1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Error", RX_Buffer, TX_Buffer);
	WWW_InsertFromFLASH(WWW_HTML_Header2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_HTML_ERR[ID-1],RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_HTML_Padding,RX_Buffer,TX_Buffer);	
	TCP_AddDataChar(0, RX_Buffer, TX_Buffer, 1);						// Odeslani paketu
}

/* ----------------------------------------------
 Funkce vygeneruje prvni polovinu layoutu
 (tu s menu)
 --------------------------------------------- */
void WWW_GenerateLayout1(uint8_t VybranoID, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	WWW_InsertFromFLASH(WWW_Layout1,RX_Buffer,TX_Buffer);
	WWW_GenerateMenu(VybranoID,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Layout2,RX_Buffer,TX_Buffer);
	// Vlozi informace zobrazovane pod menu (datum a cas)
	
	// Vlozi zbytek layoutu
	WWW_InsertFromFLASH(WWW_Layout3,RX_Buffer,TX_Buffer);	
}

/* ----------------------------------------------
 Funkce vygeneruje druhou polovinu layoutu
 (zbytek po hlavnim obsahu)
 --------------------------------------------- */
void WWW_GenerateLayout2(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	WWW_InsertFromFLASH(WWW_Layout4,RX_Buffer,TX_Buffer);
}

/* ----------------------------------------------
 Funkce vygeneruje menu
 --------------------------------------------- */
void WWW_GenerateMenu(uint8_t VybranoID, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
 	uint16_t i;
	
	for(i=0;i<WWW_MENU_MAX_COUNT;i++)
	{
		// Vlozi zacatek bunky pro polozku v menu
		WWW_InsertFromFLASH(WWW_Layout_MenuPolozka_Start1,RX_Buffer,TX_Buffer);		
		if(VybranoID == i)
		{			
			WWW_InsertFromFLASH(WWW_Menu_Zelena,RX_Buffer,TX_Buffer);
		}
		else
		{
			WWW_InsertFromFLASH(WWW_Menu_Seda,RX_Buffer,TX_Buffer);
		}		
		WWW_InsertFromFLASH(WWW_Layout_MenuPolozka_Start2,RX_Buffer,TX_Buffer);
		// Vlozeni odkazu -> identifikacni znacky stranky
		TCP_AddDataChar(WWW_PageID[i][0], RX_Buffer, TX_Buffer, 0);
		TCP_AddDataChar(WWW_PageID[i][1], RX_Buffer, TX_Buffer, 0);
		// Vlozeni konce odkazu
		WWW_InsertFromFLASH(WWW_Layout_MenuPolozka_Start3,RX_Buffer,TX_Buffer);
		// Vlozeni nazvu menu
		WWW_InsertFromFLASH(WWW_MenuPolozky[i],RX_Buffer,TX_Buffer);
		// Vlozeni konce bunky
		WWW_InsertFromFLASH(WWW_Layout_MenuPolozka_Stop,RX_Buffer,TX_Buffer);
	}
}

/* -------------------------------------------------
 Funkce vygeneruje obsah ramce stranky Stav systemu
 ------------------------------------------------ */
void WWW_Generate_StavSystemu(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint8_t i,j;
	// Vlozeni uvodniho nadpisu a popisu obsahu stranky
	WWW_InsertFromFLASH(WWW_Obsah_StavSystemu_Zacatek,RX_Buffer,TX_Buffer);

/*** Zacatek tabulky O systému ***/
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("O Systému",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Obsah tabulky
	for(i=0;i<WWW_OSYSTEMU_POLOZEK;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuPolozky[i],RX_Buffer,TX_Buffer);				// Vlozi nazev polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
		WWW_InsertSystemDataFromFLASH(WWW_StavSystemuSystemObsahPolozky[i],RX_Buffer,TX_Buffer);	// Vlozi obsah polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	}
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);
	

/*** Zactek tabulky LED diody ***/
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("LED diody",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStart2,RX_Buffer,TX_Buffer);
	
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStart,RX_Buffer,TX_Buffer);			// Vlozeni odkazu pro editaci
	TCP_AddDataString("04",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStop,RX_Buffer,TX_Buffer);

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStop,RX_Buffer,TX_Buffer);

	for(i=0;i<WWW_LED_POLOZEK;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuLEDPolozky[i],RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);
		
		for(j=0;j<WWW_LED_SLOUPCE_POLOZEK;j++)
		{
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
			WWW_InsertSystemDataFromFLASH(WWW_StavSystemuLEDObsahPolozky[(i*6)+j],RX_Buffer,TX_Buffer);
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		}
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);
	}
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop4,RX_Buffer,TX_Buffer);
	

/*** Zacatek tabulky Cidla teploty ***/
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Čidla teploty a relativní vzdušné vlhkosti",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Obsah tabulky
	for(i=0;i<WWW_CIDLA_POLOZEK;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuCidlaPolozky[i],RX_Buffer,TX_Buffer);			// Vlozi nazev polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
		WWW_InsertSystemDataFromFLASH(WWW_StavSystemuCidlaObsahPolozky[i],RX_Buffer,TX_Buffer);		// Vlozi obsah polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	}
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);

/*** Zacatek tabulky nastaveni ventilatoru a hranicnich teplot ***/
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení ventilátoru a hraničních teplot",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStart,RX_Buffer,TX_Buffer);				// Vlozeni odkazu pro editaci
	TCP_AddDataString("03",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStop,RX_Buffer,TX_Buffer);
				
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Obsah tabulky
	for(i=0;i<WWW_CHLAZENI_POLOZEK;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuChlazeniPolozky[i],RX_Buffer,TX_Buffer);			// Vlozi nazev polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
		WWW_InsertSystemDataFromFLASH(WWW_StavSystemuChlazeniObsahPolozky[i],RX_Buffer,TX_Buffer);	// Vlozi obsah polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	}
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);	

/*** Zacatek tabulky nastaveni site ***/
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení sítě",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStart,RX_Buffer,TX_Buffer);				// Vlozeni odkazu pro editaci
	TCP_AddDataString("05",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_tabulka1_EditovatStop,RX_Buffer,TX_Buffer);
				
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Obsah tabulky
	for(i=0;i<WWW_SIT_POLOZEK;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuSitPolozky[i],RX_Buffer,TX_Buffer);			// Vlozi nazev polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
		WWW_InsertSystemDataFromFLASH(WWW_StavSystemuSitObsahPolozky[i],RX_Buffer,TX_Buffer);		// Vlozi obsah polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	}	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce slouzi k vygenerovani obsahu stranky
 s editaci sitoveho nastaveni
 ------------------------------------------------ */
void WWW_Generate_NastaveniSite(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint8_t temp, i;	
	
	WWW_InsertFromFLASH(WWW_Obsah_NastaveniSiteNadpis,RX_Buffer,TX_Buffer);

	// Vygenerovani hlavicky formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Start,RX_Buffer,TX_Buffer);
	TCP_AddDataString("05",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Stop,RX_Buffer,TX_Buffer);	
	
	// Vlozeni hlavicky tabulky a jejiho nadpisu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení sítě",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Vkladani polozek tabulky	
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[0],1,15,"$n01",15,"(formát: 192.168.0.1)",RX_Buffer,TX_Buffer);	// Zmena IP adresy
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[1],2,15,"$n02",15,"(formát: 255.255.255.0)",RX_Buffer,TX_Buffer);	// Zmena masky podsite
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[2],3,15,"$n03",15,"(formát: 192.168.0.1)",RX_Buffer,TX_Buffer);	// Zmena IP adresy vychozi brany
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[3],4,12,"$n11",12,"(HEX formát 0123456789AB)",RX_Buffer,TX_Buffer);	// Zmena MAC adresy
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[4],5,5,"$n05",5,"(1-65535, výchozí port 80)",RX_Buffer,TX_Buffer);	// Zmena portu www
	WWW_InsertTableInputText(WWW_StavSystemuSitPolozky[5],6,5,"$n06",5,"(1-65535, výchozí port 1234)",RX_Buffer,TX_Buffer);	// Zmena portu UDP
	
	// Enable/Disable
	for(i=0;i<4;i++)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuPolozky[2+i],RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
		/* Zjisteni jestli je server zakazany nebo ne */
		temp=0;
		if(ServerEnable&(1<<i))
		{
			temp=1;
		}
		WWW_InsertRadioButtonText(1,7+i,"Povolit", temp,RX_Buffer,TX_Buffer);
		if(temp==1)
		{
			temp=0;
		}
		else
		{
			temp=1;
		}
		WWW_InsertRadioButtonText(2,7+i,"Zakázat", temp,RX_Buffer,TX_Buffer);	
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	}
	
	// Konec tabulky	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);
	
	// Vygenerovani konce formulare s tlacitky
	WWW_InsertFromFLASH(WWW_Obsah_Form_Tlacitka,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce slouzi k vygenerovani obsahu stranky
 s editaci sitoveho nastaveni
 ------------------------------------------------ */
void WWW_Generate_NastaveniLED(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint8_t temp, i;	
	// Vygenerovani nadpisu stranky
	WWW_InsertFromFLASH(WWW_Obsah_NastaveniLEDNadpis,RX_Buffer,TX_Buffer);

	// Vygenerovani hlavicky formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Start,RX_Buffer,TX_Buffer);
	TCP_AddDataString("04",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Stop,RX_Buffer,TX_Buffer);
	
	// Vygenerovani hlavicky tabulky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení LED diod",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStart2,RX_Buffer,TX_Buffer);

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStop,RX_Buffer,TX_Buffer);
	
	// Vkladani polozek tabulky	
		// Zacatek radku s nazvem parametru	- radek "Typ LED"
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuLEDPolozky[0],RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);		
		// Hodnota parametu v jednom sloupci - "Typy LED"
		for(i=0;i<6;i++)
		{
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
			WWW_InsertSystemDataFromFLASH(WWW_StavSystemuLEDObsahPolozky[i],RX_Buffer,TX_Buffer);
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		}
		// Konec radku parametru
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);
	
		// Zacatek radku s nazvem parametru	- radek "Aktuální proud"
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuLEDPolozky[1],RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);
		// Hodnota parametu v jednom sloupci - "Aktualni proud"
		for(i=0;i<6;i++)
		{
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
			WWW_InsertSystemDataFromFLASH(WWW_StavSystemuLEDObsahPolozky[6+i],RX_Buffer,TX_Buffer);
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		}
		// Konec radku parametru
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);

		// Zacatek radku s nazvem parametru	- radek "Nastavený výkon"
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuLEDPolozky[3],RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);
		// Hodnota parametu v jednom sloupci - "nastaveny vykon"
		WWW_InsertTable2InputText(1,3,"$p31",3," %",RX_Buffer,TX_Buffer);	// Zmena vykonu kanal 1
		WWW_InsertTable2InputText(2,3,"$p32",3," %",RX_Buffer,TX_Buffer);	// Zmena vykonu kanal 2
		WWW_InsertTable2InputText(3,3,"$p33",3," %",RX_Buffer,TX_Buffer);	// Zmena vykonu kanal 3
		WWW_InsertTable2InputText(4,3,"$p34",3," %",RX_Buffer,TX_Buffer);	// Zmena vykonu kanal 4
		WWW_InsertTable2InputText(5,3,"$p35",3," %",RX_Buffer,TX_Buffer);	// Zmena vykonu kanal 5
		temp=0;
		if(PWM_Get_LED6())
		{
			temp=1;
		}
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
		WWW_InsertCheckBoxText(6,1," Zapnout",temp,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		// Konec radku parametru
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);

		// Zacatek radku s nazvem parametru	- radek "Maximální PWM"
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_StavSystemuLEDPolozky[4],RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);
		// Hodnota parametu v jednom sloupci - "maximalni PWM"
		WWW_InsertTable2InputText(7,5,"$p13",5," / 48000",RX_Buffer,TX_Buffer);	// Zmena maxima PWM kanal 1
		WWW_InsertTable2InputText(8,5,"$p14",5," / 48000",RX_Buffer,TX_Buffer);	// Zmena maxima PWM kanal 2
		WWW_InsertTable2InputText(9,5,"$p15",5," / 48000",RX_Buffer,TX_Buffer);	// Zmena maxima PWM kanal 3
		WWW_InsertTable2InputText(10,5,"$p16",5," / 48000",RX_Buffer,TX_Buffer);// Zmena maxima PWM kanal 4
		WWW_InsertTable2InputText(11,5,"$p17",5," / 48000",RX_Buffer,TX_Buffer);// Zmena maxima PWM kanal 5
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
		TCP_AddDataString("-",RX_Buffer,TX_Buffer);								// U kanalu 6 nelze nastavovat PWM
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		// Konec radku parametru
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);

		// Zacatek radku s nazvem parametru	- radek "Automaticky rezim"
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart1,RX_Buffer,TX_Buffer);
		TCP_AddDataString("Automatický režim",RX_Buffer,TX_Buffer);	
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop1,RX_Buffer,TX_Buffer);
		// Hodnota parametu v jednom sloupci - "automaticky rezim"
		for(i=0;i<6;i++)
		{
			temp=0;
			if(AutomatickyRezim & (1<<i))
			{
				temp=1;
			}			
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);
			WWW_InsertCheckBoxText(12+i,1,"",temp,RX_Buffer,TX_Buffer);
			WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
		}
		// Konec radku parametru
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop3,RX_Buffer,TX_Buffer);

	// Konec tabulky	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop4,RX_Buffer,TX_Buffer);
	
	// Vygenerovani konce formulare s tlacitky
	WWW_InsertFromFLASH(WWW_Obsah_Form_Tlacitka,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce slouzi k vygenerovani obsahu stranky
 s editaci systemoveho nastaveni
 ------------------------------------------------ */
void WWW_Generate_NastaveniSystemu(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{	
	WWW_InsertFromFLASH(WWW_Obsah_NastaveniSystemuNadpis,RX_Buffer,TX_Buffer);

	// Vygenerovani hlavicky formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Start,RX_Buffer,TX_Buffer);
	TCP_AddDataString("03",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Stop,RX_Buffer,TX_Buffer);	
	
	// Vlozeni hlavicky tabulky a jejiho nadpisu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení systému",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);	
	// Vkladani polozek tabulky	
	// Nazev
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Systémový čas",RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
	WWW_InsertCheckBoxText(1,1,"Změnit ",0,RX_Buffer,TX_Buffer);
	WWW_InsertInputText(3,8,"$c01",8,"(formát: 15:01:34)",RX_Buffer,TX_Buffer);				// Zmena casu	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Systémové datum",RX_Buffer,TX_Buffer);								// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
	WWW_InsertCheckBoxText(2,1,"Změnit ",0,RX_Buffer,TX_Buffer);
	WWW_InsertInputText(4,10,"$c02",10,"(formát: 1.4.2012)",RX_Buffer,TX_Buffer);			// Zmena datumu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	// Konec tabulky	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);
	
	// Vlozeni hlavicky tabulky a jejiho nadpisu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Nastavení ventilátoru a hraničních teplot",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);	
	// Vkladani polozek tabulky	
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[0],5,5,"$t17",5," °C (formát: 30,6) nejnižší teplota",RX_Buffer,TX_Buffer);			// Zmena hranicni teploty
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[1],6,3,"$t18",3," % (formát: 0 - 100) nejnižší výkon",RX_Buffer,TX_Buffer);			// Zmena nastaveni vykonu ventilatoru
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[2],7,5,"$t19",5," °C (formát: 30,6) větší než předchozí",RX_Buffer,TX_Buffer);		// Zmena hranicni teploty
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[3],8,3,"$t20",3," % (formát: 0 - 100) větší než předchozí",RX_Buffer,TX_Buffer);	// Zmena nastaveni vykonu ventilatoru
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[4],9,5,"$t21",5," °C (formát: 30,6) větší než předchozí",RX_Buffer,TX_Buffer);		// Zmena hranicni teploty
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[5],10,3,"$t22",3," % (formát: 0 - 100) větší než předchozí",RX_Buffer,TX_Buffer);	// Zmena nastaveni vykonu ventilatoru
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[6],11,5,"$t23",5," °C (formát: 30,6) větší než předchozí",RX_Buffer,TX_Buffer);		// Zmena hranicni teploty
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[7],12,3,"$t24",3," % (formát: 0 - 100) nejvyšší výkon",RX_Buffer,TX_Buffer);		// Zmena nastaveni vykonu ventilatoru
	WWW_InsertTableInputText(WWW_StavSystemuChlazeniPolozky[8],13,5,"$t25",5," °C (formát: 30,6) nejvyšší teplota",RX_Buffer,TX_Buffer);		// Zmena hranicni teploty	
	// Konec tabulky	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);

	// Vygenerovani konce formulare s tlacitky
	WWW_InsertFromFLASH(WWW_Obsah_Form_Tlacitka,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce slouzi k vygenerovani obsahu stranky
 s editaci systemoveho nastaveni
 ------------------------------------------------ */
void WWW_Generate_Planovani(uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{	
	uint8_t i;	
	uint8_t Zacatek[5];
	uint8_t Konec[5];
	uint8_t Opakovani;
	uint8_t NastaveniLED[6];
	uint8_t ZaznamuCelkem, ZaznamuAktivnich;

	WWW_InsertFromFLASH(WWW_Obsah_PlanovaniNadpis,RX_Buffer,TX_Buffer);
	// Vlozeni hlavicky tabulky a jejiho nadpisu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Vytvořené časové plány",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);	
	
	// Vkladani polozek tabulky - nadpisy sloupcu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Operace se záznamem",RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart2,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<b>Opakování</b>",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<b>Datum a čas začátku</b>",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<b>Datum a čas konce</b>",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<p align=\"left\"><b>Nastavení LED</b></p>",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStop1,RX_Buffer,TX_Buffer);
	// Vlozeni polozek planovace
	for(i=0;i<PLANOVAC_MAXZAZNAMU;i++)
	{
		if(Planovac_ExistujiciZaznam(i)==0)										// Overeni jestli je zaznam platny
		{
			continue;
		}
		if(Planovac_GetZaznam(i,Zacatek,Konec,&Opakovani,NastaveniLED)==0)		// Nacteni dat z FLASH a overeni 
		{																		// jestli byla nactena spravne
			continue;
		}
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart1,RX_Buffer,TX_Buffer);
		TCP_AddDataString("<a href=\"07?1=",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(i,0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("\"><font color=\"#0000FF\">Editovat</font></a> / <a href=\"02?2=",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(i,0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("\"><font color=\"#FF0000\">Vymazat</font></a>",RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart2,RX_Buffer,TX_Buffer);
		switch(Opakovani)
		{
			case 0:
			{
				TCP_AddDataString("Deaktivováno",RX_Buffer,TX_Buffer);
				break;
			}
			case 1:
			{
				TCP_AddDataString("Jednou",RX_Buffer,TX_Buffer);
				break;
			}
			case 2:
			{
				TCP_AddDataString("Denně",RX_Buffer,TX_Buffer);
				break;
			}
			case 3:
			{
				TCP_AddDataString("Týdně (",RX_Buffer,TX_Buffer);
				TCP_AddDataString((uint8_t *)JmenaDni3[WeekDayEurope(2010+Zacatek[2],Zacatek[1],Zacatek[0])],RX_Buffer,TX_Buffer);
				TCP_AddDataString(")",RX_Buffer,TX_Buffer);
				break;
			}
			case 4:
			{
				TCP_AddDataString("Měsíčně",RX_Buffer,TX_Buffer);
				break;
			}
			case 5:
			{
				TCP_AddDataString("Ročně",RX_Buffer,TX_Buffer);
				break;
			}
			default:
			{
				TCP_AddDataString("??? (",RX_Buffer,TX_Buffer);
				WWW_InsertInt16(Opakovani,0,RX_Buffer,TX_Buffer);
				TCP_AddDataString(")",RX_Buffer,TX_Buffer);
				break;
			}		
		}		
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Zacatek[0],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(".",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Zacatek[1],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(".",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(2010+Zacatek[2],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("&nbsp;&nbsp;",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Zacatek[3],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(":",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Zacatek[4],0,RX_Buffer,TX_Buffer);		
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Konec[0],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(".",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Konec[1],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(".",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(2010+Konec[2],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("&nbsp;&nbsp;",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Konec[3],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(":",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(Konec[4],0,RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);		
		TCP_AddDataString("<p align=\"left\">",RX_Buffer,TX_Buffer);
		TCP_AddDataString("Kanál 1 (645 nm): ",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(NastaveniLED[0],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(" %<br>Kanál 2 (660 nm): ",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(NastaveniLED[1],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(" %<br>Kanál 3 (735 nm): ",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(NastaveniLED[2],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString(" %<br>Kanál 4 (\"bílá\"): ",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(NastaveniLED[3],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("% <br>Kanál 5 (455 nm): ",RX_Buffer,TX_Buffer);
		WWW_InsertInt16(NastaveniLED[4],0,RX_Buffer,TX_Buffer);
		TCP_AddDataString("% <br>Kanál 6 (385 nm): ",RX_Buffer,TX_Buffer);
		if(NastaveniLED[5]==0)
		{
			TCP_AddDataString("Vypnuto",RX_Buffer,TX_Buffer);
		}
		else
		{
			TCP_AddDataString("Zapnuto",RX_Buffer,TX_Buffer);
		}
		TCP_AddDataString("</p>",RX_Buffer,TX_Buffer);
		WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStop1,RX_Buffer,TX_Buffer);
	}

	// Vkladani polozek tabulky - posledni radek s moznosti vlozeni dalsiho
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<a href=\"06\"><font color=\"#008000\">Přidat nový plán</font></a>",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStart3,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStop1,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka3_ObsahStop2,RX_Buffer,TX_Buffer);

	Planovac_PocetZaznamu(&ZaznamuCelkem,&ZaznamuAktivnich);
	TCP_AddDataString("<br><b>Celkový počet záznamů:</b> ",RX_Buffer,TX_Buffer);
	WWW_InsertInt16(ZaznamuCelkem,0,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<br><b>Celkový počet aktivních záznamů:</b> ",RX_Buffer,TX_Buffer);
	WWW_InsertInt16(ZaznamuAktivnich,0,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<br><b>Maximální počet záznamů:</b> ",RX_Buffer,TX_Buffer);
	WWW_InsertInt16(PLANOVAC_MAXZAZNAMU,0,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce slouzi k vygenerovani obsahu stranky
 s editaci/pridanim zaznamu do planovace
 ------------------------------------------------ */
void WWW_Generate_PlanovaniEditace(uint8_t ID, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{	
	uint8_t Opakovani=0;
	uint8_t Zacatek[5]={1,1,0,0,0};
	uint8_t Konec[5]={1,1,0,0,0};
	uint8_t NastaveniLED[6]={0,0,0,0,0,0};
	uint8_t temp[11] = {0,0,0,0,0,0,0,0,0,0,0};

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("GEN > Zaznam ID=",0);
		USART1_SendNumber(ID);
		USART1_Send_Enter();
		USART1_FreeMUTEX();
	#endif
	
	if((ID<PLANOVAC_MAXZAZNAMU)&(Planovac_ExistujiciZaznam(ID)))			// Rozhodnuti jestli se budou data pridavat 
	{																		// a nebo editovat
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GEN > Editace zaznamu planovace",1);
			USART1_FreeMUTEX();
		#endif
		if(Planovac_GetZaznam(ID,Zacatek,Konec,&Opakovani,NastaveniLED)==0)
		{
			ID=0xFF;														// Nactena data nejsou platna -> záznam se bude pridávat
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("GEN > Nactena data z FLASH nejsou platna",1);
				USART1_FreeMUTEX();
			#endif
		}
	}
	else
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GEN > Pridani noveho zaznamu planovace",1);
			USART1_FreeMUTEX();
		#endif
	}

	WWW_InsertFromFLASH(WWW_Obsah_PlanovaniEditovatNadpis,RX_Buffer,TX_Buffer);

	// Vygenerovani hlavicky formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Start,RX_Buffer,TX_Buffer);	
	TCP_AddDataString("07",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_Zacatek_Stop,RX_Buffer,TX_Buffer);	
	
	// Vlozeni hlavicky tabulky a jejiho nadpisu
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Plán",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStart2,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_NadpisStop,RX_Buffer,TX_Buffer);

	// Vkladani radku
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Opakování",RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);
	TCP_AddDataString("<input type=\"hidden\" name=\"1\" size=\"3\" value=\"",RX_Buffer,TX_Buffer);			// Vlozeni neviditelneho pole pro odeslani ID editovaneho zaznamu
	WWW_InsertInt16(ID,0,RX_Buffer,TX_Buffer);
	TCP_AddDataString("\">",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<select size=\"1\" name=\"2\">",RX_Buffer,TX_Buffer);			// Zacatek DropBoxu
	
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID>=PLANOVAC_MAXZAZNAMU)|((ID<PLANOVAC_MAXZAZNAMU)|(Opakovani==0)))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"0\">Deaktivovat</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID<PLANOVAC_MAXZAZNAMU)&(Opakovani==1))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"1\">Jednou</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID<PLANOVAC_MAXZAZNAMU)&(Opakovani==2))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"2\">Denně</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID<PLANOVAC_MAXZAZNAMU)&(Opakovani==3))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"3\">Týdně</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID<PLANOVAC_MAXZAZNAMU)&(Opakovani==4))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"4\">Měsíčně</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("<option ",RX_Buffer,TX_Buffer);									// Zacatek moznosti DropBoxu
	if((ID<PLANOVAC_MAXZAZNAMU)&(Opakovani==5))
	{
		TCP_AddDataString("selected ",RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("value=\"5\">Ročně</option>",RX_Buffer,TX_Buffer);
	TCP_AddDataString("</select> Při opakování je den v týdnu/den/měsíc určen datem začátku",RX_Buffer,TX_Buffer);
		
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Čas začátku",RX_Buffer,TX_Buffer);								// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+Zacatek[3]/10;
	temp[1]='0'+Zacatek[3]%10;
	temp[2]=':';
	temp[3]='0'+Zacatek[4]/10;
	temp[4]='0'+Zacatek[4]%10;
	temp[5]=0x00;
	WWW_InsertInputText(3,5,temp,5,"(formát: 15:01)",RX_Buffer,TX_Buffer);				// Cas zacatku

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Datum začátku",RX_Buffer,TX_Buffer);								// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+Zacatek[0]/10;
	temp[1]='0'+Zacatek[0]%10;
	temp[2]='.';
	temp[3]='0'+Zacatek[1]/10;
	temp[4]='0'+Zacatek[1]%10;
	temp[5]='.';
	temp[6]='2';
	temp[7]='0';
	temp[8]='0'+(Zacatek[2]+10)/10;
	temp[9]='0'+(Zacatek[2]+10)%10;
	temp[10]=0x00;
	WWW_InsertInputText(4,10,temp,10,"(formát: 23.03.2010, Rok: 2010-2060)",RX_Buffer,TX_Buffer);	// Datum zacatku

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Čas Konce",RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+Konec[3]/10;
	temp[1]='0'+Konec[3]%10;
	temp[2]=':';
	temp[3]='0'+Konec[4]/10;
	temp[4]='0'+Konec[4]%10;
	temp[5]=0x00;
	WWW_InsertInputText(5,5,temp,5,"(formát: 15:01) Netřeba zadávat při jednorázovém plánu",RX_Buffer,TX_Buffer);				// Cas konce

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Datum Konce",RX_Buffer,TX_Buffer);								// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+Konec[0]/10;
	temp[1]='0'+Konec[0]%10;
	temp[2]='.';
	temp[3]='0'+Konec[1]/10;
	temp[4]='0'+Konec[1]%10;
	temp[5]='.';
	temp[6]='2';
	temp[7]='0';
	temp[8]='0'+(Konec[2]+10)/10;
	temp[9]='0'+(Konec[2]+10)%10;
	temp[10]=0x00;
	WWW_InsertInputText(6,10,temp,10,"(formát: 23.03.2010, Rok: 2010-2060) Netřeba zadávat při jednorázovém plánu",RX_Buffer,TX_Buffer);	// Datum konce

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 1 (645 nm)",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+NastaveniLED[0]/100;
	temp[1]='0'+(NastaveniLED[0]%100)/10;	
	temp[2]='0'+(NastaveniLED[0]%100)%10;	
	temp[3]=0x00;
	WWW_InsertInputText(7,3,temp,3,"% (0-100%)",RX_Buffer,TX_Buffer);				// Vykon kanalu 1

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 2 (660 nm)",RX_Buffer,TX_Buffer);								
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+NastaveniLED[1]/100;
	temp[1]='0'+(NastaveniLED[1]%100)/10;	
	temp[2]='0'+(NastaveniLED[1]%100)%10;	
	temp[3]=0x00;
	WWW_InsertInputText(8,3,temp,3,"% (0-100%)",RX_Buffer,TX_Buffer);				// Vykon kanalu 2
	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 3 (735 nm)",RX_Buffer,TX_Buffer);								
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+NastaveniLED[2]/100;
	temp[1]='0'+(NastaveniLED[2]%100)/10;	
	temp[2]='0'+(NastaveniLED[2]%100)%10;	
	temp[3]=0x00;
	WWW_InsertInputText(9,3,temp,3,"% (0-100%)",RX_Buffer,TX_Buffer);				// Vykon kanalu 3

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 4 (\"bílá\")",RX_Buffer,TX_Buffer);								
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+NastaveniLED[3]/100;
	temp[1]='0'+(NastaveniLED[3]%100)/10;	
	temp[2]='0'+(NastaveniLED[3]%100)%10;	
	temp[3]=0x00;
	WWW_InsertInputText(10,3,temp,3,"% (0-100%)",RX_Buffer,TX_Buffer);				// Vykon kanalu 4

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 5 (455 nm)",RX_Buffer,TX_Buffer);								
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	temp[0]='0'+NastaveniLED[4]/100;
	temp[1]='0'+(NastaveniLED[4]%100)/10;	
	temp[2]='0'+(NastaveniLED[4]%100)%10;	
	temp[3]=0x00;
	WWW_InsertInputText(11,3,temp,3,"% (0-100%)",RX_Buffer,TX_Buffer);				// Vykon kanalu 5

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("Výkon kanálu 6 (385 nm)",RX_Buffer,TX_Buffer);								
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("1",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start2,RX_Buffer,TX_Buffer);
	TCP_AddDataString("12",RX_Buffer,TX_Buffer);	
	if(NastaveniLED[5]!=0)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_StopChecked,RX_Buffer,TX_Buffer);
	}
	else
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Stop,RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("Zapnout&nbsp;&nbsp;",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start1,RX_Buffer,TX_Buffer);
	TCP_AddDataString("2",RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start2,RX_Buffer,TX_Buffer);
	TCP_AddDataString("12",RX_Buffer,TX_Buffer);
	if(NastaveniLED[5]!=0)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Stop,RX_Buffer,TX_Buffer);		
	}
	else
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_StopChecked,RX_Buffer,TX_Buffer);
	}
	TCP_AddDataString("Vypnout",RX_Buffer,TX_Buffer);

	// Konec tabulky	
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop2,RX_Buffer,TX_Buffer);

	// Vygenerovani konce formulare s tlacitky
	WWW_InsertFromFLASH(WWW_Obsah_Form_Tlacitka,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu polozku pro editaci 
 pole input (text) ve formatu radku tabulky vcetne
 bunky s pojmenovanim 
 <tr><td>nazev</td><td>obsah</td></tr>
 ------------------------------------------------ */
void WWW_InsertTableInputText(const uint8_t *nazev, uint8_t ID, uint8_t size, uint8_t *value, uint8_t maxlength, uint8_t *text, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	// Nazev
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart1,RX_Buffer,TX_Buffer);
	WWW_InsertFromFLASH(nazev,RX_Buffer,TX_Buffer);									// Vlozi nazev polozky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStart2,RX_Buffer,TX_Buffer);		
	
	// Obsah
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start1,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(ID,0,RX_Buffer,TX_Buffer);								// ID prvku formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start2,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(size,0,RX_Buffer,TX_Buffer);							// velikost prvku formulare ve znacich
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start3,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(value,RX_Buffer,TX_Buffer);				// Pocatecni hodnota
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start4,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(maxlength,0,RX_Buffer,TX_Buffer);						// Maximalni pocet znaku
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Stop,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(text,RX_Buffer,TX_Buffer);				// Text za polozkou

	WWW_InsertFromFLASH(WWW_Obsah_Tabulka1_ObsahStop,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu polozku pro editaci 
 pole input (text) ve formatu radku tabulky vcetne
 bunky s pojmenovanim 
 "obsah"
 ------------------------------------------------ */
void WWW_InsertInputText(uint8_t ID, uint8_t size, uint8_t *value, uint8_t maxlength, uint8_t *text, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{			
	// Obsah
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start1,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(ID,0,RX_Buffer,TX_Buffer);								// ID prvku formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start2,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(size,0,RX_Buffer,TX_Buffer);							// velikost prvku formulare ve znacich
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start3,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(value,RX_Buffer,TX_Buffer);				// Pocatecni hodnota
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start4,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(maxlength,0,RX_Buffer,TX_Buffer);						// Maximalni pocet znaku
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Stop,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(text,RX_Buffer,TX_Buffer);				// Text za polozkou
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu polozku pro editaci 
 pole input (text) ve formatu radku tabulky vcetne
 bunky s pojmenovanim 
 <td>obsah</td>
 ------------------------------------------------ */
void WWW_InsertTable2InputText(uint8_t ID, uint8_t size, uint8_t *value, uint8_t maxlength, uint8_t *text, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{	
	// Zacatek bunky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStart2,RX_Buffer,TX_Buffer);			
	
	// Obsah
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start1,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(ID,0,RX_Buffer,TX_Buffer);								// ID prvku formulare
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start2,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(size,0,RX_Buffer,TX_Buffer);							// velikost prvku formulare ve znacich
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start3,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(value,RX_Buffer,TX_Buffer);				// Pocatecni hodnota
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start4,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(maxlength,0,RX_Buffer,TX_Buffer);						// Maximalni pocet znaku
	WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Stop,RX_Buffer,TX_Buffer);
	WWW_InsertSystemDataFromFLASH(text,RX_Buffer,TX_Buffer);				// Text za polozkou

	// Konec bunky
	WWW_InsertFromFLASH(WWW_Obsah_Tabulka2_ObsahStop2,RX_Buffer,TX_Buffer);
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu polozku pro editaci 
 pole input radio ve formatu cisteho textu bez tabulky
 ------------------------------------------------ */
void WWW_InsertRadioButtonText(uint8_t value, uint8_t name, uint8_t *text, uint8_t checked, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	// Obsah
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start1,RX_Buffer,TX_Buffer);	
	WWW_InsertInt16(value,0,RX_Buffer,TX_Buffer);								// Value prvku
	WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Start2,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(name,0,RX_Buffer,TX_Buffer);							// velikost prvku formulare ve znacich
	if(checked)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_StopChecked,RX_Buffer,TX_Buffer);
	}
	else
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_RadioButton_Stop,RX_Buffer,TX_Buffer);
	}
	
	WWW_InsertSystemDataFromFLASH(text,RX_Buffer,TX_Buffer);				// Text za polozkou	
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu polozku pro editaci 
 pole check box ve formatu cisteho textu bez tabulky
 ------------------------------------------------ */
void WWW_InsertCheckBoxText(uint8_t value, uint8_t name, uint8_t *text, uint8_t checked, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	// Obsah
	WWW_InsertFromFLASH(WWW_Obsah_Form_CheckBox_Start1,RX_Buffer,TX_Buffer);	
	WWW_InsertInt16(value,0,RX_Buffer,TX_Buffer);								// Value prvku
	WWW_InsertFromFLASH(WWW_Obsah_Form_CheckBox_Start2,RX_Buffer,TX_Buffer);
	WWW_InsertInt16(name,0,RX_Buffer,TX_Buffer);							// velikost prvku formulare ve znacich
	if(checked)
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_CheckBox_StopChecked,RX_Buffer,TX_Buffer);
	}
	else
	{
		WWW_InsertFromFLASH(WWW_Obsah_Form_CheckBox_Stop,RX_Buffer,TX_Buffer);
	}
	
	WWW_InsertSystemDataFromFLASH(text,RX_Buffer,TX_Buffer);				// Text za polozkou	
}

/* -------------------------------------------------
 Funkce zapise do TX bufferu text z FLASH ktery musi
 byt zakonceny 0x00
 ------------------------------------------------ */
void WWW_InsertFromFLASH(const uint8_t *data, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint16_t i=0;
	while(data[i]!=0x00)
	{
		TCP_AddDataChar(data[i++], RX_Buffer, TX_Buffer, 0);
	}
}

/* -------------------------------------------------
 Funkce dekoduje data z formulare predana metodou GET
 ze stranky pridat nebo editovat zaznam planovace
 ------------------------------------------------ */
void WWW_DecodeFormGET_Planovani(uint8_t typ, uint8_t *RX_Buffer)
{
	uint16_t OffsetHledani;
	uint8_t Parametr;
	uint16_t HodnotaZacatek;
	uint8_t HodnotaDelka,j,k;
	uint16_t i,temp,temp2;
	uint8_t TempArray[6] = {0x00,0x00,0x00,0x00,0x00,0x00};
	const uint16_t Rady[5] = {1,10,100,1000,10000};
	uint8_t DocasnyZaznam[17] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
	uint8_t ID_edit = 0xFF;

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > Zacatek zpracovani planovani",1);
		USART1_FreeMUTEX();
	#endif

	OffsetHledani=WWW_GetFormParamStart(RX_Buffer);							// Nalezeni zacatku requestu (po znaku '?')
	while(OffsetHledani!=0)
	{
		OffsetHledani=WWW_GetFormHodnota(OffsetHledani,&Parametr,&HodnotaZacatek,&HodnotaDelka,RX_Buffer);
		if(OffsetHledani==0)												// Overeni jestli funkce nejaky parametr nasla
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM GET > Konec vyhledavani",1);
				USART1_FreeMUTEX();
			#endif
			break;
		}
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM Parametr > ID=",0);
			USART1_SendInteger(Parametr);
			USART1_Send(" Hodnota='",0);
			for(i=0;i<HodnotaDelka;i++)
			{
				USART1_Write(RX_Buffer[HodnotaZacatek+i]);
			}
			USART1_Send("'",0);
			USART1_Send_Enter();
			USART1_FreeMUTEX();
		#endif
		switch(Parametr)
		{
			case 1:													// ID editovaneho zaznamu
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > ID editovaneho zaznamu",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_IDEDIT_EXIT;
					}					
				}
				if(temp2>255)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				ID_edit=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > ID editovaneho zaznamu=",0);
					USART1_SendInteger(ID_edit);
					USART1_Send(" %",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_IDEDIT_EXIT:
				break;
			}
			case 2:														// Vyber opakovani
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Opakovani",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka==0) | (HodnotaDelka>1))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				DocasnyZaznam[WWW_PLAN_OPAKOVANI]=RX_Buffer[HodnotaZacatek]-'0';
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Opakovani=",0);
					USART1_SendInt32(DocasnyZaznam[WWW_PLAN_OPAKOVANI]);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
				
				break;
			}
			case 3:														// Cas zacatku
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Cas zacatku",1);
					USART1_FreeMUTEX();
				#endif				
				if((HodnotaDelka<5) | (HodnotaDelka>7))					// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<2;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<2;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if(((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]=='A') &  
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]=='3') & 
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]=='%')) | 
						(k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(2-1))											// Preskoceni kontroly neexistujici dvojtecky za poslednim radem casu (hodin)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]!='A') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]!='3') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]!='%'))			// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_EXIT;
						}
					}
WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_NEXT:
					k+=3;												// Posun na dalsi znak za dvojteckou
					if(((temp2>59) & (i==0)) | ((temp2>23) & (i==1)))	// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				DocasnyZaznam[WWW_PLAN_ZACATEK_HODIN]=TempArray[1];
				DocasnyZaznam[WWW_PLAN_ZACATEK_MINUT]=TempArray[0];
				
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > cas zacatku=",0);					
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_ZACATEK_HODIN]);
					USART1_Send(":",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_ZACATEK_MINUT]);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_PRIDATPLAN_DECODE_CAS_ZACATKU_EXIT:	
				break;
			}
			case 4:														// Datum
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Datum Zacatku",1);
					USART1_FreeMUTEX();
				#endif				
				if((HodnotaDelka<8) | (HodnotaDelka>10))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<3;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<4;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(3-1))											// Preskoceni kontroly neexistujici tecky za poslednim radem datumu (dny)
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_EXIT;
						}
					}
WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if((((temp2<2010) & (i==0)) & ((temp2>2100) & (i==0))) | 
					    ((temp2>12) & (i==1)) | 
						((temp2>31) & (i==2)))							// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				DocasnyZaznam[WWW_PLAN_ZACATEK_DEN]=TempArray[2];
				DocasnyZaznam[WWW_PLAN_ZACATEK_MESIC]=TempArray[1];
				DocasnyZaznam[WWW_PLAN_ZACATEK_ROK]=TempArray[0]-2010;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > datum zacatku=",0);					
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_ZACATEK_DEN]);
					USART1_Send(".",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_ZACATEK_MESIC]);
					USART1_Send(".",0);
					USART1_SendInteger(2010+DocasnyZaznam[WWW_PLAN_ZACATEK_ROK]);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_PRIDATPLAN_DECODE_DATUM_ZACATKU_EXIT:	
				break;
			}
			case 5:														// Cas zacatku
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Cas konce",1);
					USART1_FreeMUTEX();
				#endif				
				if((HodnotaDelka<5) | (HodnotaDelka>7))					// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<2;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<2;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if(((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]=='A') &  
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]=='3') & 
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]=='%')) | 
						(k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_CAS_KONCE_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_CAS_KONCE_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_CAS_KONCE_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(2-1))											// Preskoceni kontroly neexistujici dvojtecky za poslednim radem casu (hodin)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]!='A') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]!='3') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]!='%'))			// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_CAS_KONCE_EXIT;
						}
					}
WWW_PRIDATPLAN_DECODE_CAS_KONCE_NEXT:
					k+=3;												// Posun na dalsi znak za dvojteckou
					if(((temp2>59) & (i==0)) | ((temp2>23) & (i==1)))	// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_PRIDATPLAN_DECODE_CAS_KONCE_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				DocasnyZaznam[WWW_PLAN_KONEC_HODIN]=TempArray[1];
				DocasnyZaznam[WWW_PLAN_KONEC_MINUT]=TempArray[0];
				
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > cas konce=",0);					
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_KONEC_HODIN]);
					USART1_Send(":",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_KONEC_MINUT]);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_PRIDATPLAN_DECODE_CAS_KONCE_EXIT:	
				break;
			}
			case 6:														// Datum
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Datum Konce",1);
					USART1_FreeMUTEX();
				#endif				
				if((HodnotaDelka<8) | (HodnotaDelka>10))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<3;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<4;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_DATUM_KONCE_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_PRIDATPLAN_DECODE_DATUM_KONCE_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_DATUM_KONCE_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(3-1))											// Preskoceni kontroly neexistujici tecky za poslednim radem datumu (dny)
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_PRIDATPLAN_DECODE_DATUM_KONCE_EXIT;
						}
					}
WWW_PRIDATPLAN_DECODE_DATUM_KONCE_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if((((temp2<2010) & (i==0)) & ((temp2>2100) & (i==0))) | 
					    ((temp2>12) & (i==1)) | 
						((temp2>31) & (i==2)))							// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_PRIDATPLAN_DECODE_DATUM_KONCE_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				DocasnyZaznam[WWW_PLAN_KONEC_DEN]=TempArray[2];
				DocasnyZaznam[WWW_PLAN_KONEC_MESIC]=TempArray[1];
				DocasnyZaznam[WWW_PLAN_KONEC_ROK]=TempArray[0]-2010;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > datum konce=",0);					
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_KONEC_DEN]);
					USART1_Send(".",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_KONEC_MESIC]);
					USART1_Send(".",0);
					USART1_SendInteger(2010+DocasnyZaznam[WWW_PLAN_KONEC_ROK]);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_PRIDATPLAN_DECODE_DATUM_KONCE_EXIT:	
				break;
			}
			case 7:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 1",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_VYKONKANAL1_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				DocasnyZaznam[WWW_PLAN_LED1]=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 1=",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_LED1]);
					USART1_Send("%",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_VYKONKANAL1_EXIT:
				break;
			}
			case 8:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 2",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_VYKONKANAL2_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				DocasnyZaznam[WWW_PLAN_LED2]=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 2=",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_LED2]);
					USART1_Send("%",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_VYKONKANAL2_EXIT:
				break;
			}
			case 9:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 3",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_VYKONKANAL3_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				DocasnyZaznam[WWW_PLAN_LED3]=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 3=",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_LED3]);
					USART1_Send("%",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_VYKONKANAL3_EXIT:
				break;
			}
			case 10:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 4",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_VYKONKANAL4_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				DocasnyZaznam[WWW_PLAN_LED4]=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 4=",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_LED4]);
					USART1_Send("%",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_VYKONKANAL4_EXIT:
				break;
			}
			case 11:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 5",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_PRIDATPLAN_DECODE_VYKONKANAL5_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}								
				DocasnyZaznam[WWW_PLAN_LED5]=temp2;
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 5=",0);
					USART1_SendInteger(DocasnyZaznam[WWW_PLAN_LED5]);
					USART1_Send("%",1);					
					USART1_FreeMUTEX();
				#endif
WWW_PRIDATPLAN_DECODE_VYKONKANAL5_EXIT:
				break;
			}
			case 12:													// Zapnuti kanalu 6
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 6",1);
					USART1_FreeMUTEX();
				#endif
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					DocasnyZaznam[WWW_PLAN_LED6]=1;
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 6 ON",1);
						USART1_FreeMUTEX();
					#endif
				}
				else if(temp==2)									// Vybrano zakazat
				{						
					DocasnyZaznam[WWW_PLAN_LED6]=0;
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 6 OFF",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
		}
	}
	// Kontrola jestli byly zadany vsechny parametry
	for(i=0;i<WWW_PLAN_LED6;i++)
	{
		if(DocasnyZaznam[i]==0xFF)
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send(" > Nebyly zadany vsechny parametry. ID parametru: ",0);
				USART1_SendInteger(i);
				USART1_Send_Enter();
				USART1_FreeMUTEX();
			#endif
			return;
		}
	}
	// Kontrola jestli zadavany zaznam jiz neexistuje - pokud existuje -> exit
	if(Planovac_Existuje(DocasnyZaznam[WWW_PLAN_ZACATEK_DEN],DocasnyZaznam[WWW_PLAN_ZACATEK_MESIC],
						 DocasnyZaznam[WWW_PLAN_ZACATEK_ROK],DocasnyZaznam[WWW_PLAN_ZACATEK_HODIN],
					  	 DocasnyZaznam[WWW_PLAN_ZACATEK_MINUT],DocasnyZaznam[WWW_PLAN_KONEC_DEN],
						 DocasnyZaznam[WWW_PLAN_KONEC_MESIC],DocasnyZaznam[WWW_PLAN_KONEC_ROK],
					  	 DocasnyZaznam[WWW_PLAN_KONEC_HODIN],DocasnyZaznam[WWW_PLAN_KONEC_MINUT],
						 DocasnyZaznam[WWW_PLAN_OPAKOVANI],&DocasnyZaznam[WWW_PLAN_LED1]))
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("DECODE > Jiz existujici zaznam. Nevlozeno!",1);			
			USART1_FreeMUTEX();
		#endif
		return;
	}
	// Zjisteni jestli se jedna o editaci zaznamu nebo vlozeni noveho
	if(ID_edit>PLANOVAC_MAXZAZNAMU)										// Novy zaznam
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("DECODE > Pridavam zaznam",1);			
			USART1_FreeMUTEX();
		#endif
		Planovac_PridatZaznam(DocasnyZaznam[WWW_PLAN_ZACATEK_DEN],DocasnyZaznam[WWW_PLAN_ZACATEK_MESIC],
							  DocasnyZaznam[WWW_PLAN_ZACATEK_ROK],DocasnyZaznam[WWW_PLAN_ZACATEK_HODIN],
					  		  DocasnyZaznam[WWW_PLAN_ZACATEK_MINUT],DocasnyZaznam[WWW_PLAN_KONEC_DEN],
							  DocasnyZaznam[WWW_PLAN_KONEC_MESIC],DocasnyZaznam[WWW_PLAN_KONEC_ROK],
					  		  DocasnyZaznam[WWW_PLAN_KONEC_HODIN],DocasnyZaznam[WWW_PLAN_KONEC_MINUT],
							  DocasnyZaznam[WWW_PLAN_OPAKOVANI],&DocasnyZaznam[WWW_PLAN_LED1]);
	}
	else																// Editovany zaznam
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("DECODE > Edituji zaznam",1);			
			USART1_FreeMUTEX();
		#endif
		Planovac_EditovatZaznam(ID_edit,DocasnyZaznam[WWW_PLAN_ZACATEK_DEN],DocasnyZaznam[WWW_PLAN_ZACATEK_MESIC],
							    DocasnyZaznam[WWW_PLAN_ZACATEK_ROK],DocasnyZaznam[WWW_PLAN_ZACATEK_HODIN],
					  		    DocasnyZaznam[WWW_PLAN_ZACATEK_MINUT],DocasnyZaznam[WWW_PLAN_KONEC_DEN],
							    DocasnyZaznam[WWW_PLAN_KONEC_MESIC],DocasnyZaznam[WWW_PLAN_KONEC_ROK],
					  		    DocasnyZaznam[WWW_PLAN_KONEC_HODIN],DocasnyZaznam[WWW_PLAN_KONEC_MINUT],
							    DocasnyZaznam[WWW_PLAN_OPAKOVANI],&DocasnyZaznam[WWW_PLAN_LED1]);
	}
}

/* -------------------------------------------------
 Funkce dekoduje data z formulare predana metodou GET
 ------------------------------------------------ */
void WWW_DecodeFormGET_NastaveniSite(uint8_t *RX_Buffer)
{
	uint16_t OffsetHledani;
	uint8_t Parametr;
	uint16_t HodnotaZacatek;
	uint8_t HodnotaDelka,j,k;
	uint16_t i,temp,temp2;
	uint8_t TempArray[6] = {0x00,0x00,0x00,0x00,0x00,0x00};
	const uint16_t Rady[5] = {1,10,100,1000,10000};

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > Zacatek zpracovani",1);
		USART1_FreeMUTEX();
	#endif

	OffsetHledani=WWW_GetFormParamStart(RX_Buffer);							// Nalezeni zacatku requestu (po znaku '?')
	while(OffsetHledani!=0)
	{
		OffsetHledani=WWW_GetFormHodnota(OffsetHledani,&Parametr,&HodnotaZacatek,&HodnotaDelka,RX_Buffer);
		if(OffsetHledani==0)												// Overeni jestli funkce nejaky parametr nasla
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM GET > Konec vyhledavani",1);
				USART1_FreeMUTEX();
			#endif
			break;
		}
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM Parametr > ID=",0);
			USART1_SendInteger(Parametr);
			USART1_Send(" Hodnota='",0);
			for(i=0;i<HodnotaDelka;i++)
			{
				USART1_Write(RX_Buffer[HodnotaZacatek+i]);
			}
			USART1_Send("'",0);
			USART1_Send_Enter();
			USART1_FreeMUTEX();
		#endif
		switch(Parametr)
		{
			case 1:										// IP adresa
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > IP adresa",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<7) | (HodnotaDelka>15))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<IP_ADR_SIZE;i++)								// Prochazeni jednotlivych byte adresy
				{
					temp2=0;
					for(j=0;j<3;j++)									// Prochazeni jednotlivych cifer byte adresy
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_IP_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_IP_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_IP_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(IP_ADR_SIZE-1))								// Preskoceni kontroly neexistujici tecky za poslednim byte adresy
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola tecky (pokud jsou pritomny vsechny 3 cifry byte
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi tecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_IP_EXIT;
						}
					}
WWW_NASTAVENISITE_DECODE_IP_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if(temp2>255)										// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISITE_DECODE_IP_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > IP=",0);
					USART1_FreeMUTEX();
				#endif
				for(i=0;i<IP_ADR_SIZE;i++)								// Nakopirovani docasne promenne do skutecne
				{
					my_IP[i]=TempArray[(IP_ADR_SIZE-1)-i];			// Ulozeni adresy v reverznim poradi (do temp byla ukladana pozpatku)
					if(i%2==0)
					{
						FlashSave_Save8_high(FLASHSAVE_IP_0_1+(i/2), my_IP[i]);
					}
					else
					{
						FlashSave_Save8_low(FLASHSAVE_IP_0_1+(i/2), my_IP[i]);
					}
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_SendInteger(my_MASK[i]);
						if(i<(IP_ADR_SIZE-1))
						{
							USART1_Send(".",0);
						}						
						USART1_FreeMUTEX();
					#endif
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISITE_DECODE_IP_EXIT:	
				break;
			}
			case 2:										// Maska podsite
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Maska podsite",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<7) | (HodnotaDelka>15))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<IP_ADR_SIZE;i++)								// Prochazeni jednotlivych byte adresy
				{
					temp2=0;
					for(j=0;j<3;j++)									// Prochazeni jednotlivych cifer byte adresy
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_MASK_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_MASK_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_MASK_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(IP_ADR_SIZE-1))								// Preskoceni kontroly neexistujici tecky za poslednim byte adresy
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola tecky (pokud jsou pritomny vsechny 3 cifry byte
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi tecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_MASK_EXIT;
						}
					}
WWW_NASTAVENISITE_DECODE_MASK_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if(temp2>255)										// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISITE_DECODE_MASK_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Mask=",0);
					USART1_FreeMUTEX();
				#endif
				for(i=0;i<IP_ADR_SIZE;i++)								// Nakopirovani docasne promenne do skutecne
				{
					my_MASK[i]=TempArray[(IP_ADR_SIZE-1)-i];			// Ulozeni adresy v reverznim poradi (do temp byla ukladana pozpatku)
					if(i%2==0)
					{
						FlashSave_Save8_high(FLASHSAVE_MASKA_0_1+(i/2), my_MASK[i]);
					}
					else
					{
						FlashSave_Save8_low(FLASHSAVE_MASKA_0_1+(i/2), my_MASK[i]);
					}
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_SendInteger(my_MASK[i]);
						if(i<(IP_ADR_SIZE-1))
						{
							USART1_Send(".",0);
						}						
						USART1_FreeMUTEX();
					#endif
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISITE_DECODE_MASK_EXIT:	
				break;
			}
			case 3:										// Vychozi brana
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vychozi brana",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<7) | (HodnotaDelka>15))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<IP_ADR_SIZE;i++)								// Prochazeni jednotlivych byte adresy
				{
					temp2=0;
					for(j=0;j<3;j++)									// Prochazeni jednotlivych cifer byte adresy
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_GATE_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISITE_DECODE_GATE_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_GATE_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(IP_ADR_SIZE-1))								// Preskoceni kontroly neexistujici tecky za poslednim byte adresy
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola tecky (pokud jsou pritomny vsechny 3 cifry byte
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi tecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISITE_DECODE_GATE_EXIT;
						}
					}
WWW_NASTAVENISITE_DECODE_GATE_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if(temp2>255)										// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISITE_DECODE_GATE_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Gate=",0);
					USART1_FreeMUTEX();
				#endif
				for(i=0;i<IP_ADR_SIZE;i++)								// Nakopirovani docasne promenne do skutecne
				{
					my_GATE[i]=TempArray[(IP_ADR_SIZE-1)-i];			// Ulozeni adresy v reverznim poradi (do temp byla ukladana pozpatku)
					if(i%2==0)
					{
						FlashSave_Save8_high(FLASHSAVE_GATE_0_1+(i/2), my_GATE[i]);
					}
					else
					{
						FlashSave_Save8_low(FLASHSAVE_GATE_0_1+(i/2), my_GATE[i]);
					}
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_SendInteger(my_GATE[i]);
						if(i<(IP_ADR_SIZE-1))
						{
							USART1_Send(".",0);
						}						
						USART1_FreeMUTEX();
					#endif
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISITE_DECODE_GATE_EXIT:	
				break;
			}
			case 4:										// MAC adresa
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > MAC adresa",1);
					USART1_FreeMUTEX();
				#endif
				if(HodnotaDelka!=12)									// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				for(i=0;i<MAC_ADR_SIZE;i++)
				{
					temp = (RX_Buffer[HodnotaZacatek+((i*2)+0)]);
					if((temp>='0') & (temp<='9'))						// Detekce cisla v HEX
					{
						temp = (temp-'0')*16;
					}
					else if((temp>='A') & (temp<='F'))					// Detekce velkeho pismena v HEX
					{
						temp =((temp-'A')+10)*16;
					}
					else if((temp>='a') & (temp<='f'))					// Detekce velkeho pismena v HEX
					{
						temp =((temp-'a')+10)*16;
					}
					else												// Zadany znak neodpovida HEX mnozine
					{
						goto WWW_NASTAVENISITE_DECODE_MAC_EXIT;
					}
					temp2 = temp;
					temp = (RX_Buffer[HodnotaZacatek+((i*2)+1)]);
					if((temp>='0') & (temp<='9'))						// Detekce cisla v HEX
					{
						temp = (temp-'0');
					}
					else if((temp>='A') & (temp<='F'))				// Detekce velkeho pismena v HEX
					{
						temp =((temp-'A')+10);
					}
					else if((temp>='a') & (temp<='f'))				// Detekce velkeho pismena v HEX
					{
						temp =((temp-'a')+10);
					}
					else											// Zadany znak neodpovida HEX mnozine
					{
						goto WWW_NASTAVENISITE_DECODE_MAC_EXIT;
					}
					temp2 += temp;
					
					if(temp2>255)									// Kontrola prekroceni maxima
					{
						goto WWW_NASTAVENISITE_DECODE_MAC_EXIT;
					}
					TempArray[i]=temp2;								// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)					
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > MAC=",0);
					USART1_FreeMUTEX();
				#endif
				for(i=0;i<MAC_ADR_SIZE;i++)							// Nakopirovani docasne promenne do skutecne
				{
					my_MAC[i]=TempArray[i];
					if(i%2==0)
					{
						FlashSave_Save8_high(FLASHSAVE_MAC_0_1+(i/2), my_MAC[i]);
					}
					else
					{
						FlashSave_Save8_low(FLASHSAVE_MAC_0_1+(i/2), my_MAC[i]);
					}
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_BinToHex(TempArray[i]);						
						USART1_FreeMUTEX();
					#endif
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send_Enter();
					USART1_Send("ReInit ENC28J60",1);
					USART1_FreeMUTEX();
				#endif
				ServerInit();
WWW_NASTAVENISITE_DECODE_MAC_EXIT:
				break;
			}
			case 5:													// HTTP port
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > HTTP port",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISITE_DECODE_HTTPPORT_EXIT;
					}					
				}
				my_HTTP_Port = temp2;								// Ulozeni
				FlashSave_Save16(FLASHSAVE_HTTPPORT, my_HTTP_Port);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > HTTP port=",0);
					USART1_SendInteger(my_HTTP_Port);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISITE_DECODE_HTTPPORT_EXIT:
				break;
			}
			case 6:													// UDP port
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > UDP port",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISITE_DECODE_UDPPORT_EXIT;
					}					
				}
				my_UDP_Port = temp2;								// Ulozeni
				FlashSave_Save16(FLASHSAVE_UDPPORT, my_UDP_Port);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > UDP port=",0);
					USART1_SendInteger(my_UDP_Port);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISITE_DECODE_UDPPORT_EXIT:
				break;
			}
			case 7:													// Povoleni HTTP serveru
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > HTTP enable",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>1) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					ServerEnable|=(1<<SERVER_ENABLE_WWW);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > HTTP enable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else if(temp==2)										// Vybrano zakazat
				{						
					ServerEnable&=~(1<<SERVER_ENABLE_WWW);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > HTTP disable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 8:													// Povoleni UDP serveru
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > UDP enable",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>1) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					ServerEnable|=(1<<SERVER_ENABLE_UDP);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > UDP enable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else if(temp==2)										// Vybrano zakazat
				{						
					ServerEnable&=~(1<<SERVER_ENABLE_UDP);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > UDP disable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 9:													// Povoleni Telnet serveru
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Telnet enable",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>1) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					ServerEnable|=(1<<SERVER_ENABLE_TELNET);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Telnet enable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else if(temp==2)										// Vybrano zakazat
				{						
					ServerEnable&=~(1<<SERVER_ENABLE_TELNET);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Telnet disable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 10:												// Povoleni Ping serveru
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Ping enable",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>1) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					ServerEnable|=(1<<SERVER_ENABLE_PING);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Ping enable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else if(temp==2)										// Vybrano zakazat
				{						
					ServerEnable&=~(1<<SERVER_ENABLE_PING);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Ping disable",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
		}
	}
	FlashSave_Save16(FLASHSAVE_SERVERENABLE, ServerEnable);
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > KONEC",1);
		USART1_FreeMUTEX();
	#endif
}

/* -------------------------------------------------
 Funkce dekoduje data z formulare predana metodou GET
 ------------------------------------------------ */
void WWW_DecodeFormGET_NastaveniLED(uint8_t *RX_Buffer)
{
	uint16_t OffsetHledani;
	uint8_t Parametr;
	uint16_t HodnotaZacatek;
	uint8_t HodnotaDelka;
	uint16_t i,temp2;
	uint32_t temp;
	uint8_t CheckBox = 0;
	const uint16_t Rady[5] = {1,10,100,1000,10000};

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > Zacatek zpracovani",1);
		USART1_FreeMUTEX();
	#endif

	OffsetHledani=WWW_GetFormParamStart(RX_Buffer);							// Nalezeni zacatku requestu (po znaku '?')
	if(OffsetHledani==0)													// Nebyly nalezeny parametry -> konec
	{
		return;
	}
	while(OffsetHledani!=0)
	{
		OffsetHledani=WWW_GetFormHodnota(OffsetHledani,&Parametr,&HodnotaZacatek,&HodnotaDelka,RX_Buffer);
		if(OffsetHledani==0)												// Overeni jestli funkce nejaky parametr nasla
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM GET > Konec vyhledavani",1);
				USART1_FreeMUTEX();
			#endif
			break;
		}
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM Parametr > ID=",0);
			USART1_SendInteger(Parametr);
			USART1_Send(" Hodnota='",0);
			for(i=0;i<HodnotaDelka;i++)
			{
				USART1_Write(RX_Buffer[HodnotaZacatek+i]);
			}
			USART1_Send("'",0);
			USART1_Send_Enter();
			USART1_FreeMUTEX();
		#endif
		switch(Parametr)
		{			
			case 1:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 1",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_VYKONKANAL1_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (PWM_max[0] * temp2)/100;
				PWM_Set_LED_1(temp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 1=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_VYKONKANAL1_EXIT:
				break;
			}
			case 2:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 2",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_VYKONKANAL2_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (PWM_max[1] * temp2)/100;
				PWM_Set_LED_2(temp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 2=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_VYKONKANAL2_EXIT:
				break;
			}
			case 3:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 3",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_VYKONKANAL3_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (PWM_max[2] * temp2)/100;
				PWM_Set_LED_3(temp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 3=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_VYKONKANAL3_EXIT:
				break;
			}
			case 4:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 4",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_VYKONKANAL4_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (PWM_max[3] * temp2)/100;
				PWM_Set_LED_4(temp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 4=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_VYKONKANAL4_EXIT:
				break;
			}
			case 5:													// Nastaveny vykon
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon kanal 5",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_VYKONKANAL5_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (PWM_max[4] * temp2)/100;
				PWM_Set_LED_5(temp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Vykon kanal 5=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_VYKONKANAL5_EXIT:
				break;
			}
			case 6:													// Zapnuti kanalu 6
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 6",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<0);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					PWM_Set_LED_6_ON();
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 6 ON",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}			
			case 7:													// Nastaveni max. PWM  1
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Max PWM kanal 1",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_MAXPWMKANAL1_EXIT;
					}					
				}
				if(temp2>48000)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				PWM_max[0]= temp2;
				FlashSave_Save16(FLASHSAVE_PWMMAX_1, PWM_max[0]);
				if (PWM_Get_LED_1()>temp2)
				{
					PWM_Set_LED_1(temp2);
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Max PWM kanal 1=",0);
					USART1_SendInteger(temp2);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_MAXPWMKANAL1_EXIT:
				break;
			}
			case 8:													// Nastaveni max. PWM 2
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Max PWM kanal 2",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_MAXPWMKANAL2_EXIT;
					}					
				}
				if(temp2>48000)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				PWM_max[1]= temp2;
				FlashSave_Save16(FLASHSAVE_PWMMAX_2, PWM_max[1]);
				if (PWM_Get_LED_2()>temp2)
				{
					PWM_Set_LED_2(temp2);
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Max PWM kanal 2=",0);
					USART1_SendInteger(temp2);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_MAXPWMKANAL2_EXIT:
				break;
			}
			case 9:													// Nastaveni max. PWM 3
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Max PWM kanal 3",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_MAXPWMKANAL3_EXIT;
					}					
				}
				if(temp2>48000)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				PWM_max[2]= temp2;
				FlashSave_Save16(FLASHSAVE_PWMMAX_3, PWM_max[2]);
				if (PWM_Get_LED_3()>temp2)
				{
					PWM_Set_LED_3(temp2);
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Max PWM kanal 3=",0);
					USART1_SendInteger(temp2);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_MAXPWMKANAL3_EXIT:
				break;
			}
			case 10:													// Nastaveni max. PWM 4
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Max PWM kanal 4",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_MAXPWMKANAL4_EXIT;
					}					
				}
				if(temp2>48000)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				PWM_max[3]= temp2;
				FlashSave_Save16(FLASHSAVE_PWMMAX_4, PWM_max[3]);
				if (PWM_Get_LED_4()>temp2)
				{
					PWM_Set_LED_4(temp2);
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Max PWM kanal 4=",0);
					USART1_SendInteger(temp2);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_MAXPWMKANAL4_EXIT:
				break;
			}
			case 11:													// Nastaveni max. PWM 5
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Max PWM kanal 5",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>5) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENILED_DECODE_MAXPWMKANAL5_EXIT;
					}					
				}
				if(temp2>48000)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				PWM_max[4]= temp2;
				FlashSave_Save16(FLASHSAVE_PWMMAX_5, PWM_max[4]);
				if (PWM_Get_LED_5()>temp2)
				{
					PWM_Set_LED_5(temp2);
				}
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Max PWM kanal 5=",0);
					USART1_SendInteger(temp2);					
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENILED_DECODE_MAXPWMKANAL5_EXIT:
				break;
			}
			case 12:													// Zapnuti automatickeho rezimu na kanalu 1
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 1->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<1);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<0);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 1->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 13:													// Zapnuti automatickeho rezimu na kanalu 2
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 2->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<2);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<1);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 2->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 14:													// Zapnuti automatickeho rezimu na kanalu 3
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 3->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<3);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<2);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 3->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 15:													// Zapnuti automatickeho rezimu na kanalu 4
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 4->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<4);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<3);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 4->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 16:													// Zapnuti automatickeho rezimu na kanalu 5
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 5->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<5);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<4);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 5->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 17:													// Zapnuti automatickeho rezimu na kanalu 6
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Kanal 6->AUTOMATIKA",1);
					USART1_FreeMUTEX();
				#endif
				CheckBox|=(1<<6);
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					AutomatickyRezim|= (1<<5);						// Aktivace automatickeho rezimu (podle planovace)
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Kanal 6->AUTOMATIKA",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
		}
	}
	// Deaktivace vsech prvku ovladanych checkboxem ktere nebyly pritomny v odeslanem formulari (-> nebyly zaskrtnuty)
	if(!(CheckBox&(1<<0)))				// Vypnuti LED kanalu 6
	{
		PWM_Set_LED_6_OFF();
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 6 OFF",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<1)))				// Prepnuti kanalu 1 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<0);						// Deaktivace automatickeho rezimu (podle planovace)
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 1->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<2)))				// Prepnuti kanalu 2 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<1);						// Deaktivace automatickeho rezimu (podle planovace)
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 2->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<3)))				// Prepnuti kanalu 3 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<2);						// Deaktivace automatickeho rezimu (podle planovace)
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 3->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<4)))				// Prepnuti kanalu 4 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<3);						// Deaktivace automatickeho rezimu (podle planovace)
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 4->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<5)))				// Prepnuti kanalu 5 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<4);						// Deaktivace automatickeho rezimu (podle planovace)
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 5->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	if(!(CheckBox&(1<<6)))				// Prepnuti kanalu 6 na manualni rezim
	{
		AutomatickyRezim&= ~(1<<5);						// Deaktivace automatickeho rezimu (podle planovace)		
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SAVE > Kanal 6->MANUAL",1);
			USART1_FreeMUTEX();
		#endif
	}
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > KONEC",1);
		USART1_FreeMUTEX();
	#endif
	FlashSave_Save16(FLASHSAVE_LEDREZIM, AutomatickyRezim);
}

/* -------------------------------------------------
 Funkce dekoduje data z formulare predana metodou GET
 ------------------------------------------------ */
void WWW_DecodeFormGET_NastaveniSystemu(uint8_t *RX_Buffer)
{
	uint16_t OffsetHledani;
	uint8_t Parametr;
	uint16_t HodnotaZacatek;
	uint8_t HodnotaDelka,j,k;
	uint16_t i,temp,temp2;
	uint16_t TempArray[3] = {0x00,0x00,0x00};
	uint8_t PrepsatDatumCas = 0;
	const uint16_t Rady[5] = {1,10,100,1000,10000};

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > Zacatek zpracovani",1);
		USART1_FreeMUTEX();
	#endif

	OffsetHledani=WWW_GetFormParamStart(RX_Buffer);							// Nalezeni zacatku requestu (po znaku '?')
	while(OffsetHledani!=0)
	{
		OffsetHledani=WWW_GetFormHodnota(OffsetHledani,&Parametr,&HodnotaZacatek,&HodnotaDelka,RX_Buffer);
		if(OffsetHledani==0)												// Overeni jestli funkce nejaky parametr nasla
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM GET > Konec vyhledavani",1);
				USART1_FreeMUTEX();
			#endif
			break;
		}
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM Parametr > ID=",0);
			USART1_SendInteger(Parametr);
			USART1_Send(" Hodnota='",0);
			for(i=0;i<HodnotaDelka;i++)
			{
				USART1_Write(RX_Buffer[HodnotaZacatek+i]);
			}
			USART1_Send("'",0);
			USART1_Send_Enter();
			USART1_FreeMUTEX();
		#endif
		switch(Parametr)
		{
			case 1:													// Povoleni prepsat cas
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Povoleni prepsat cas",1);
					USART1_FreeMUTEX();
				#endif				
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					PrepsatDatumCas|=(1<<0);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Povolen prepis casu",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 2:													// Povoleni prepsat datum
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Povoleni prepsat datum",1);
					USART1_FreeMUTEX();
				#endif				
				if(HodnotaDelka!=1)			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = (RX_Buffer[HodnotaZacatek+0]-'0');					
				if(temp==1)											// Vybrano povolit
				{						
					PrepsatDatumCas|=(1<<1);
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM SAVE > Povolen prepis datumu",1);
						USART1_FreeMUTEX();
					#endif
				}
				else												// spatny znak
				{
					break;
				}
				break;				
			}
			case 3:														// Cas
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Cas",1);
					USART1_FreeMUTEX();
				#endif
				if((PrepsatDatumCas & (1<<0))==0)						// Kontrola povoleni prepsat cas
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Nepovolena zmena casu",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				if((HodnotaDelka<9) | (HodnotaDelka>12))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<3;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<2;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if(((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]=='A') &  
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]=='3') & 
							(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]=='%')) | 
						(k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISYSTEMU_DECODE_CAS_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISYSTEMU_DECODE_CAS_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_CAS_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(3-1))											// Preskoceni kontroly neexistujici dvojtecky za poslednim radem casu (hodin)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-0]!='A') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-1]!='3') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k-2]!='%'))			// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_CAS_EXIT;
						}
					}
WWW_NASTAVENISYSTEMU_DECODE_CAS_NEXT:
					k+=3;												// Posun na dalsi znak za teckou
					if(((temp2>59) & (i<2)) | ((temp2>23) & (i==2)))	// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_CAS_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				SetTime(TempArray[2],TempArray[1],TempArray[0]);		// Ulozeni casu v reverznim poradi (do temp byla ukladana pozpatku)
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > cas=",0);					
					USART1_SendInteger(TempArray[2]);
					USART1_Send(":",0);
					USART1_SendInteger(TempArray[1]);
					USART1_Send(":",0);
					USART1_SendInteger(TempArray[0]);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_NASTAVENISYSTEMU_DECODE_CAS_EXIT:	
				break;
			}
			case 4:														// Datum
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Datum",1);
					USART1_FreeMUTEX();
				#endif
				if((PrepsatDatumCas & (1<<1))==0)						// Kontrola povoleni prepsat datum
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Nepovolena zmena datumu",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				if((HodnotaDelka<8) | (HodnotaDelka>10))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				k=0;													// Vynulovani posunu -> zacina se na poslednim znaku
				for(i=0;i<3;i++)										// Prochazeni jednotlivych radu casu (hodiny, minuty, vteriny)
				{
					temp2=0;
					for(j=0;j<4;j++)									// Prochazeni jednotlivych cifer v danem radu
					{
						temp = RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k];
						if((temp=='.') | (k>=HodnotaDelka))				// Hledani predcasne tecky (byte ma mene nez 3 cifry)
						{
							if(j>0)										// Byte adresy musi mit alespon 1 cifru
							{								
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > Zkracene cislo",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISYSTEMU_DECODE_DATUM_NEXT;	// Odskok na ulozeni docasne hodnoty
							}
							else
							{
								#ifdef DEBUG
									USART1_WaitForMUTEX();
									USART1_SetMUTEX();
									USART1_Send("FORM DECODE > i=",0);
									USART1_SendInteger(i);
									USART1_Send(", j=",0);
									USART1_SendInteger(j);
									USART1_Send(", k=",0);
									USART1_SendInteger(k);
									USART1_Send_Enter();
									USART1_Send("FORM DECODE > Cislo nema alespon 1 cifru->exit",1);
									USART1_FreeMUTEX();
								#endif
								goto WWW_NASTAVENISYSTEMU_DECODE_DATUM_EXIT;
							}
						}
						if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: znak neni cislo->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_DATUM_EXIT;
						}
						temp2+=(temp-'0')*Rady[j];						// Docasne ulozeni cisla
						k++;											// Posun na dalsi znak (o jeden doleva)
					}					
					if(i<(3-1))											// Preskoceni kontroly neexistujici tecky za poslednim radem datumu (dny)
					{
						if(RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-k]!='.')		// Kontrola dvojtecky (pokud jsou pritomny vsechny 2 cifry radu
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chybi dvojtecka->exit",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_DATUM_EXIT;
						}
					}
WWW_NASTAVENISYSTEMU_DECODE_DATUM_NEXT:
					k++;												// Posun na dalsi znak za teckou
					if(((temp2>2100) & (i==0)) | ((temp2>12) & (i==1)) | ((temp2>31) & (i==2)))	// Kontrola prekroceni maxima
					{
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Prekrocena max. hodnota",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_DATUM_EXIT;
					}
					TempArray[i]=temp2;									// Ulozeni do docasne promenne (aby pri zjisteni chybneho zadan mohla byt ponechana puvodni hodnota)
				}								
				RTC_SetDate(TempArray[2],TempArray[1],TempArray[0]);		// Ulozeni casu v reverznim poradi (do temp byla ukladana pozpatku)
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > datum=",0);					
					USART1_SendInteger(TempArray[2]);
					USART1_Send(".",0);
					USART1_SendInteger(TempArray[1]);
					USART1_Send(".",0);
					USART1_SendInteger(TempArray[0]);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif								
WWW_NASTAVENISYSTEMU_DECODE_DATUM_EXIT:	
				break;
			}			
			case 5:													// Komparacni teplota 1
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Komparacni teplota 1",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<5) | (HodnotaDelka>7))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Chyba: Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]);
					if(i==1)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-1]=='C') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-2]=='2') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-3]=='%'))		// Kontrola pritomnosti desetinne carky
						{
							i+=2;									// Preskoceni "2C"
							continue;								// Preskoceni "%"
						}
						else
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: Nenalezena desetinna carka",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA1_EXIT;
						}
					}					
					if((temp<'0') | (temp>'9'))										// Kontrola jestli bylo zadano cislo
					{						
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Znak neni cislo",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA1_EXIT;
					}					
					if(i==0)
					{
						temp2 += (temp-'0')*Rady[i];
					}
					else
					{
						temp2 += (temp-'0')*Rady[i-3];
					}
				}
				FANtemp[0] = temp2;									// Ulozeni
				FlashSave_Save16(FLASHSAVE_FANTEMP_0, FANtemp[0]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Teplota 1=",0);
					USART1_SendInteger(FANtemp[0]);
					USART1_Send(" x 0,1 °C",1);
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA1_EXIT:
				break;
			}
			case 6:													// Nastaveni vykonu ventilatoru pro teplotu 1
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon FAN teplota 1",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN1_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = ((48000/100) * temp2);
				FANval[0]=temp;
				FlashSave_Save16(FLASHSAVE_FANVAL_0, FANval[0]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > FAN teplota 1=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN1_EXIT:
				break;
			}
			case 7:													// Komparacni teplota 2
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Komparacni teplota 2",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<5) | (HodnotaDelka>7))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Chyba: Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]);
					if(i==1)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-1]=='C') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-2]=='2') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-3]=='%'))		// Kontrola pritomnosti desetinne carky
						{
							i+=2;									// Preskoceni "2C"
							continue;								// Preskoceni "%"
						}
						else
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: Nenalezena desetinna carka",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA2_EXIT;
						}
					}					
					if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
					{						
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Znak neni cislo",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA2_EXIT;
					}					
					if(i==0)
					{
						temp2 += (temp-'0')*Rady[i];
					}
					else
					{
						temp2 += (temp-'0')*Rady[i-3];
					}
				}
				FANtemp[1] = temp2;									// Ulozeni
				FlashSave_Save16(FLASHSAVE_FANTEMP_1, FANtemp[1]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Teplota 2=",0);
					USART1_SendInteger(FANtemp[1]);
					USART1_Send(" x 0,1 °C",1);
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA2_EXIT:
				break;
			}
			case 8:													// Nastaveni vykonu ventilatoru pro teplotu 2
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon FAN teplota 2",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN2_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = ((48000/100) * temp2);
				FANval[1]=temp;
				FlashSave_Save16(FLASHSAVE_FANVAL_1, FANval[1]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > FAN teplota 2=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN2_EXIT:
				break;
			}
			case 9:													// Komparacni teplota 3
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Komparacni teplota 3",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<5) | (HodnotaDelka>7))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Chyba: Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]);
					if(i==1)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-1]=='C') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-2]=='2') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-3]=='%'))		// Kontrola pritomnosti desetinne carky
						{
							i+=2;									// Preskoceni "2C"
							continue;								// Preskoceni "%"
						}
						else
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: Nenalezena desetinna carka",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA3_EXIT;
						}
					}					
					if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
					{						
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Znak neni cislo",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA3_EXIT;
					}					
					if(i==0)
					{
						temp2 += (temp-'0')*Rady[i];
					}
					else
					{
						temp2 += (temp-'0')*Rady[i-3];
					}
				}
				FANtemp[2] = temp2;									// Ulozeni
				FlashSave_Save16(FLASHSAVE_FANTEMP_2, FANtemp[2]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Teplota 3=",0);
					USART1_SendInteger(FANtemp[2]);
					USART1_Send(" x 0,1 °C",1);
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA3_EXIT:
				break;
			}
			case 10:													// Nastaveni vykonu ventilatoru pro teplotu 3
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon FAN teplota 3",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN3_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = ((48000/100) * temp2);
				FANval[2]=temp;
				FlashSave_Save16(FLASHSAVE_FANVAL_2, FANval[2]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > FAN teplota 3=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN3_EXIT:
				break;
			}
			case 11:													// Komparacni teplota 4
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Komparacni teplota 4",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<5) | (HodnotaDelka>7))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Chyba: Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]);
					if(i==1)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-1]=='C') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-2]=='2') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-3]=='%'))		// Kontrola pritomnosti desetinne carky
						{
							i+=2;									// Preskoceni "2C"
							continue;								// Preskoceni "%"
						}
						else
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: Nenalezena desetinna carka",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA4_EXIT;
						}
					}					
					if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
					{						
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Znak neni cislo",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA4_EXIT;
					}					
					if(i==0)
					{
						temp2 += (temp-'0')*Rady[i];
					}
					else
					{
						temp2 += (temp-'0')*Rady[i-3];
					}
				}
				FANtemp[3] = temp2;									// Ulozeni
				FlashSave_Save16(FLASHSAVE_FANTEMP_3, FANtemp[3]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Teplota 4=",0);
					USART1_SendInteger(FANtemp[3]);
					USART1_Send(" x 0,1 °C",1);
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_TEPLOTA4_EXIT:
				break;
			}
			case 12:												// Nastaveni vykonu ventilatoru pro teplotu 4
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Vykon FAN teplota 4",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka>3) | (HodnotaDelka==0))			// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]-'0')*Rady[i];
					temp2 += temp;
					if(temp>9*Rady[i])								// Kontrola jestli bylo zadano cislo
					{						
						goto WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN4_EXIT;
					}					
				}
				if(temp2>100)
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Prekrocena max. velikost",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}				
				temp = ((48000/100) * temp2);
				FANval[3]=temp;
				FlashSave_Save16(FLASHSAVE_FANVAL_3, FANval[3]);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > FAN teplota 4=",0);
					USART1_SendInteger(temp2);
					USART1_Send(" % -> ",0);
					USART1_SendInteger(temp);
					USART1_Send_Enter();
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_VYKONFAN4_EXIT:
				break;
			}
			case 13:													// Komparacni teplota pro vypnuti LED
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM DECODE > Komparacni teplota vypnuti LED",1);
					USART1_FreeMUTEX();
				#endif
				if((HodnotaDelka<5) | (HodnotaDelka>7))				// Kontrola spravne delky
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("FORM DECODE > Chyba: Spatna delka hodnoty",1);
						USART1_FreeMUTEX();
					#endif
					break;
				}
				temp2 = 0;
				for(i=0;i<HodnotaDelka;i++)							// Prepocet ASCII cisla na 16-bit format
				{
					temp = (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-i]);
					if(i==1)
					{
						if((RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-1]=='C') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-2]=='2') & 
						   (RX_Buffer[HodnotaZacatek+(HodnotaDelka-1)-3]=='%'))		// Kontrola pritomnosti desetinne carky
						{
							i+=2;									// Preskoceni "2C"
							continue;								// Preskoceni "%"
						}
						else
						{
							#ifdef DEBUG
								USART1_WaitForMUTEX();
								USART1_SetMUTEX();
								USART1_Send("FORM DECODE > Chyba: Nenalezena desetinna carka",1);
								USART1_FreeMUTEX();
							#endif
							goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTAVYPNOUT_EXIT;
						}
					}					
					if((temp<'0') | (temp>'9'))						// Kontrola jestli bylo zadano cislo
					{						
						#ifdef DEBUG
							USART1_WaitForMUTEX();
							USART1_SetMUTEX();
							USART1_Send("FORM DECODE > Chyba: Znak neni cislo",1);
							USART1_FreeMUTEX();
						#endif
						goto WWW_NASTAVENISYSTEMU_DECODE_TEPLOTAVYPNOUT_EXIT;
					}					
					if(i==0)
					{
						temp2 += (temp-'0')*Rady[i];
					}
					else
					{
						temp2 += (temp-'0')*Rady[i-3];
					}
				}
				SHUTDOWNtemp = temp2;									// Ulozeni
				FlashSave_Save16(FLASHSAVE_SHUTDOWNTEMP, SHUTDOWNtemp);
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("FORM SAVE > Teplota vypnout=",0);
					USART1_SendInteger(SHUTDOWNtemp);
					USART1_Send(" x 0,1 °C",1);
					USART1_FreeMUTEX();
				#endif
WWW_NASTAVENISYSTEMU_DECODE_TEPLOTAVYPNOUT_EXIT:
				break;
			}
		}
	}
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM GET > KONEC",1);
		USART1_FreeMUTEX();
	#endif
}

/* -------------------------------------------------
 Funkce vrati parametr zadany nazvem nasledujici 
 bezprostredne po '?'
 ------------------------------------------------ */
uint8_t WWW_GetParametr(uint8_t *Nazev,uint8_t *RX_Buffer)
{
	uint16_t offset;
	uint8_t i;
	uint16_t cislo;
	const uint8_t Nasobky[3] = {100,10,1};

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("GET PARAMETR > Nazev=",0);
		USART1_Send(Nazev,1);		
		USART1_FreeMUTEX();
	#endif

	offset=WWW_GetFormParamStart(RX_Buffer);
	if(offset==0)
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("GET PARAMETR > Parametr nenalezen!",1);
			USART1_FreeMUTEX();
		#endif
		return(0xFF);
	}
	if((RX_Buffer[offset+1]==Nazev[0])&(RX_Buffer[offset+2]=='=')) 	// Overeni jestli se v requestu nachazi hledany parametr
	{
		cislo=0;
		for(i=0;i<3;i++)
		{
			if((RX_Buffer[offset+3+i]>='0')&(RX_Buffer[offset+3+i]<='9'))		// Overeni ze je znak cislo
			{
				cislo+=(RX_Buffer[offset+3+i]-'0')*Nasobky[i];
			}
			else if((RX_Buffer[offset+3+i]==' ')|(RX_Buffer[offset+3+i]==0x00))
			{
				if(i!=0)
				{
					for(;i<3;i++)										// Zarovnani cisla pokud ma mene nez 3 cifry
					{
						cislo=cislo/10;						
					}
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("GET PARAMETR > Hodnota=",0);				
						USART1_SendInteger(cislo);
						USART1_Send_Enter();
						USART1_FreeMUTEX();
					#endif
					return(cislo);
				}
				else													// Paramtr ma 0 cifer -> chyba
				{
					#ifdef DEBUG
						USART1_WaitForMUTEX();
						USART1_SetMUTEX();
						USART1_Send("GET PARAMETR > Hodnota ma 0 cifer",1);								
						USART1_FreeMUTEX();
					#endif
					return(0xFF);
				}
			}
			else
			{
				#ifdef DEBUG
					USART1_WaitForMUTEX();
					USART1_SetMUTEX();
					USART1_Send("GET PARAMETR > Neexistujici hodnota",1);
					USART1_FreeMUTEX();
				#endif
				return(0xFF);
			}
		}
		if(cislo<=255)													// Kontrola preteceni parametru
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("GET PARAMETR > Hodnota=",0);				
				USART1_SendInteger(cislo);
				USART1_Send_Enter();
				USART1_FreeMUTEX();
			#endif
			return(cislo);
		}
		else															
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("GET PARAMETR > Neplatna Hodnota",1);								
				USART1_FreeMUTEX();
			#endif
			return(0xFF);
		}
	}
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("GET PARAMETR > V requestu neni zadny parametr!",1);
		USART1_FreeMUTEX();
	#endif
	return(0xFF);
}
/* -------------------------------------------------
 Funkce vrati zacatek requestu poslaneho z formulare 
 metodou GET (offset odpovidajici znaku '?')
 ------------------------------------------------ */
uint16_t WWW_GetFormParamStart(uint8_t *RX_Buffer)
{
	uint16_t OffsetZacatku;
	uint8_t DelkaRequestu;

	DelkaRequestu = HTTP_GetRequestFromGET(RX_Buffer, &OffsetZacatku);
	// Overeni jestli obsahuje request nejake zpracovatelne parametry
	if(DelkaRequestu<3)
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM GET > Request je priliz kratky (<3 znaky)",1);
			USART1_FreeMUTEX();
		#endif
		return(0);
	}
	// Nalezeni zacatku parametru
	while((RX_Buffer[OffsetZacatku]!='?') & (RX_Buffer[OffsetZacatku]!=' ') & (DelkaRequestu!=0))
	{
		OffsetZacatku++;
		DelkaRequestu--;
	}
	if((RX_Buffer[OffsetZacatku]=='?') & (DelkaRequestu!=0))
	{
		return(OffsetZacatku);
	}
	else
	{
		return(0);
	}
}

/* -------------------------------------------------
 Funkce vrati offset pro dalsi hledani a do 
 predanych promennych ulozi ID dekodovaneho parametru
 offset zacatku hodnoty a jeji delku
 ------------------------------------------------ */
uint16_t WWW_GetFormHodnota(uint16_t ZacatekHledani, uint8_t *Parametr, uint16_t *ZacatekHodnoty, uint8_t *DelkaHodnoty, uint8_t *RX_Buffer)
{
	*DelkaHodnoty = 0;	

	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM SEARCH > Hledam...",1);
		USART1_FreeMUTEX();
	#endif

	// Overeni pritomnosti parametru (jestli se uz nedoslo na konec GET requestu)
	if(RX_Buffer[ZacatekHledani]==' ')
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SEARCH > Nenalezen (dalsi) parametr",1);
			USART1_FreeMUTEX();
		#endif
		return(0);
	}
	
	// Nalezeni zacatku parametru (pokud se na nem uz "nestalo"
	while((RX_Buffer[ZacatekHledani]!='&') & (RX_Buffer[ZacatekHledani]!='?'))	
	{
		ZacatekHledani++;
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SEARCH > Posun zacatku parametru",1);
			USART1_FreeMUTEX();
		#endif
		if(RX_Buffer[ZacatekHledani]==0x00)							// Zamezeni aby se posunem dostal ukazatel uplne mimo prijaty request
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM SEARCH > Chyba. Nalezen '0x00'",1);
				USART1_FreeMUTEX();
			#endif
			return(0);
		}
		if(RX_Buffer[ZacatekHledani]==' ')							// Zamezeni aby se posunem dostal ukazatel uplne mimo prijaty request
		{
			#ifdef DEBUG
				USART1_WaitForMUTEX();
				USART1_SetMUTEX();
				USART1_Send("FORM SEARCH > Nalezena mezera->konec",1);
				USART1_FreeMUTEX();
			#endif
			return(0);
		}
	}
	
	// Vyhledavani nazvu parametru
	ZacatekHledani++;
	if((RX_Buffer[ZacatekHledani+0]<'0') | (RX_Buffer[ZacatekHledani+0]>'9'))		// Overeni jestli je znak cislice
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SEARCH > Nazev neni cislo",1);
			USART1_FreeMUTEX();
		#endif
		return(0);
	}
	if(RX_Buffer[ZacatekHledani+1]=='=')										// Zjisteni jestli je parametr jedno nebo dvou znakovy
	{
		*Parametr=RX_Buffer[ZacatekHledani+0]-'0';
		ZacatekHledani+=1;
	}
	else
	{
		*Parametr=(RX_Buffer[ZacatekHledani+0]-'0')*10+(RX_Buffer[ZacatekHledani+1]-'0');
		ZacatekHledani+=2;
	}
	
	// Vyhledani hodnoty parametru
	if(RX_Buffer[ZacatekHledani]!='=')					// Kontrola pritomnosti deliciho znaku => '='
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SEARCH > Chyba overeni pritomnosti '=' za parametrem",1);
			USART1_FreeMUTEX();
		#endif
		return(0);
	}
	ZacatekHledani++;									// Posun na prvni znak hodnoty parametru
	*ZacatekHodnoty = ZacatekHledani;
	while((RX_Buffer[ZacatekHledani]!='&') & (*DelkaHodnoty<WWW_MAX_DELKA_HODNOTY) & (RX_Buffer[ZacatekHledani]!=' '))
	{
		*DelkaHodnoty=*DelkaHodnoty+1;
		ZacatekHledani++;		
	}
	#ifdef DEBUG
		USART1_WaitForMUTEX();
		USART1_SetMUTEX();
		USART1_Send("FORM SEARCH > Delka parametru: ",0);
		USART1_SendInteger(*DelkaHodnoty);
		USART1_Send_Enter();
		USART1_FreeMUTEX();
	#endif

	if(*DelkaHodnoty>=WWW_MAX_DELKA_HODNOTY)
	{
		#ifdef DEBUG
			USART1_WaitForMUTEX();
			USART1_SetMUTEX();
			USART1_Send("FORM SEARCH > Prekrocena maximalni delka hodnoty parametru",1);
			USART1_FreeMUTEX();
		#endif
	}
	return(ZacatekHledani);
}
/* -------------------------------------------------
 Funkce slouzi k prochazeni dat vkladanych do 
 paketu z FLASH a vyhledavani a vyplnovani znacek 
 systemovymi promennymy. Funkce predava index dalsiho
 znaku kery se ma vlozit po provedeni teto funkce.
 ------------------------------------------------ */
void WWW_InsertSystemDataFromFLASH(const uint8_t *data, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
 	uint16_t i=0;
	uint8_t j=0;
	uint8_t kod=0;
	uint32_t temp;
	uint8_t temp1;
	uint8_t temp2;
	/* 
	Struktura znacky: 
	 [0] ... zacatek znacky - klic podle ktereho se rozlysuje znacka od ostatniho textu
	 [1] ... znacka skupiny do ktere znacka patri (kvuli urychleni prochazeni)
	 [2] ... prvni ciselna cast znacky konkretni promenne
	 [3] ... druha ciselna cast znacky konkretni promenne
	 Celkova delka znacky jsou 4 znaky. Cisela jsou kodovany v ASCII 
	*/
	while(data[i]!=0x00)
	{
		if(data[i+0]=='$')									// Vyhledavani znacky zacatku vkladaneho obsahu
		{
			/* Nalezen zacatek znacky - dekodovani */
			if((data[i+1]==0x00) | (data[i+2]==0x00) | (data[i+3]==0x00))	// Overeni jestli vsechny parametry znacky jsou ve vkladanem poly (jestli nekonci v pulce)
			{
				i++;
				continue;
			}
			kod = ((data[i+2]-'0')*10) + (data[i+3]-'0');	// Prepocet kodu znacky z ASCII formatu dvou znaku na cislo
			// Rozpoznani skupiny
			switch(data[i+1])
			{
				case 'c':									//Skupina urcujici znacky casu a datumu
				{
					switch(kod)
					{
						case 1:								// Vlozeni aktualniho casu ve formatu HH:MM:SS
						{
							WWW_InsertInt16(Time_Hodiny,0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(Time_Minuty,0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(Time_Vteriny,0,RX_Buffer,TX_Buffer);							
							break;
						}
						case 2:								// Vlozeni aktualniho datumu ve formatu DD:MM:RRRR
						{
							WWW_InsertInt16(Time_Den,0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(Time_Mesic,0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(Time_Rok,0,RX_Buffer,TX_Buffer);							
							break;
						}
						case 3:								// Vlozeni aktualniho dne v tydnu ve formatu Pondeli-Nedele
						{							
							TCP_AddDataStringFromFLASH(JmenaDni3[Time_DenVTydnu],RX_Buffer,TX_Buffer);
							break;
						}
						case 4:
						{
							WWW_InsertInt16(RunTime/(24*60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString("dní ",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((RunTime%(24*60*60))/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(((RunTime%(24*60*60))%(60*60))/60,0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(((RunTime%(24*60*60))%(60*60))%60,0,RX_Buffer,TX_Buffer);
							break;
						}
					}
					break;
				}
				case 't':									//Skupina urcujici znacky teploty a relativni vlhkosti
				{
					switch(kod)
					{
						case 1:								// Vlozeni poctu teplotnich cidel
						{
							WWW_InsertInt16(PocetCidel,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 2:								// Vlozeni aktualni teploty chladice LED
						{
							WWW_InsertTemp(Teplota[0],RX_Buffer,TX_Buffer);
							break;
						}
						case 3:								// Vlozeni maximalni teploty chladice LED
						{
							WWW_InsertTemp(TeplotaHistorie[0][1],RX_Buffer,TX_Buffer);
							break;
						}
						case 4:								// Vlozeni minimalni teploty chladice LED
						{
							WWW_InsertTemp(TeplotaHistorie[0][0],RX_Buffer,TX_Buffer);
							break;
						}
						case 5:								// Vlozeni serioveho cisla cidla chladice LED
						{
							for(j=0;j<DS18X20_SP_SIZE-1;j++)
							{
								WWW_InsertHex(FLASHSensorIDs[0][j],RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 6:								// Vlozeni aktualni teploty chladice tranzistoru
						{
							WWW_InsertTemp(Teplota[1],RX_Buffer,TX_Buffer);
							break;
						}
						case 7:								// Vlozeni maximalni teploty chladice tranzistoru
						{
							WWW_InsertTemp(TeplotaHistorie[1][1],RX_Buffer,TX_Buffer);
							break;
						}
						case 8:								// Vlozeni minimalni teploty chladice tranzistoru
						{
							WWW_InsertTemp(TeplotaHistorie[1][0],RX_Buffer,TX_Buffer);
							break;
						}
						case 9:								// Vlozeni serioveho cisla cidla chladice tranzistorů
						{
							for(j=0;j<DS18X20_SP_SIZE-1;j++)
							{
								WWW_InsertHex(FLASHSensorIDs[1][j],RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 10:							// Vlozeni aktualni teploty externiho cidla
						{
							WWW_InsertTemp(Teplota[2],RX_Buffer,TX_Buffer);
							break;
						}
						case 11:							// Vlozeni maximalni teploty externiho cidla
						{
							WWW_InsertTemp(TeplotaHistorie[2][1],RX_Buffer,TX_Buffer);
							break;
						}
						case 12:							// Vlozeni minimalni teploty externiho cidla
						{
							WWW_InsertTemp(TeplotaHistorie[2][0],RX_Buffer,TX_Buffer);
							break;
						}
						case 13:							// Vlozeni serioveho cisla externiho cidla chladice
						{
							for(j=0;j<DS18X20_SP_SIZE-1;j++)
							{
								WWW_InsertHex(FLASHSensorIDs[2][j],RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 14:							// Vlozeni aktualni relativni vzdusne vlhkosti
						{
							if(Humidity==0xFF)
							{
								 TCP_AddDataString("Chyba",RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(Humidity,0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 15:							// Vlozeni maximalni relativni vzdusne vlhkosti
						{
							if(HumidityHistorie[1]==0xFF)
							{
								 TCP_AddDataString("Chyba",RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(HumidityHistorie[1],0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 16:							// Vlozeni minimalni relativni vzdusne vlhkosti
						{
							if(HumidityHistorie[0]==0xFF)
							{
								 TCP_AddDataString("Chyba",RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(HumidityHistorie[0],0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 17:							// Vlozeni 1. porovnavaci teploty pro nastavovani otacek ventilatoru
						{
							WWW_InsertTemp(FANtemp[0],RX_Buffer,TX_Buffer);
							break;
						}
						case 18:							// Vlozeni 1. nastavovani otacek ventilatoru
						{
							WWW_InsertInt16(FANval[0]/480,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 19:							// Vlozeni 2. porovnavaci teploty pro nastavovani otacek ventilatoru
						{
							WWW_InsertTemp(FANtemp[1],RX_Buffer,TX_Buffer);
							break;
						}
						case 20:							// Vlozeni 2. nastavovani otacek ventilatoru
						{
							WWW_InsertInt16(FANval[1]/480,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 21:							// Vlozeni 3. porovnavaci teploty pro nastavovani otacek ventilatoru
						{
							WWW_InsertTemp(FANtemp[2],RX_Buffer,TX_Buffer);
							break;
						}
						case 22:							// Vlozeni 3. nastavovani otacek ventilatoru
						{
							WWW_InsertInt16(FANval[2]/480,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 23:							// Vlozeni 4. porovnavaci teploty pro nastavovani otacek ventilatoru
						{
							WWW_InsertTemp(FANtemp[3],RX_Buffer,TX_Buffer);
							break;
						}
						case 24:							// Vlozeni 4. nastavovani otacek ventilatoru
						{
							WWW_InsertInt16(FANval[3]/480,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 25:							// Vlozeni porovnavaci teploty pro vypnuti LED (proti prehrati)
						{
							WWW_InsertTemp(SHUTDOWNtemp,RX_Buffer,TX_Buffer);
							break;
						}
						case 26:
						{
							if(FANmode)
							{
								TCP_AddDataString("Manuální nastavení",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Automatická regulace",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 27:							// Vlozeni aktualni teplotu MCU
						{
							WWW_InsertTemp(ADC_GetTempMCU(),RX_Buffer,TX_Buffer);
							break;
						}
						case 28:								// Vlozeni maximalni teploty MCU
						{
							WWW_InsertTemp(TeplotaHistorie[3][1],RX_Buffer,TX_Buffer);
							break;
						}
						case 29:								// Vlozeni minimalni teploty MCU
						{
							WWW_InsertTemp(TeplotaHistorie[3][0],RX_Buffer,TX_Buffer);
							break;
						}
					}
					break;
				}
				case 'p':									//Skupina urcujici znacky proudu LED diodami
				{
					switch(kod)
					{
						case 1:								// Vlozeni aktualniho proudu 1. kanalu
						{
							if(ADC_HodnotyPrumer[ADC_VALUE_LED1]<=10)	// Filtrace sumu pri vypnutych LED
							{
								WWW_InsertInt16(0,0,RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(ADC_ConvertTomA(ADC_HodnotyPrumer[ADC_VALUE_LED1]),0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 2:								// Vlozeni maximalniho proudu 1. kanalu
						{
							TCP_AddDataString("1400",RX_Buffer,TX_Buffer);
							break;
						}
						case 3:								// Vlozeni aktualniho proudu 2. kanalu
						{							
							if(ADC_HodnotyPrumer[ADC_VALUE_LED2]<=10)	// Filtrace sumu pri vypnutych LED
							{
								WWW_InsertInt16(0,0,RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(ADC_ConvertTomA(ADC_HodnotyPrumer[ADC_VALUE_LED2]),0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 4:								// Vlozeni maximalniho proudu 2. kanalu
						{
							TCP_AddDataString("1000",RX_Buffer,TX_Buffer);
							break;
						}
						case 5:								// Vlozeni aktualniho proudu 3. kanalu
						{
							if(ADC_HodnotyPrumer[ADC_VALUE_LED3]<=10)	// Filtrace sumu pri vypnutych LED
							{
								WWW_InsertInt16(0,0,RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(ADC_ConvertTomA(ADC_HodnotyPrumer[ADC_VALUE_LED3]),0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 6:								// Vlozeni maximalniho proudu 3. kanalu
						{
							TCP_AddDataString("1000",RX_Buffer,TX_Buffer);
							break;
						}
						case 7:								// Vlozeni aktualniho proudu 4. kanalu
						{
							if(ADC_HodnotyPrumer[ADC_VALUE_LED4]<=10)	// Filtrace sumu pri vypnutych LED
							{
								WWW_InsertInt16(0,0,RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(ADC_ConvertTomA(ADC_HodnotyPrumer[ADC_VALUE_LED4]),0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 8:								// Vlozeni maximalniho proudu 4. kanalu
						{
							TCP_AddDataString("350",RX_Buffer,TX_Buffer);
							break;
						}
						case 9:								// Vlozeni aktualniho proudu 5. kanalu
						{
							if(ADC_HodnotyPrumer[ADC_VALUE_LED5]<=10)	// Filtrace sumu pri vypnutych LED
							{
								WWW_InsertInt16(0,0,RX_Buffer,TX_Buffer);
							}
							else
							{
								WWW_InsertInt16(ADC_ConvertTomA(ADC_HodnotyPrumer[ADC_VALUE_LED5]),0,RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 10:								// Vlozeni maximalniho proudu 5. kanalu
						{
							TCP_AddDataString("700",RX_Buffer,TX_Buffer);
							break;
						}
						case 11:
						{
							if(PWM_Get_LED6())
							{
								TCP_AddDataString("20",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("0",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 12:								// Vlozeni maximalniho proudu 6. kanalu
						{
							TCP_AddDataString("20",RX_Buffer,TX_Buffer);
							break;
						}
						case 13:								// Vlozeni maximalni PWM 1. kanalu
						{
							WWW_InsertInt16(PWM_max[0],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 14:								// Vlozeni maximalni PWM 2. kanalu
						{
							WWW_InsertInt16(PWM_max[1],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 15:								// Vlozeni maximalni PWM 3. kanalu
						{
							WWW_InsertInt16(PWM_max[2],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 16:								// Vlozeni maximalni PWM 4. kanalu
						{
							WWW_InsertInt16(PWM_max[3],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 17:								// Vlozeni maximalni PWM 5. kanalu
						{
							WWW_InsertInt16(PWM_max[4],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 18:								// Vlozeni maximalni PWM 6. kanalu
						{
							TCP_AddDataString("-",RX_Buffer,TX_Buffer);
							break;
						}
						case 19:
						{
							if(AutomatickyRezim & (1<<0))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 20:
						{
							if(AutomatickyRezim & (1<<1))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 21:
						{
							if(AutomatickyRezim & (1<<2))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 22:
						{
							if(AutomatickyRezim & (1<<3))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 23:
						{
							if(AutomatickyRezim & (1<<4))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 24:
						{
							if(AutomatickyRezim & (1<<5))
							{
								TCP_AddDataString("Automatický",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Manuální",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 25:								// Vlozeni aktualni PWM 1. kanalu
						{
							WWW_InsertInt16(PWM_Get_LED_1(),0,RX_Buffer,TX_Buffer);
							break;
						}
						case 26:								// Vlozeni aktualni PWM 2. kanalu
						{
							WWW_InsertInt16(PWM_Get_LED_2(),0,RX_Buffer,TX_Buffer);
							break;
						}
						case 27:								// Vlozeni aktualni PWM 3. kanalu
						{
							WWW_InsertInt16(PWM_Get_LED_3(),0,RX_Buffer,TX_Buffer);
							break;
						}
						case 28:								// Vlozeni aktualni PWM 4. kanalu
						{
							WWW_InsertInt16(PWM_Get_LED_4(),0,RX_Buffer,TX_Buffer);
							break;
						}
						case 29:								// Vlozeni aktualni PWM 5. kanalu
						{
							WWW_InsertInt16(PWM_Get_LED_5(),0,RX_Buffer,TX_Buffer);
							break;
						}
						case 30:								// Vlozeni aktualni PWM 5. kanalu
						{
							if(PWM_Get_LED6())
							{
								TCP_AddDataString("ON",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("OFF",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 31:
						{
							temp = ((uint32_t)PWM_Get_LED_1()*100)/PWM_max[0];
							WWW_InsertInt16(temp,0,RX_Buffer,TX_Buffer);
							break;
						}						
						case 32:
						{
							temp = ((uint32_t)PWM_Get_LED_2()*100)/PWM_max[1];
							WWW_InsertInt16(temp,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 33:
						{
							temp = ((uint32_t)PWM_Get_LED_3()*100)/PWM_max[2];
							WWW_InsertInt16(temp,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 34:
						{
							temp = ((uint32_t)PWM_Get_LED_4()*100)/PWM_max[3];
							WWW_InsertInt16(temp,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 35:
						{
							temp = ((uint32_t)PWM_Get_LED_5()*100)/PWM_max[4];
							WWW_InsertInt16(temp,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 36:
						{
							if(PWM_Get_LED6())
							{
								TCP_AddDataString("100",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("0",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 37:
						{							
							WWW_InsertInt16(LED_Time[0]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[0]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 38:
						{
							WWW_InsertInt16(LED_Time[1]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[1]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 39:
						{							
							WWW_InsertInt16(LED_Time[2]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[2]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 40:
						{							
							WWW_InsertInt16(LED_Time[3]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[3]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 41:
						{							
							WWW_InsertInt16(LED_Time[4]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[4]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 42:
						{							
							WWW_InsertInt16(LED_Time[5]/(60*60),0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(":",RX_Buffer,TX_Buffer);
							WWW_InsertInt16((LED_Time[5]%(60*60))/60,0,RX_Buffer,TX_Buffer);
							break;
						}
					}
					break;
				}
				case 'n':									//Skupina urcujici znacky sitovych adres a portu
				{
					switch(kod)
					{
						case 1:								// Vlozeni IP adresy serveru
						{
							WWW_InsertInt16(my_IP[0],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_IP[1],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_IP[2],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_IP[3],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 2:								// Vlozeni masky podsite serveru
						{
							WWW_InsertInt16(my_MASK[0],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_MASK[1],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_MASK[2],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_MASK[3],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 3:								// Vlozeni IP adresy vychozi brany serveru
						{
							WWW_InsertInt16(my_GATE[0],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_GATE[1],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_GATE[2],0,RX_Buffer,TX_Buffer);
							TCP_AddDataChar('.',RX_Buffer,TX_Buffer,0);
							WWW_InsertInt16(my_GATE[3],0,RX_Buffer,TX_Buffer);
							break;
						}
						case 4:								// Vlozeni MAC adresy serveru
						{
							WWW_InsertHex(my_MAC[0],RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertHex(my_MAC[1],RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertHex(my_MAC[2],RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertHex(my_MAC[3],RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertHex(my_MAC[4],RX_Buffer,TX_Buffer);
							TCP_AddDataChar(':',RX_Buffer,TX_Buffer,0);
							WWW_InsertHex(my_MAC[5],RX_Buffer,TX_Buffer);
							break;
						}
						case 5:								// Vlozeni portu www serveru
						{
							WWW_InsertInt16(my_HTTP_Port,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 6:								// Vlozeni portu UDP serveru
						{
							WWW_InsertInt16(my_UDP_Port,0,RX_Buffer,TX_Buffer);
							break;
						}
						case 7:
						{
							if(ServerEnable&(1<<SERVER_ENABLE_WWW))
							{
								TCP_AddDataString("Povolen",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Zakázán",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 8:
						{
							if(ServerEnable&(1<<SERVER_ENABLE_UDP))
							{
								TCP_AddDataString("Povolen",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Zakázán",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 9:
						{
							if(ServerEnable&(1<<SERVER_ENABLE_TELNET))
							{
								TCP_AddDataString("Povolen",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Zakázán",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 10:
						{
							if(ServerEnable&(1<<SERVER_ENABLE_PING))
							{
								TCP_AddDataString("Povolen",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Zakázán",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 11:							// Vlozeni MAC adresy serveru (bez delicich dvojtecek
						{
							WWW_InsertHex(my_MAC[0],RX_Buffer,TX_Buffer);
							WWW_InsertHex(my_MAC[1],RX_Buffer,TX_Buffer);
							WWW_InsertHex(my_MAC[2],RX_Buffer,TX_Buffer);
							WWW_InsertHex(my_MAC[3],RX_Buffer,TX_Buffer);
							WWW_InsertHex(my_MAC[4],RX_Buffer,TX_Buffer);
							WWW_InsertHex(my_MAC[5],RX_Buffer,TX_Buffer);
							break;
						}
					}
					break;
				}
				case 'E':
				{
					switch(kod)
					{
						case 1:
						{
							WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start1,RX_Buffer,TX_Buffer);
							break;
						}
						case 2:
						{
							WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start2,RX_Buffer,TX_Buffer);
							break;
						}
						case 3:
						{
							WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start3,RX_Buffer,TX_Buffer);
							break;
						}
						case 4:
						{
							WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Start4,RX_Buffer,TX_Buffer);
							break;
						}
						case 5:
						{
							WWW_InsertFromFLASH(WWW_Obsah_Form_Input_Stop,RX_Buffer,TX_Buffer);
							break;
						}
					}
					break;
				}
				case 'l':									//Skupina urcujici znacky Planovace
				{
					switch(kod)
					{
						case 1:								// Stav planovace
						{
							temp2=0;
							for(temp1=0;temp1<6;temp1++)
							{
								if((AutomatickyRezim&(1<<temp1)))
								{
									temp2++;
								}
							}
							if(temp2==0)
							{
								TCP_AddDataString("Zakázán",RX_Buffer,TX_Buffer);
							}
							else if(temp2==6)
							{
								TCP_AddDataString("Povolen",RX_Buffer,TX_Buffer);
							}
							else
							{
								TCP_AddDataString("Povolen (částečně)",RX_Buffer,TX_Buffer);
							}
							break;
						}
						case 2:								// Pocty zaznamu planovace
						{
							Planovac_PocetZaznamu(&temp1,&temp2);
							TCP_AddDataString("Aktivních: ",RX_Buffer,TX_Buffer);
							WWW_InsertInt16(temp2,0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(" Celkem: ",RX_Buffer,TX_Buffer);
							WWW_InsertInt16(temp1,0,RX_Buffer,TX_Buffer);
							TCP_AddDataString(" Maximum: ",RX_Buffer,TX_Buffer);
							WWW_InsertInt16(PLANOVAC_MAXZAZNAMU,0,RX_Buffer,TX_Buffer);
							break;
						}
					}
				}
			}
			i+=3;											// Presun az za konec znacky (na dalsi 'znak')
		}
		else
		{
			TCP_AddDataChar(data[i], RX_Buffer, TX_Buffer, 0);
		}
		i++;												// Posun na dalsi znak
	}
}

/* ------------------------------------------
 Fukce vepise do TX bufferu cislo v ASCII 
 formatu
 ----------------------------------------- */
void WWW_InsertInt16(uint16_t cislo, uint8_t zobrazitnulu, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint16_t temp;
	uint8_t i;
	const uint16_t rady[5] = {10000,1000,100,10,1};
	
	for(i=0;i<5;i++)
	{
		temp=cislo/rady[i];
		if (temp!=0)
		{
			TCP_AddDataChar('0'+temp, RX_Buffer, TX_Buffer, 0);
			zobrazitnulu = 1;
		}
		else if ((zobrazitnulu==1) | (i==4))
		{
			TCP_AddDataChar('0', RX_Buffer, TX_Buffer, 0);
		}
		cislo = cislo-(temp*rady[i]);
	}	
}

/* ------------------------------------------
 Fukce vepise do TX bufferu cislo v HEX 
 formatu (pomoci ASCII znaku)
 ----------------------------------------- */
void WWW_InsertHex(uint8_t cislo, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint8_t tmp;
	uint8_t i;

	for(i=0;i<2;i++)
	{
		if (i==0)
		{
			tmp = (((cislo%16) | ((cislo/16)<<4))&0xF0) >> 4;
		}
		else
		{
			tmp = (((cislo%16) | ((cislo/16)<<4))&0x0F);
		}
		if (tmp>9)
		{
			TCP_AddDataChar('A'+tmp-10, RX_Buffer, TX_Buffer, 0);
		}
		else
		{
			TCP_AddDataChar('0'+tmp, RX_Buffer, TX_Buffer, 0);
		}
	}	
}

/* ------------------------------------------
 Fukce vepise do TX bufferu cislo v HEX 
 formatu (pomoci ASCII znaku)
 ----------------------------------------- */
void WWW_InsertTemp(int16_t teplota, uint8_t *RX_Buffer, uint8_t *TX_Buffer)
{
	uint16_t tmp = 0;
	uint8_t bylanula = 0;
	
	// Zobrazeni neplatne hodnoty teploty
	if(teplota==DS18X20_INVALID_TEMP)
	{
		TCP_AddDataString("Chyba ",RX_Buffer,TX_Buffer);
		return;
	}
	// Znamenko
	if(teplota < 0)		// zaporna teplota
	{
		TCP_AddDataChar('-', RX_Buffer, TX_Buffer, 0);
		teplota = -teplota;					// prevod zaporneho cisla na kladne
	}

	// Stovky
	tmp = teplota / 1000;
	if (tmp==0)
	{
		bylanula = 1;
	}
	else
	{
		TCP_AddDataChar('0'+tmp, RX_Buffer, TX_Buffer, 0);
		bylanula = 0;
	}
	
	// Desitky
	teplota = teplota - (tmp * 1000);
	tmp = teplota / 100;
	if ((tmp==0) && (bylanula == 1))
	{
		
	}
	else
	{
		TCP_AddDataChar('0'+tmp, RX_Buffer, TX_Buffer, 0);
	}
	
	// Jednotky
	teplota = teplota - (tmp * 100);
	tmp = teplota / 10;	
	TCP_AddDataChar('0'+tmp, RX_Buffer, TX_Buffer, 0);
	
	// Desetiny
	tmp = teplota - (tmp * 10);
	TCP_AddDataChar(',', RX_Buffer, TX_Buffer, 0);
	TCP_AddDataChar('0'+tmp, RX_Buffer, TX_Buffer, 0);
}

/* Konec souboru */
