var sportyclick=0;
var gal_poprve = 0;
var gal_akt = 0;
var gal_show = false;
var load_count = 0; 

	  function stisknutaklavesa()
	  {
		if ((event.keyCode >= 48) && (event.keyCode <= 57)){ event.returnValue = true;}
		else { event.returnValue = false;}
	  }

	  function stisknutaklavesa1()
	  {
		if ((event.keyCode >= 48) && (event.keyCode <= 57) || (event.keyCode == 46)){ event.returnValue = true;}
		else { event.returnValue = false;}
	  }	  

	  function stisknutaklavesa2()
	  {
		if ((event.keyCode >= 48) && (event.keyCode <= 57) || (event.keyCode == 32)){ event.returnValue = true;}
		else { event.returnValue = false;}
	  }
	  
	  function ValidationNejvyhodnejsi(f)
	  {
	  	if (typeof document.forms[f].pocet == "object")
	  	{
	  		if (parseInt(document.forms[f].pocet.value)>0){return true;}
	  		else 
	  		{
		  		alert ("Položka 'Počet kusů' musí být nenulová!");
	  			return false;
	  		}
	  	}
	  	else 
	  	{ 
	  		return false;
	  	}
	  }
	  
	  function ValidationProdukt()
	  {
	  	if (ValidationNejvyhodnejsi('Form1'))
	  	{
	  		if ((typeof document.Form1.velikosti_pocet == "object") && (parseInt(document.Form1.velikosti_pocet.value)>0))
	  		{
	  			velikosti = true;
	  			for (i=1;i<=parseInt(document.Form1.velikosti_pocet.value);i++)
	  			{
	  				if ((typeof document.Form1.elements["velikost"+i] == "object") && (parseInt(document.Form1.elements["velikost"+i].value)>0))
	  				{
	  				}
	  				else
	  				{
	  					velikosti = false;
	  					break;
	  				}
	  			}
	  			if (velikosti)
	  			{
	  				if (typeof document.Form1.zdarma == "object")
	  				{
	  					if (parseInt(document.Form1.zdarma.selectedIndex)>0)	{return true;}
	  					else 
	  					{
	  						alert ("Zvolte v nabídce, zda chcete či nikoliv objednat i podukt za 1 Kč!"); 
	  						return false;
	  					}
	  				}
	  				else {return true;}
	  			}
	  			else 
	  			{	
	  				alert ("Všechny vlastnosti produktu musí být zvoleny!"); 
	  				return false;
	  			}
	  		}
	  		else 
	  		{
	  			if (typeof document.Form1.zdarma == "object")
	  			{
	  				if (parseInt(document.Form1.zdarma.selectedIndex)>0)	{return true;}
	  				else 
	  				{
	  					alert ("Zvolte v nabídce, zda chcete či nikoliv objednat i podukt za 1 Kč!"); 
	  					return false;
	  				}
	  			}
	  			else {return true;}
	  		}
	  	}
	  	else { return false; }
	  }
	  
	  function ValidationKosik()
	  {
//	    alert(document.Form1.action.value);
	  	if (document.Form1.action.value==1)
	  	{
	  		SetElement('Form1','action',0);
	  		return confirm("Opravdu odstranit z košíku?");
	  	}
	  	else
	  	{
	  		if (document.Form1.action.value==2)
	  		{
	  			SetElement('Form1','action',0);
	  			return confirm("Opravdu odstranit vše z košíku?");
	  		}
	  		else {return true;}
	  	}
	  }
	  
	  function SetElement(f,e,v)
	  {
	  	document.forms[f].elements[e].value=v;
	  }
	  
	  function ValidationLogin()
	  {
	  	var ok = false;
	  	if((parseInt(document.Form1.login.value)>0)||(document.Form1.login.value.length>=5))
	  	{
	  		if(document.Form1.heslo.value.length>=1) {ok = true;}
	  		else { alert("Heslo musí být řádně vyplněno!"); }
	  	}
	  	else {alert("E-mail musí být řádně vyplněn!");}
  		return ok;
	  }
	  
	  function check_pass(typ)
	  {
	  	if ((typeof document.Form1.heslo=='object') && (typeof document.Form1.heslo2=='object') && (typeof document.Form1.heslo_puv=='object'))
	  	{
	  		if ((document.Form1.heslo.value.length>0) || (document.Form1.heslo2.value.length>0))
	  		{
	  			if ((typ==1) || (typ==2)&&(document.Form1.heslo_puv.value.length>0))
	  			{	  		
		  			if (document.Form1.heslo.value.length>=5)
		  			{
		  				if (document.Form1.heslo.value==document.Form1.heslo2.value){	return 0;} 
		  				else { return 3; }
		  			} 
		  			else { return 2; }
			  	}
		  		else {return 5;}
	  		} 
	  		else { return 1; }
	  	} 
	  	else {return 4;}
	  }
	  
	  function ValidationRegistrace(typ)
	  {
	  	var ok = true;
	  	var message = '';
	  	var pass = 4;
	  	for (i=1;i<=6;i++)
	  	{
	  		if ((typeof document.Form1.elements[inputs[i]]=='object')&&(document.Form1.elements[inputs[i]].value.length>maxlength[i])) {}
	  		else { ok=false; message += "Položka '"+nazev[i]+"' musí být řádně vyplněna!\n";}
	  	}
	  	if (!ok) { alert(message); return false;}
	  	else 
	  	{
  			pass = check_pass(typ);
	  		if (((document.getElementById('reg')!=null) && (pass==0))||((document.getElementById('zmena')!=null)&&(pass<=1))) { return true; } 
	  		else { alert(messpass[pass]); return false;}
	  	}
	  }
	  
	  function ValidationHeslo()
	  {
	  	ok = false;
	  	message = 'E-mail musí být řádně vyplněn!';
	  	if (typeof document.Form2.email=='object')
	  	{
	  		if (document.Form2.email.value.length>=5) { ok=true;}
	  		else {alert(message);}
	  	}
	  	return ok;
	  }

	  function ValidationObjednavky(objednavka, objednavky)
	  {
	  	ok = false;
		message = "Musíte zvolit způsob "+objednavky+"!";
	  	if ((typeof document.Form1.elements[objednavka+"_pocet"]=='object')&&(parseInt(document.Form1.elements[objednavka+"_pocet"].value)>0))
	  	{
	  		check = false;
	  		for (i=1;i<=parseInt(document.Form1.elements[objednavka+"_pocet"].value);i++)
	  		{
	  			if((typeof document.Form1.elements[objednavka+i]=='object')&&(document.Form1.elements[objednavka+i].checked))
	  			{
	  				check = true;
	  				break;
	  			}
	  		}
	  		if (check) { ok=true;}
	  		else {alert(message);}
	  	}
	  	else {alert("Stránku musíte načíst znovu / aktualizovat (refresh-F5)!");}
	  	return ok;	  	
	  }
	  
	  function ValidationDoprava()
	  {
	  	return ValidationObjednavky("doprava", "dopravy");
	  }
	  
	  function ValidationPlatba()
	  {
	  	return ValidationObjednavky("platba", "platby");	
	  }
	  
	  function ValidationKupony()
	  {
	  	if ((typeof document.Form4.kupon=='object')&&(document.Form4.kupon.value.length==13))	{return true;}
	  	else {alert("Musíte vložit kupón ve správném tvaru (ABCDEF-123456)."); return false;}
	  }
	  
	  function ValidationKPZ()
	  {
	  	if ((typeof document.Form2.kpz=='object')&&(document.getElementById('send_kpz')!=null))
	  	{
	  		if (document.Form2.kpz.value.length>0) {return true;}
	  		else {alert("Musíte vložit číslo karty Kolo pro život."); return false;}
	  	}
	  	else
	  	{
	  		if (document.getElementById('del_kpz')!=null) {return confirm("Opravdu smazat číslo karty Kolo pro život?");}
	  		else {alert("Stránku musíte načíst znovu / aktualizovat (refresh-F5)!"); return false;}
	  	}
	  }	  
	  
	  function ValidationKuponyDel()
	  {
	  	return confirm("Opravdu odstranit kupóny?");
	  }
	  
	  function ValidationObjednavka()
	  {
	  	return ValidationObjednavky("charita", "charity");
	  }
	  
	  function ValidationZeptejtese(typ)
	  {
	  	ok = false;
	  	if (typ==1)
	  	{
	  		if ((typeof document.Form2.jmeno=='object') && (document.Form2.jmeno.value.length>1))
	  		{
	  			if ((typeof document.Form2.email=='object') && (fcheck_email(document.Form2.email.value)))	{ok=true;}
	  			else {alert("Položka 'e-mail' musí být řádně vyplněná!");}
	  		}
	  		else {alert("Položka 'jméno' musí být vyplněná!");}
	  	}
	  	else{ok = true;}
	  	if (ok)
	  	{
	  		if ((typeof document.Form2.dotaz=='object') && (document.Form2.dotaz.value.length>0))	{}
	  		else
	  		{
	  			alert ("Text dotazu musí být vyplněn!")
	  			ok = false;
	  		}
	  	}
	  	return ok;
//	  	return true;
	  }
	  
	  function ValidationDoporucit()
	  {
	  	ok = false;
		if ((typeof document.Form2.email=='object') && (document.Form2.email.value.length>4))	
		{
			if ((typeof document.Form2.doporuceni=='object') && (document.Form2.doporuceni.value.length>0))	{ok = true;}
	  		else {alert ("Text doporučení produktu musí být vyplněn!");}
		}
		else {alert("E-mail adresáta musí být řádně vyplněn!");}
	  	return ok;
//        return true; 
	  }	  
	  
	  function ValidationStorno()
	  {
	  	return confirm('Opravdu chcete stornovat objednávku?');
	  }
	  
	  function ValidationHodnoceni(typ)
	  {
		ok = false;	  
	  	if (typ==1)
	  	{
	  		if ((typeof document.Form2.jmeno=='object') && (document.Form2.jmeno.value.length>1))
	  		{
	  			ok=true;
	  		}
	  		else {alert("Položka 'Vaše jméno' musí být vyplněna!")}
	  	}
	  	else{ok = true;}
	  	if (ok)
	  	{
	  		ok = false;
	  		if ((typeof document.Form2.hodnoceni=='object') && (document.Form2.hodnoceni.value.length>1))
	  		{
	  			if ((typeof document.Form2.hvezdicky=='object') && (document.Form2.hvezdicky.value>0) && (document.Form2.hvezdicky.value<=5)){ok = true;}
	  			else {alert("Musí být zvolen počet hvězdiček!\n1-nejhorší, 5-nejlepší")}
	  		}
	  		else {alert("'Váš komentář hodnocení' musí být vyplněn!")}
	  	}
	  	return ok;
	  }
	  
	  function ValidationHledani()
	  {
/*	  
	  	if ((typeof Form1.hledani_nazev=='object') && (Form1.hledani_nazev.value.length>0)){return true;}
	  	else
	  	{
	  		alert("Hledaný text musí být vyplněn!");
	  		return false;
	  	}
*/	  	
		return true;
	  }
	  
	  function ValidationReklamace()
	  {
	  	ok = false;
		if ((document.Form1.typ1.checked) || (document.Form1.typ2.checked)|| (document.Form1.typ3.checked)|| (document.Form1.typ4.checked))
		{
			if ((document.Form1.typ1.checked) || ((document.Form1.typ2.checked) || (document.Form1.typ3.checked) || (document.Form1.typ4.checked))&& (document.Form1.duvod.value.length>0))
			{
				if ((document.Form1.reseni1.checked) || (document.Form1.reseni2.checked) || (document.Form1.reseni3.checked))
				{
					if ((!document.Form1.reseni2.checked) || (document.Form1.reseni2.checked)&&(document.Form1.ucet.value.length>0)&&(document.Form1.banka_kod.value.length>0))
					{
						if ((!document.Form1.reseni3.checked) || (document.Form1.reseni3.checked)&&(document.Form1.informace.value.length>0))
						{
							if (document.Form1.prohlaseni.checked) 
                            {
                                if ((document.Form1.typ1.checked) && (document.Form1.id_fa.value>0) && (document.Form1.fa.value==0))
                                {
                                    produkt_za_korunu();
                                }
                                ok = true;
                            }
							else { alert ("Prohlášení musí být zatrhnuto!");}
						}
						else { alert ("Musíte uvést více informací!");}
					}
					else { alert ("Musíte uvést číslo účtu a kód banky!");}
				}
				else { alert ("Musíte zvolit preferovaný způsob řešení reklamace!");}
			}
			else { alert ("Musíte vyplnit popis reklamace!");}
		}
		else { alert ("Musíte zvolit typ požadavku!");}
  		return ok;
//  		return true;
	  }
	  
	  function ValidationExpedice()
	  {
	  	if ((typeof document.Form1.jmeno=='object') && (document.Form1.jmeno.value.length>0))
	  	{
	  		if ((typeof document.Form1.email=='object') && (document.Form1.email.value.length>=5))
	  		{
	  			if ((typeof document.Form1.velikosti_pocet == "object") && (parseInt(document.Form1.velikosti_pocet.value)>0))
	  			{
	  				velikosti = true;
	  				for (i=1;i<=parseInt(document.Form1.velikosti_pocet.value);i++)
	  				{
	  					if ((typeof document.Form1.elements["velikost"+i] == "object") && (parseInt(document.Form1.elements["velikost"+i].value)>0))
	  					{
	  					}
	  					else
	  					{
	  						velikosti = false;
	  						break;
	  					}
	  				}
	  				if (velikosti){return true;}
	  				else 
	  				{	
	  					alert ("Všechny vlastnosti produktu musí být zvoleny!"); 
	  					return false;
	  				}
	  			}
	  			else{return true;}
	  		}
	  		else
	  		{
	  			alert("Položka 'e-mail' musí být řádně vyplněna!");
	  			return false;
	  		}
	  	}
	  	else
	  	{
  			alert("Položka 'jméno' musí být řádně vyplněna!");
  			return false;
	  	}
	  }
	  
	  function ValidationSkladem()
	  {
		if ((typeof document.Form1.velikosti_pocet == "object") && (parseInt(document.Form1.velikosti_pocet.value)>0))
		{
			velikosti = true;
			for (i=1;i<=parseInt(document.Form1.velikosti_pocet.value);i++)
			{
				if ((typeof document.Form1.elements["velikost"+i] == "object") && (parseInt(document.Form1.elements["velikost"+i].value)>0))
				{
				}
				else
				{
					velikosti = false;
					break;
				}
			}
			if (velikosti){return true;}
			else 
			{	
				alert ("Všechny vlastnosti produktu musí být zvoleny!"); 
				return false;
			}
		}
		else{return true;}
	  }
      	  
	  function ValidationAukce()
	  {
	  	if ((typeof document.Form1.prihoz_castka=='object') && (document.Form1.prihoz_castka.value.length>0))
	  	{
	  		if (parseInt(document.Form1.prihoz_castka.value)>=parseInt(document.Form1.min_castka.value)){return true;}
	  		else
	  		{
	  			alert("Částka k přihození musí být minimálně "+parseInt(document.Form1.min_castka.value)+" Kč!");
	  			return false;
	  		}
	  	}
	  	else
	  	{
	  		alert("Částka k přihození musí být vyplněna!");
	  		return false;
	  	}
	  }
	  
	  function ValidationAukcePotvrzeni()
	  {
	  	if ((typeof document.Form1.souhlas=='object') && (document.Form1.souhlas.checked)){return true;}
	  	else
	  	{
	  		alert("Musíte potvrdit Souhlas se smluvním ujednáním a všeobecnými podmínkami");
	  		return false;
	  	}
	  }
	  
    function fcheck_kategorie(id)
    {
    	vsechny = true;
    	zadna = true;
    	if (id==0)
    	{
	    	for (i=0;i<=document.Form1.kategorie_pocet.value;i++)
	    	{
	    		if (typeof document.Form1.elements["hledani_kategorie"+i]=='object')
	    		{
    				document.Form1.elements["hledani_kategorie"+i].checked = true;
	    		}
	    	}    	
    	}
    	else
    	{
	    	for (i=1;i<=document.Form1.kategorie_pocet.value;i++)
	    	{
	    		if (typeof document.Form1.elements["hledani_kategorie"+i]=='object')
	    		{
	    			if (!document.Form1.elements["hledani_kategorie"+i].checked)
	    			{
	    				vsechny = false;
	    			}
	    			else
	    			{
	    				zadna = false;
	    			}
	    		}
	    	}
	    }
   		document.Form1.hledani_kategorie0.checked = vsechny;
   		if (zadna)
   		{
   			document.Form1.elements["hledani_kategorie"+id].checked = true;
   		}
	}
	
	function ValidationOnLine()
    {
    		ok = false;
    		for (i=1;i<=4;i++)
    		{
    			if (document.MERCHANTFORM.elements["brand"+i].checked)
    			{
    				ok = true;
    			}
    		}
    		if (ok)
    		{
    			return true;
    		}
    		else
    		{
    			alert("Musíte zvolit typ Vaší platební karty!")
    			return false;
    		}
    }	

    function ValidationAnketa()
    {
    		if (document.Form1.anketa_email.value.length<5)
	    	{
	      		alert ("Položka \'e-mail\' musí být správně vyplněna!");
	      		return false;
	    	}
	    	else
	    	{
				message = "";
				for (i=1;i<=5;i++)
				{
					zatrhnuto = false;
					odpovedi = false;
					for (j=1;j<=4;j++)
					{
						if (document.getElementById("odpoved"+i+""+j) != null)
						{
							odpovedi = true;
							if (document.Form1.elements["odpoved"+i+""+j].checked)
							{
								zatrhnuto = true;
								break;
							}
						}
					}
					message += (odpovedi&&!zatrhnuto)?"U otázky č."+i+" nemáte vyplněnou žádnou odpověď!\n":"";
				}
				if (message=="")
				{
					return true;
				}
				else
				{
					alert(message);
					return false;
				}
	    	}
    }
    
    function fsort(typ)
    {
        document.getElementById('znacky_url2').value = (document.getElementById('znacky_url2').value=='')?'sort=1':'';
        fset_znacka();
    }
    
    function fset_znacka()
    {
    	var znacky ='';
    	var vlastnosti ='';
    	var sort ='';
    	var pocet = 0;
    	if (document.getElementById('znacek_count')!=null)
    	{
        	for (i=document.getElementById('znacek_count').value;i>=1;i--)
        	{
        		if (document.getElementById('znacka'+i).checked)
        		{
        			znacky += (znacky=='')?'':'|';
        			znacky += document.getElementById('znacka'+i).value;
        			pocet ++;
        		}
        	}
        	znacky = ((pocet==document.getElementById('znacek_count').value)||(pocet==0))?'':'?z='+znacky;
        }
    	if (document.getElementById('znacky_url2').value!='')
    	{
    	   sort = (znacky=='')?'?':'&';
    	   sort += document.getElementById('znacky_url2').value;
    	}
    	if ((document.getElementById('vlastnosti_pocet')!=null) && (parseInt(document.getElementById('vlastnosti_pocet').value)>0))
    	{
    	   for (i=0;i<=parseInt(document.getElementById('vlastnosti_pocet').value);i++)
    	   {
    	       if (!document.getElementById('vlastnosti'+i).disabled)
    	       {
    	           vlastnosti += (vlastnosti!='')?'&':'';
    	           vlastnosti += "vlastnosti"+i+"="+document.getElementById('vlastnosti'+i).value;
    	           if (document.getElementById('vlastnosti_max'+i)!= null)
    	           {
    	               vlastnosti += "&vlastnosti_max"+i+"="+document.getElementById('vlastnosti_max'+i).value;
    	           }
    	           vlastnosti += "&prvek"+i+"="+document.getElementById('prvek'+i).value;
    	       }
    	   }
    	   if (vlastnosti!='')
    	   {
    	       vlastnosti += "&select_vlastnosti=ZOBRAZIT&vlastnosti_pocet="+parseInt(document.getElementById('vlastnosti_pocet').value);
    	   }
    	}
    	if (vlastnosti!='')
    	{
        	vlastnosti = ((znacky=='')&&(sort==''))?'?'+vlastnosti:'&'+vlastnosti;
    	}
//    	alert(document.getElementById('znacky_url1').value+" z:"+znacky+" s:"+sort+" v:"+vlastnosti);
    	document.location = document.getElementById('znacky_url1').value+znacky+sort+vlastnosti;
    }

    function zkontroluj_email(adresa)
    {
        var ok = true;
        re1 = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
        re2 = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;
        re = /.+@.+\..+$/;
        if (adresa.search(re) != 0)
        {
            chyba = "E-mail musí být řádně vyplněn!"
            ok = false;
        }
        else
        {
            
        }
        return ok;
    } 
        
    var stat = 'stat';

    function fcheck_doprava_stat()
    {
        pol = [];
        pol[1] = 'krukam_dod';
        pol[2] = 'ulice_dod';
        pol[3] = 'mesto_dod';
        pol[4] = 'psc_dod';
        pol[5] = 'nazev_dod';
        
        stat = 'stat';
        for (i=1;i<=5;i++)
        {
            if (typeof document.Form2.elements[pol[i]] == "object")
            {
                if (document.Form2.elements[pol[i]].value.length!=0)
                {
                    stat = 'stat_dod';
                    break;
                }
            }
        }
        var ok = false;
        if (astaty.length>0)
        {
            for (i=0;i<astaty.length;i++)
            {
                if (document.Form2.elements[stat].value==astaty[i])
                {
                    ok = true;
                    break;
                }
            }
        }
        else
        {
            alert ("Chyba stránky, zkuste stránku znovu načíst/aktualizovat (F5, refresh, reload).");
        }
        return ok;
    }

    function OdeslaniValidace()
    {
        
        var ok = false;
        var polozky = new Array();
        polozky[0] = Array();
        polozky[0][1] = 'email';
        polozky[0][2] = 'E-mail'+"\n";
        polozky[1] = Array();
        polozky[1][1] = 'jmeno';
        polozky[1][2] = 'Vaše jméno'+"\n";
        polozky[2] = Array();
        polozky[2][1] = 'prijmeni';
        polozky[2][2] = 'Vaše příjmení'+"\n";
        polozky[3] = Array();
        polozky[3][1] = 'ulice';
        polozky[3][2] = 'Ulice fakturačních údajů'+"\n";
        polozky[4] = Array();
        polozky[4][1] = 'mesto';
        polozky[4][2] = 'Město fakturačních údajů'+"\n";
        polozky[5] = Array();
        polozky[5][1] = 'psc';
        polozky[5][2] = 'PSČ fakturačních údajů'+"\n";
        polozky[6] = Array();
        polozky[6][1] = 'krukam_prijmeni';
        polozky[6][2] = 'Příjmení fakturačních údajů'+"\n";
        polozky[7] = Array();
        polozky[7][1] = 'krukam_dod';
        polozky[7][2] = 'Jméno fakturačních údajů'+"\n";
        polozky[8] = Array();
        polozky[8][1] = 'ulice_dod';
        polozky[8][2] = 'Ulice zasílací adresy'+"\n";
        polozky[9] = Array();
        polozky[9][1] = 'mesto_dod';
        polozky[9][2] = 'Město zasílací adresy'+"\n";
        polozky[10] = Array();
        polozky[10][1] = 'psc_dod';
        polozky[10][2] = 'PSČ zasílací adresy'+"\n";
        polozky[11] = Array();
        polozky[11][1] = 'nazev_dod';
        polozky[12] = Array();
        polozky[12][1] = 'gsm';
        polozky[12][2] = 'Telefon'+"\n";
        
        var chyba = '';
        if (fcheck_doprava_stat())
        {
            if (typeof document.Form2.email == "object")
            {
                for (i=0;i<=6;i++)
                {
                    i =(i==6)?12:i;
                    if (typeof document.Form2.elements[polozky[i][1]] == "object")
                    {
                        if (document.Form2.elements[polozky[i][1]].value.length==0)
                        {
                            chyba += polozky[i][2];
                            document.getElementById(polozky[i][1]).className="chyba-input";
                        }
                        else
                        {
                            document.getElementById(polozky[i][1]).className="";
                        }
                    }
                    else
                    {
                        chyba += polozky[i][2];
                    }
                }
                
                var vyplneny = false;
//                if (document.getElementById("fakturace").checked)
                {
                    for (i=7;i<=11;i++)
                    {
                        if (typeof document.Form2.elements[polozky[i][1]] == "object")
                        {
                            if (document.Form2.elements[polozky[i][1]].value.length!=0)
                            {
                                vyplneny = true;
                                break;
                            }
                        }
                    }
                }
                    if (vyplneny)
                    {
                        for (i=8;i<=10;i++)
                        {
                            if (typeof document.Form2.elements[polozky[i][1]] == "object")
                            {
                                if (document.Form2.elements[polozky[i][1]].value.length==0)
                                {
                                    chyba += polozky[i][2];
                                    document.getElementById(polozky[i][1]).className="chyba-input";
                                }
                                else
                                {
                                    document.getElementById(polozky[i][1]).className="";
                                }
                            }
                            else
                            {
                                chyba += polozky[i][2];
                            }
                        }
                    }
                
                
            }
            if (chyba!='')
            {
            
//                document.getElementById("email_error").innerHTML='<div class="chyba"><strong>Nevyplnil(a) jste následující položky:</strong></br><ul>'+chyba+'</ul></div>';
//                document.getElementById("h1").scrollIntoView(true);
                alert("Nejsou vyplněny následující položky:\n\n"+chyba);
            }
            else
            {
                if (!document.Form2.souhlas.checked)
                {
                    alert("Potvrďte prosím souhlas obchodních podmínek.")
                    ok = false;
                }
                else
                {
                    ok = true;
                }
            }
        }
        else
        {
/*        
            document.getElementById("email_error").innerHTML='<div class="chyba2">Vámi zvolený typ dopravy "'+doprava_nazev+'" <B>nelze použít</b> pro doručení zboží pro stát "'+document.Form2.stat.options.item(document.Form2.stat.selectedIndex).text+'"!<BR>'+
                                                            'Zvolte jiný způsob dopravy nebo jiný stát pro doručení v dodací adrese.<br><ul class="ull"><li class="formsubmit11"><a id="formbutton11" href="http://www.bkd.cz/doprava_platba.php"><< Zpět</a></li></ul></div>';
*/                                                            
//            document.getElementById("email_error").scrollIntoView(true);
            alert('Vámi zvolený typ dopravy "'+doprava_nazev+'" nelze použít pro doručení zboží pro stát "'+document.Form2.elements[stat].options.item(document.Form2.elements[stat].selectedIndex).text+'"'+"\nZvolte jiný způsob dopravy nebo jiný stát pro doručení v dodací adrese.");
            ok = false;
        }
//        alert(ok);
//////////////////////////////////
/*
        if (ok)
        {
//            alert("Odeslání objednávky zatím není plně funkční - objednávku nelze odeslat.")
//            ok = false;
        }
        else
        {
            ok = true;
        }
*/                
//        return true;
        return ok;
    }


    function OdeslaniRegistraceValidace(typ)
    {
        
        var ok = false;
        var polozky = new Array();
        polozky[0] = Array();
        polozky[0][1] = 'email';
        polozky[0][2] = 'E-mail'+"\n";
        polozky[1] = Array();
        polozky[1][1] = 'jmeno';
        polozky[1][2] = 'Jméno'+"\n";
        polozky[2] = Array();
        polozky[2][1] = 'prijmeni';
        polozky[2][2] = 'Příjmení'+"\n";
        polozky[3] = Array();
        polozky[3][1] = 'ulice';
        polozky[3][2] = 'Ulice a čp'+"\n";
        polozky[4] = Array();
        polozky[4][1] = 'mesto';
        polozky[4][2] = 'Město'+"\n";
        polozky[5] = Array();
        polozky[5][1] = 'psc';
        polozky[5][2] = 'PSČ'+"\n";
        
        polozky[6] = Array();
        polozky[6][1] = 'nazev_dod';
        polozky[7] = Array();
        polozky[7][1] = 'krukam_dod';
        polozky[7][2] = 'Jméno fakturačních údajů'+"\n";
        polozky[8] = Array();
        polozky[8][1] = 'ulice_dod';
        polozky[8][2] = 'Ulice fakturačních údajů'+"\n";
        polozky[9] = Array();
        polozky[9][1] = 'mesto_dod';
        polozky[9][2] = 'Město fakturačních údajů'+"\n";
        polozky[10] = Array();
        polozky[10][1] = 'psc_dod';
        polozky[10][2] = 'PSČ fakturačních údajů'+"\n";

        polozky[11] = Array();
        polozky[11][1] = 'gsm';
        polozky[11][2] = 'Telefon'+"\n";

        
        var chyba = '';
        var chyba_pass = '';
            if (typeof document.Form1.email == "object")
            {
                for (i=0;i<=6;i++)
                {
                    i = (i==6)?11:i;
                    if (typeof document.Form1.elements[polozky[i][1]] == "object")
                    {
                        if (document.Form1.elements[polozky[i][1]].value.length==0)
                        {
                            chyba += polozky[i][2];
                            document.getElementById(polozky[i][1]).className="chyba-input";
                        }
                        else
                        {
                            document.getElementById(polozky[i][1]).className="";
                        }
                    }
                    else
                    {
                        chyba += polozky[i][2];
                    }
                }
                pass = check_pass(typ);
	  		    if (((document.getElementById('reg')!=null) && (pass==0))||((document.getElementById('zmena')!=null)&&(pass<=1))) 
                {} 
	  		    else 
                {
//                    alert(pass)
                    chyba_pass = messpass[pass]+"\n";
                    document.getElementById("heslo").className="chyba-input"
                    document.getElementById("heslo2").className="chyba-input"
                    if (pass==5)
                    {
                        document.getElementById("heslo_puv").className="chyba-input"
                    }
                    
                } 
                
                var vyplneny = false;
//                if (document.getElementById("fakturace").checked)
                {
                    for (i=6;i<=10;i++)
                    {
                        if (typeof document.Form1.elements[polozky[i][1]] == "object")
                        {
                            if (document.Form1.elements[polozky[i][1]].value.length!=0)
                            {
                                vyplneny = true;
                                break;
                            }
                        }
                    }
                }
                    if (vyplneny)
                    {
                        for (i=7;i<=10;i++)
                        {
                            if (typeof document.Form1.elements[polozky[i][1]] == "object")
                            {
                                if (document.Form1.elements[polozky[i][1]].value.length==0)
                                {
                                    chyba += polozky[i][2];
                                    document.getElementById(polozky[i][1]).className="chyba-input";
                                }
                                else
                                {
                                    document.getElementById(polozky[i][1]).className="";
                                }
                            }
                            else
                            {
                                chyba += polozky[i][2];
                            }
                        }
                    }
                
                
            }
            if ((chyba!='')||(chyba_pass!=''))
            {
            
//                document.getElementById("email_error").innerHTML='<div class="chyba"><strong>Nevyplnil(a) jste následující položky:</strong></br><ul>'+chyba+'</ul></div>';
                if (chyba!='')
                {
                    chyba = 'Nejsou vyplněny následující položky:'+"\n\n"+chyba+"\n"; 
                }
                alert(chyba+chyba_pass);
//                document.getElementById("h1").scrollIntoView(true);
            }
            else
            {
                ok = true;
            }
        
//        alert(ok);
//////////////////////////////////                
//        return true;
        return ok;
    }

    function fcheck_email_start(reg, f, varianta)
    {
//        alert(reg);
//        alert(document.Form2.email.value);
        document.getElementById("iframe").src="check_email.php?reg="+reg+"&email="+document.forms[f].email.value+"&varianta="+varianta;
        return false;
    }
    
    function fcheck_email_end(chyba, typ, varianta)
    {
//        alert(chyba+", "+ typ+", "+varianta);
        if (chyba!='')
        {
            document.getElementById("email_error").innerHTML=chyba;
            document.getElementById("email").className="chyba-input";
            document.getElementById("h1").scrollIntoView(true);
///////////////////////////////////                                    document.Form1.formsubmit.click();
        }
        else
        {
            document.getElementById("email_error").innerHTML="";
            document.getElementById("email").className="";
            if (typ!=1)
            {
//                alert("click");
                document.getElementById("formsubmit").click();
            }
        }
        
        
    }
    
    function fcheck_email_blur(reg, f, varianta)
    {
//        alert(document.Form2.email.value);
        if (document.forms[f].email.value.length>0)
        {
            document.getElementById("iframe").src="check_email.php?reg="+reg+"&typ=1&email="+document.forms[f].email.value+"&varianta="+varianta;
            return false;
        }
        else
        {
            document.getElementById("email_error").innerHTML="";
            document.getElementById("email").className="";
        }
        
    }

    function Validation_Vas_Nazor()
    {
        ok = true;
        if (document.Form1.poznamka.value.length==0)
        {
            alert("Text poznamky musí být vyplněný!");
            ok = false;
        }
        return ok;
    }

    function fshow_kosik_save()
    {
        document.getElementById("link_save").className="invisible";
        document.getElementById("Form5").className="";
        
    }
    
    function ValidationKosikEmail()
    {
        var ok = true;
        if(!zkontroluj_email(document.Form5.email.value))
        {
            alert("E-mailová adresa pro zaslání znovuobnovovacího kódu musí být řádně vyplněna!");
            ok = false;
        }
        return ok;
    }

