
/*
/	ÀÚ¹Ù½ºÅ©¸³Æ® ÇÔ¼ö - ÀüÃ¼ °ø¿ë
/	ÀÛ¼ºÀÚ : ¹æ±âÁØ
/										*/

var ns4=document.layers;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;

// °ø¹éÁ¦°Å ÇÔ¼ö
function trim(str){
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function trims(str) {	
	str = str.replace(/^\s+/, '');	
	for (var i = str.length - 1; i > 0; i--) {		
		if (/\S/.test(str.charAt(i))) {			
			str = str.substring(0, i + 1);			
			break;
			}
		}
	return str;
}
// °ø¹éÁ¦°Å³¡

// ¼ýÀÚ ÀÔ·Â¸¸ Çã¿ë
function onlyNumber(txtEl)
{
	 if (isNaN(txtEl.value) || txtEl.value == "") 
        { 
                alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä."); 
                txtEl.value = ""; 
                return false; 
        } 
        return true; 
}

function checkNumber2(objEv)
{
	var numPattern = /([^0-9])/;

	numPattern = objEv.value.match(numPattern);

	if(numPattern != null)
	{
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		objEv.value = "";
		objEv.focus();
		return false;
	}
	return true;
}

// Æ¯¼ö¹®ÀÚ Ã¼Å©ÇÔ¼ö
function checkNumber()
{
	var objEv = event.srcElement;
	var num ="{}[]()<>?_|~`!@#$%^&*-+\"'\\/ ";
	event.returnValue = true;
	for (var i=0;i<objEv.value.length;i++)
	{
		if(-1 != num.indexOf(objEv.value.charAt(i)))
		event.returnValue = false;
	}
  
	if (!event.returnValue)
	{
		alert("Æ¯¼ö¹®ÀÚ´Â ÀÔ·ÂÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
		objEv.value="";
	}
}

// Æ¯¼ö¹®ÀÚ Ã¼Å©ÇÔ¼ö2
function checkText(str)
{
	var num ="{}[]()<>?_|~`!@#$%^&*-+\"'\\/ ";
	var returnValue = true;
	for (var i=0;i<str.length;i++)
	{
		if(-1 != num.indexOf(str.charAt(i)))
		returnValue = false;
	}
  
	return returnValue;
}

// Æ¯¼ö¹®ÀÚ Ã¼Å©ÇÔ¼ö3
function checkText2(str)
{
	var num ="{}[]()<>?|~`!@#$%^&*+\"'\\/";
	var returnValue = true;
	for (var i=0;i<str.length;i++)
	{
		if(-1 != num.indexOf(str.charAt(i)))
		returnValue = false;
	}
  
	return returnValue;
}

// È­¸é¿¡¼­ ÆË¾÷ ¶Ç´Â ·¹ÀÌ¾îÀÇ °ªÀ¸·Î ³ª´²¼­ À§Ä¡¸¦ ¹ÝÈ¯
function getWidthPosition(w){
	// °¡·Î
	var screenWidth =  document.body.scrollWidth; //screen.width;
    return screenWidth/2 - w/2;

}

// È­¸é¿¡¼­ ÆË¾÷ ¶Ç´Â ·¹ÀÌ¾îÀÇ °ªÀ¸·Î ³ª´²¼­ À§Ä¡¸¦ ¹ÝÈ¯
function getHeightPosition(h){
	// ¼¼·Î
	var screenHeight = document.body.scrollHeight; //screen.height;
    return screenHeight/2 - h/2;
}

// object °¡Á®¿À±â 
function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId);
    }else if (document.all && document.all(objectId)) {
        return document.all(objectId);
    }else if (document.layers && document.layers[objectId]) {
        return document.layers[objectId];
    } else {
        return false;
    }
}

// »õÃ¢¿­±â
function NewWindow(popurl,pWidth,pHeight)
{
	pLeft=(screen.width-pWidth)/2;
	pTop=(screen.height-pHeight)/2;
	window.open(popurl,"popId","width="+pWidth+",height="+pHeight+",left="+pLeft+",top="+pTop+",scrollbars=yes");
}

