//------------------------------------
function Trim(tx)  // vymaze vsechny mezery
{  var b=0; 
   var tv="";
   for (b=0; b<tx.length;  b++)
     {  if (tx.substring(b,b+1)!=' ') tv=tv+tx.substring(b,b+1); }
   return tv;
}
//----------------------------------
function IsInt(tx)   //  kontrola na integer
{  var b=0; 
   for (b=0; b<tx.length;  b++)
     {  if ( tx.substring(b,b+1)<'0' | tx.substring(b,b+1)>'9' ) return 0; }
   return 1;
}
//-------------------------
function Number5 (tx)
{ var N;
sPom=Trim(tx);
  if (sPom=='') N=0; 
	else {   if (IsInt(sPom)==1) N=sPom; } 
  if (sPom.length!=5) return 0;
      else return N;
}

//----------------------

function Start(){
          Vyber();
          validate();
}

//----------------------

function Vyber()
{   
   if ( objGet('typ').value=='1' )
        { objGet('subtyp1').style.display='inline';
          objGet('subtyp2').style.display='none';
          objGet('subtyp3').style.display='none';
          objGet('subtyp4').style.display='none';
          objGet('subtyp5').style.display='none';
          objGet('subtyp6').style.display='none';
        }
   if ( objGet('typ').value=='2')
        {  objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='inline';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='none';
           objGet('subtyp6').style.display='none';
        }      
    if ( objGet('typ').value=='3')
        {  objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='inline';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='none';
           objGet('subtyp6').style.display='none';
        }      
    if ( objGet('typ').value=='4')
        {  objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='inline';
           objGet('subtyp5').style.display='none';
           objGet('subtyp6').style.display='none';
        }     
    if ( objGet('typ').value=='5')
        {  objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='inline';
           objGet('subtyp6').style.display='none';
        }   
    if ( objGet('typ').value=='6')
        {  objGet('subtyp1').style.display='none';
           objGet('subtyp2').style.display='none';
           objGet('subtyp3').style.display='none';
           objGet('subtyp4').style.display='none';
           objGet('subtyp5').style.display='none';
           objGet('subtyp6').style.display='inline';
        }    
}

//------------------

function objGet(id) {
   
   if (Boolean(document.getElementById))
      return document.getElementById(id);
   else if (Boolean(document.all))
      return eval('document.all.'+id);
   else
      return eval('document.'+id);
}

//------------

function openImage(url){
  okno = window.open('/show_pict.php?url='+url, 'image','resizable=1,top=20,left=20,menubar=0,scrollbars=1,width=690,height=530');
  okno.focus();
}

function OpenWindow(jmeno, w, h) 
{
    
    nem_id = objGet('nem_id').value;
	  url = 'info.php?nem_id=' + nem_id;
    Fokus = window.open(url, jmeno,'resizable=1,top=20,left=20,menubar=0,scrollbars=1,width=' + w + ',height=' + h);
    Fokus.focus();
}

//------------

var cislo = 1;

function OpenWindowID(nem_id, jmeno) 
{
	  url = 'info.php?nem_id=' + nem_id;
	  jmeno = 'okno'+cislo;
    var fokus = window.open(url, jmeno ,'resizable=1,top=20,left=20,menubar=0,scrollbars=1');
    fokus.focus()
    cislo++;
}
//------------


function OpenFotos(nem_id, jmeno, w, h) 
{   
    url = 'fotos.php?nem_id=' + nem_id;
    Foto = window.open(url, jmeno,'resizable=1,top=10,left=10,menubar=0,scrollbars=1,width=' + w + ',height=' + h);
    Foto.focus()
}

function delImage(id){
  if(confirm("opravdu odstranit tuto fotografii?")){
      location.href='realized.php?del='+id;
    }
}

function delKatalog(id){
  if(confirm("opravdu odstranit tento projekt?")){
      location.href='katalog.php?del='+id;
    }
}