function zobrazSkryj(el, el2, nocheck)
{
    if (nocheck)
    {
        document.getElementById(el).checked = !document.getElementById(el).checked;
    } 
    document.getElementById(el2).className = (document.getElementById(el).checked)?"":"invisible";
}

/*
function browser_function()
{
    var nav = navigator.appVersion;
	if ((nav.indexOf('MSIE 7')>0) || (nav.indexOf('MSIE 6')>0))
	{ 
    	document.getElementById("WBControl").ExecWB(7, 1);
    	document.getElementById("WBControl").outerHTML = "";
    }
    else
    {
        window.print();
    }
}
*/

function fshow_kosik(stav)
{
    document.getElementById("kosik").style.display=stav;
}

function fkosik_click(id)
{
    document.getElementById('so_iframe').src="/get_produkt_atribs.php?id="+id;
}

function fclose_vel_box()
{
    document.getElementById("atribs").style.display='none';
    document.getElementById("overlay1").style.height = "0px";
    document.getElementById("overlay1").style.width = "0px"

}

function fvel_box_pos() 
{
  var  myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) 
  {
    //Non-IE
    myHeight = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  
  var scrOfY=0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } 
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }

  document.getElementById('atribs').style.top=myHeight/2-50+scrOfY+"px";
  document.getElementById('atribs').style.left=document.body.clientWidth/2-150+"px"
}



