function target_blank(adresa) {
  window.open(adresa);
}

function blank(sender) {
  window.open(sender.href);
}

function target_self(adresa) {
  document.location.href=adresa;
}

function emailDecode(url)
{
  window.open(url,"okno", "height=170px, width=480px, resizable=no, status=no, toolbar=no, location=no");
}


function goBack(kolik)
{
  history.go(-kolik);
}

function viewPhoto(cesta) {
  window.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
  window.document.write("<html>");
  window.document.write("<head>");
  window.document.write("<title>Obec Přísnotice: Fotografie</title>");
  window.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />");
  window.document.write("<meta http-equiv=\"content-language\" content=\"cs\" />");
  window.document.write("<meta name=\"keywords\" content=\"Přísnotice fotografie\" />");
  window.document.write("<meta name=\"author\" content=\"all: Lukáš Klicnar (Lukas Klicnar); root@prisnotice.cz\" />");
  window.document.write("</head>");
  window.document.write("<body id=\"www-prisnotice-cz\" style=\"background-color: #e3f0f6;\">");
  window.document.write("<table style=\"width: 100%; height: 100%; text-align: center; vertical-align: middle;\"><tr><td><img src=\""+cesta+"\" onclick=\"history.go(-1);\" alt=\"Kliknutím dojde k zavření fotografie\" /></td></tr></table>");
  window.document.write("</body>");
  window.document.write("</html>");
}

function viewPhotoText(cesta, text) {
  window.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
  window.document.write("<html>");
  window.document.write("<head>");
  window.document.write("<title>Obec Přísnotice: Fotografie</title>");
  window.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />");
  window.document.write("<meta http-equiv=\"content-language\" content=\"cs\" />");
  window.document.write("<meta name=\"keywords\" content=\"Přísnotice fotografie\" />");
  window.document.write("<meta name=\"author\" content=\"all: Lukáš Klicnar (Lukas Klicnar); root@prisnotice.cz\" />");
  window.document.write("</head>");
  window.document.write("<body id=\"www-prisnotice-cz\" style=\"background-color: #e3f0f6;\">");
  window.document.write("<table style=\"width: 100%; height: 100%; text-align: center; vertical-align: middle;\"><tr><td><img src=\""+cesta+"\" onclick=\"history.go(-1);\" alt=\"Kliknutím dojde k zavření fotografie\" /><p>"+text+"</p></td></tr></table>");
  window.document.write("</body>");
  window.document.write("</html>");
}

function viewPhotoGallery(tema, galerie, photo) {
  document.location = "galleryview.php?tema="+tema+"&galerie="+galerie+"&soubor="+photo;
}

