//test emailu
function validate_email(form) {
   email = /^[-a-zA-Z0-9_.+]+@[-a-zA-Z0-9_.+]+\.[a-zA-Z0-9]+$/;
   if(!email.test(form.email.value)) {
      alert(js_text_mlist["form_bad_email"]); 
      form.email.focus(); 
      return false;
   }
   return true;
}

//test vyhledavaciho formulare	
function validate_search(form) {
   if(form.key_words.value=='' || form.key_words.value.length<2) {
      alert('Nebylo zadáno slovo pro hledání (min. 3 znaky)');
      form.key_words.focus();
      return false;
   }
   return true;
}

//*************************************************************//
//pomucka pro target _blank v xhtml strict
//pouziti: vsude
function newWindow(url)
{
	windowRef = window.open(url,"nove","");
	wasOpen = false;
	if (typeof(windowRef) == "object")
	{
		wasOpen = true;
	}
	return wasOpen;
}	

//****************************************************//
//otevreni okna s obrazkem
//pouziti: veskere pripojene obrazky tzv. male fotogalerie
function otevri_okno(obrazek, popisek)
{
	var win=window.open("","nazev","width=600,height=600,menubar=no,toolbar=no");
	win.document.write("<html><head><title>Detail</title>");
   win.document.write('<link href="'+window_func_style_path+'" type="text/css" rel="stylesheet" />');
   win.document.write('<link href="'+window_func_common_style_path +'" type="text/css" rel="stylesheet" /></head>');
	win.document.write("<body class='new-window'><table width='100%' height='100%'><tr><td valign='middle' align='center'><a href='javascript:window.close()'><img src='"+obrazek+"' border='0' alt='"+popisek+"' /></a>");
   if (popisek) {
      win.document.write('<br /><div class="new-window-text">'+popisek+'</div>');      
   }
	win.document.write("</td></tr></table></body></html>");
   win.document.close();
   win.focus();
}


//****************************************************//
//otevreni okna s obrazkem pro fotogalerii
function gallery_window(obrazek, jmeno, popis, i)
{
   win=window.open("","nazev","width=600,height=680,menubar=no,toolbar=no,scrollbars=yes");
	win.document.write("<html><head><title>"+jmeno+"</title>");
   win.document.write('<link href="'+window_func_style_path+'" type="text/css" rel="stylesheet" />');
   win.document.write('<link href="'+window_func_common_style_path +'" type="text/css" rel="stylesheet" /></head>');
	win.document.write('<script type="text/javascript">play_interval = 0; interval = 1;</script>');
	win.document.write('<body class="new-window">');
   win.document.write('<input type="hidden" style="display: none;" id="i" value="'+i+'" />');
   win.document.write("<table width='100%' height='100%'><tr><td valign='middle' align='center'>"); 	
   if (js_path.length > 1) {
      win.document.write('<div class="align-center">');
      style = (i == 0) ? ' style="visibility: hidden;"' : '';
      if (js_path.length > 2) {
         win.document.write('<a '+style+' id="link_first" class="gallery-move" href="" onclick="return opener.gallery_move(\'first\')">|&lt;</a> &nbsp;');         
      }
      win.document.write('<a '+style+' class="gallery-move" id="link_prev"  href="" onclick="return opener.gallery_move(\'prev\')">&lt;&lt;</a> ');
      style = ((i+1) == js_path.length) ? ' style="visibility: hidden;"' : '';
      win.document.write(' <a id="link_next" '+style+' class="gallery-move" href="" onclick="return opener.gallery_move(\'next\')">&gt;&gt;</a>');
      if (js_path.length > 2) {
         win.document.write('&nbsp; <a class="gallery-move" id="link_last" '+style+' href="" onclick="return opener.gallery_move(\'last\')">&gt;|</a>');         
      }
      win.document.write('&nbsp; &nbsp; <span id="pozice">('+(i+1)+'/'+js_path.length+')</span> &nbsp; &nbsp; &nbsp; ');
      win.document.write('<select style="vertical-align: middle; font-size: 10px;" onchange="interval=this.value;" size="1" id="interval"><option value="1">1 sec</option><option value="2">2 sec</option><option value="3">3 sec</option><option value="4">4 sec</option><option value="5">5 sec</option></select> ');
      win.document.write('<a id="gallery_move" class="gallery-move" href="" onclick="if (play_interval) {clearInterval(play_interval); play_interval = 0;this.innerHTML = \'&gt;\';return false;};document.getElementById(\'i\').value = 0;this.innerHTML = \'||\';opener.gallery_move(\'first\');play_interval = setInterval(opener.gallery_play, (interval * 1000)); return false;">&gt;</a>');
      win.document.write('</div><br />');
   }
   win.document.write('<div id="gallery_window_name" class="gallery-window-name">'+jmeno+'</div>');
   win.document.write("<a href='javascript:window.close()'><img id='gallery_pic' src='"+obrazek+"' border='0' alt='"+jmeno+"' /></a>");
	win.document.write('<br /><div id="gallery_window_text" class="gallery-window-text">'+popis+"</div>");
   win.document.write("</td></tr></table></body></html>");
   win.document.close();
   win.focus();
}

function gallery_play() {
   /*i = win.document.getElementById('i').value;
   if ((i+1) > js_path.length) {
      clearInterval(win.play_interval); 
      win.play_interval = 0;
      win.document.getElementById('gallery_move').innerHTML = '&gt;';
      return false;
   }*/
   gallery_move('next');
}

function gallery_move(direction) {
   i = win.document.getElementById('i').value;
   if (direction == 'next') {
      i++;
      if ((i+1) > js_path.length) return false;
   }
   if (direction == 'prev') {
      i--;
      if (i < 0) return false;   
   }
   if (direction == 'first') {
      i = 0;
   }
   if (direction == 'last') {
      i = js_path.length - 1;
   }
   win.document.getElementById('gallery_pic').src = js_path[i];
   win.document.getElementById('gallery_window_text').innerHTML = js_text[i];
   win.document.getElementById('gallery_window_name').innerHTML = js_title[i];
   win.document.getElementById('i').value = i;
   if (win.document.getElementById('link_next')) {
      win.document.getElementById('link_next').style.visibility = ((i+1) == js_path.length) ? 'hidden' : 'visible';
   }
   if (win.document.getElementById('link_prev')) {
      win.document.getElementById('link_prev').style.visibility = (i == 0) ? 'hidden' : 'visible';
   }
   if (win.document.getElementById('link_first')) {
      win.document.getElementById('link_first').style.visibility = (i == 0) ? 'hidden' : 'visible';
   }
   if (win.document.getElementById('link_last')) {
      win.document.getElementById('link_last').style.visibility = ((i+1) == js_path.length) ? 'hidden' : 'visible';
   }
   win.document.getElementById('pozice').innerHTML = '('+(i+1)+'/'+js_path.length+')';
   return false;
}

//****************************************************//
