//·¹ÇÁÆ®¸Þ´º °¹¼ö¸¦ °¡Á®¿É´Ï´Ù(bbsÀÇ ·¹ÇÁÆ®¸Þ´º¸¦ À§ÇÔ)
function menuCnt(oneDepth){
	try{
		var oneDepthCnt = 0;
		for(var i = 1; i <=20; i++){	 
			var locationArr = eval("u"+oneDepth+"_"+i);
			if(locationArr) {
				oneDepthCnt = oneDepthCnt +1
			}
		}
	}catch(e){}
	return oneDepthCnt;
}

//·¹ÇÁÆ®¸Þ´º °¹¼ö¸¦ °¡Á®¿É´Ï´Ù(pds ·¹ÇÁÆ®¸Þ´º¸¦ À§ÇÔ - 2depth)
function menuCnt2(oneDepth, twoDepth){
	var twoDepthCnt = 0;
	try{
		
		for(var i = 1; i <=20; i++){
			if ( eval("u"+oneDepth+"_"+twoDepth+"_"+i) != null)
			{
				var locationArr = eval("u"+oneDepth+"_"+twoDepth+"_"+i);
				if(locationArr) {
					twoDepthCnt++;
				}
			}else{
				break;
			}
		}
	}catch(e){}
	return twoDepthCnt;
}
/* 
ÆÄÀÏÀÌ ÀÌ¹ÌÁöÀÎÁö ÆÄÀÏÀÎÁö ±¸ºÐ
Ã¹¹øÂ° ÀÎÀÚ : ÆÄÀÏ¸í
µÎ¹øÂ° ÀÎÀÚ : ¾÷·Îµå °¡´ÉÇÑ È®ÀåÀÚ
*/
function chkFileExtGubun(fileName, ext) {
	var fileExtVal = "";
	var extention = ext.split(",");
	var lastIndex = fileName.lastIndexOf(".");
	var fileExt = fileName.substring(lastIndex+1);	
	if(extention.length > 0 ) {
		for(var i = 0 ; i <= extention.length-1 ; i++) {
			if( fileExt == extention[i] ) {
				fileExtVal = "IMG"
			}
		}
		if(fileExtVal == "" ) {
			fileExtVal = "FILE"
		} 
	}

	return fileExtVal;
	
}

// ±Ûµî·Ï,¼öÁ¤½Ã Ã·ºÎÆÄÀÏ '|^|' ¸¦ ±¸ºÐÀÚ·Î ÇØ¼­ È÷µçÇÊµå·Î ³Ñ±è //
function getAttachFile() {

	var oriAttachFile = document.getElementById("oriAttachFile");
	var newAttachFile = document.getElementById("newAttachFile");
	var attachedFileList = document.getElementById("attachedFileList");
	var attachType = document.getElementById("attachType");
	var oriFile = "";
	var newFile = "";
	var fileType = "";

	if(oriAttachFile && newAttachFile && attachedFileList) {
		for(var i=0; i<attachedFileList.length; i++) {
			if(attachedFileList[i].value != "") {
				oriFile += attachedFileList[i].text + "|^|";
				newFile += attachedFileList[i].value + "|^|";
				fileType += chkFileExtGubun(attachedFileList[i].value, "gif,jpg,png,bmp, jpeg") +  "|^|";
			}
		}
		oriFile = oriFile.substr(0,oriFile.length-3);
		newFile = newFile.substr(0,newFile.length-3);
		oriAttachFile.value = oriFile;
		newAttachFile.value = newFile;
		attachType.value = fileType;
	}
}



// ÆÄÀÏ´Ù¿î·Îµå //
function bbsDownload(num,fileType) {
	location.href='/bbs/bbs_download.asp?num=' + num+'&fileType='+fileType;
}

function videoDownload(fileName, filepath) {
	location.href='/common/include/download2.asp?fn=' + fileName + '&fp=' + filepath;
}
// ÆÄÀÏ´Ù¿î·Îµå //
function pdsDownload(num,fileType, table) {
	if (num == "" || num == null){
		alert("Ã·ºÎµÈ µ¿¿µ»óÀÌ ¾ø½À´Ï´Ù!");
		return;
	}
	location.href='/pds/pds_download.asp?num=' + num+'&fileType='+fileType+'&table='+table;
}
//ÇöÀçURL length-1À» ÇÑ°ÍÀº ³¡¿¡ # ÀÌ µé¾î°¡±â ¶§¹®ÀÔ´Ï´Ù.
var documentUrl = location.href; 
//¹ÌÅõµ¥ÀÌ·Î ½ºÅ©¸³ÆÃÇÕ´Ï´Ù.
function sendMe2Day() {
	var pageTitle = eval("u" + globalId + "[1]");	// global_url.js ¿¡ ÀÖ´Â ¹è¿­¿¡¼­ µÎ¹øÂ° Á¦¸ñÀ» °¡Á®¿È.	
	if( pageTitle == "Home") {
		pageTitle = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) È¨ÆäÀÌÁö"
	}
	var tag = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) " + pageTitle;

	var wp = window.open("http://me2day.net/posts/new?new_post[body]=%22"+encodeURIComponent(pageTitle)+"%22:"+encodeURIComponent(documentUrl)+"&new_post[tags]="+encodeURIComponent(tag),'me2Day','');

	if(wp) {
		wp.focus();
	}
}

