/**
* °øÅë ÇÔ¼ö
*/

/* for textarea */
function PrintEmbed(EmbID) 
{ 
    document.write(document.getElementById(EmbID).value);
} 

/* for div */
function PrintEmbed2(EmbID)
{
	//alert(document.getElementById(EmbID).innerHTML);
    var objHtml = document.getElementById(EmbID).innerHTML;
    //alert(objHtml);
    document.getElementById(EmbID).innerHTML = "";
	document.write(objHtml);
}


/**
* ÇÑ±ÛÀ» 2¹ÙÀÌÆ® ¾¿ °è»êÇÏ¿© ÀÔ·Â¹ÞÀº ¹®ÀÚ¿­ÀÌ DB¿¡ ÀúÀåµÉ ¶§ ÃÑ ¸î¹ÙÀÌÆ®¸¦ Â÷ÁöÇÏ´ÂÁö °è»êÇÑ´Ù.
* ¿£ÅÍ(\r\n)´Â 2¹ÙÀÌÆ®¸¦ Â÷ÁöÇÑ´Ù.
* @param val : ÀÔ·Â¹ÞÀº ¹®ÀÚ¿­
*/
function getLength(val)
{

	// ÀÔ·Â¹ÞÀº ¹®ÀÚ¿­À» escape() ¸¦ ÀÌ¿ëÇÏ¿© º¯È¯ÇÑ´Ù.
	// º¯È¯ÇÑ ¹®ÀÚ¿­ Áß À¯´ÏÄÚµå(ÇÑ±Û µî)´Â °øÅëÀûÀ¸·Î %uxxxx·Î º¯È¯µÈ´Ù.
	var temp_estr = escape(val);
	var s_index = 0;
	var e_index = 0;
	var temp_str = "";
	var cnt = 0;

	// ¹®ÀÚ¿­ Áß¿¡¼­ À¯´ÏÄÚµå¸¦ Ã£¾Æ Á¦°ÅÇÏ¸é¼­ °¹¼ö¸¦ ¼¾´Ù.
	while ((e_index = temp_estr.indexOf("%u", s_index)) >= 0) // Á¦°ÅÇÒ ¹®ÀÚ¿­ÀÌ Á¸ÀçÇÑ´Ù¸é
	{
	temp_str += temp_estr.substring(s_index, e_index);
	s_index = e_index + 6;
	cnt ++;
	}

	temp_str += temp_estr.substring(s_index);

	temp_str = unescape(temp_str); // ¿ø·¡ ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

	// À¯´ÏÄÚµå´Â 2¹ÙÀÌÆ® ¾¿ °è»êÇÏ°í ³ª¸ÓÁö´Â 1¹ÙÀÌÆ®¾¿ °è»êÇÑ´Ù.
	return ((cnt * 2) + temp_str.length) + "";
}

/* Uplaod & validate */
/*
function editor_upload() {

	document.form_name.p_html_content.value = document.NetEditorGlobal.Submit();

	if("" == document.form_name.p_html_content.value){
		alert("ÀÌ¹ÌÁö ¾÷·Îµå¸¦ ½ÇÆÐÇÏ¿´½À´Ï´Ù!");
		return;
	}
/*
	var fm_ok = document.FileManagerGlobal.Submit();
	if(fm_ok == -1){
		alert("ÆÄÀÏ ¾÷·Îµå¸¦ ½ÇÆÐÇÏ¿´½À´Ï´Ù.!");
		return;
	}

	for(var i=0; i<10000; i++){
		temp = 1*100;
	}

	// ÀÌ¹ÌÁö ¾÷·Îµå °á°ú¸¦ º¸¿©ÁÙ Å×½ºÆ® °á°ú ÇÁ·Î±×·¥.
	document.form_name.p_add_con_img_list.value = document.NetEditorGlobal.GetFileList("GetAddFileList");
	document.form_name.p_del_con_img_list.value = document.NetEditorGlobal.GetFileList("GetDelFileList");

	// ÆÄÀÏ ¾÷·Îµå °á°ú¸¦ º¸¿©ÁÙ Å×½ºÆ® °á°ú ÇÁ·Î±×·¥.
//	document.form_name.p_add_att_list.value = document.FileManagerGlobal.GetFileList("GetAddFileList");
//	document.form_name.p_del_att_list.value = document.FileManagerGlobal.GetFileList("GetDelFileList");

	//document.form_name.submit();
	BBsWrite();
}
*/

function editor_getHTML(){
	alert(document.NetEditorGlobal.GetAction("GetHTML"));		// º»¹® HTML
	alert(document.NetEditorGlobal.GetAction("GetFullHTML"));	// ÀüÃ¼ HTML
}

