/**
 *	ÀÔ·ÂÀÌ °ø¹éÀÎÁö °Ë»çÇÏ´Â ÇÔ¼ö
 */
function isBlank(str) {
	// ±æÀÌ°¡ 0ÀÌ¸é °ø¹é
	if(str.length==0) {
		return true;
	}
			
	// ¸ðµç Ä³¸¯ÅÍ¸¦ °Ë»ç
	for(var i=0; i<str.length; i++) {
		if(str.charAt(i)!=' ') {
		// °ø¹éÀÌ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖ´Ù¸é..
			return false;
		}
	}
	return true;
}

/**
 *	ÆûÀ» Ãë¼ÒÇÏ´Â ÇÔ¼ö
 */
function cancelForm(form) {
	form.reset();
	history.back();
	
	return false;
}


/**
 *	ÆûÀÇ ¸ðµç checkbox¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö
 */
function selectAll(form)
{
	for(var i = 0; i < form.elements.length; i++) {
		if(form.elements[i].type == 'checkbox') {
			form.elements[i].checked = true;
		}
	}
}

/**
 *	ÆûÀÇ ¸ðµç checkboxÀÇ Ã¼Å©¸¦ Ãë¼ÒÇÏ´Â ÇÔ¼ö
 */
function deselectAll(form)
{
	for(var i = 0; i < form.elements.length; i++) {
		if(form.elements[i].type == 'checkbox') {
			form.elements[i].checked = false;
		}
	}
}


/**
 *	ÆûÀÇ checkbox¸¦ ¼±ÅÃ/Ãë¼Ò¸¦ ¹Ýº¹ÇÏ´Â ÇÔ¼ö
 */
function toggleSelect(form)
{
	var flag = true;
	
	if(form == null) {
		return;
	}
	
	for(var i = 0; i < form.elements.length; i++) {
		if(form.elements[i].type == 'checkbox') {
			if(form.elements[i].checked) {
				flag = false;
			}else {
				flag = true;
			}
			break;
		}
	}
	
	if(flag) {
		selectAll(form);
	}else {
		deselectAll(form);
	}
}


/**
 *	»õ·Î Ã¢À» ¶ç¿ì´Â ÇÔ¼ö		
 */
function openWindow(url,name,property) {
	var wnd = window.open(url, name, property);
	wnd.focus();
}

/**
 *	ÀÌ¸ÞÀÏÁÖ¼ÒÃ¼Å©
 */
function checkEmail(email)
{
	var oRegular = new RegExp("^([A-Z0-9_-]+)@([A-Z0-9_-]+)([.]([A-Z0-9_-]+))+$", "i");
	if(oRegular.exec(email)) {
		return true;
	}else {
		return false;
	}
}


function checkUserID(userid) {
	var oRegular = new RegExp("^([A-Z0-9]{3,20})$", "i");
	if(!oRegular.exec(userid)){
		window.alert('¾ÆÀÌµð´Â ¿µ¹®, ¼ýÀÚ 3 ~ 20ÀÚÀÔ´Ï´Ù.');
		return false;
	}
	return true;
}

// ÆÐ½º¿öµå°¡ ÀÏÄ¡ÇÏ´ÂÁö °Ë»çÇÏ´Â ÇÔ¼ö
function checkPasswd(passwd1, passwd2) {
	var oRegular = new RegExp("^([A-Z0-9]{4,12})$", "i");
	if(!oRegular.exec(passwd1)){
		window.alert('ºñ¹Ð¹øÈ£´Â ¿µ¹®, ¼ýÀÚ 4 ~ 12ÀÚÀÔ´Ï´Ù.');
		return false;
	}else if(passwd1 != passwd2) {
		window.alert('ºñ¹Ð¹øÈ£ µÎ °³°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.');
		return false;
	}
	return true;
}

/**
 * À±³âÀÎÁö °Ë»çÇÏ´Â ÇÔ¼ö
 */