// °³ÀÎÆË¾÷
function PersonWindow(popurl,pWidth,pHeight)
{
	pLeft=(screen.width-pWidth)/2;
	pTop=(screen.height-pHeight)/2;
	window.open(popurl,"person","width="+pWidth+",height="+pHeight+",left="+pLeft+",top="+pTop+",scrollbars=yes");
}

// °³ÀÎÆË¾÷
function PrintWindow(popurl,pWidth,pHeight)
{
	pLeft=(screen.width-pWidth)/2;
	pTop=(screen.height-pHeight)/2;
	window.open(popurl,"printing","menubar=yes,width="+pWidth+",height="+pHeight+",left="+pLeft+",top="+pTop+",scrollbars=yes");
}

// ÆË¾÷
function OpenWindow(popurl,popname,pWidth,pHeight,scroll)
{
	pLeft=(screen.width-pWidth)/2;
	pTop=(screen.height-pHeight)/2;
	window.open(popurl,popname,"width="+pWidth+",height="+pHeight+",left="+pLeft+",top="+pTop+",scrollbars="+scroll);
}

// ÆÄÀÏÅ©±â Ã¼Å©
function getFileSize(filepath) {
	var img = new Image();
	img.dynsrc = filepath;
	var size = eval(img.fileSize);
	return size;
}

// ÆÄÀÏÁ¦ÇÑ¿©ºÎ Ã¼Å©ÇÔ¼ö
function FileSizeCheck(Fsize,Maxsize){
	var maxarr = Maxsize.split(' ');
	var Msize = 0;
	if(maxarr[1]=="Mb"){
		Msize = parseFloat(maxarr[0])*1048576;
	}else if(maxarr[1]=="Kb"){
		Msize = parseFloat(maxarr[0])*1024;
	}else if(maxarr[1]=="b"){
		Msize = parseFloat(maxarr[0]);
	}else{
		Msize = parseFloat(maxarr[0]);
	}// ÆÄÀÏÃÖ´ëÄ¡¸¦ ¹ÙÀÌÆ®´ÜÀ§·Î °è»ê
//	alert('Fsize='+Fsize+'|Msize='+Msize);
	if (Fsize<Msize)
	{
		return true;
	}else{
		return false;
	}
}

// ÀÌ¸ÞÀÏ Ã¼Å©
function MailCheck(ObjMail)
{
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var numeric = '1234567890';
	var other = '@.-_';
	var nonkorean = alpha+numeric+other ; 
	
	var i ; 
	for ( i=0; i<ObjMail.length; i++ )
		if( nonkorean.indexOf(ObjMail.substring(i,i+1))<0) {
			break ; 
		}
	if ( i != ObjMail.length ) {
		return false ; 
	}else{
		if (ObjMail.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) 
		{
			return false;    
		}
		return true;
	}	
}

//-------------------------------------------------------------------
// ¾ÆÀÌµð ¼ýÀÚ/¿µ¹® Ã¼Å© ÇÔ¼ö
//-------------------------------------------------------------------

function charTest(name) {
	for(var i=0; i<name.length; i++) {
		vAsc = name.charCodeAt(i);

		if ((vAsc > 96) && (vAsc < 124))	//¿ä°Ô ¼Ò¹®ÀÚ
			continue;
		if ((vAsc > 64) && (vAsc < 91)) 	//¿ä°Ç ´ë¹®ÀÚ
			continue;
		if ((vAsc > 47) && (vAsc < 58))		//¿ä°Ç ¼ýÀÚ...
			continue;

		return false;		//¿µ¹®,¼ýÀÚ ÀÌ¿ÜÀÇ ¹®ÀÚ°¡ ÀÖ´Â °æ¿ì
	}
	return true;    		//¿µ¹®,¼ýÀÚ·Î¸¸ ÀÌ·ç¾îÁø °æ¿ì
}
// ¼ýÀÚ¹×- ¸¸Çã¿ë
function charTest2(name) {
	for(var i=0; i<name.length; i++) {
		vAsc = name.charCodeAt(i);

		if (vAsc==45) 	//¿ä°Ç "-" ¹®ÀÚ
			continue;
		if ((vAsc > 47) && (vAsc < 58))		//¿ä°Ç ¼ýÀÚ...
			continue;

		return false;		//¿µ¹®,¼ýÀÚ ÀÌ¿ÜÀÇ ¹®ÀÚ°¡ ÀÖ´Â °æ¿ì
	}
	return true;    		//¿µ¹®,¼ýÀÚ·Î¸¸ ÀÌ·ç¾îÁø °æ¿ì
}