function editor_insertHTML()	{
	document.NetEditorGlobal.setAction("InsertHTML", "<a href='http://dev1.donorscamp.org'><b>µµ³Ê½ºÄ·ÇÁ</b></a><br>", "", "");
}

function editor_loadURL()	{
	document.NetEditorGlobal.setAction("LoadURL", "http://dev1.donorscamp.org", "", "");
}

function editor_setHTML(){
	document.NetEditorGlobal.setAction("SetHTML", "<a href='http://dev1.donorscamp.org'><b>µµ³Ê½ºÄ·ÇÁ</b></a><br>", "", "");
}

// wi = 700 / hi = 670
function popupImage(folder,ViewIdName,hiddenName, filepath) {

	var url = "/Netville/netimage_Popup.asp?folder="+folder+"&ViewIdName="+ViewIdName+"&hiddenName="+hiddenName+"&filepath=" + filepath;
	var width = 760;
	var height = 690;
	window.open(url, "NetImage", "width="+width+", height="+height+", toolbar=no, directories=no, resizable=no, menubar=no, status=no, scrollbars=yes, top=100,left="+(screen.availwidth-width)/2);
}

function popupImage2(folder,ViewIdName,hiddenName,filepath,cnt) {

	var url = "/Netville/netimage_Popup.asp?folder="+folder+"&ViewIdName="+ViewIdName+"&hiddenName="+hiddenName+"&filepath=" + filepath+"&cnt="+cnt;
	var width = 760;
	var height = 690;
	window.open(url, "NetImage", "width="+width+", height="+height+", toolbar=no, directories=no, resizable=no, menubar=no, status=no, scrollbars=yes, top=100,left="+(screen.availwidth-width)/2);
}


function popupThumImg(folder,ViewIdName,hiddenName, filepath) {

	var url = "/Netville/thumimg_Popup.asp?folder="+folder+"&ViewIdName="+ViewIdName+"&hiddenName="+hiddenName+"&filepath=" + filepath;
	var width = 760;
	var height = 690;

	window.open(url, "NetImage", "width="+width+", height="+height+", toolbar=no, directories=no, resizable=no, menubar=no, status=no, scrollbars=yes, top=100,left="+(screen.availwidth-width)/2);
}

function popupThumImg_m(folder,ViewIdName,hiddenName,filepath,strthumdiv) {

	var url = "/Netville/thumimg_Popup.asp?folder="+folder+"&ViewIdName="+ViewIdName+"&hiddenName="+hiddenName+"&filepath=" + filepath;
	var width = 760;
	var height = 690;

	if (strthumdiv != " ")
	{
		if(document.getElementById(strthumdiv).style.display != 'none')
		{
			alert('½æ³×ÀÏ »èÁ¦ ÈÄ º¯°æ °¡´ÉÇÕ´Ï´Ù	');
			return;
		}
	}
	window.open(url, "NetImage", "width="+width+", height="+height+", toolbar=no, directories=no, resizable=no, menubar=no, status=no, scrollbars=yes, top=100,left="+(screen.availwidth-width)/2);
}

// wi = 430 / hi = 620
function popupMovie() {
	var url = "/Netville/moviemate_Popup.asp";	
	var width = 430;
	var height = 620;
	
	window.open(url, "MovieMat", "width="+width+", height="+height+", toolbar=no, directories=no, resizable=no, menubar=no, status=no, scrollbars=no, top=100,left="+(screen.availwidth-width)/2);
}

function FileViewform(ViewIdName,hiddenName, filepath)
{
	var f = document.form_name;
	// ³ª´²¼­ Ãâ·ÂÇÑ´Ù.
	var txtFileList = "";

	var NameEval = "document.form_name."+hiddenName;
	var hiddenNameValue = eval(NameEval).value;
	
	var Filearr = hiddenNameValue.split("|");
	
	if (Filearr.length > 0)
	{
	
		for (k = 0; k < Filearr.length - 1; k+=2)
		{
			txtFileList = txtFileList + "<dl class='fir'><dt><img src='"+filepath+"/"+Filearr[k]+"' width='160' height='120'/></dt><dd>"+Filearr[k]+ "<a href=javascript:imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','" +filepath + "');><img src='http://www.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a>"
			// txtFileList = txtFileList + Filearr[k] + "(" + Filearr[k+1] + ") <a href=javascript:imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','" +filepath + "');><img src='http://www.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a><br>";
		}

		document.getElementById(ViewIdName).innerHTML = txtFileList;

		f.all[ViewIdName].style.display="";
	}
	return;
}

