var tempimg = new Image();
tempimg.src = "styles/loading.gif";

function foto(foto){
  window.open("foto.php?idf="+foto,"x","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=no,width=350,height=262,left=50,top=50"); 
}
function swapimg(i, j){
  var img = document.getElementById(j);
  img.src = 'soubory/nahledy/'+i+'.jpg';
}
function vloz_tag(t1,t2,cil){
var textc = document.getElementsByName(cil)[0];
textc.focus();
if (document.selection) {
  sel = document.selection.createRange();
  sel.text = t1 + sel.text + t2;
} else if (textc.selectionStart || textc.selectionStart == '0') {
  var startPos = textc.selectionStart;
  var endPos = textc.selectionEnd;
  textc.value = textc.value.substring(0, startPos)
  + t1
  + textc.value.substring(startPos,endPos)
  + t2
  + textc.value.substring(endPos, textc.value.length);
} else {
  textc.value += t1 + t2;
}
textc.focus();
}
function vloz_url(cil){
var url = document.getElementsByName('url'+cil)[0].value;
var popis = document.getElementsByName('url_popis'+cil)[0].value;
if(popis == 'popis')
  popis = '';
if(popis == ''){
  var t1 = '[url]'+url+'[/url]';
  var t2 = '';
} else {
  var t1 = '[url=' + url + ']';
  var t2 = popis + '[/url]';
}
vloz_tag(t1,t2,cil);
}
function vloz_img(cil){
var url = document.getElementsByName('img_url'+cil)[0].value;
var t1 = '[img]' + url;
var t2 = '[/img]';
vloz_tag(t1,t2, cil);
}
function zobrazenimenu(i){
  var prvek = document.getElementById(i);
  if (prvek.style.display=='block'){
    prvek.style.display='none';
  } else {
    prvek.style.display='block';
  }
}
function validuj()
{
  var jmeno = document.getElementsByName('jmeno')[0];
  var email = document.getElementsByName('email')[0];
  var dotaz = document.getElementsByName('dotaz')[0];
  if(jmeno.value == '' || jmeno.value == '- Vaše jméno -')
  {
    alert('Vyplňte prosím vaše jméno');
    return false;
  }
  if(email.value == '' || email.value == '- Váš email -')
  {
    alert('Vyplňte prosím váš email');
  }
  else
  {
    apos = email.value.indexOf("@")
    dotpos = email.value.lastIndexOf(".")
    if (apos < 1 || (dotpos - apos) < 2) 
    {
      alert('Vyplňte prosím váš email správně');
      return false;
    }
  }
  if(dotaz.value == '' || dotaz.value == '- Váš dotaz -')
  {
    alert('Vyplňte prosím váš dotaz');
    return false;
  }
  return true;
}
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 top = window.scrollTop;
  var nahled = document.getElementById("nahled");
  var img = document.getElementById("nahledimg");
  var imgn = document.getElementById("imgn");
  var button = document.getElementById("nahledbutton");
  var y = (document.all)?document.body.scrollTop:window.pageYOffset;
  var ph = "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';
}