function isLeapYear(year)
{
	if((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0) {
		return 1;
	}
	
	return 0;
}

/**
 * À¯È¿ÇÑ ³¯Â¥ÀÎÁö °Ë»çÇÏ´Â ÇÔ¼ö
 */
function isValidDate(year, month, day)
{
 	var monthDays = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	
	// ³â °Ë»ç.
	if(year < 1) {
		return false;
	}
	
	// ¿ù °Ë»ç.
	if(month < 1 || month > 12) {
		return false;
	}
	
	// ÀÏ °Ë»ç.
	if(day > monthDays[month]) {
		// À±³â¿¡ 2¿ù 29ÀÏÀÌ ¾Æ´Ï¶ó¸é..
		if(!(day == 29 && month == 2 && isLeapYear(year))) {
			return false;
		}
	}

	return true;
}


function showhide(what){
	if (what.style.display=='none'){
		what.style.display='';
	}
	else{
		what.style.display='none'
	}
}


function menu(name)
{
	submenu=eval("block"+name+".style");
	if(old!=submenu)
	{
		if(old!='')
		{
			old.display='none';
		}
		submenu.display='block';
		old=submenu;
	}
	else
	{
		submenu.display='none';
		old='';
	}
} 

function makeFlash(target, f_path, f_width, f_height, f_wmode)
{
	var myObjectElement = document.createElement('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ f_width +'" height="'+ f_height +'"></object>');
	var myParamElement1 = document.createElement('<PARAM NAME=movie value="'+ f_path +'">');
	var myParamElement2 = document.createElement('<Param name=quality value=high>');
	
	myObjectElement.appendChild(myParamElement1);
	myObjectElement.appendChild(myParamElement2);
	if (f_wmode) {
		var myParamElement3 = document.createElement('<param name=wmode value=transparent>');
		myObjectElement.appendChild(myParamElement3);
	}
	
	eval(target).appendChild(myObjectElement);
}

function numberOnly() {		//onkeypress="return InputControl.numberOnly()"
	return (event.keyCode >= 48 && event.keyCode <= 57);
}

/**
	3ÀÚ¸® ¸¶´Ù ,¸¦ Âï¾îÁÖ´Â ÇÔ¼ö
*/
function commaNum(num) {  

    if (num < 0) { num *= -1; var minus = true} 
    else var minus = false 
     
    var dotPos = (num+"").split(".") 
    var dotU = dotPos[0] 
    var dotD = dotPos[1] 
    var commaFlag = dotU.length%3 

    if(commaFlag) { 
        var out = dotU.substring(0, commaFlag)  
        if (dotU.length > 3) out += "," 
    } 
    else var out = "" 

    for (var i=commaFlag; i < dotU.length; i+=3) { 
        out += dotU.substring(i, i+3)  
        if( i < dotU.length-3) out += "," 
    } 

    if(minus) out = "-" + out 
    if(dotD) return out + "." + dotD 
    else return out  
}

function checkPersonID(personid01, personid02)
{
	personid = personid01 + "-" + personid02;
	// ÁÖ¹Î¹øÈ£ÀÇ ÇüÅÂ¿Í 7¹øÂ° ÀÚ¸®(¼ºº°) À¯È¿¼º °Ë»ç
	fmt = /^\d{6}-[1234]\d{6}$/;
	if (!fmt.test(personid)) {
		return false;
	}
	
	// ³¯Â¥ À¯È¿¼º °Ë»ç
	birthYear = (personid.charAt(7) <= "2") ? "19" : "20";
	birthYear += personid.substr(0, 2);
	birthMonth = personid.substr(2, 2) - 1;
	birthDate = personid.substr(4, 2);
	birth = new Date(birthYear, birthMonth, birthDate);
	
	if (birth.getYear() % 100 != personid.substr(0, 2) ||
		birth.getMonth() != birthMonth ||
		birth.getDate() != birthDate) {
		return false;
	}
	
	// Check Sum ÄÚµåÀÇ À¯È¿¼º °Ë»ç
	buf = new Array(13);
	for (i = 0; i < 6; i++) buf[i] = parseInt(personid.charAt(i));
	for (i = 6; i < 13; i++) buf[i] = parseInt(personid.charAt(i + 1));
	
	multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);
	
	if ((11 - (sum % 11)) % 10 != buf[12]) {
		return false;
	}
	
	return true;
}

function dataintComma(form, num)
{
	
	num1 = num.length;        
	
	FirstNum = num.substr(0,1);
	FirstNum2 = num.substr(1,num1);
	
	if(FirstNum == "0"){
//		alert("ÀÔ·Â¼ýÀÚ´Â 0 À¸·Î ½ÃÀÛÇÒ ¼ö ¾ø½À´Ï´Ù.");
		return 0;
		num = 0;
	}
	
	loop = /^\$|,/g; 
	num = num.replace(loop, ""); 
		
	var fieldnum = '' + num;    
	
	if (isNaN(fieldnum)) {
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");        
		form.Won.value == "";
		form.Won.focus();
		return "";
	} else {
		var comma = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var data = fieldnum.split('.');
		data[0] += '.';
		do {
			data[0] = data[0].replace(comma, '$1,$2');
		} while (comma.test(data[0]));
	
		if (data.length > 1) {
			return data.join('');
		} else {
			return data[0].split('.')[0];
		}
	}
}


function openWindow2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function CheckRainImg(max_width) {
	try {
		var rainimg_len = document.all('rainimg_resize').length;
		if (rainimg_len == null ||rainimg_len == 0) {
			if ((imgobj = document.all('rainimg_resize')) != null) {
				if (imgobj.width > max_width) {
					imgobj.height = Number(imgobj.height * max_width / imgobj.width);
					imgobj.width = 	max_width;
				}
			}
		} else {
			for(i = 0; i < rainimg_len; i++) {
				if ((imgobj = document.all('rainimg_resize')[i]) != null) {
					if (imgobj.width > max_width) {
						imgobj.height = Number(imgobj.height * max_width / imgobj.width);
						imgobj.width = 	max_width;
					}
				}
			}
		}
	} catch(ex) {}
} // ÀÌ¹ÌÁö°¡ Á¦ÇÑ ¿µ¿ªÀ» ¹þ¾î³ªÁö ¾Ê°Ô »çÀÌÁî Á¶Á¤

function imgView(img_obj) {
	if (typeof(img_obj) == 'string') {
		var img_name = img_obj;
	} else if (img_obj.height > 650) {
		var win_scrollbars = 'yes';
		var width_plus = 20;
		var img_name = img_obj.src;
	} else {
		var win_scrollbars = 'no';
		var width_plus = 0;
		var img_name = img_obj.src;
	}
	popup = window.open('about:blank','imgView','width=10,height=10, toolbar=0,menubar=0,resizable=yes,scrollbars='+win_scrollbars+', top=50, left=50');
	popup.document.writeln('<html><title>ÀÌ¹ÌÁö »ó¼¼º¸±â</title>'
		+ '<body topmargin="0" rightmargin="0" leftmargin="0" bgcolor="#FFFFFF">'
		+ '<sc'+'ript>function reSize() {if(document.all("pre_img").width > 0) resizeTo(((document.all("pre_img").width > 800)?800:document.all("pre_img").width) + 10 + '+width_plus+',((document.all("pre_img").height > 600)?600:document.all("pre_img").height) + 50);}</scr'+'ipt>'
		+ '<img src=' + encodeURI(img_name) + ' border=0 onclick=self.close() style="cursor:hand" name=pre_img id=pre_img onload=reSize()>'
		+ '');
} // ÀÌ¹ÌÁö ÆË¾÷Ã¢À¸·Î º¸±â


function RainImgError(imgobj) {
	imgobj.src = './editor/images/nopic_article.gif';
} // ÀÌ¹ÌÁö Error ½Ã ½ÇÆÐ ÀÌ¹ÌÁö º¸ÀÌ±â

