
	function webhard_upload_object_view(src){
			document.write(src);
	}	// function

	function attachFile()
	{
		if (webhard_perm_check('W') == false) return;

		if (nmail_updown_cp_check() == false) return;

		//frm.fUpload.AddFile(frm.txtAttachFile.value);
		frm.fUpload.AddFindFile();
		uploadAutoResize();
		attachSizeUpdate();
	}
	function attachFolder()
	{
		if (webhard_perm_check('W') == false) return;

		if (nmail_updown_cp_check() == false) return;

		frm.fUpload.AddFolder();
		uploadAutoResize();
		attachSizeUpdate();

		nm_isAttachFolder = true;
	}
	function Del_File()
	{
		if (nmail_updown_cp_check() == false) return;

		frm.fUpload.DeleteFile();
		attachSizeUpdate();
	}
	function ListTest()
	{
		frm.fUpload.TestLinkListValue();
	}
	function upload()
	{
		if (webhard_perm_check('W') == false) return;

		if (nmail_updown_cp_check() == false) return;

		if (frm.fUpload.TotalUploadCount() < 1)
		{
			alert("업로드할 파일을 먼저 추가하여 주십시오.");
		} else 
		{
			frm.fUpload.UploadExistUrl(nm_http_url_root + "/webhard/file_up_exists.php?wfd_key=" + document.webhard_info.wfd_key.value);
			frm.fUpload.UploadUrlAddress(nm_http_url_root + "/webhard/file_up_ok.php?wfd_key=" + document.webhard_info.wfd_key.value);

			var result = frm.fUpload.UploadStart(0);

			document.getElementById('fUpload').height = 105;
			webhard_file_upload_click();

			if (nm_isAttachFolder)
				webhard_folder_reload();

			webhard_file_reload();
			attachSizeUpdate();
		}	// if()
	}
	function getUploadFile_test()
	{
		var tmpsize = frm.fUpload.GetTotalUpSize();  //업로드 파일의 총크기

		var tmpcount = frm.fUpload.TotalUploadCount(); // 업로드 파일 갯수

		var tmpfile = frm.fUpload.GetUpFileInfo(); //업로드 파일정보.

		alert(tmpsize + ' | ' + tmpcount + ' | ' + tmpfile);		
	}	// function()

	function uploadAutoResize()
	{
		var obj = document.getElementById('fUpload');
		var tuc = obj.TotalUploadCount();
		var tcu_base = 18;
		var tcu_margin = 20;
		var tcu_max = 400;
		var u_height = parseInt(obj.height, 10);
		var now_height = (tuc * tcu_base)+tcu_margin;
		if (u_height < now_height)
		{
			if (now_height > tcu_max)
				now_height = tcu_max;
			obj.height = now_height;
		}	// if()
	}	// function()

	function UpdateSize()
	{
		attachSizeUpdate();
		/*
		var s_big = frm.fUpload.GetBigTotalSize(); //대용량 첨부파일 사이즈
		var s_small = frm.fUpload.GetSmallTotalSize(); //일반첨부파일 사이즈.
		alert('UpdateSize : ' + s_big + ' / ' + s_small);
		*/
	}	// function()

	function nmail_updown_cp_error()
	{
		nmail_updown_cp_status = false;
		//alert("업로드/다운로드용 컴포넌트가 설치되지 않았습니다.");		
	}	// function()

	function nmail_updown_cp_check()
	{
		if (!frm)
		{
			alert("업로드/다운로드를 위한 ActiveX 컨트롤이 로드되지 않았습니다.\n\n화면이 제대로 보이지 않을 경우 브라우저에서 [새로고침]을 시도해보시기 바랍니다. ");
			return false;
		}	// if()

		if (nmail_updown_cp_status == false)
		{
			if (navigator.appVersion.indexOf("MSIE") == -1)
			{
				alert("업로드/다운로드를 위한 ActiveX 컨트롤은 Internet Explorer 웹브라우저에서만 지원됩니다.");
			} else if (get_activex_use_support() == false)		// [2012-10-22] IE 10 fix
			{
				alert("업로드/다운로드를 위한 ActiveX 컨트롤을 현재 브라우저에서는 지원하지 않습니다.");
			} else
			{
				alert("업로드/다운로드를 위한 ActiveX 컨트롤이 설치되지 않았습니다.");
			}
			return false;
		}	// if()		
	}	// function()

	function SizeCalc(fileSize) {
		var strSize = 0.0;
		var strUnit = "";

		// GB 단위 계산
		if (fileSize > (1024*1024*1024))
		{
			strSize = (fileSize / (1024 * 1024 * 1024));
			strUnit = "G";
		} else if (fileSize > (1024*1024))              // MB 단위 계산
		{
			strSize = (fileSize / (1024 * 1024));
			strUnit = "M";
		}else	// KB 단위 계산
		{
			strSize = (fileSize / 1024);
			strUnit = "K";
		}

		return strSize.toFixed(2) + strUnit;
	}

	function attachSizeUpdate()
	{
		document.getElementById('sUploadSize').innerHTML = SizeCalc(frm.fUpload.GetSmallTotalSize());
	}	// function()



	function webhard_folder_add()
	{
		if (webhard_perm_check('W') == false) return;

		if (parseInt(document.webhard_info.wfd_key.value, 10) == 0)
		{
			alert("상위 폴더를 먼저 클릭하여 주십시오.");
		} else
		{
			window_open(nmpath + '/webhard/folder_add.php?wfd_parent=' + document.webhard_info.wfd_key.value, '_nm_webhard_folder_add', 350, 300);
		}	// if()
	}	// function

	function webhard_folder_mod()
	{
		if (webhard_perm_check('D') == false) return;

		window_open(nmpath + '/webhard/folder_mod.php?wfd_key=' + document.webhard_info.wfd_key.value, '_nm_webhard_folder_add', 350, 300);
	}	// function

	function webhard_folder_del()
	{
		if (webhard_perm_check('D') == false) return;

		if (confirm("선택한 폴더를 삭제하시겠습니까?"))
		{
			if (confirm("경고 !!!\n\n폴더안에 존재하는 모든 폴더와 파일들이 삭제되며 복구할 수 없게 됩니다.\n\n정말로 삭제하시겠습니까?"))
			{
				_nm_webhard_folder_frame.location.href = nmpath + '/webhard/folder_del.php?wfd_key=' + document.webhard_info.wfd_key.value;
			}	// if()
		}
	}	// function

	function webhard_folder_reload()
	{
		document.getElementById('_nm_webhard_folder_frame').src = nmpath + '/webhard/folder_list.php?wfd_key=' + document.webhard_info.wfd_key.value;
	}	// function

	function webhard_folder_click(wfd_key)
	{
		document.webhard_info.wfd_key.value = wfd_key;
		document.getElementById('_nm_webhard_file_frame').src = nmpath + '/webhard/file_list.php?wfd_key=' + wfd_key;

		document.webhard_search.reset();

		//_nm_webhard_folder_frame.iframe_height_sync('_nm_webhard_folder_frame');
	}	// function()


	function webhard_file_upload_click()
	{
		if (webhard_perm_check('W') == false) return;

		if (document.all.webhard_file_upload.style.display == 'none')
		{
			if (nmail_updown_cp_check() == false) return;

			document.all.webhard_file_upload.style.display = '';
			var tmpsize = parseInt(document.webhard_info.webhard_free_size.value, 10);
			frm.fUpload.SetLimitUploadSize(tmpsize/1024/1024);
			document.getElementById('sMaxSize').innerHTML = SizeCalc(tmpsize);
		} else
		{
			document.all.webhard_file_upload.style.display = 'none';
		}	// if()
	}	// function

	function webhard_file_download()
	{
		if (webhard_perm_check('R') == false) return;

		if (nmail_updown_cp_check() == false) return;

		if (!_nm_webhard_file_frame.document.getElementById('cmf[]'))
		{
			alert("다운로드할 파일이 없습니다.");
		} else
		{
			var el = _nm_webhard_file_frame.document.list.elements;
			var el_check_cnt = 0;

			for (var eCount = 0; eCount < el.length; eCount++)
			{
				if(el[eCount].type == "checkbox" && el[eCount].name == 'cmf[]' && el[eCount].checked)
				{
					el_check_cnt++;
				}
			}

			if (el_check_cnt < 1)
			{
				alert("다운로드할 파일들을 먼저 선택하여 주십시오.");
			} else
			{
				var wfd_list = "";
				var files = new Array();
				for (var eCount = 0; eCount < el.length; eCount++)
				{
					if(el[eCount].type == "checkbox" && el[eCount].name == 'cmf[]' && el[eCount].checked)
					{
						// [2009-06-17] 선택된 파일을 먼저 다운로드에 추가하고, 폴더는 나중에 일괄 추가.
						if (el[eCount].value.indexOf("|") == -1)
						{
							wfd_list += "|" + el[eCount].value;
						} else
						{
							files.push(el[eCount].value);
							//var sp = el[eCount].value.split("|");
							//frm2.fUpload.AddDownloadFile(nmpath + "/webhard/file_down.php?wf_key=" + sp[0] + "&wfd_key=" + sp[1],sp[2],sp[3],wf_cnt);
						}
					}
				}

				// [2009-06-17] 폴더 다운로드
				if (wfd_list != "")
				{
					new Ajax.Request(nmpath + '/webhard/file_list_ajax.php', {
						method: 'post',
						parameters: 'q=' + wfd_list,
						onSuccess: function(transport) {
							var sp2 = transport.responseText.split('|!|');
							for (i=0; i<sp2.length; i++)
							{
								if (sp2[i] != '')
								{
									files.push(sp2[i]);
								}
							}	// for()

							for (i=0; i<files.length; i++)
							{
								if (files[i] != '')
								{
									sp = files[i].split("|");
									frm2.fUpload.AddDownloadFile(nmpath + "/webhard/file_down.php?wf_key=" + sp[0] + "&wfd_key=" + sp[1],sp[2],sp[3],files.length);
								}
							}	// for()

							frm2.fUpload.DownloadStart();
						},
						onFailure: function(transport) {
							alert('Error: '+transport.status+"\n\n"+transport.responseText);
						}
					});		
				} else
				{
					for (i=0; i<files.length; i++)
					{
						if (files[i] != '')
						{
							sp = files[i].split("|");
							frm2.fUpload.AddDownloadFile(nmpath + "/webhard/file_down.php?wf_key=" + sp[0] + "&wfd_key=" + sp[1],sp[2],sp[3],files.length);
						}
					}	// for()

					frm2.fUpload.DownloadStart();
				}
			}	// if()
		}	// if()
	}	// function


	function webhard_mail_write()
	{
		var msg = "";
		var res = true;
		var form = _nm_webhard_file_frame.document.list;

 		if (countCheckBox(form, 'cmf[]') < 1)
 		{
			alert("편지쓰기시 첨부할 항목들을 선택하여 주십시오.");
			return;
 		}

		form.action = nmpath + "/mail_write.php?mode=WEBHARD";
		form.method = "post";
		form.target= "_parent";
		form.submit();
	}	// function


	function webhard_file_del()
	{
		if (webhard_perm_check('D') == false) return;

		var msg = "";
		var res = true;
		var form = _nm_webhard_file_frame.document.list;

 		if (countCheckBox(form, 'cmf[]') < 1)
 		{
			alert("삭제할 항목들을 선택하여 주십시오.");
			return;
 		}

		res = confirm("선택한 항목들을 삭제하시겠습니까?");
		if (res == true)
		{
			form.action = nmpath + "/webhard/file_del.php";
			form.method = "post";
			form.submit();
		}
	}	// function


	function webhard_file_reload()
	{
		document.getElementById('_nm_webhard_file_frame').src = nmpath + '/webhard/file_list.php?wfd_key=' + document.webhard_info.wfd_key.value;

		document.webhard_search.reset();
	}	// function


	function webhard_file_search()
	{
		var form = document.webhard_search;

		if (form_chk_value(form.s_word, "검색할 단어") == false) return;

		form.wfd_key.value = document.webhard_info.wfd_key.value;

		form.action = nmpath + "/webhard/file_list.php";
		form.target = "_nm_webhard_file_frame";
		form.submit();

		form.s_word.select();
	}	// function


	// 권한 검사
	function webhard_perm_check(perm_kind)
	{
		switch (perm_kind)
		{
			case 'W':
				if (document.webhard_info.ws_perm.value.indexOf("|W|") == -1)
				{
					alert("선택하신 공용웹하드에 [업로드]권한이 없습니다.");
					document.all.webhard_file_upload.style.display = 'none';
					return false;
				}	// if()		
				break;

			case 'R':
				if (document.webhard_info.ws_perm.value.indexOf("|R|") == -1)
				{
					alert("선택하신 공용웹하드에 [다운로드]권한이 없습니다.");
					return false;
				}	// if()		
				break;

			case 'D':
				if (document.webhard_info.ws_perm.value.indexOf("|D|") == -1)
				{
					alert("선택하신 공용웹하드에 [삭제]권한이 없습니다.");
					return false;
				}	// if()		
				break;
		
			default:
				alert("Error : webhard_perm_check - " + perm_kind);
				return false;
				break;
		}	// switch()
	}	// function()
