function zobraz() {
if (nactiCookie('etyp')=="1")
  {
  cr=nactiCookie('ocenakc')*1;
  sr=nactiCookie('ocenask')*1;
  }
else
  {
  cr=nactiCookie('cenakc')*1;
  sr=nactiCookie('cenask')*1;
  }

x = document.vkladani.firmaosoba.value;
r = document.vkladani.republika.value;

if (x=='o')
	{
	document.getElementById('tab_osoby').style.display='block';
	document.getElementById('tab_firmy').style.display='none';
	}
else if ((r=='cr' && cr<240) || (r=='sr' && sr<10.8))
	{
  alert ('Minimální objednávka na firmu je 240 Kč / 10,80 EUR');
	document.vkladani.firmaosoba.value='o';

	document.getElementById('tab_osoby').style.display='block';
	document.getElementById('tab_firmy').style.display='none';
	x='o';
	}
else if (x=='f')
	{
	document.getElementById('tab_firmy').style.display='block';
	document.getElementById('tab_osoby').style.display='none';
	} 

if (r=='cr') { document.getElementById('platba_cr'+x).style.display='block'; document.getElementById('platba_sr'+x).style.display='none'; }
else { document.getElementById('platba_sr'+x).style.display='block'; document.getElementById('platba_cr'+x).style.display='none'; }
}



function nahled(a, celkem) {
pole = document.getElementById('nahl'+a);
stav = pole.style.display;

for (i = 1; i <= celkem; i++)
	{
	document.getElementById('nahl'+i).style.display='none';
	}

if (stav=='none') pole.style.display='block';
}



function repub() {
x = document.vkladani.firmaosoba.value;
r = document.vkladani.republika.value;

if (r=='sr') 
	{
	document.getElementById('dan').innerHTML = 'IČ DPH';
	document.getElementById('znako').src = '../img/vlajka_slovensko.gif';
	document.getElementById('znakf').src = '../img/vlajka_slovensko.gif';
	document.getElementById('platba_sr'+x).style.display='block';
	document.getElementById('platba_cr'+x).style.display='none'; 
	}
else
	{
	document.getElementById('dan').innerHTML = 'DIČ';
	document.getElementById('znako').src = '../img/vlajka_cesko.gif';
	document.getElementById('znakf').src = '../img/vlajka_cesko.gif';
	document.getElementById('platba_cr'+x).style.display='block';
	document.getElementById('platba_sr'+x).style.display='none'; 
	}
}