function movieFileViewform(pixTime, pixSize)
{
	var f = document.form_name;
	var txtFileList = "";
	var ViewIdName = "movFileList";
	
	if (pixTime != "" && pixSize != "")
	{
			var hiddenNameValue = f.pixTime.value;
			txtFileList = pixTime + "conver.flv|" + pixSize + "|";
			f.pixTime.value = txtFileList + hiddenNameValue;
			
			txtFileList=""
			var hiddenNameValue = f.pixTime.value;
			var Filearr = hiddenNameValue.split("|");
			
			if (Filearr.length > 0)
			{
				for (k = 0; k < Filearr.length - 1; k+=2)
				{
					txtFileList = txtFileList + Filearr[k] + "(" + Filearr[k+1] + ") <br>";
				}

				document.getElementById(ViewIdName).innerHTML = txtFileList;

				f.all[ViewIdName].style.display="";
			}
	}
	return;
}


function imageDataDelete(ViewIdName,hiddenName,imageFile,filepath)
{
	var f = document.form_name;
	var txtFileList = "";
	var txtHTMLList = "";
	var NameEval = "document.form_name."+hiddenName;
	var hiddenNameValue = eval(NameEval).value;

	if(confirm(imageFile + "À» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		var Filearr = hiddenNameValue.split("|");
		if (Filearr.length > 0)
		{
		
			for (k = 0; k < Filearr.length - 1; k+=2)
			{
				if (Filearr[k] != imageFile)
				{
					if (txtFileList == "")
					{
						txtFileList = Filearr[k] + "|" + Filearr[k+1];
					}
					else
					{
						txtFileList = txtFileList + "|" + Filearr[k] + "|" + Filearr[k+1];
					}
					txtHTMLList = txtHTMLList + "<dl class='fir'><dt><img src='"+filepath+"/"+Filearr[k]+"' width='160' height='120'/></dt><dd>"+Filearr[k]+ "<a href=javascript:imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','" +filepath + "');><img src='http://www.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a>"

					//txtHTMLList = txtHTMLList + Filearr[k] + "(" + Filearr[k+1] + ") <a href=javascript:imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','"+filepath+"');><img src='http://www.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a><br>";
				}
			}
			
			eval(NameEval).value = txtFileList;
			document.getElementById(ViewIdName).innerHTML = txtHTMLList;

			if (txtFileList == "")
			{
				f.all[ViewIdName].style.display="none";
			}

			f.target="NetvilleDeleteImage";
			f.action = "/Netville/NetvilleDeleteImage.asp?imageFile="+imageFile + "&filepath=" + filepath;		
			f.submit();
			return;
		}
	}
	return;

}

function movDelete(movPkid, filepath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ µ¿¿µ»óÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/movieDeleteProc.asp?Pkid="+movPkid+"&filepath="+filepath;		
		f.submit();
		return;
	}
	return;
}

function movDelete_real(movPkid,thumPkid,filepath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ µ¿¿µ»óÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/movieDeleteProc.asp?Pkid="+movPkid+"&filepath="+filepath+"&thumPkid="+thumPkid;		
		f.submit();
		return;
	}
	return;
}

function imgDelete(imgPkid,FileName,FilePath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ ÀÌ¹ÌÁö¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/ImageDeleteProc.asp?Pkid="+imgPkid+"&FileName="+FileName+"&FilePath=" + FilePath;		
		f.submit();
		return;
	}
	return;
}

function movFutureDelete(movPkid, filepath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ µ¿¿µ»óÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/movieFutureDeleteProc.asp?Pkid="+movPkid+"&filepath="+filepath;		
		f.submit();
		return;
	}
	return;
}

function movFutureDelete_real(movPkid,thumPkid,filepath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ µ¿¿µ»óÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/movieFutureDeleteProc.asp?Pkid="+movPkid+"&filepath="+filepath+"&thumPkid="+thumPkid;		
		f.submit();
		return;
	}
	return;
}

function imgFutureDelete(imgPkid,FileName,FilePath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ ÀÌ¹ÌÁö¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/ImageFutureDeleteProc.asp?Pkid="+imgPkid+"&FileName="+FileName+"&FilePath=" + FilePath;		
		f.submit();
		return;
	}
	return;
}

