﻿

function download(path, file){
	location.href = "/include/common/download.asp?path="+path+"&file="+encodeURIComponent(file);
}

function DivideString(objFrm, strMIMEValue){
	var tags;
	
	// 전송할 MIME 데이터를 100KB 단위로 분리하여
	// contents라는 이름의 hidden 타입 폼 태그를 생성하여 저장.
	// 수신 측(여기서는 TWE_UPDATE.asp)에서는 
	// 이를 contents 폼 파라미터 컬렉션으로 가져와서 재조합하여 사용.
	while(strMIMEValue.length > 0){
			tags = document.createElement("input");
			tags.setAttribute("type", "hidden");
			tags.name = "mime_contents";
			tags.value = strMIMEValue.substr(0, 1000);
			objFrm.appendChild(tags);
			strMIMEValue = strMIMEValue.substr(1000);
	}
	tags = document.createElement("input");
	tags.setAttribute("type", "hidden");
	tags.name = "mime_contents";
	tags.value = strMIMEValue;
	objFrm.appendChild(tags);
}


function ShowProgress(obj) { 
   strAppVersion = navigator.appVersion; 
   if (obj.value != "") {
	  if (strAppVersion.indexOf('MSIE')!=-1 && 
		  strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) { 

		  winstyle = "dialogWidth=385px; dialogHeight:150px; center:yes"; 
		  window.showModelessDialog("/common/upload/show_progress.asp?nav=ie", null, winstyle); 
	  } 
	  else { 
		  winpos = "left=" + ((window.screen.width-380)/2)+",top=" +
			   ((window.screen.height-110)/2); 
		  winstyle = "width=380,height=110,status=no,toolbar=no,menubar=no," + 
			   "location=no,resizable=no,scrollbars=no,copyhistory=no," + winpos; 
		  window.open("/common/upload/show_progress.asp",null,winstyle); 
	  } 
   }
   return true; 
} 


function imgPopView(path, imgnm){
	if(imgnm != ""){
		imgPath = path + encodeURIComponent(imgnm);
		objImg = new Image();
		objImg.src = (imgPath);
		imgPopViewModule(imgPath);
	}
}

function imgPopViewModule(imgPath){
	if((objImg.width != 0)&&(objImg.height != 0)){
		imgPopViewCreate(imgPath);
	} else{
		funzione="imgPopViewModule('"+imgPath+"')";
		interval=setTimeout(funzione,20);
	}
}

function imgPopViewCreate(imgPath){
	width  = objImg.width+20;
	height = objImg.height+20;
	opt = "width="+width+",height="+height;
	img_view = window.open("about:blank", "", opt);
	img_view.document.open();
	img_view.document.writeln("<html>");
    	img_view.document.writeln("<head>");
	img_view.document.writeln("<title>이미지 뷰</title>");
	img_view.document.writeln("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
	img_view.document.writeln("</head>");
	img_view.document.writeln("<body>");
	img_view.document.writeln("<img src="+ imgPath +" border=0 style='cursor:hand' onclick=javascript:window.close()>");
	img_view.document.writeln("</body>");
	img_view.document.writeln("</html>");
	img_view.document.close();
}
//checkbox한개만 선택되게
	function checkCheckbox(frm,obj) {
		var str = obj.name;
		var len = frm.length;

		var chk = 0;
		for(i=0; i<len; i++) {
			if (frm[i].name == str && frm[i].checked == true) {
				chk++;
			}
			if (chk > 1) {
			alert("1개만 선택할 수 있습니다.");
			obj.checked = false;
			break;
			}
		}
	}
	function chkYn(e1){
		var isChecked =false;
		var chValue = "";
		if(e1 != null){
			if(e1.length == undefined){
				isChecked = e1.checked;
				chValue = e1.value;
			}else{
				for(j=0; j<e1.length; j++){
					if(e1[j].checked){
						isChecked = true;
						chValue = e1[j].value;
					}
				}
			}
		}
		if(isChecked != true){
			alert("대상을 선택하세요.");
			return;
		}
		return chValue;
	}