function kontrola() {
x = document.vkladani.firmaosoba.value;
rep = document.vkladani.republika.value;

if (rep=="cr" && x=="o") { if (document.vkladani.platbacro[1].checked || document.vkladani.platbacro[2].checked || document.vkladani.platbacro[3].checked) iplatba="1"; else iplatba="0"; karta=document.vkladani.platbacro[3].checked; tp=document.vkladani.kartacro.value; }
if (rep=="cr" && x=="f") { if (document.vkladani.platbacrf[1].checked) iplatba="1"; else iplatba="0"; karta=document.vkladani.platbacrf[1].checked; tp=document.vkladani.kartacrf.value; }
if (rep=="sr" && x=="o") { if (document.vkladani.platbasro[1].checked || document.vkladani.platbasro[2].checked) iplatba="1"; else iplatba="0"; karta=document.vkladani.platbasro[2].checked; tp=document.vkladani.kartasro.value; }
if (rep=="sr" && x=="f") { if (document.vkladani.platbasrf[1].checked) iplatba="1"; else iplatba="0"; karta=document.vkladani.platbasrf[1].checked; tp=document.vkladani.kartasrf.value; }

if (x=="f") 
	{
	txt1=document.vkladani.ico.value;
	str1length= txt1.length;
	txt8=document.vkladani.dic.value;
	str8length= txt8.length;
	txt0=document.vkladani.firmaf.value;
	str0length= txt0.length;
	}
txt2=document.getElementById('prijmeni'+x).value;
txt22=document.getElementById('jmeno'+x).value;
txt3=document.getElementById('ulice'+x).value;
txt4=document.getElementById('mesto'+x).value;
txt5=document.getElementById('psc'+x).value;
txt7=document.getElementById('heslo'+x).value;
txt9=document.getElementById('heslo2'+x).value;

str2length= txt2.length;
str22length= txt22.length;
str3length= txt3.length;
str4length= txt4.length;
str5length= txt5.length;
str7length= txt7.length;		

if (x=="o" || (x=="f" && str1length>7 && IsNumeric(txt1)==true)) {
 if (x=="o" || str8length==0 || (x=="f" && rep=="cr" && str8length>9 && (/^CZ/i).test(txt8)) || (x=="f" && rep=="sr" && str8length==12 && (/^SK/i).test(txt8))) {
  if (x=="o" || str0length>2){
  if (str2length>2){
  if (str22length>2){
   if (str3length>5){
    if (str4length>1){
		 if ((str5length==5 && obsahuje(txt5, '0123456789')==true) || (str5length==6 && obsahuje(txt5, '0123456789 ')==true)) {
		  if ((rep=="cr" && txt5.charAt(0)!='0' && txt5.charAt(0)!='8' && txt5.charAt(0)!='9') || (rep=="sr" && (txt5.charAt(0)=='0' || txt5.charAt(0)=='8' || txt5.charAt(0)=='9'))) {
			 if (zkontroluj_email(document.getElementById('email'+x).value)) {
			  if (str7length>6) {
				 if (txt7==txt9) {
					if (nactiCookie('kos')!="") {
					 if (karta==false || (karta==true && tp!="")) {
         					document.vkladani.submit();
						      if (iplatba=="1") return true; else return false;
         					}
			                else {
		         		    window.alert('Vyberte typ platební karty!');
	         			    return false;
	         			    }
					    }
			              else {
		         		  window.alert('Nemáte v košíku žádné časopisy!');
	         			  return false;
	         			  }
					  }
			            else {
		         		window.alert('Hesla se neshodují... vyplňte je prosím znovu!');
					document.getElementById('heslo'+x).focus();
	        	 		return false;
	         			}
					}
			            else {
		         		window.alert('Zadejte prosím heslo, minimálně 7 znaků!');
					document.getElementById('heslo'+x).focus();
	        	 		return false;
	         			}
					}
		            else {
	         		window.alert('Nezadali jste Váš e-mail, nebo má špatný formát!');
				document.getElementById('email'+x).focus();
	         		return false;
	         		}
				}
	               else {
			   if (rep=="cr") r="Slovenské"; else r="České";
         		   window.alert('Zadejte prosím správné PSČ!\nPokud jste ze '+ r +' republiky, vyplňujete špatný formulář.\nPřepněte si na správný pomocí menu na této stránce (vlevo nahoře).');
			   document.getElementById('psc'+x).focus();
         		   return false;
         		   }
			   }
	            else {
         		window.alert('Zadejte prosím PSČ!');
			document.getElementById('psc'+x).focus();
         		return false;
         		}
			}
			else {
         window.alert('Zadejte prosím název Vašeho města!!');
	 document.getElementById('mesto'+x).focus();
         return false;
         }
         }
      else {
      window.alert('Zadejte prosím název Vaší ulice!');
      document.getElementById('ulice'+x).focus();
      return false;
      }
      }
   else {
    window.alert('Zadejte prosím jméno!');
    document.getElementById('jmeno'+x).focus();
    return false;
    }
    }
   else {
    window.alert('Zadejte prosím příjmení!');
    document.getElementById('prijmeni'+x).focus();
    return false;
    }
    }
  else {
    window.alert('Zadejte prosím název firmy!');
    document.vkladani.firmaf.focus();
    return false;
    }
    }
 else {
 if (rep=="cr") window.alert('DIČ firmy musí začínat písmeny CZ a obsahovat min. 8 číslic!'); else window.alert('Zadejte IČ DPH - 12 znaků a musí začínat písmeny SK!');
 document.vkladani.dic.focus();
 return false;
 }
 }
else {
window.alert('Zadejte IČO firmy - 8 číslic!\n\nPokud jste soukromá osoba, vyplňujete špatný formulář.\nPřepněte si na správný pomocí menu na této stránce (vlevo nahoře).');
document.vkladani.ico.focus();
return false;
}
}