function ThumImgDelete(imgPkid, FileName, FilePath)
{
	var f = document.form_name;
	if(confirm("¼±ÅÃÇÑ ÀÌ¹ÌÁö¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		f.target="NetvilleDeleteImage";
		f.action = "/Netville/ThumImageDeleteProc.asp?Pkid="+imgPkid+"&FileName="+FileName+"&FilePath="+FilePath;		
		f.submit();
		return;
	}
	return;
}

function displayDiv(str)
{
	var f = document.form_name;
	f.all[str].style.display="none";
	return;
}

//ÀÌ¹ÌÁöÅ©±â·Î ÆË¾÷¶ç¿ì±â...½ÃÀÛ
function open_img(img_name,img_path)
{ 
	var largh = 30;
	var altez = 30;
	var winl = 0;
	var wint = 0;
	stringa="width="+largh+",height="+altez+',top='+wint+',left='+winl+',scrollbars=no,resizable=yes';
	pop_win=window.open("/Netville/img_pop.asp?sfile_name="+img_name+"&img_path="+img_path,"img001",stringa);
}

//µ¿¿µ»óÆË¾÷¶ç¿ì±â...½ÃÀÛ
function open_movie(movie_path, move_type)
{ 
	var largh = 420;
	var altez = 340;
	var winl = 0;
	var wint = 0;
	stringa="width="+largh+",height="+altez+',top='+wint+',left='+winl+',scrollbars=no,resizable=yes';
	pop_win=window.open("/Netville/movie_pop.asp?filepath="+movie_path+"&filetype="+move_type,"movie001",stringa);
}

// Ã·ºÎÆÄÀÏ ´Ù¿î·Îµå
function fnc_down(arg_file, arg_path)
{
	//alert(arg_file);
	//alert(arg_path);
	
	var f = document.FrmNetvilleDown;
	
	if (typeof(f) != "object") 

	{
		alert("FrmNetvilleDown FORMÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù. ÀÌ FORMÀ» ÆäÀÌÁö¿¡ »ðÀÔÇØ¾ß °¡´ÉÇÕ´Ï´Ù.");
		return;
//		var Redirect_Url = '/Netville/File_Download.asp?FileName='+arg_file+'&FilePath='+arg_path;
//		location.href = Redirect_Url;
//		window.open(Redirect_Url,'filedownload','width=0,height=0,top=5000,left=5000')
	}
	else
	{	
		f.FileName.value = arg_file;
		f.FilePath.value = arg_path;
		f.action = "/Netville/File_Download.asp";
		f.submit();
	}
	
//	var Redirect_Url = '/Netville/File_Download.asp?FileName='+arg_file+'&FilePath='+arg_path;
//	location.href = Redirect_Url;
	// window.open(Redirect_Url,'filedownload','width=0,height=0,top=5000,left=5000')
}

// CJ_CGV Àü¿ë ÀÓ½Ã ÆÄÀÏÆû
function CGV_FileViewform(ViewIdName,hiddenName, filepath)
{
	var f = document.form_name;
	// ³ª´²¼­ Ãâ·ÂÇÑ´Ù.
	var txtFileList = "";

	var NameEval = "document.form_name."+hiddenName;
	var hiddenNameValue = eval(NameEval).value;
	
	var Filearr = hiddenNameValue.split("|");
	
	if (Filearr.length > 0)
	{
	
		for (k = 0; k < Filearr.length - 1; k+=2)
		{
			txtFileList = txtFileList + "<dl class='fir'><dt><img src='"+filepath+"/"+Filearr[k]+"' width='160' height='120'/></dt><dd>"+Filearr[k]+ "<a href=javascript:CGV_imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','" +filepath + "');><img src='http://dev1.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a>"
			// txtFileList = txtFileList + Filearr[k] + "(" + Filearr[k+1] + ") <a href=javascript:imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"','" +filepath + "');><img src='http://www.donorscamp.org/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a><br>";
		}

		document.getElementById(ViewIdName).innerHTML = txtFileList;

		f.all[ViewIdName].style.display="";
	}
	return;
}


function CGV_imageDataDelete(ViewIdName,hiddenName,imageFile)
{
	var f = document.form_name;
	var txtFileList = "";
	var txtHTMLList = "";
	var NameEval = "document.form_name."+hiddenName;
	var hiddenNameValue = eval(NameEval).value;

	if(confirm(imageFile + "À» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		var Filearr = hiddenNameValue.split("|");
		if (Filearr.length > 0)
		{
		
			for (k = 0; k < Filearr.length - 1; k+=2)
			{
				if (Filearr[k] != imageFile)
				{
					if (txtFileList == "")
					{
						txtFileList = Filearr[k] + "|" + Filearr[k+1];
					}
					else
					{
						txtFileList = txtFileList + "|" + Filearr[k] + "|" + Filearr[k+1];
					}

					txtHTMLList = txtHTMLList + Filearr[k] + "(" + Filearr[k+1] + ") <a href=javascript:CGV_imageDataDelete('"+ ViewIdName +"','"+ hiddenName +"','"+ Filearr[k] +"');><img src='/Cj_cgv/images/icon/icon_del.gif' class='va_m' alt='»èÁ¦' /></a><br>";
				}
			}
			
			eval(NameEval).value = txtFileList;
			document.getElementById(ViewIdName).innerHTML = txtHTMLList;

			if (txtFileList == "")
			{
				f.all[ViewIdName].style.display="none";
			}

			f.target="NettvilleDeleteImage";
			f.action = "/CJ_CGV/inc/NettvilleDeleteImage.asp?imageFile="+imageFile;		
			f.submit();
		}
	}
	return;

}
