/**
 *	ÀÔ·ÂÀÌ °ø¹éÀÎÁö °Ë»çÇÏ´Â ÇÔ¼ö
 */
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 checkPasswd(passwd1, passwd2) {
	var oRegular = new RegExp("^([A-Z0-9]{7,20})$", "i");
	if(!oRegular.exec(passwd1)){
		window.alert('ÆÐ½º¿öµå´Â ¿µ¹®, ¼ýÀÚ 7 ~ 20ÀÚÀÔ´Ï´Ù.');
		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 numberOnly() {		//onkeypress="return InputControl.numberOnly()"
	return (event.keyCode >= 48 && event.keyCode <= 57);
}

// È¸¿ø ¾ÆÀÌµð¸¦ °Ë»çÇÏ´Â ÇÔ¼ö
function checkUserID(userID) {
	var oRegular = new RegExp("^([a-z]+[a-z0-9_-]{3,29})$", "i");
	if(!oRegular.exec(userID)){
		return false;
	}
	return true;
}

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 ½Ã ½ÇÆÐ ÀÌ¹ÌÁö º¸ÀÌ±â
