var tempimg = new Image();
tempimg.src = "app/layout_web/images/loading.gif";
function isNum(str) {
   var test = "0123456789"
   for (i=0; i <= str.length-1; i++) {
      if (test.indexOf(str.charAt(i)) == -1) return false;
   }
   return true;
}
function mapa(image, target)
{
	var images = new Array('sumperk','hradec','olomouc','ostrava','zlin','brno','vysocina','d1','budejovice','vary','liberec','praha','slovensko_on');
	var mapa = document.getElementById(target);
	var adresa = document.getElementById('adresa_'+image);
	var img = 'app/layout_web/images/mapy/'+image+'.png';
	mapa.src = img;
	for(var misto in images)
	{
		var temp = document.getElementById('adresa_'+images[misto]);
		if(temp) temp.style.background = '#ffffff';
	}
	if(adresa) adresa.style.background = '#dddddd';
}
function menu(i, j, k, keep, from)
{
	var n;
	for(n = from+1; n < from+20; n++)
	{
	  if(document.getElementById('mnu'+n) != null)
		{
	    var submenu = document.getElementById('mnu'+n);
			if(n == i || n == j || n == k)
				submenu.style.display = 'block';
			else
				submenu.style.display = 'none';
		}
	}
	if(i + j + k)
		document.getElementById('mnu'+from).style.backgroundPosition = '0 -41px';
	else if(!keep)
		document.getElementById('mnu'+from).style.backgroundPosition = '0 -1px';
}
function new_window(link)
{
  window.open(link,"x","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=620,height=800,right=50,top=50"); 
}
function editor_toEditor(target)
{
  var editor = document.getElementById('editor_'+target);
  var text = document.getElementById('data_'+target);
  editor.contentWindow.document.body.innerHTML = text.innerHTML;
  return true;
}
function editor_toTextarea(target)
{
  var editor = document.getElementById('editor_'+target);
  var text = document.getElementsByName(target)[0];
  text.value = editor.contentWindow.document.body.innerHTML;
  return true;
}
function editor_setup()
{
	var editors = document.getElementsByTagName('iframe');
	var i;
	for(i = 0; i < editors.length; i++)
	{
		editors[i].contentWindow.document.designMode = 'on';
	}
}
function editor_submit()
{
	var editors = document.getElementsByTagName('iframe');
	var i;
	for(i = 0; i < editors.length; i++)
	{
		var eid = editors[i].id;
		var tname = eid.split("_")[1];
		var text = document.getElementsByName(tname)[0];
		
		text.value = editors[i].contentWindow.document.body.innerHTML;
	}
}
function editor_execCommand(target, command, value)
{
  var top = document.body.scrollTop;
  var editor = document.getElementById('editor_'+target);
  editor.contentWindow.document.execCommand(command, false, value);
  editor.contentWindow.focus();
  document.body.scrollTop = top;
}
function editor_eurl(target)
{
  var url = document.getElementById('url_'+target).value;
	url = url.replace(/\\\\/g, 'file://///');
	url = url.replace(/\\/g, '/');
  editor_execCommand(target, 'createLink', url);
}
function editor_eimg(target)
{
  var url = document.getElementById('img_'+target).value;
  editor_execCommand(target, 'insertImage', url);
}
function editor_galerie(target)
{
  window.open("galerie_shout.php?target="+target,"x","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=yes,width=800,height=300,left=500,top=50"); 
}
function editor_insertimg(target, img)
{
  var pos = document.getElementById('pos').value;
  var vel = document.getElementById('vel').value;
  var url = 'data/galerie/'+vel+'/'+img;
  var urlp = 'data/galerie/'+vel+'/'+img+'xyz';
  var urlm = "javascript:zobraznahled('data/galerie/medium/"+img+"')";
  var editor = window.opener.document.getElementById('editor_'+target);
  editor.contentWindow.document.execCommand('insertImage', false, urlp);
  var str = editor.contentWindow.document.body.innerHTML;
  var newstr = str.replace('<img src="'+urlp+'">', '<a href="'+urlm+'"><img src="'+url+'" style="float:'+pos+';" class="text'+pos+'"></a>');
  editor.contentWindow.document.body.innerHTML = newstr;
  editor.contentWindow.focus();
}
function editor_inserturl(target)
{
  var url = document.getElementById('url_'+target).value;
	url = url.replace(/\\\\/g, 'file://///');
	url = url.replace(/\\/g, '/');
  var urlp = document.getElementById('url_'+target).value+'xyz';
	urlp = url.replace(/\\\\/g, 'file://///');
	urlp = url.replace(/\\/g, '/');
  var editor = document.getElementById('editor_'+target);
  editor.contentWindow.document.execCommand('createLink', false, urlp);
  var str = editor.contentWindow.document.body.innerHTML;
  var newstr = str.replace('href="'+urlp+'"', 'href="'+url+'" onclick="target=\'_blank\';"');
  editor.contentWindow.document.body.innerHTML = newstr;
  editor.contentWindow.focus();
}

function zobrazskryj(cil)
{
  var item = document.getElementById(cil);
  if(item.style.display == 'block')
    item.style.display = 'none';
  else
    item.style.display = 'block';
}
function gzobraz(cil)
{
  var img = document.getElementById('img'+cil);
  var over = document.getElementById('over'+cil);
  img.style.display = 'block';
  if(document.getElementById('txt'+cil) != null) document.getElementById('txt'+cil) = 'block';
}
function gskryj(cil)
{
  var img = document.getElementById('img'+cil);
  var over = document.getElementById('over'+cil);
  img.style.display = 'none';
  if(document.getElementById('txt'+cil) != null) document.getElementById('txt'+cil) = 'block';
}

function winHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' )
    myHeight = window.innerHeight;
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    myHeight = document.documentElement.clientHeight;
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    myHeight = document.body.clientHeight;
  return myHeight;
}
function zobraznahled(i)
{
  var nahled = document.getElementById("nahled");
  var img = document.getElementById("nahledimg");
  var imgn = document.getElementById("imgn");
  var button = document.getElementById("nahledbutton");
  var ph = "layout/styles/loading.gif";
  imgn.src = ph;
  imgn.src = i;
  button.style.left = ((screen.width / 2) - 45) + 'px';
  nahled.style.display = 'block';
  nahled.style.height = winHeight() + 'px';
  img.style.display = 'block';
}
function skryjnahled()
{
  var nahled = document.getElementById("nahled");
  var img = document.getElementById("nahledimg");
  nahled.style.display = 'none';
  img.style.display = 'none';
}
function faqq(i)
{
	faq = document.getElementById('faq'+i);
	if(faq.style.display == 'block')
		faq.style.display = 'none';
	else
		faq.style.display = 'block';
}