//ÆäÀÌ½ººÏÀ¸·Î ½ºÅ©¸³ÆÃ ÇÕ´Ï´Ù.
function sendFacebook() {
	var pageTitle = eval("u" + globalId + "[1]");	// global_url.js ¿¡ ÀÖ´Â ¹è¿­¿¡¼­ µÎ¹øÂ° Á¦¸ñÀ» °¡Á®¿È.	
	if( pageTitle == "Home") {
		pageTitle = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) È¨ÆäÀÌÁö"
	}
	var tag = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) " + pageTitle;

	var wp = window.open("http://www.facebook.com/sharer.php?u="+documentUrl+"&t="+encodeURIComponent(pageTitle),'FaceBook','');

	if(wp) {
		wp.focus();
	}
}


//Æ®À§ÅÍ·Î ½ºÅ©¸³ÆÃ ÇÕ´Ï´Ù.
function sendTwitter() {
	var pageTitle = eval("u" + globalId + "[1]");	// global_url.js ¿¡ ÀÖ´Â ¹è¿­¿¡¼­ µÎ¹øÂ° Á¦¸ñÀ» °¡Á®¿È.	
	if( pageTitle == "Home") {
		pageTitle = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) È¨ÆäÀÌÁö"
	}
	var tag = "ÇÑ±¹ÄÉÀÌºíTV¹æ¼ÛÇùÈ¸(KCTA) " + pageTitle;

	var content = '"' +pageTitle + '" ' +documentUrl; //±»ÀÌ : (ÄÝ·Ð)À» ³ÖÀ» ÇÊ¿ä°¡ ¾øÀ½
	var wp = window.open('http://twitter.com/home?status='+encodeURIComponent(content),'Twitter','');

	if(wp) {
		wp.focus();
	}
}

function printIt() {
	window.open("/bbs/board_print.asp","°Ô½Ã¹°ÀÎ¼â","width=700,height=500,scrollbars=yes");
}

function bbs_sendMail(pNum, tbl) {
	window.open("/bbs/sendEmail.asp?pNum="+pNum+"&tbl="+tbl,"°Ô½Ã¹°¸ÞÀÏº¸³»±â","width=460,height=590");
}
function job_sendMail(pNum) {
	window.open("/notice/sendEmail.asp?pNum="+pNum,"°Ô½Ã¹°¸ÞÀÏº¸³»±â","width=460,height=590");
}
function printIt2() {
	window.open("/pds/pds_print.asp","°Ô½Ã¹°ÀÎ¼â","width=700,height=500,scrollbars=yes");
}

function pds_sendMail(pNum, tbl) {
	window.open("/pds/sendEmail.asp?pNum="+pNum+"&tbl="+tbl,"°Ô½Ã¹°¸ÞÀÏº¸³»±â","width=460,height=590");
}

	//-----------------------------------------------------------------------------
	// ¼ýÀÚÀÇ ÀÚ¸®¼ö(cnt)¿¡ ¸Âµµ·Ï ¹ÝÈ¯
	// @return : º¯È¯µÈ String			ex) 33.digits(4) => "0033";
	// ex) ¼ýÀÚ.digits(ÀÚ¸®¼ö);
	//-----------------------------------------------------------------------------
	Number.prototype.digits = function(cnt) {
		var sThis = this.toString();
		var digit = "";

		if (sThis.length < cnt) {
			for(var i = 0; i < cnt - sThis.length; i++) {
				digit += "0";
			}
		}

		return digit + sThis;
	};



	// ÇØ´ç ³â/¿ùÀÇ ÃÑ ³¯Â¥¸¦ °è»êÇÑ´Ù..
	function getLastDay(year, month){
		var arrDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
		
		if( (month == 2) && isLeapYear(year) ){
			return (arrDays[1] + 1);
		} else{
			return arrDays[month - 1]; 
		}
	}


	// À±³â Ã¼Å©..
	function isLeapYear(year){
		return (year%4==0) && ((year%10!=0) || (year%400==0));
	}


	// ÇØ´ç¿ùÀÇ Ã¹¹øÂ° ¿ù¿äÀÏÀÇ ³¯Â¥¸¦ ±¸ÇÑ´Ù!
	function getFirstMonday(year, month){
		var oDate = new Date(year, (month-1), 1);

		while( oDate.getDay() != 1 ){
			oDate.setDate( oDate.getDate() + 1 );
		}

		return oDate;
	}
