// Schovej/ukaž blok

 function showA(d) {
  document.getElementById(d).style.display = '';
 }
 function hideA(d) {
  document.getElementById(d).style.display = 'none';
 } 
  
  
 function show(d) {
  document.getElementById(d).style.display = (document.getElementById(d).style.display=='none'?'':'none');
 }

// Kontrola dat z formuláře

function formCheck() {
  msg = "Zadali jste neúplné nebo chybné údaje!\n\n";
  
  
  if (document.forms.user.user_name.value.length > 20) {
      msg += "\tZadadali jste příli‘ dlouhý login. Zadejte maximálně 20 znaků.\n";
     }   
      
  if (document.forms.user.user_name.value < 3) {
      msg += "\tLogin musí mít alespoň 3 znaky.\n";
      }  
   
  if (document.forms.user.user_firstname.value.length > 16) {
      msg += "\tZadadali jste příli‘ dlouhé jméno. Zadejte maximálně 16 znaků.\n";
      }  
     
  if (document.forms.user.user_firstname.value.length < 3) {
      msg += "\tJméno musí mít alespoň 3 znaky.\n";
      }  
      
  if (document.forms.user.user_lastname.value.length > 16) {
      msg += "\tZadadali jste příli‘ dlouhé příjmení. Zadejte maximálně 16 znaků.\n";
      }  
      
  if (document.forms.user.user_lastname.value.length < 3) {
      msg += "\tPříjmení musí mít alespoň 3 znaky.\n";
      }
      
  if (document.forms.user.new_pass.value != "") {
      if (document.forms.user.new_pass.value.length > 8 || document.forms.user.new_pass.value.length < 4) {
        msg += "\tNesprávně zadané heslo. Zadejte minimálně 4 a maximálně 8 znaků.\n";
        }
      if (document.forms.user.new_pass.value != document.forms.user.new_pass_check.value) {
        msg += "\tNové heslo musíte zadat 2x stejné.\n";
        }
      } 
  
  if (msg != "Zadali jste neúplné nebo chybné údaje!\n\n") { 
      alert(msg);
      return false;
      }     
     
}

function formNapisteCheck() {
    msg = "Zadali jste neúplné nebo chybné údaje!\n\n";
     
    if (document.forms.napiste.name.value == "") {
        msg += "Nevyplnili jste jméno.";
    } 
    
    if (document.forms.napiste.email.value == "" || document.forms.napiste.email.value == "@") {
        msg += "Nevyplnili jste email.";
    } 
    
    if (document.forms.napiste.email.length < 6) {
        msg += "Chybně zadaný email.";
    } 
    
    if (document.forms.napiste.email.value >= 6) {
        function checkemail()
        {
          var str=document.validation.email.value;
          var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
          if (filter.test(str)) {
            }
          else{
            msg += alert("Chybně zadaný email!")
            }
        }
    } 
    
    if (msg != "Zadali jste neúplné nebo chybné údaje!\n\n") { 
        alert(msg);
        return false;
    }               
}
                    
//kontrola při změně hesla
function formPassCheck() {
  msg = "Zadali jste neúplné nebo chybné údaje!\n\n";
  
  if (document.forms.pass.new_pass.value == "") {
      msg += "Nevyplnili jste původní heslo.";
  } 
  
  if (document.forms.pass.new_pass.value == "") {
      msg += "Nevyplnili jste nové heslo.";
  } 
  
  if (document.forms.pass.new_pass.value.length < 3) {
        msg += "\tNesprávně zadané heslo. Zadejte minimálně 3 znaky.\n";
  }
  
  if (document.forms.pass.new_pass.value != document.forms.pass.new_pass_check.value) {
        msg += "\tNové heslo musíte zadat do kontrolního políčka stejné.\n";
  }
  
  if (msg != "Zadali jste neúplné nebo chybné údaje!\n\n") { 
      alert(msg);
      return false;
  }
}


  
function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if( !d ) d = document; 
  if( (p = n.indexOf("?")) > 0 && parent.frames.length ) {
    d = parent.frames[n.substring(p+1)].document; 
    n = n.substring(0,p);
    }
  if( !(x = d[n]) && d.all ) x = d.all[n];  
  for ( i=0; !x && i<d.forms.length; i++ ) x = d.forms[i][n];
  for( i = 0; !x && d.layers && i<d.layers.length; i++ ) x = MM_findObj(n,d.layers[i].document);
  if( !x && d.getElementById ) x = d.getElementById(n); 
  return x;
  }
  