function fcheck_email(str) 
{
    var regex = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    return str.search(regex)!=-1;
//    return true;
  				
}

var aprolinac_title = new Array();
var aprolinac_annot = new Array();
var aprolinac_ahref = new Array();
var aprolinac_background = new Array();
var prolinac_page = 0;
var prolinac_timeout_id = 0;
var prolinac_fade_timeout_id = 0;
var prolinac_fade_value = 0;

function fprolinac_goto(page)
{
    prolinac_page = page;
    document.getElementById("prolinac_title").innerHTML=aprolinac_title[page];
    document.getElementById("prolinac_annot").innerHTML=aprolinac_annot[page];
    document.getElementById("prolinac_ahref").href=aprolinac_ahref[page];

    for (i=1;i<=3;i++)
    {
        document.getElementById("prolinac_dot"+i).src="/img/paging-row-dot.png";
    }
    document.getElementById("prolinac_dot"+(page+1)).src="/img/paging-row-active.png";
    
    if (typeof(document.getElementById("prolinac_img").style.filter)=="string")
    {
        if(typeof(document.getElementById("prolinac_img").filters)=="object")
        {
            document.getElementById("prolinac_img").filters[0].Apply();
        }
        document.getElementById("prolinac_img").style.backgroundImage = "url("+aprolinac_background[page]+")";
        if(typeof(document.getElementById("prolinac_img").filters)=="object")
        {
            document.getElementById("prolinac_img").filters[0].Play();
        }
        window.clearTimeout(prolinac_timeout_id);
        prolinac_timeout_id = window.setTimeout("fprolinac_start()", 5000);
    }
    else
    {
        document.getElementById("prolinac").style.backgroundImage = document.getElementById("prolinac_img").style.backgroundImage;
        document.getElementById("prolinac").style.MozOpacity = 100;
        document.getElementById("prolinac_img").style.MozOpacity = 0;
        document.getElementById("prolinac_img").style.backgroundImage = "url("+aprolinac_background[page]+")";
        prolinac_fade_value = 0;
        window.clearTimeout(prolinac_timeout_id);
        prolinac_timeout_id = window.setTimeout("ffade_images()", 25);
    }
}


