function getElement(e)
{
  if(document.all) return document.all[e];
  else return document.getElementById(e);
}

function InsertFileInput()
{
  getElement("File_Loading").innerHTML += "<br><input type='file' name='fileload[]'>";
}

function DeleteFile(soubor,cesta)
{
  smazat = window.confirm("Opravdu chcete smazat soubor "+soubor+"?"); 
  if (smazat)
  {
    location.href="editace.php?path="+cesta+"&order=delete&file="+soubor;
  }
}

function RenameFile(soubor,cesta)
{
  novynazev = window.prompt('Přejmenování souboru '+soubor+'!', soubor);
  if (novynazev!=null)
  {
    location.href="editace.php?path="+cesta+"&order=rename&oldname="+soubor+"&newname="+novynazev;
  }
}

function DeleteDir(cesta,adresar)
{
  smazat = window.confirm("Opravdu chcete smazat adresar "+adresar+"?");
  if (smazat)
  {
    location.href="editace.php?path="+cesta+"&order=deletedir&dir="+adresar;
  }
}

function RenameDir(cesta,adresar)
{
  novynazev = window.prompt('Přejmenování adresáře '+adresar+'!', adresar);
  if (novynazev!=null)
  {
    location.href="editace.php?path="+cesta+"&order=renamedir&oldname="+adresar+"&newname="+novynazev;
  }
}

function CreateDir(cesta)
{
  jmeno = window.prompt('Vytvořit adresář','');
  if (jmeno!=null)
  {
    location.href="editace.php?path="+cesta+"&order=createdir&dir="+jmeno;
  }
}

function OpenEdit(cesta,soubor)
{
	window.open('edit.php?path='+cesta+'&file='+soubor, 'Editace', 'height='+(screen.height-50)+',width='+screen.width+',left=0,top=0,menubar=0,status=0,toolbar=0,scrollbars=0');
}

function OpenNewEdit(cesta)
{
  jmeno = window.prompt('Jméno nového souboru:', '');
  if (jmeno!=null)
  {
    window.open('edit.php?path='+cesta+'&file='+jmeno, 'Editace', 'height='+(screen.height-50)+',width='+screen.width+',left=0,top=0,menubar=0,status=0,toolbar=0,scrollbars=0');
  }
}

function CloseWindowFromSave(cesta, soubor)
{
	window.opener.focus();
	window.opener.location='editace.php?path='+cesta+'&order=editfile&file='+soubor;
	window.close();
}

function CloseWindow()
{
	window.opener.focus();
	window.close();
}

function SaveFileAs(cesta)
{
	if (document.ulozit.cil.value=="")
	{
		CloseWindow();
	} else {
		window.opener.document.editform.path.value=cesta;
		window.opener.document.editform.file.value=document.ulozit.cil.value;
		window.opener.document.editform.submit();
		CloseWindow();
	}
}

function Writable(cesta,soubor)
{
	var prepsat = window.confirm("Daný soubor už existuje, chcete jej přepsat??")
	if (prepsat)
	{
		window.opener.document.editform.path.value=cesta;
		window.opener.document.editform.file.value=soubor;
		window.opener.document.editform.submit();
		CloseWindow();
	}
}

function SaveAs(cesta, soubor)
{
	window.open('save_as.php?path='+cesta+'&file='+soubor, 'Saving', 'height=300,width=250,left=412,top=284,menubar=0,status=0,toolbar=0,scrollbars=1');
}

