function kontrolaForm()
	{
	var form = document.getElementById('controlled_form');
	puvodni_pozadi = "#9C5B00";
	bool = "true";
	upozorneni = "";
	
	
	if(document.getElementById('name'))
		{
		form.name.style.backgroundColor=puvodni_pozadi;
		if(form.name.value=="")
			{
			upozorneni += "- Je nutno vyplnit jméno!! \n";
			form.name.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('surname'))
		{
		form.surname.style.backgroundColor=puvodni_pozadi;
		if(form.surname.value=="")
			{
			upozorneni += "- Je nutno vyplnit příjmení!! \n";
			form.surname.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('usermail'))
		{
		form.usermail.style.backgroundColor=puvodni_pozadi;
		if(document.getElementById('captcha') && (form.usermail.value=="" || form.usermail.value=="@"))
			{
			upozorneni += "- Je nutno vyplnit email! \n";
			form.usermail.style.backgroundColor="red";
			bool = "false";
			}
		else if (form.usermail.value!="")
			{
			usermail = form.usermail.value;
	      	re = /^[a-zA-Z0-9_]{1}[a-zA-Z0-9\-_]*(\.[a-zA-Z0-9\-_]+)*@[a-zA-Z0-9]{1}[a-zA-Z0-9\-_]*(\.[a-zA-Z0-9\-_]+)*\.[a-zA-Z]{2,4}$/;
			if(re.test(usermail) == false)
			     	{
				upozorneni += "- Email má špatný tvar! \n";
				form.usermail.style.backgroundColor="red";
				bool = "false";
				}
			}
		}
	if(document.getElementById('icq'))
		{
		form.icq.style.backgroundColor=puvodni_pozadi;
		if(form.icq.value!="")
			{
			icq = form.icq.value;
			icq.replace(' ','');
	      	re = /^[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}|[0-9]{5,9}$/;
			if(re.test(icq) == false)
			     	{
				upozorneni += "- ICQ číslo má špatný tvar! \n";
				form.icq.style.backgroundColor="red";
				bool = "false";
				}
			}
		}
      if(document.getElementById('mobil'))
		{
		form.mobil.style.backgroundColor=puvodni_pozadi;
		if(form.mobil.value!="")
			{
			mobil = form.mobil.value;
			mobil.replace(' ','');
	      	re = /[6,7]{1}[0-9]{8}$/;
			if(re.test(mobil == false))
			     	{
				text += "- Mobil má špatný tvar! \n";
				form.mobil.style.backgroundColor="red";
				bool = "false";
				}
			}
		}
	if(document.getElementById('captcha'))
		{
		form.captcha.style.backgroundColor=puvodni_pozadi;
		if(form.captcha.value=="")
			{
			upozorneni += "- Je nutno opsat kontrolní kód! \n";
			form.captcha.style.backgroundColor="red";
			bool = "false";
			}
		}
      if(document.getElementById('souhlas'))
		{
		form.souhlas.style.backgroundColor=puvodni_pozadi;
		if(!form.souhlas.checked)
			{
			upozorneni += "- Je nutno souhlasit s podmínkami! \n";
			bool = "false";
			}
		}
	 if(document.getElementById('tema'))
		{
		form.tema.style.backgroundColor=puvodni_pozadi;
		if(form.tema.value=="")
			{
			upozorneni += "- Je nutno vyplnit téma!! \n";
			form.tema.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('text'))
		{
		form.text.style.backgroundColor=puvodni_pozadi;
		if(form.text.value=="")
			{
			upozorneni += "- Je nutno vyplnit text!! \n";
			form.text.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('kde'))
		{
		form.kde.style.backgroundColor=puvodni_pozadi;
		if(form.kde.value=="")
			{
			upozorneni += "- Je nutno vyplnit místo konání!! \n";
			form.kde.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('kdy'))
		{
		form.kdy.style.backgroundColor=puvodni_pozadi;
		if(form.kdy.value=="" || form.kdy.value=='yyyy-mm-dd hh:ii')
			{
			upozorneni += "- Je nutno vyplnit datum koncertu!! \n";
			form.kdy.style.backgroundColor="red";
			form.kdy.value=='yyyy-mm-dd hh:ii';
			bool = "false";
			}
		}
	if(document.getElementById('poznamka'))
		{
		form.poznamka.style.backgroundColor=puvodni_pozadi;
		if(form.poznamka.value=="")
			{
			upozorneni += "- Je nutno vyplnit poznámku!! \n";
			form.poznamka.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('mapa'))
		{
		form.mapa.style.backgroundColor=puvodni_pozadi;
		if(form.mapa.value=="" || form.mapa.value=="http://")
			{
			upozorneni += "- Je nutno vyplnit odkaz na mapu!! \n";
			form.mapa.style.backgroundColor="red";
			bool = "false";
			}
		}
	if(document.getElementById('vstup'))
		{
		form.vstup.style.backgroundColor=puvodni_pozadi;
		if(form.vstup.value=="" || form.vstup.value=="Kč")
			{
			upozorneni += "- Je nutno vyplnit výši vstupného!! \n";
			form.vstup.style.backgroundColor="red";
			bool = "false";
			}
		}
   	if(document.getElementById('album_code') && document.getElementById('pocet'))
		{
		form.pocet.style.backgroundColor=puvodni_pozadi;
		if(form.pocet.value=="")
			{
			upozorneni += "- Je nutno zadat počet!! \n";
			form.pocet.style.backgroundColor="red";
			bool = "false";
			}
		else 	{
			pocet = form.pocet.value;
	      	re = /^[0-9]+$/;
			if(re.test(pocet) == false || pocet <= 0)
			     	{
				upozorneni += "- Počet musí být číslo větší než nula!! \n";
				form.pocet.style.backgroundColor="red";
				bool = "false";
				}
			}
		}
	if(document.getElementById('album_code'))
		{
		form.album_code.style.backgroundColor=puvodni_pozadi;
		if(form.album_code.value=="" || form.album_code.value=="yymmdd_nazev")
			{
			upozorneni += "- Je nutno vyplnit album id!! \n";
			form.album_code.style.backgroundColor="red";
			form.album_code.value="yymmdd_nazev"
			bool = "false";
			}
		}
	if(document.getElementById('album_name'))
		{
		form.album_name.style.backgroundColor=puvodni_pozadi;
		if(form.album_name.value=="" || form.album_name.value=="Název - d.m.yyyy")
			{
			upozorneni += "- Je nutno vyplnit název alba!! \n";
			form.album_name.style.backgroundColor="red";
			form.album_name.value="Název - d.m.yyyy"
			bool = "false";
			}
		}
		
      if(bool=="false")
		{
		alert(upozorneni);
		return false;
		}
	}
	
	
function smail(smajlik)
	{
	smile_array = new Array(":-D",":-P","8-)",";-)",":-)","*TIRED*",":-|",":-o",":\'\(","*BORED*","*DEATH*","=-O",":-\\",":-!",":-[","*LOVE*",":-(","]:->","*SATISFIED*","*QUESTION*","*COMMAND*");
	obrazek = smile_array[smajlik] + " ";
	textarea = document.getElementById('controlled_form').text;
	
	textarea.focus();
	
	if (typeof textarea.selectionStart != 'undefined') 
		{
		start = textarea.selectionStart;
		end = textarea.selectionEnd;
		
		textarea.value = textarea.value.substr(0, start) + obrazek + textarea.value.substr(end);
		//skoceni za posledni tag
		textarea.selectionStart = start + obrazek.length;
		textarea.selectionEnd = start + obrazek.length;
		}
	else if (typeof document.selection != 'undefined') {
		var range = document.selection.createRange();
		range.text = obrazek;
		
		//nastaveni kurzoru na spravné misto / vybrani pozadovaneho textu
		if (typeof selectionStart != 'undefined' && typeof selectionEnd != 'undefined') {
			range.moveStart('character', -obrazek.length + selectionStart);
			range.moveEnd('character', -obrazek.length + selectionEnd);
		} 
		range.select();
	}

	//unset promenych
	delete selectionStart;
	delete selectionEnd;
	}