function fprolinac_move(page)
{
    prolinac_page += page;
    prolinac_page = (prolinac_page<0)?2:prolinac_page;
    prolinac_page = (prolinac_page>2)?0:prolinac_page;
    fprolinac_goto(prolinac_page);
}

function fprolinac_start()
{ 
    fprolinac_move(1);
}

function ffade_images()
{
    window.clearTimeout(prolinac_timeout_id);
    if (prolinac_fade_value<1)
    {
        prolinac_fade_value += 0.1;
        document.getElementById("prolinac_img").style.MozOpacity = prolinac_fade_value;
        prolinac_timeout_id = window.setTimeout("ffade_images()", 25);
    }
    else
    {
        prolinac_timeout_id = window.setTimeout("fprolinac_start()", 5000);
    }
}


function fopen_zasoby(produkt_id)
{
    var win = window.open("/Produkt_skladem.php?id="+produkt_id, "online_skladova_dostupnost", "width=800,height=400,toolbar=no,toolbar=no,toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes");
    win.focus();
}   

function fshow_kat()
{
    document.getElementById('hide_kat').className=''; 
    document.getElementById('link_kat').className='invisible';
}

function fshow_add_kosik()
{
    document.getElementById("overlay1").style.height = document.body.clientHeight+"px";
    document.getElementById("overlay1").style.width = document.body.clientWidth+"px"
}