function displayer(objs){
	if(getObject(objs).style.display=='none'){
		getObject(objs).style.display = '';
	}else{
		getObject(objs).style.display = 'none';
	}
}

function add_item(itemname) {
	
	switch (itemname){
		case 'addfile':
			addfile_count = Number(document.theform.addfile_dbcount.value)
			addfile_count = addfile_count + 1;
			document.theform.addfile_dbcount.value = addfile_count;
			var tableID = 'addfile_table'
			var table = document.all ? document.all[tableID] : document.getElementById(tableID);

			var row = table.insertRow(table.rows.length);
			if (document.all){
				for (var i = 1; i < 3; i++){
					var cell = row.insertCell(i - 1);

					switch(i){
						case 1:
							cell.width = "590";
							cell.innerHTML = "<input type=hidden name=old_add_file_no" + addfile_count + " value=\"\">";
							cell.innerHTML += "<input type=hidden name=old_add_file_link" + addfile_count + " value=\"\">";
							cell.innerHTML += "<input type=hidden name=old_add_file" + addfile_count + " value=\"\">";
							cell.innerHTML += "<input type=file name=add_file" + addfile_count + " style='width:400px' value=\"\">";
							break;
						case 2: 
							cell.width = "60";
							cell.innerHTML = "<a href=\"javascript:del_item('addfile','addfile_table'," + addfile_count + ");\"><img src='/images/common/bt_delete.gif' alt='»èÁ¦' border=0></a>";
							break;
					}
				}
			}
			break;
		default:
			return
	}
}

function del_item(itemname, tableID, del_no) {
	switch (itemname) {
		case "addfile":
			var lo_table = document.getElementById(tableID); 
			var row_index = document.theform.addfile_dbcount.value;
			var row_count = (del_no) * 1
			del_addfile_str = document.theform.addfile_del.value

			if(row_index >= 0){
				del_addfile_hidden	= eval("theform.old_add_file_no" + row_count).value
				lo_table.deleteRow(row_count-1);

				if (row_index > 1) {
					for ( k = del_no ; k < row_index ; k++)
					{
						row_count = k * 1

						t_addfileno_hidden	= eval("theform.old_add_file_no" + (k+1)).value
						t_addfilelink_hidden	= eval("theform.old_add_file_link" + (k+1)).value
						t_addfile_hidden	= eval("theform.old_add_file" + (k+1)).value
						t_addfile		= eval("theform.add_file" + (k+1)).value

						lo_table.rows[row_count-1].deleteCell(0)
						cell = lo_table.rows[row_count-1].insertCell(0)
						cell.width = "590";
						cell.innerHTML = "[<a href='/common_inc/filedown.asp?folder=" + escape(t_addfilelink_hidden) + "&filename=" + escape(t_addfile_hidden) + "'>" + t_addfile_hidden + "</a>] ";
						cell.innerHTML += "<input type=hidden name=old_add_file_no" + k + " value=\"" + t_addfileno_hidden + "\">";
						cell.innerHTML += "<input type=hidden name=old_add_file_link" + k + " value=\"" + t_addfilelink_hidden + "\">";
						cell.innerHTML += "<input type=hidden name=old_add_file" + k + " value=\"" + t_addfile_hidden + "\">";
						cell.innerHTML += "<input type=file name=add_file" + k + " style='width:300px'  value=\"\">";

						lo_table.rows[row_count-1].deleteCell(1)
						cell = lo_table.rows[row_count-1].insertCell(1)
						cell.width = "60";
						cell.innerHTML = "<a href=\"javascript:del_item('addfile','addfile_table'," + k + ");\"><img src='/images/common/bt_delete.gif' alt='»èÁ¦'></a>";
					}
				}
			}
			theform.addfile_dbcount.value = theform.addfile_dbcount.value-1;
			del_addfile_str = del_addfile_str + ':' + del_addfile_hidden;
			theform.addfile_del.value = del_addfile_str;
			break;
		default:
			return;
	}
}

