// hrdik: ukaz skryty text
function showText(id){
    var elem = document.getElementById(id);
    elem.style.display = 'block';
}

// nixx: natahne mesta podle kraje
function loadTowns(id,typeProducts)
{
	var sReg=document.getElementById(id),val=sReg.options[sReg.selectedIndex].value;
	if (val=="") return;
	location.href="?search_kraj="+val+(typeProducts?'&type=product':'');
}

// nixx: zobrazeni formulare poptavky pro soukromou osobu/firmu
function togDemandForm(id)
{
	var frmPerson=document.getElementById('frmPerson'),
		  frmCompany=document.getElementById('frmCompany');
	if (id=='frmCompany')
	{
		frmPerson.style.display="none";
		frmCompany.style.display="block";
	}
	else
	{
		frmPerson.style.display="block";
		frmCompany.style.display="none";
	}
}

function chkBlank(id,desc)
{
	var elem=document.getElementById(id);
	if (elem.value=='') alert('Text '+desc+' nesmí být prázdný!');
	return elem.value!='';
}

function chkSelected(id,desc)
{
	var sId=document.getElementById(id),val=sId.options[sId.selectedIndex].value;
	if (val=='') alert('Musíte vybrat nìjakou hodnotu '+desc+'.');
	return val!='';
}

//////// pro napovedu po kliknuti na ikonku ///////
function ShowHelp(id){
	if (document.getElementById(id).style.display == '' ){
		document.getElementById(id).style.display='none';
	}else{
		document.getElementById(id).style.display='';
	}
}
/////////// kontrola zda je vkladana hodnota cislo ////////////
	function CheckOnNumber(hodnota)					//kontrola zda je hodnota ciselna
	{
		if (hodnota==""){
			return false;
		}
		for (i=0;i<hodnota.length;i++){
			if (hodnota.charAt(i)<'0' && hodnota.charAt(i) != '.'){
			return false;
			}
			if (hodnota.charAt(i)>'9' && hodnota.charAt(i) != '.'){
			return false;
			}
		}
		return true;
	}


//////////////////// kontrola poctu vlozenych znaku /////////////
function CountChars(obj,maxchars,text){
			retezec = document.getElementById(obj).value;
			strlength=retezec.length;
				if (strlength > maxchars ) 
				{
	                alert("Text je pøíliš dlouhý !");           
	                document.getElementById(obj).value=retezec.substring(0,maxchars);
				}
				else{
			document.getElementById(text).innerText =  retezec.length ;
				}
}



////////////////// kontrola emailove adresy ///////////////////
	function CheckOnEmail(email)
	{
		invalidChars='/:,;ìšèøžýáíéúùÌŠÈØŽÝÁÍÉÙÚòÒ#$%^]}{[!?>¨§"`<+=|-&*() ';			//vytvoreni promene se znaky ktere se nesmeji v adrese objevit
		for (i=0;i<invalidChars.length;i++){	//smicka proveruje zda se jeden ze znaku nevyskytuje v adrese
			badChar=invalidChars.charAt(i)
				if (email.indexOf(badChar,0)>-1){
				return false;
				}
		}
		atPos = email.indexOf('@',1)
		if (atPos==-1){
		return false;
		}
		if (email.indexOf('@',atPos+1)>-1){		//od mista nalezu prvniho @ se pokousime hledat @ (dva nelze)
		return false;
		}
		periodPos=email.indexOf('.',atPos)
		if (periodPos==-1){
		return false;
		}
		if (periodPos+3>email.length){
		return false;
		}
		return true;
	}



///////////// HTML EDITOR ////////////
function edit_mod_inic(val){
  HTMLEdit1.document.body.innerHTML =  window.edit_form.text_cz.value;
 HTMLEdit2.document.body.innerHTML =  window.edit_form.text_en.value;
}

function edit_mod_uloz(val){
  window.edit_form.text_cz.value = HTMLEdit1.document.body.innerHTML;
  window.edit_form.text_en.value = HTMLEdit2.document.body.innerHTML;
  return true;
}

function nastav_hodnotu(x,y,z) {
  (HTMLEdit1.document.selection.createRange()).execCommand(x,y,z);
  (HTMLEdit2.document.selection.createRange()).execCommand(x,y,z);
}

function ImageButton_MouseDown(q) 
{
  q.style.left = 2;
  q.style.top = 2;
}

function ImageButton_MouseOver(q) 
{
  q.style.left = -1;
  q.style.top = -1;
}

function ImageButton_MouseOut(q) 
{
  q.style.left = 0;
  q.style.top = 0;
}
/////////////////////// KONEC EDITORU /////////////////