function fchange_cena(el)
{
//    alert(document.Form1.elements["velikost"+el].selectedIndex+" "+document.Form1.elements["velikost"+el].options.length);
    sel = (document.Form1.elements["velikost"+el].selectedIndex==document.Form1.elements["velikost"+el].options.length-1)?1:document.Form1.elements["velikost"+el].selectedIndex+1;
//    alert(sel);
    document.getElementById("produkt_cena").innerHTML = velikosti_array[sel];
}


function fset_barva(el, val)
{
//    alert(el+" "+val);
    document.Form1.elements["velikost"+el].value=val;
    if (el==ceny_skupina)
    {
        fchange_cena(el);
    }
}

function get_src_offsety()
{
  
  var scrOfY=0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } 
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function show_image(poradi)
{
//        alert(gal_show)
//    if (gal_show)
    {
        gal_show = true;
//        document.getElementById("lightbox").className="";
//        document.getElementById("lightboxImage").src="/Show_picture.php?typ=10&id="+aobr_id[poradi];
        document.getElementById("lightboxImage").src="/img/produkty/full/"+aobr_id[poradi];
        document.getElementById('lightbox').style.top=get_src_offsety()+20+"px";
        document.getElementById('loading').style.display="inline";
        gal_akt = poradi;
        gal_poprve = 1;
        fonload_image();
    }
}