function ShowCalendarDialog( objSource)
{
	var strYear;
	var strMonth;
	var strDay;

	var strSelectedDate = window.showModalDialog( "/common_inc/calendar/calendar-body.html", window, "dialogWidth:290px; dialogHeight:245px; status:false; help:no;");

	if( strSelectedDate==null ) return;

	// ³âµµ
	strYear = strSelectedDate.substring( 0, 4);
	// ¿ù
	strMonth = strSelectedDate.substring( 4, 6);
	// ÀÏ
	strDay = strSelectedDate.substring( 6, 8);

	objSource.value = strYear + strMonth + strDay;
}

function img_pop(mypage,w,h) { 
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes'; 
	win = window.open(mypage,'popimg',settings);
	if(win.focus) {
		win.focus();
	}
}

// ÀÌ¹ÌÁö »çÀÌÁî Á¶Á¤
// ³ÐÀÌor³ôÀÌ °­Á¦°ª¾øÀ»°æ¿ì ºñÀ²Á¶Á¤
function ImgResize(imgid,imgwidth,imgheight){
	var tmpsize = 0;
	var tosize;
	var imgobj = getObject(imgid);	//eval('document.all.'+imgid);
	var toheight = 0;
	var towidth = 0;
	var fromheight = imgobj.height;
	var fromwidth = imgobj.width;
	if (imgobj!=false)
	{
		if ( (imgwidth!='')&&(imgheight!='') ){		// ³ÐÀÌ ¹× ³ôÀÌ °­Á¦Á¶Á¤
			toheight = imgwidth;
			towidth = imgheight;
		}else if ( (imgwidth!='')&&(imgheight=='') ){		// ³ÐÀÌ¿¡ °íÁ¤½ÃÅ³°æ¿ì
			if (imgwidth<fromwidth){
				tmpsize = parseInt((parseInt(imgwidth)/fromwidth)*100);
				tosize = parseInt(fromheight*(tmpsize/100));
				towidth = imgwidth;
				toheight = tosize;
			}else{
				towidth = fromwidth;
				toheight = fromheight;
			}

		}else if ( (imgwidth=='')&&(imgheight!='') ){		// ³ôÀÌ¿¡ °íÁ¤½ÃÅ³°æ¿ì
			if (imgheight<fromheight)
			{
				tmpsize = parseInt((parseInt(imgheight)/fromheight)*100);
				tosize = parseInt(fromwidth*(tmpsize/100));
				towidth = tosize;
				toheight = imgheight;
			}else{
				towidth = fromwidth;
				toheight = fromheight;
			}
//			alert('asa');
		}else{		//°­Á¦Á¶Á¤ ¾øÀ»°æ¿ì
			toheight = fromheight;
			towidth = fromwidth;
		}
//		alert(towidth+' '+toheight);
		imgobj.width = towidth;
		imgobj.height = toheight;
	}
	return towidth+'|'+toheight;
}