function P7_autoLayers() { //v1.4 by PVII
 var g, b, k, f, args = P7_autoLayers.arguments;
 a = parseInt(args[0]);
 if( isNaN(a) ) a = 0;
 if( !document.p7setc ) {
 	p7c = new Array();
  document.p7setc = true;
 for( var u=0; u<10; u++ ) {
 		p7c[u]=new Array();}
 	  }
 for( k = 0; k<p7c[a].length; k++ ) {
   	if( (g=MM_findObj(p7c[a][k]))!= null ) {
   	b = (document.layers) ? g : g.style; b.visibility = "hidden";}
    }
 for( k = 1; k < args.length; k++) {
 if( (g = MM_findObj(args[k]))!= null ){
 	b = (document.layers) ? g : g.style;b.visibility = "visible"; f = false;
 	for(var j=0; j<p7c[a].length; j++){
 		if( args[k] == p7c[a][j] ) { f = true; }
 		}
 	if( !f ) { p7c[a][p7c[a].length++] = args[k]; }	
 	}
 }
/*	if (a==3 && f==true) P7_autoLayers(3,'menuprodukty');
	else if (a==3 && f==false) P7_autoLayers(9); 
	*/
}

function imgView(source, w, h, popis) {

  obr = new Image();
  obr.src = "img/" + source;
  
  preview = window.open("", "Náhled", "left=10, top=10, width=" + w + ", height=" + h + ", toolbars=no, location=no, directories=no, status=no, menubar=no, scollbars=no,copyhistory=no");
  
  with (preview.document)
  {
  open();
  write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
  write('<html>\n<head>\n');
  write('<meta http-equiv="content-type" content="text/html; charset=windows-1250" />\n');
  write('<title>Náhled obrázku</title>\n<style type="text/css">\n');
  write('<!--\nbody { margin-top: 0px; margin-left: 0; font-family: "Arial", sans-serif; font-size: 12px; }\nimg { margin-bottom: 5px; }\n-->\n');
  write('</style>\n</head>\n<body><div align="center">');
  write('<a href="javascript:close();">');
  write('<img src="' + obr.src + '" border="0" alt="" /></a><br />');
  write(popis + '</div></body>\n</html>\n');
  close();    
  }
  
  preview.document.focus();
}


function newWin(title, w, h, obsah) {
  
  preview = window.open("", title, "left=10, top=10, width=" + w + ", height=" + h + ", toolbars=no, location=no, directories=no, status=no, scollbars=yes");
  
  with (preview.document)
  {
  open();
  write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
  write('<html>\n<head>\n');
  write('<meta http-equiv="content-type" content="text/html; charset=windows-1250" />\n');
  write('<title>' + title + '</title>\n<style type="text/css">\n');
  write('<!--\nbody { margin-top: 0px; margin-left: 0; font-family: "Arial", sans-serif; font-size: 12px; }\nimg { margin-bottom: 5px; }\np.border { border-bottom: 1px solid #cdcccc; padding-bottom: 20px; }\n-->\n');
  write('</style>\n</head>\n<body><div style="margin: 5px;">');
  write('<h4 style="text-transform: uppercase; font-size: 12px; border-bottom: 1px solid #cdcccc; padding: 0 0 5px 0;">Přečíst dotaz</h4>');
  write(obsah + '<br /><br /><a href="javascript:close();">Zavřít okno</a><br /></div>');
  write('</body>\n</html>\n');
  close();    
  }
  
  preview.document.focus();
}

function vizitka(id) {
  okno = window.open('vcard.php?id='+id , 'Vizitka', 'width=550,height=350');
  okno.focus();
  return false;
}