function fonload_image()
{
    if /*(gal_poprve>0)*/(gal_show)    
    {
        fshow_add_kosik();
        show_velikosti("none");

        document.getElementById("lightbox").className="";
        document.getElementById("lightboxImage").className="";
        wi = (document.getElementById("lightboxImage").width>=250)?document.getElementById("lightboxImage").width:250;
        document.getElementById("outerImageContainer").style.width=wi+20+"px";
        document.getElementById("outerImageContainer").style.height=document.getElementById("lightboxImage").height+20+"px";
        document.getElementById("imageDataContainer").style.width=wi+20+"px";
        document.getElementById("prevLink").style.display= (gal_akt<=0)?"none":"inline";
        document.getElementById("prevLink").style.height= document.getElementById("lightboxImage").height;
        document.getElementById("nextLink").style.display=(gal_akt>=document.getElementById("imgs_count").value)?"none":"inline";
        document.getElementById("nextLink").style.height= document.getElementById("lightboxImage").height;
        document.getElementById('loading').style.display="none";
        offset = get_src_offsety();
        height = document.body.clientHeight;  
        fsize = (height>offset+document.getElementById("lightboxImage").height+100)?height:offset+document.getElementById("lightboxImage").height+100;
        document.getElementById("overlay1").style.height = fsize+"px";
//        document.getElementById("caption").innerHTML = "Galerie k produktu "+gal_nazev;
        pocet = (document.getElementById("imgs_count").value==0)?1:document.getElementById("imgs_count").value*1+1;
//        document.getElementById("numberDisplay").innerHTML = "Obrázek "+(gal_akt+1)+" z "+pocet;
        
        
    }
/*    
    else
    {
        gal_poprve = 1;
    }
*/    
}

function show_prev()
{
    if (gal_akt>0)
    {
        show_image(gal_akt-1)
    }
}

function show_next()
{
    if (gal_akt<document.getElementById("imgs_count").value)
    {
        show_image(gal_akt+1)
    }
}

function close_galery()
{
    document.getElementById("lightbox").className="invisible";
    document.getElementById("overlay1").style.height = "0px";
    document.getElementById("overlay1").style.width = "0px"
    show_velikosti("inline");
    gal_show = false
}

function fonload_pictures()
{
    load_count++;
//    alert(load_count+" "+document.getElementById("imgs_count").value);
    if ((load_count==document.getElementById("imgs_count").value)||(load_count==1&&(document.getElementById("imgs_count").value==0)))
    {
////        gal_show = true;
//        alert('x');
    }
}

function show_velikosti(styl)
{
    if (document.getElementById("velikosti_pocet")!=null)
    {
        if (document.getElementById("velikosti_pocet").value>0)
        {
            for (i=1;i<=document.getElementById("velikosti_pocet").value;i++)
            {
                document.getElementById("velikost"+i).style.display=styl;
            }
        }
    }
    if (document.getElementById("zdarma")!=null)
    {
        document.getElementById("zdarma").style.display=styl;
    }
}

