/**
 *	ÀÔ·ÂÀÌ °ø¹éÀÎÁö °Ë»çÇÏ´Â ÇÔ¼ö
 */
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]{6,20})$", "i");
	if(!oRegular.exec(passwd1)){
		window.alert('ÆÐ½º¿öµå´Â ¿µ¹®, ¼ýÀÚ 6 ~ 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 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);
}