if (top.length != self.length) top.location.href = self.location.href;
if (!document.getElementById && document.all) document.getElementById = document.all;



var jeVidet = false;
var jeVidet2 = false;

// IE je prase!!
function prm(d,e,f,g)
{
document.getElementById(d).style.display = 'block';
document.getElementById(e).style.display = 'none';	
document.getElementById(f).style.display = 'none';
document.getElementById(g).style.display = 'none';
}


function prn(d)
{
document.getElementById(d).style.display = (jeVidet ? 'none' : 'block');
  jeVidet = (jeVidet ? false : true);
}

function prn2(d)
{
document.getElementById(d).style.display = (jeVidet2 ? 'none' : 'block');
  jeVidet2 = (jeVidet2 ? false : true);
}

function prn3(d)
{
  if(document.getElementById(d).style.display =='none')
  {
  document.getElementById(d).style.display = 'block';
  document.getElementById('zv').value = 'Skrýt vysvětlivky >>';
  }
  else
  {
  document.getElementById(d).style.display = 'none';
  document.getElementById('zv').value = 'Zobrazit vysvětlivky >>';
  }

}

function heslo_inp(obj)
{
var newO=document.createElement('input');
newO.setAttribute('type','password');
newO.setAttribute('name',obj.getAttribute('name'));
newO.className='inp3y';
obj.parentNode.replaceChild(newO,obj);
newO.focus();

}


function open_new(w,h) 
{
Okno=window.open("","JSL",'toolbar=0,location=0,scrollbars=0,width='+w+',height='+h+',resizable=0,top=50,left=50');
Okno.focus();
}


function checkoff(p)
{
for(i = 1; i <= p; i++)	
	{
		document.getElementById('n'+i).checked = false;	
	}

}


function CheckIt(i)
{
	if(document.getElementById(i).checked == false)
	{
document.getElementById(i).checked = true;
	}
	if(document.getElementById(i).checked == true)
	{
document.getElementById(i).checked = false;
	}
}


function validate_1()
{
if(document.getElementById('vase_jmeno').value == "")
	{
         alert('Nevyplnili jste jméno');
         document.getElementById('vase_jmeno').focus();
         return false;
        }
else if(document.getElementById('kontaktni_telefon').value == "")
	{
         alert('Nevyplnili jste telefon');
         document.getElementById('kontaktni_telefon').focus();
         return false;
        }
else if(document.getElementById('emailova_adresa').value == "")
	{
         alert('Nevyplnili jste emailovou adresu');
         document.getElementById('emailova_adresa').focus();
         return false;
        } 
else if(document.getElementById('text_dotazu').value == "")
	{
         alert('Nevyplnili jste text dotazu');
         document.getElementById('text_dotazu').focus();
         return false;
        }
else if (window.RegExp)

    {

        re = new RegExp("^[^@]+@[^.]+\..+$");

        if (!re.test(document.getElementById('emailova_adresa').value))

        {

            alert("Zadaná adresa není správnou adresou elektronické pošty!");
            document.getElementById('emailova_adresa').focus();
            return false;

        }

    }
else 
{
return true;
}
}


function validate_2()
{
if(document.getElementById('prihlaseni_uz_jm').value == "")
	{
         alert('Nevyplnili jste uživatelské jméno');
         document.getElementById('prihlaseni_uz_jm').focus();
         return false;
        }
else if(document.getElementById('prihlaseni_heslo').value == "")
	{
         alert('Nevyplnili jste heslo');
         document.getElementById('prihlaseni_heslo').focus();
         return false;
        }
else 
{
return true;
}
}

function vystraha(p)
{ 
  // p - pocet daneho produktu na skladu	
  // r - pocet kusu, ktere objednal zakaznik
  
  r = document.getElementById('pocet').value;
  
  if(r>p)
  {
    alert('Pokoušíte se objednat větší počet kusů než máme skladem.');
	return false;
  }
  else
  {
   return true;
  }
	
}

function odeslat(adresa,idf)
   {
       if (adresa)
       {
           var e = document.getElementById(idf);
           e.submit(adresa);
           
       }
   }
   
 
 

function kontrola()
{
	
//alert('test');	
if(document.krok2.typ_reg[0].checked==false && document.krok2.typ_reg[1].checked==false)
	{
         alert('Nevybrali jste typ registrace');
         return false;
    }
	else 
	{
	//return true;
	var e = document.getElementById('krok2');
    var adresa;
    
    if(document.krok2.typ_reg[0].checked==true)
    {
	adresa = '/registrace.html';	
	}
	else
	{
	adresa = '/bez-registrace.html';
	}
    
    
    
    e.setAttribute('action', adresa);
    e.submit(adresa);

	
	}
}  


