var num_di = 0;
var renameOn = false;
var permissionsOn = false;
permission="";


function submitForm(action, file, file2)
{
  document.actionform.actionType.value = action;
  document.actionform.file.value = file;
  document.actionform.file2.value = file2;
  document.actionform.submit();
};

function toggle(layer) {
	if (document.getElementById(layer).style.display=="none")
	{
		document.getElementById(layer).style.display="";
	} else {
		document.getElementById(layer).style.display="none";
	}
}
function setNewFileName()
{
	if(renameOn) {
		document.getElementById("renameFileEntry").style.display="none";
		renameOn = false;
	} else {
		document.actionform.actionType.value="rename";
		document.getElementById("renameFileEntry").style.display="";
		document.renameFile.newName.value=document.actionform.file.value;
		document.renameFile.newName.focus();
		renameOn=true;
	}
};


function createDirectory(directory)
{
  if(directory)
  {submitForm("createdir", directory);}
  else
  {alert('ใส่ชื่อ Folder ด้วยท่าน'); }
};


function uploadnon()
{
		document.up.submit();
};

//               ================   Go Zip  ========================================
function ZipFileSize(fname,fsize)
{	if (fsize)
		{
					document.zipfi.filename.value = fname;
					document.zipfi.dsize.value = fsize;
					document.zipfi.submit();
					return;
		}
};

function ZipGo()
{		
		document.zigo.submit();
		return;

};

function ZipFolSize(fname)
{	if (fname)
		{
					document.zipfi.filename.value = fname;
					document.zipfi.submit();
					return;
		}
};

function ZipData(zdata,fname)
{	if (zdata)
		{
					document.zsend.data.value = fname;
					document.zsend.data.value = zdata;
					document.zsend.submit();
					return;
		}
};

function clearbasket()
{		
		document.zAdel.submit();
		return;

};

function DelZip(id_zip)
{		if (id_zip)
	{
		document.zdel.idzip.value = id_zip;
		document.zdel.submit();
		return;
	}
};
//               ================   End Zip  ========================================
//               ================   Go DVD   ========================================document.dvd.pathname.value = fullpath;
function GoConfirmDVD(id_send)
{
		document.gofirmdvd.id_send.value = id_send;
		document.gofirmdvd.submit();
return;
};
function firmDVD(id_send)
{
		document.firmdvd.check_firm.value = 1;
		document.firmdvd.id_send.value = id_send;
		document.firmdvd.submit();
return;
};


function goems()
{
		document.goems.gogo.value = 1;
		document.goems.submit();
return;
};

function gosize(fname)
{	if (fname)
{document.dvd.pathname.value = fname;
document.dvd.typ.value = 0;
			document.dvd.submit();
			return;}
};

function gofilesize(fname,fsize,ftype)
{	if (ftype == ".!ut")
		{
			if (confirm("File นี้ยัง Download ไม่เสร็จ -> " + fname + " ยังต้องการย้ายอยู่ไหม ?"))
				{
					document.dvd.pathname.value = fname;
					document.dvd.dsize.value = fsize;
					document.dvd.typ.value = 1;
					document.dvd.submit();
					return;
				}
			else
				{
					return;
				}
		}
	else
		{
					document.dvd.pathname.value = fname;
					document.dvd.dsize.value = fsize;
					document.dvd.typ.value = 1;
					document.dvd.submit();
					return;
		}
};
//               ================   Re Folder Name   ========================================

function Repro(product_id)
{
			document.Repro.pro_id.value = product_id;
			document.Repro.submit();
			return;
};
//               ================   Re File Name   ========================================
function ReFileName(fname,tname,fullname)
{
oldname = fullname;
numloop = 0;
while (numloop < 3) 
{
	var nfname = prompt("ชื่อเดิม => " + fullname + " \n ใส่ชื่อที่ต้องการเปลี่ยนครับ",fname);
	var nfullname = nfname + tname;
	if (nfname == fname || nfname == null)
		{
			if (confirm("คุณยังไม่ได้เปลี่ยนชื่อ File " + oldname + " ยังต้องการเปลี่ยนอยู่ไหม ?"))
				{}
			else
				{return;}
		}
	else if (nfname == "" || nfname == " ")
		{
			if (confirm("คุณลบชื่อ File และยังไม่ได้ตั้งใหม่ ยังต้องการเปลี่ยนอยู่ไหม ?"))
				{}
			else
				{return;}
		}
	else if(confirm("คุณต้องการเปลี่ยนชื่อ File \n" + oldname + " เป็น " + nfullname +" ?"))
		{
					document.refilename.fullname.value = fullname;
					document.refilename.nfullname.value = nfullname;
					document.refilename.submit();
					return;
		}		

			numloop++;
 }
};

function goremote()
{

		document.gremote.submit();

};


function deleteFile()
{
	if (confirm("[  สั่งลบ...ตรวจดูดีแล้วนะครับ ?]\n"))
	{
		document.de.submit();
	}
};

function ddel(deld)
{	if (deld)
{document.de.godel.value = deld;}

};

function fdel(deld)
{	if (deld)
{document.de.gofdel.value = deld;}
};

function Confirmation(URL)
{
  if (confirm("[  สั่งลบ...ตรวจดูดีแล้วนะครับ ?]\n"))
  {location = String(URL);}
  else
  {
	  //Do nothing 
  }
};

function gohash()
{
		document.gohash_c.para.value = document.location.search;
		document.gohash_c.submit();
return;
};
function goh(menud)
{
var inhtm = "menu-lv" + menud;
var inspan = menud + "x";
			if(document.getElementById(inhtm).style.display == 'none'){
	document.getElementById(inhtm).style.display = 'none';
		document.getElementById(inspan).innerHTML = '+';
		
	}else{
	
		document.getElementById(inhtm).style.display =  'list-item';
		document.getElementById(inspan).innerHTML = '-';
	}

};