function checkGuestbookInsert()
{
  nm = document.getElementById("nm");
  otazka = document.getElementById("otazka");
  email = document.getElementById("email");
  text = document.getElementById("text");
  form = document.getElementById("guestbook");
   if (email.value != "") {
   mail=/^.+@.+\..{2,3}$/
   if(mail.test(email.value) != true) {window.alert("Nesprávně zadaná e-mailová adresa!");} else {
    if((text.value == "") || (nm.value == "") || (otazka.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}
   }
  } else {if((text.value == "") || (nm.value == "") || (cq.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}}
}

function checkDiscussionAdd()
{
  nm = document.getElementById("nm");
  cq = document.getElementById("cq");
  email = document.getElementById("email");
  text = document.getElementById("text");
  form = document.getElementById("discussion");
   if (email.value != "") {
   mail=/^.+@.+\..{2,3}$/
   if(mail.test(email.value) != true) {window.alert("Nesprávně zadaná e-mailová adresa!");} else {
    if((text.value == "") || (nm.value == "") || (cq.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}
   }
  } else {if((text.value == "") || (nm.value == "") || (cq.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}}
}

function checkDiscussionCT()
{
  topic = document.getElementById("topic");
  name = document.getElementById("nm");
  cq = document.getElementById("cq");
  email = document.getElementById("email");
  text = document.getElementById("text");
  form = document.getElementById("discussionCT");
   if (email.value != "") {
   mail=/^.+@.+\..{2,3}$/
   if(mail.test(email.value) != true) {window.alert("Nesprávně zadaná e-mailová adresa!");} else {
    if((text.value == "") || (nm.value == "") || (cq.value == "") || (topic.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}
   }
  } else {if((text.value == "") || (nm.value == "") || (cq.value == "") || (topic.value == "")) {window.alert('Formulář je nedostatečně vyplněn!');} else {document.form.submit();}}
}

function checkEform()
{
  nm = document.getElementById("nm");
  test = document.getElementById("test");
  email = document.getElementById("email");
  question = document.getElementById("question");
  form = document.getElementById("eform");
  if((nm.value == "") || (email.value == "") || (question.value == "") || (test.value == "")) {window.alert("Formulář je nedostatečně vyplněn!");} else {
   mail=/^.+@.+\..{2,3}$/
   if(mail.test(email.value) != true) {window.alert('Nesprávně zadaná e-mailová adresa!');} else {document.form.submit();}
  }
}

function football_course(nadpis,skore,obsah)
{
  okno = window.open("","okno", "height=370px, width=300px, resizable=no, status=no, toolbar=no, location=no");
  okno.document.write("<html><head><title>Průběh zápasu</title><style type='text/css'>h2 {margin: 0px;} h3 {margin: 0px;} img {margin: 5px;}</style></head><body bgcolor='#E3F0F6'>");
  okno.document.write("<h2 align='center'>"+nadpis+"</h2>");
  okno.document.write("<h3 align='center'>"+skore+"</h3><hr>");
  okno.document.write("<div style=\"width: 280px; height: 240px; overflow: auto;\">"+obsah+"</div>");
  okno.document.write("<p align='center' onclick='window.close()'><a href='#' onclick='return false;'>[zavřít]</a></p>");
  okno.document.write("</body></html>");
} 

function football_photos(co1,co1th,co2,co2th,co3,co3th,co4,co4th,co5,co5th,co6,co6th,co7,co7th,co8,co8th,co9,co9th,co10,co10th,co11,co11th,co12,co12th,co13,co13th,co14,co14th,co15,co15th,co16,co16th,co17,co17th,co18,co18th,co19,co19th,co20,co20th)
{
  window.document.write("<html>");
  window.document.write("<head>");
  window.document.write("<title>Detail fotografie</title>");
  window.document.write("<script language='javascript'>function zpet() {history.go(-1);}</script>");
  window.document.write("<style type='text/css'>img {margin: 5px;} p {margin: 0px;}</style>");
  window.document.write("</head>");
  window.document.write("<body bgcolor='#e3f0f6' style='margin: 0px;'>");
  window.document.write("<table width='100%' height='100%' align='center' valign='middle'><tr align='center' height='90'><td><div style='width: 100%;'>");
  if(co1 != 'N') {window.document.write("<a href='#'><img src='"+co1th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co1+"'; return false;\"></a>");}
  if(co2 != 'N') {window.document.write("<a href='#'><img src='"+co2th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co2+"'; return false;\"></a>");}
  if(co3 != 'N') {window.document.write("<a href='#'><img src='"+co3th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co3+"'; return false;\"></a>");}
  if(co4 != 'N') {window.document.write("<a href='#'><img src='"+co4th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co4+"'; return false;\"></a>");}
  if(co5 != 'N') {window.document.write("<a href='#'><img src='"+co5th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co5+"'; return false;\"></a>");}
  if(co6 != 'N') {window.document.write("<a href='#'><img src='"+co6th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co6+"'; return false;\"></a>");}
  if(co7 != 'N') {window.document.write("<a href='#'><img src='"+co7th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co7+"'; return false;\"></a>");}
  if(co8 != 'N') {window.document.write("<a href='#'><img src='"+co8th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co8+"'; return false;\"></a>");}
  if(co9 != 'N') {window.document.write("<a href='#'><img src='"+co9th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co9+"'; return false;\"></a>");}
  if(co10 != 'N') {window.document.write("<a href='#'><img src='"+co10th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co10+"'; return false;\"></a>");}
  if(co11 != 'N') {window.document.write("<a href='#'><img src='"+co11th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co11+"'; return false;\"></a>");}
  if(co12 != 'N') {window.document.write("<a href='#'><img src='"+co12th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co12+"'; return false;\"></a>");}
  if(co13 != 'N') {window.document.write("<a href='#'><img src='"+co13th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co13+"'; return false;\"></a>");}
  if(co14 != 'N') {window.document.write("<a href='#'><img src='"+co14th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co14+"'; return false;\"></a>");}
  if(co15 != 'N') {window.document.write("<a href='#'><img src='"+co15th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co15+"'; return false;\"></a>");}
  if(co16 != 'N') {window.document.write("<a href='#'><img src='"+co16th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co16+"'; return false;\"></a>");}
  if(co17 != 'N') {window.document.write("<a href='#'><img src='"+co17th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co17+"'; return false;\"></a>");}
  if(co18 != 'N') {window.document.write("<a href='#'><img src='"+co18th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co18+"'; return false;\"></a>");}
  if(co19 != 'N') {window.document.write("<a href='#'><img src='"+co19th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co19+"'; return false;\"></a>");}
  if(co20 != 'N') {window.document.write("<a href='#'><img src='"+co20th+"' alt='Zobrazit fotografii' border='0' onclick=\"obr.src='"+co20+"'; return false;\"></a>");}
  window.document.write("</div><hr></td></tr><tr align='center' valign='middle'><td>");
  window.document.write("<a href='#'><img id='obr' src='"+co1+"' border='0' alt='Kliknutím dojde k zavření obrázku' onclick='zpet(); return false;'></a>");
  window.document.write("</td></tr></table></body></html>");
}

function book_anim(obrazek)
{
  obrazek.src="data/img/kniha_anim.gif"
}

function book_static(obrazek)
{
  obrazek.src="data/img/kniha_static.gif"
}

function fo_detail(cesta,nazev,autor,info) {
  window.document.write("<html>");
  window.document.write("<head>");
  window.document.write("<title>Fotografie občanů: "+nazev+"</title>");
  window.document.write("<script language='javascript'>function zpet() {history.go(-1);}</script>");
  window.document.write("</head>");
  window.document.write("<body bgcolor='#e3f0f6'>");
  window.document.write("<table cellspacing=´0´ cellpadding=´0´ width='100%' height='100%'><tr align='center' valign='middle'><td width='100%' valign='middle'>");
  window.document.write("<center><span style='font-style: italic;'>"+autor+"</span><br><span style='font-size: 18px; font-weight: bold;'>"+nazev+"</span><br><br></center><img src='"+cesta+"' onclick='zpet()' border='0' alt='Kliknutím dojde k zavření obrázku'><br><br><hr><center>"+info+"</center>");
  window.document.write("</td></tr></table>");
  window.document.write("</body>");
  window.document.write("</html>");
}

function refreshimg(elid) {
  imgelement = document.getElementById(elid);

  if(imgelement != null) {
    ts = (new Date()).getTime();
    old_src = imgelement.src;
    new_src = old_src;

    if(old_src.indexOf('?') == -1) {
      new_src = old_src + '?tmp=' + ts;
    }
    else {
      posQ = old_src.indexOf('?tmp=');
      posA = old_src.indexOf('&tmp=');
      
      if(posQ == -1 && posA == -1) {
        new_src = old_src + '&tmp=' + ts;
      }
      else {
        if(posQ == -1) {
          new_src = old_src.replace(/\&tmp\=[0-9]*$/i, '') + '&tmp=' + ts;
        }
        else {
          new_src = old_src.replace(/\?tmp\=[0-9]*$/i, '') + '?tmp=' + ts;
        }
      }
    }
    
    imgelement.src = new_src;
  }
}

function checkPostcardForm() {
  form = document.getElementById("postcardForm");
  name_sender = document.getElementById("name_sender");
  email_sender = document.getElementById("email_sender");
  name_recipient = document.getElementById("name_recipient");
  email_recipient = document.getElementById("email_recipient");
  caption = document.getElementById("caption");
  message = document.getElementById("message");
  cq = document.getElementById("cq");
  
  mail=/^.+@.+\..{2,3}$/  
  
  if((cq.value == "") || (name_sender.value == "") || (email_sender.value == "") || (name_recipient.value == "") || (email_recipient.value == "") || (caption.value == "") || (message.value == "")) {
    window.alert("Formulář je nedostatečně vyplněn!");
  }
  else { 
    if(!mail.test(email_sender.value)) {
      window.alert('Nesprávně zadaná e-mailová adresa odesílatele!');
    }
    else {
      if(!mail.test(email_recipient.value)) {
        window.alert('Nesprávně zadaná e-mailová adresa příjemce!');
      }
      else {
        form.submit();
      }
    }
  }
}