function kontrola2()
{
var zatrzeno = false;
for(var i = 0; i < document.pokladna_1.doprava.length; i++)
{
  if(document.pokladna_1.doprava[i].checked) 
  zatrzeno = true;
}

if(zatrzeno!=true)
{
 window.alert("Nevybrali jste způsob dopravy");
return false;
}
else 
	{
	return true;

	}
}    


PositionX = 100;
PositionY = 100;

defaultWidth  = 500;
defaultHeight = 500;
 
var AutoClose = true;
 
if (parseInt(navigator.appVersion.charAt(0))>=4)
{
  var isNN=(navigator.appName=="Netscape")?1:0;
  var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;

  if(navigator.appName=="Opera")
  {
   var isNN=1;
  }
}


var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;


function popImage(imageURL,imageTitle){
  if (isNN){imgWin=window.open('','U',optNN);}
  if (isIE){imgWin=window.open('','U',optIE);}

  
  imgWin.focus();
  with (imgWin.document){
    writeln('<html><head><title>Loading...</title><style>body{margin:0px; text-align: center;}</style>');writeln('<sc'+'ript>');
    writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
    writeln('width=100-(document.body.clientWidth-document.images[0].width);');
    writeln('height=100-(document.body.clientHeight-document.images[0].height);');
    writeln('window.resizeTo(width+150,height);}');writeln('if (isNN){');
    writeln('window.innerWidth=document.images["image"].width;');writeln('window.innerHeight=document.images["image"].height;}}');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');

    if (!AutoClose)
      writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
    else
		  writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onclick="self.close()">');

		writeln('<img name="image" src='+imageURL+' style="display:block"></body></html>');
		close();
  }

}





// AJAX


function processRequest(s)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
	  var sel = document.getElementById(s);
      sel.innerHTML = httpRequest.responseText;
	  
	  // pokud neni zadna hlaska tak odesleme formular
	  delka = httpRequest.responseText.length;
	  //alert(delka);
	  
	  if(delka<2)
	   {
		   var e = document.getElementById('pokladna_1');
		   //e.submit('/objednavka.html');
		   e.submit('/stranky/zarezervuj.php');
	   }
	  
	  
    }
    else
    {
        alert("Chyba pri nacitani stranky "+ httpRequest.status +" : "+ httpRequest.statusText);
    }
  }
}

function zkontroluj_pocty()
{

var zatrzeno = false;

for(var i = 0; i < document.pokladna_1.doprava.length; i++)
{
  if(document.pokladna_1.doprava[i].checked) 
  zatrzeno = true;
}

if(zatrzeno!=true)
{
 window.alert("Nevybrali jste způsob dopravy");
return false;
}
else 
	{
	 if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
		
	    httpRequest.open("GET", "/stranky/kp.php?x=1");
        httpRequest.onreadystatechange= function () {processRequest("alert_div"); };
        httpRequest.send(null);

	}

/*
if(document.pokladna_1.doprava[0].checked==false && document.pokladna_1.doprava[1].checked==false && document.pokladna_1.doprava[2].checked==false)
	{
         alert('Nevybrali jste způsob dopravy');
         return false;
    }
	else 
	{
	


        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
		
	    httpRequest.open("GET", "/stranky/kp.php?x=1");
        httpRequest.onreadystatechange= function () {processRequest("alert_div"); };
        httpRequest.send(null);
        
		
	
	}
*/
}

function processRequest2(s)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
	  var sel = document.getElementById(s);
      sel.innerHTML = httpRequest.responseText;
	  
	  // pokud neni zadna hlaska tak odesleme formular
	  delka = httpRequest.responseText.length;
	  //alert(delka);
	  
	  if(delka<2)
	   {

		  window.location.href="/stranky/zarezervuj.php";
	   }
	  
	  
    }
    else
    {
        alert("Chyba pri nacitani stranky "+ httpRequest.status +" : "+ httpRequest.statusText);
    }
  }
}


function zkontroluj_pocty2()
{



        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
		
	    httpRequest.open("GET", "/stranky/kp.php?x=1");
        httpRequest.onreadystatechange= function () {processRequest2("alert_div"); };
        httpRequest.send(null);
        
	
	

}

