<? if ( !defined("_INCLUDED_GLOBAL") ) exit;		// [Security]Allow_url_fopen = On ?>

<script language="JavaScript" src="<?= $nmpath ?>/addon/js/prototype.js?v=<?= NM_VER ?>"></script>

<script language="javascript">
<!--
	var frm2;
	var nmail_updown_cp_status = true;
	var nm_isAttachFolder = false;

	var nm_http_host = "http://<?= $_SERVER["HTTP_HOST"] ?>";
	var nm_http_url_root = "<?= $G_SYS['HTTP_URL_ROOT'] ?>";
	var nm_mb_id = "<?= $_GET['mb_id'] ?>";

	// IE 외의 브라우저에서는 ActiveX를 지원하지 않으므로 비활성화처리
	if (navigator.appVersion.indexOf("MSIE") == -1)
		nmail_updown_cp_status = false;
	
	function uploadConfigSet()
	{
		frm2 = document.frmOcx;

		if (nmail_updown_cp_status == true)
		{
			// download
			frm2.fUpload.SetDownHostUrl(nm_http_host);
			frm2.fUpload.SetDnTitle("<?= $G_SYS['NM_UPLOADER_TITLE_DN'] ?>");
		}	// if()
	}

	window.onload = function()
	{
		uploadConfigSet();
	}



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

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

		if (nmail_updown_cp_status == false)
		{
			alert("업로드/다운로드를 위한 ActiveX 컨트롤이 설치되지 않았습니다.");
			return false;
		}	// if()		
	}	// function()

	function nmail_download_activex(from)
	{
		if (nmail_updown_cp_check() == false) return;

			var el = document.list.elements;

			var mf_no_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)
				{
					mf_no_list += "|" + el[eCount].value;
				}
			}

			new Ajax.Request(nmpath + '/mail_list_ajax.php', {
				method: 'post',
				parameters: 'mb_id=' + nm_mb_id + '&q=' + mf_no_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 + "/mail_down.php?mb_id=" + nm_mb_id + "&mf_no=" + sp[0],sp[1],sp[2],files.length);
						}
					}	// for()

					frm2.fUpload.DownloadStart();
				},
				onFailure: function(transport) {
					alert('Error: '+transport.status+"\n\n"+transport.responseText);
				}
			});
	}	// function

//-->
</script>


<form name="frmOcx" method="post" style="margin:0px">
	<script type="text/javascript">
		<!--
			objectView('<object id="fUpload" height=0 width=0 classid=CLSID:<?= $G_SYS['NM_UPLOADER_CLSID_DN'] ?> codebase="<?= $G_SYS['NM_UPLOADER_CODEBASE'] ?>#version=<?= $G_SYS['NM_UPLOADER_VER'] ?>" name=fUpload VIEWASTEXT> <PARAM NAME="_Version" VALUE="65536"> <PARAM NAME="_ExtentX" VALUE="2646"> <PARAM NAME="_ExtentY" VALUE="1323"> <PARAM NAME="_StockProps" VALUE="0"> </OBJECT>');
			//uploadConfigSet();
	   //-->
	</script>
</form>