function ImgMaxsize(imgid,maxwidth,maxheight){
	var tmps;
	var objs = getObject(imgid);
//	alert(typeof(objs));
	objs.style.visibility='hidden';

	if (objs.readyState == "complete")
	{
		tmps = ImgResize(imgid,maxwidth,'');
		var arrwh = tmps.split('|');
		var fromh = arrwh[1];
		if (parseInt(fromh) > parseInt(maxheight))
		{
			tmps = ImgResize(imgid,'',maxheight);
			objs.style.visibility='';
	//		setTimeout("ImgResize('"+imgid+"','','"+maxheight+"')",50);
	//		setTimeout("getObject('"+imgid+"').style.visibility='';",100);
		}else{
			objs.style.visibility='';
		}
	}else {
		setTimeout("ImgMaxsize('"+imgid+"','"+maxwidth+"','"+maxheight+"')",200);
	}
	
}

//ÈÄ¿øÇÏ±â ÆË¾÷Ã¢
function goPopDonate()
{
	w = 690;
	h = 745;
	popurl = "/pop_Donate/main.asp";
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes'; 
	win = window.open(popurl,'popdonate',settings);
	if(win.focus) {
		win.focus();
	}
}

//ÆÐ¹Ð¸® »çÀÌÆ®
function goFamily() {
	var newWindow;
	url = document.all.Family_Site.value
	if (url != "") {
		if(newWindow) {
			newWindow.close();
		}
		newWindow = window.open(url,"","resizable=yes,screenX=0,screenY=0,width=1000,height=750,top=0,left=0,toolbar=yes,statusbar=yes,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes");
		newWindow.focus();
		focusnum = 0;
	}
}

// Æ¯Á¤ °´Ã¼ ³ô/³Ð ÀçÁ¶Á¤
function resizeID(getid,wid,hei){
	if (document.readyState == "complete") {
//			var innerBody = iframeObj.contentWindow.document.body;
  
//			var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
//			var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
		getObject(getid).style.height = hei+'px';		//innerHeight;
		getObject(getid).style.width = wid+'px';		//innerWidth;
	}else {
		setTimeout("resizeID('"+getid+"','"+wid+"','"+hei+"')",200);
	}
}

function ConverDate(str){
	var rtn = '';
	if (str.length==8)
	{
		rtn = str.substr(0,4)+'.'+str.substr(4,2)+'.'+str.substr(6,2);
	}else{
		rtn = str;
	}
	return rtn;
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function copy(Data) {
	window.clipboardData.setData("Text",Data);
	alert('ÁÖ¼Ò°¡ Å¬¸³º¸µå¿¡ º¹»çµÇ¾ú½À´Ï´Ù\n Ctrl+V ·Î ºÙ¿©³ÖÀ¸¼¼¿ä');
}

function AutoSize(){
//	number
//	undefined
	if (document.readyState == "complete") {
		if (typeof(resizing_idx)=='object')			// ÀÌ¹ÌÁö°¡ ÀÖÀ»°æ¿ì
		{
			if (typeof(resizing_idx.length)=='number')		// ´Ù¼öÀÏ°æ¿ì
			{
				for (ddi=0;ddi<resizing_idx.length ;ddi++ )
				{
					ImgMaxsize('resizing_idx['+ddi+']',650,'');
				}
			}else{	// ÇÑ°³ÀÏ°æ¿ì
				ImgMaxsize('resizing_idx',650,'');
			}
		}
	}else {
		setTimeout("AutoSize()",200);
	}
//	ImgMaxsize(resizing_idx,650,'');
}

// IE - FF Å°ÄÚµå°ª ±¸ÇÏ±â
function Keycode(e){
	var result;
	if(window.event)
		result = window.event.keyCode;
	else if(e)
		result = e.which;
	return result;
}

// IE - FF ÀÌº¥Æ® ¹ß»ýÁßÁö (¼ýÀÚÀÏ°æ¿ì,¹é½ºÆäÀÌ½º Á¦¿Ü)
function numerics(event){
	if (((Keycode(event)<48)||(Keycode(event)>57))&&(Keycode(event)!=8)){
		if (ie4) event.returnValue=false;
		else event.preventDefault();
	}
}

