function validateForm(form)
{
   var i,field,theCheck,theCheck2,pom2,name,errors='';
   for (i=0; i<(form.elements.length-1); i+=1)
   {
      field = form.elements[i];
      if (field.title)
      {
         theCheck=field.title.substr(field.title.length-1,1);
         theCheck2=field.title.substr(3,1);
         if (theCheck=='*')
         {
            name=field.title.substr(0,field.title.length-1);
            if (theCheck2=='-') {name= name.substr(4,name.length);}
            if (!(field.value) || (field.value=="@"))
            { //IF EMPTY FIELD
               
               errors += name + ' chybí\n';
               field.className += " inValid";
            }
            else
              {
              field.className += " isValid";
              }
            if (theCheck2=='-')
            {
              pom1 = field.title.substr(0,3);
              theExt = pom1.toUpperCase();
              pom2 = field.value.substr(field.value.length-3,3);
              testExt = pom2.toUpperCase();
              if (testExt!=theExt)
              {
               errors += name + ' nemá příponu ' + theExt + '\n';
               field.className += " inValid";
              }
              else
                {
                field.className += " isValid";
                }
            }
            
         }
         else if ((field.value) && (theCheck!='*') && (theCheck2=='-'))
            {
            name=field.title.substr(4,field.title.length);
            pom1 = field.title.substr(0,3);
              theExt = pom1.toUpperCase();
              pom2 = field.value.substr(field.value.length-3,3);
              testExt = pom2.toUpperCase();
              if (testExt!=theExt)
              {
               errors += name + ' nemá příponu ' + theExt + '\n';
               field.className += " inValid";
              }
              else
              {
              field.className += " isValid";
              }
            }
            
      }
   }
   if (errors)
      alert('Objevily se následující chyby:\n\n'+errors);

   return (errors == '');
}
function addRow() 
{
	document.formUpload.count.value = parseInt(document.formUpload.count.value) + 1;
	var i = parseInt(document.formUpload.count.value);

	form = document.getElementById('others');
	if(i<=9)
	{
		data = '<span id="lin'+i+'">'+i+'. <input type="text" size="20" class="inputText" name="name[]" title="'+i+'. Název*" value="" /> <input type="text" class="inputText" name="link[]" size="30" value="" title="'+i+'. Odkaz*" /><br /></span>';
		form.innerHTML += data;	
	}
	if(i>1)
		document.getElementById('-Butt').disabled = false;
		
	if(i==9)
		document.getElementById('+Butt').disabled = true;
}
function delRow() 
{
	var i = parseInt(document.formUpload.count.value);
	document.formUpload.count.value = parseInt(document.formUpload.count.value) - 1;

	form = document.getElementById('lin'+i);
      var parent = form.parentNode;
      parent.removeChild(form);

	if(i==2)
		document.getElementById('-Butt').disabled = true;
	
	if(i<9)
		document.getElementById('+Butt').disabled = false;
}
function addRowFile() 
{
	document.formUpload.count.value = parseInt(document.formUpload.count.value) + 1;
	var i = parseInt(document.formUpload.count.value);

	form = document.getElementById('others');
	if(i<=9)
	{
		data = '<span id="lin'+i+'">'+i+'. <input type="text" size="20" class="inputText" name="name[]" title="'+i+'. Název*" value="" /> <input type="file" class="inputText" id="ButtFile" name="file[]" title="'+i+'. Soubor*" value="Procházet..." class="button"><br /></span>';
		form.innerHTML += data;	
	}
	if(i>1)
		document.getElementById('-Butt').disabled = false;
		
	if(i==9)
		document.getElementById('+Butt').disabled = true;
}
function delRowFile() 
{
	var i = parseInt(document.formUpload.count.value);
	document.formUpload.count.value = parseInt(document.formUpload.count.value) - 1;

	form = document.getElementById('lin'+i);
      var parent = form.parentNode;
      parent.removeChild(form);

	if(i==2)
		document.getElementById('-Butt').disabled = true;
	
	if(i<9)
		document.getElementById('+Butt').disabled = false;
}
function deleteItem(path)
{
   if (confirm("Opravdu chcete soubor vymazat?"))
   {
	  window.location.href=path;
   }
   else
   {
   		return
   }
}
function PrintDocument()
{
    window.document.execCommand('print');
}

