<!--
//==================================================================================================
//¡áProgram Name	: °øÅë ÀÚ¹Ù½ºÅ©¸³Æ® ÇÔ¼ö ¸ðÀ½
//¡áFile	 Name	: /Class/Comm_Js.js
//¡áDescription		: °øÅë ÀÚ¹Ù½ºÅ©¸³Æ® ÇÔ¼ö ¸ðÀ½
//¡áEtc				: 
//==================================================================================================
//¡ØHistory
//==================================================================================================
//Number		Date				Author		Version			Description
//==================================================================================================
//	1			2005-06-08			Á¤¹Ì»ó		1.0
//==================================================================================================

//--------------------------------------------------------------------------------------------------
// FormÃ¼Å©¸¦ À§ÇÑ ÇÔ¼ö
//--------------------------------------------------------------------------------------------------
	String.prototype.IsId = function() {
		if (this.search(/[^A-Za-z0-9_-__-]/) == -1)
			return true;
		else 
			return false;
	}

	String.prototype.IsTel = function() {
		if (this.search(/[^0-9_-]/) == -1)
			return true;
		else 
			return false;
	}

	String.prototype.IsMoney = function() {
		if (this.search(/[^0-9_,]/) == -1)
			return true;
		else 
			return false;
	}

	String.prototype.IsAlpha = function() {
		if (this.search(/[^A-Za-z]/) == -1)
			return true;
		else
			return false;
	}

	String.prototype.IsNumber = function() {
		if (this.search(/[^0-9]/) == -1)
			return true;
		else
			return false;
	}

	String.prototype.IsJumin = function() {
		var jumin= this
		if (jumin.length  != 13) 
			return false;
		tval=jumin.charAt(0)*2 + jumin.charAt(1)*3 + jumin.charAt(2)*4
		+ jumin.charAt(3)*5 + jumin.charAt(4)*6 + jumin.charAt(5)*7
		+ jumin.charAt(6)*8+ jumin.charAt(7)*9 + jumin.charAt(8)*2
		+ jumin.charAt(9)*3 + jumin.charAt(10)*4 + jumin.charAt(11)*5;

		tval2=11- (tval % 11);
		tval2=tval2 % 10;
		
		if (jumin.charAt(12)==tval2 &&  (jumin.charAt(6)=="1" ||jumin.charAt(6)=="2")) {
			return true;
		}
		else{
			return false ;
		}
	}

	String.prototype.IsEmail = function() {
		if (this.search(/(.+)@.+\..+/) == -1)
			return false;
		else {
			for(var i=0; i < this.length;i++)
				if (this.charCodeAt(i) > 256)
					return false;
			return true;
		}
	}

	String.prototype.IsDate = function() {
		if (this.search(/\d{4}\.\d{2}\.\d{2}/) == -1)
			return false;
		else {
			return true;
		}
	}

	String.prototype.StrLen = function() {
		var temp;
		var set = 0;
		var mycount = 0;

		for( k = 0 ; k < this.length ; k++ ){
			temp = this.charAt(k);

			if( escape(temp).length > 4 ) {
				mycount += 2
			}
			else mycount++;
		}

		return mycount;
	}

	String.prototype.LTrim = function() {
		var i, j = 0;
		var objstr

		for ( i = 0; i < this.length ; i++){
			if (this.charAt(i) == ' ' ){
				j = j + 1;
			}
			else{
				break;
			}
		}
		return this.substr(j, this.length - j+1)  
	}

	String.prototype.RTrim = function() {
		var i, j = 0;

		for ( i = this.length - 1; i >= 0 ; i--){
			if (this.charAt(i) == ' ' ){
				j = j + 1
			}
			else{
				break;
			}
		}
		return 	this.substr(0, this.length - j);
	}

	String.prototype.Trim = function() {
		return this.replace(/\s/g, "");
	}

	function checkform(formField, checkName, message, maxlength, minlength) {	
	
	//°¢ ÇÊµåº° ÀÔ·Â°ª Ã¼Å©
	//ÁÖ¹Îµî·Ï½Ã ¹Ýµå½Ã °ªÀ¸·Î ³Ñ±ä´Ù.
	//ÇÊ¼öÀÔ·Â check
	//±ÛÀÚ¼ö check
	//field À¯È¿¼º check
		
	formValue = formField.value.LTrim().RTrim();
	
		if(checkName != 'jumin'){
			if (formField == null ) {
				return false;
			}
		
			if (formValue == '' && minlength > 0){
				alert(message + " ÇÊ¼öÀÔ·Â Ç×¸ñÀÔ´Ï´Ù.");
				_cmdfocus(formField);
				return false;
			}

			if (formValue.StrLen() < minlength) {
				alert(message + " ÃÖ¼Ò" + minlength + "ÀÚ(ÇÑ±Û" + minlength/2 + " ÀÚ)ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä.");
				_cmdfocus(formField);
				return false;
			}

			if (formValue.StrLen() > maxlength) {
				alert(message + " ÃÖ´ë" + maxlength + "ÀÚ(ÇÑ±Û" + maxlength/2 + " ÀÚ)±îÁö ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
				_cmdfocus(formField);
				return false;
			}
		}		

		switch(checkName) {
			case "" :
				return true;
			case "alpha" :
				if (formValue.IsAlpha()) {
					return true;
				} else {
					alert(message + " ¿µ¹®ÀÚ¸¸ ÀÔ·Â °¡´É ÇÕ´Ï´Ù.");
					_cmdfocus(formField);
					return false;
				}
				break;
			case "number" :

				if (formValue.IsNumber()) {
					return true;
				} else {
					alert(message + " ¼ýÀÚ¸¸ ÀÔ·Â °¡´É ÇÕ´Ï´Ù.");
					_cmdfocus(formField);		
					return false;
				}
				break;
			case "id" :
				if (formValue.IsId()) {
					return true;
				} else {
					alert(message + " ¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸ ÀÔ·Â °¡´É ÇÕ´Ï´Ù.");
					_cmdfocus(formField);		
					return false;
				}
				break;
			case "tel" :
				if (formValue.IsTel()) {
					return true;
				} else {
					alert(message + " ¼ýÀÚ¿Í - ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
					_cmdfocus(formField);		
					return false;
				}
				break;
			case "email" :
				if (formValue.IsEmail()) {
					return true;
				} else {
					alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Æ²¸³´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä(Çü½Ä: admin@localhost.com)");
					_cmdfocus(formField);		
					return false;
				}
				break;
			case "date" :
				if (formValue.IsDate()) {
					return true;
				} else {
					alert(message + " ³¯Â¥ Çü½ÄÀÌ Æ²¸³´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä(Çü½Ä: 1999.09.09)");
					_cmdfocus(formField);		
					return false;
				}
				break;
			case "jumin" :
				if(formValue.StrLen() != 13){
					alert("ÁÖ¹Îµî·Ï¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇØÁÖ¼¼¿ä");
					return false
				}

				if (formValue.IsJumin()) {
					return true;
				} else {
					alert("ÁÖ¹Îµî·Ï¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇØÁÖ¼¼¿ä");
					return false;
				}
				break;
		}
	}

//--------------------------------------------------------------------------------------------------
// Form focus
//--------------------------------------------------------------------------------------------------
	function _cmdfocus(formobj){
		formobj.select();
		formobj.focus();
	}

//--------------------------------------------------------------------------------------------------
// Next Form ÇÊµå
//--------------------------------------------------------------------------------------------------
	function Go_Next(curField, nextField, curLength){
		if (curField.value.length >= curLength){
			nextField.focus();
		}
	}

//--------------------------------------------------------------------------------------------------
// ³¯Â¥ÀÔ·Â Çü½Ä ¹ÝÈ¯
//--------------------------------------------------------------------------------------------------
	//ÀÔ·ÂÇü½Ä:"YYYY/MM/DD"(´Ù¸¥ Çü½ÄÀº ¿¡·¯ÀÔ´Ï´Ù.)
	function DateDiff(FromDate, ToDate){
		var D1,D2,Diff;						//º¯¼ö¸¦ ¼±¾ðÇÕ´Ï´Ù.
		var MinMilli = 1000 * 60;			//º¯¼ö¸¦ ÃÊ±âÈ­ÇÕ´Ï´Ù.
		var HrMilli = MinMilli * 60;
		var DyMilli = HrMilli * 24;
		D1 = Date.parse(FromDate);			//±¸¹® ºÐ¼®ÇÕ´Ï´Ù.
		D2 = Date.parse(ToDate);			//±¸¹® ºÐ¼®ÇÕ´Ï´Ù.
		Diff = Math.round(Math.abs((D2-D1) / DyMilli))
		if (Diff>-1) {
			Diff= Diff + 1;
		} else {
			Diff= Diff - 1;
		}
		return(Diff);						//°á°ú¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
	}
		
//--------------------------------------------------------------------------------------------------
// ¿ùº° ÀÏÀÚ Ã¼Å©
//--------------------------------------------------------------------------------------------------
	function chkdate(cmbYear, cmbMonth, cmbDay){
		var selectmonth = cmbMonth.selectedIndex;
		var monthday, i;
		selectmonth = selectmonth + 1;

		// Æò³âÀÏ¶§ ³¯ÀÚÃ³¸®
		if (selectmonth == 1) monthday = 31;
		if (selectmonth == 3) monthday = 31;
		if (selectmonth == 4) monthday = 30;
		if (selectmonth == 5) monthday = 31;
		if (selectmonth == 6) monthday = 30;
		if (selectmonth == 7) monthday = 31;
		if (selectmonth == 8) monthday = 31;
		if (selectmonth == 9) monthday = 30;
		if (selectmonth == 10) monthday = 31;
		if (selectmonth == 11) monthday = 30;
		if (selectmonth == 12) monthday = 31;
		if (selectmonth == 13) monthday = 30;

		// À±³âÃ³¸®
		if(selectmonth == 2) {
			var y = cmbYear.value;
			//À±³â
			if ((y % 4) == 0) {
				//Æò³â
				if ((y % 100) == 0) {
					//À±³â
					if ((y % 400) == 0) {
						monthday = 29;
					}
					//Æò³â
					else {
						monthday = 28;
					}
				}
				//À±³â
				else {
					monthday = 29;
				}
			}
			//Æò³â
			else {
				monthday = 28;
			}
		}
		cmbDay.length = monthday;
		for(i=0 ; i < monthday ;i++) {
			if (i < 9) {
				var option = new Option(i+1,'0'+(i+1));
				}
			else {
				var option = new Option(i+1, i+1);
				}
			cmbDay.options[i] = option;
		}
		return true;
	}	
//--------------------------------------------------------------------------------------------------
// ¶óµð¿À ¹Ú½º Ã¼Å©
//--------------------------------------------------------------------------------------------------
	function GetRadioValue(opt) {		
		var leng = ((isNaN(opt.length*1))?1:opt.length*1);
		
		if (leng == 1)
		{
				if (opt.checked)
				{
					return opt.value;
				}
		}
		else {
			var n = opt.length;			
			for (i=0; i<n; i++) {
				if (opt[i].checked) {					
					return opt[i].value;
				}
			}
		}
		return "";
	}

//--------------------------------------------------------------------------------------------------
// Ã¼Å©¹Ú½º Ã¼Å©
//--------------------------------------------------------------------------------------------------
	function GetCheckValue(opt) {		
		var leng = ((isNaN(opt.length*1))?1:opt.length*1);
		var chkcnt = 0;
		if (leng == 1)
		{
				if (opt.checked)
				{
					chkcnt = 1;
				}
		}
		else {
			var n = opt.length;			
			for (i=0; i<n; i++) {
				if (opt[i].checked) {					
					chkcnt = chkcnt + 1;
				}
			}
		}
		return chkcnt;
	}


//--------------------------------------------------------------------------------------------------
// ¸¶Äû¸¦ ¸ØÃß°Ô ÇÏ´Â ºÎºÐ
//--------------------------------------------------------------------------------------------------
function MStop(chk)	
{  
	Toggle = 0;  
	switch(chk) {
    	case 1:
    	ex_marquee.stop(); // IDºÎºÐ.stop();

    	break;
    	case 2:
    	mq_topic.stop();
    	break;
	}    
}
//--------------------------------------------------------------------------------------------------
// ÀÌ¹Ì ¸ØÃçÁø ¸¶Äû¸¦ ´Ù½Ã ¿òÁ÷ÀÌ°Ô ÇÏ´Â ¼Ò½º
//--------------------------------------------------------------------------------------------------
function MStart(chk)	
{  
	Toggle = 1;  
	switch(chk) {
 	case 1:
    	ex_marquee.start(); // IDºÎºÐ.start();
    	break;
    	case 2:
    	mq_topic.start();
    	break;
	}    
}
//--------------------------------------------------------------------------------------------------
// ¸¶Äû¸¦ ÁÂ¿ì·Î ¿òÁ÷ÀÌ´Â ½ºÅ©¸³Æ®
//--------------------------------------------------------------------------------------------------
function MStart2(chk)	
{  
	Toggle = 1;  

	switch(chk) {
 	case 1:
    	//ex_marquee.direction.value="left";
		ex_marquee.start(); // IDºÎºÐ.start();
		ex_marquee.direction="left";

		
    	break;
    case 2:
		ex_marquee.start(); // IDºÎºÐ.start();
		ex_marquee.direction="right";
		break;
	}    
}

function na_call(str)
{
eval(str);
}

//ÇÃ·¡½¬ ¸Þ´º MS¿¡¼­ ¹Ù²î´Â °Í Ã³¸®	2006³â 4¿ù 12ÀÏ ºÎ·Î ¹Ù²ñ

function ShowObject(ME_COMMENT) {
	document.write(ME_COMMENT.text);
	ME_COMMENT.id = "";
}
//--------------------------------------------------------------------------------------------------
// °Ë»ö¾î¿¡¼­ ÀÔ·ÂÇÏÁö ¸»¾Æ¾ß ÇÒ ¹®ÀÚ Ã¼Å©
//--------------------------------------------------------------------------------------------------
function isSearchText(val) {		
	var valid = true;
	var cmp = "!#$%^&*|'<>-;";
	
	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) > 0) {
			valid = false;
			break;
		}
	}		
	return valid;
}

//--------------------------------------------------------------------------------------------------
// °Ë»ö¾î¿¡¼­ ¿µ¹®°ú ¼ýÀÚ¸¸°¡´É...
//--------------------------------------------------------------------------------------------------

function isSearch(val) {
var tmp = 0;
    for(i=0;i<form.password.value.length;i++)
    {
     if((form.password.value.charCodeAt(i) < 97) || (form.password.value.charCodeAt(i) > 122))
     {
      if((form.password.value.charCodeAt(i) < 65) || (form.password.value.charCodeAt(i) > 90))
      {
       if((form.password.value.charCodeAt(i) < 48) || (form.password.value.charCodeAt(i) > 57))
       {
        tmp = 1;
       }
 
      }
     }
    }
     if(tmp){
     alert("ºñ¹Ð¹øÈ£´Â ¿µ¹®°ú ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.");
     form.password.focus();
     }
     else{
     form.submit();
     }
}

//ÀÌ¹ÌÁö°¡ Å¬½Ã ÀÌ¹ÌÁö »çÀÌÁî ÁÙÀÌ±â
function imgResize(which){
	var width = eval("document."+which+".width");
	var height = eval("document."+which+".height");
	var temp = 0;
	var max_width= 600;   // ÀÌ¹ÌÁöÀÇ ÃÖ´ë Å©±â
	//alert(width);
	//alert(document.main_img.width);

	if ( width > max_width ) {  
	   height = height/(width / max_width);
	   eval("document."+which+".width = max_width");
	   eval("document."+which+".height = height");
	}
}
//-->
//--------------------------------------------------------------------------------------------------
// ¼ýÀÚ¸¸ ÀÔ·Â°¡´É
//ex) ÀÔ·Â¹æ¹ý (´Ü Comm_Js.js°¡ Include µÇ¾îÀÖ¾î¾ß ÇÑ´Ù.
//onkeyPress="javascript:numberKeyPress();" style="ime-mode; disabled" 
//--------------------------------------------------------------------------------------------------
function numberKeyPress(){
	if ((event.keyCode<48) || (event.keyCode>57)){ 
		event.returnValue=false;
		return;
	}
	event.returnValue=true;
}

//--------------------------------------------------------------------------------------------------
// Select Box Value
//--------------------------------------------------------------------------------------------------
function GetSelectValue(opt){
	return opt.options[opt.selectedIndex].value;
}

function make2Digits(str) {
	if(str < 10) {
		str = "0" + str;
	}
	return str;
}

//--------------------------------------------------------------------------------------------------
// openWindow
//--------------------------------------------------------------------------------------------------
function openWindow(url, winName, width, height, center) {
	if (center == true) {
		window.open(url, winName, "toolbar=no,resizable=no,scrollbars=no,width=" + width + ",height=" + height + ",left=" + (window.screen.width/2-width) + ",top=" + (window.screen.height/2-height));
	} else {
		window.open(url, winName, "toolbar=no,resizable=no,scrollbars=no,width=" + width + ",height=" + height + ",left=0,top=0");
	}
}

//openWin_Scrollbars:PopUpÃ¢À» ¶ç¿ì´Â ÇÔ¼ö·Î Åø¹Ù,»çÀÌÁîº¯È­,½ºÅ©·Ñ¹ÙµîÀ» ¸ðµç °ªÀ» Á¤ÀÇÇÏ´Â Ã¢ÀÔ´Ï´Ù.)
function openWinDefinition(url,Center,Toolbar,Resizable,Scrollbars,Width,Height,Left,Top) {
 	window.open(url, "", "toolbar=" + Toolbar + ",resizable=" + Resizable + ",scrollbars=" + Scrollbars + ",width=" + Width + ",height=" + Height + ",left=" + Left + ",top=" + Top);
}




//hhiir ³»ºÎ Ã³¸®¿ë
 


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//Hard Coding¿ë º¯¼ö Á¤ÀÇ 
//1. IR´º½º(±¹¹®/¿µ¹®) : /(±¹¹®/¿µ¹®)/IRBoard/otherInfo_³â¿ù.asp 
var getCurrentMonth = "1" ;
//2. 
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/





function cmdSearch_comm(){
	/*
	if (isSearchText(document.sform.sSearchText.value) == false){
		alert("Æ¯¼ö¹®ÀÚ·Î °Ë»öÇÒ¼ö ¾ø½À´Ï´Ù.");
		document.sform.sSearchText.focus();
	}else{
	*/


	var years = document.sform.sSearchYear.value;
	var month = document.sform.sSearchMonth.value;
	

	//var month
	years = years.substring(2,4);

	//alert(years);
	//alert(month);

	if (document.sform.sSearchYear.value == '2006') {
		document.sform.action = "otherInfo_" + years + month + ".asp";
		document.sform.submit();
	}
	else if (document.sform.sSearchYear.value == '2007') {
		document.sform.action = "otherInfo_" + years + month + ".asp";
		document.sform.submit();
	}
	else if (document.sform.sSearchYear.value == '2008') {
		if (document.sform.sSearchMonth.value > getCurrentMonth)  {
			document.sform.action = "otherInfo.asp";
			document.sform.submit();
		} else {
			document.sform.action = "otherInfo_" + years + month + ".asp";
			document.sform.submit();
		}
	}
	else {
		document.sform.action = "monthNews.asp";
		document.sform.submit();
	}
	return;
}


// Setting default value - [select], [radio]
function setSelect(elName, targetValue){
	var el;
	el = document.getElementById(elName);

	switch (el.type) {
		case 'select-one':
			for (var i = 0; i < el.length; i++) {
				if (el.options[i].value == targetValue) {
					el.options[i].selected = true;
				}
			}
			break;

		case 'radio':
			var radioEl = document.getElementsByName(elName);
			;
			for (var i = 0; i < radioEl.length; i++) {
				if (radioEl[i].value == targetValue) {
					radioEl[i].checked = true;
					break;
				}
			}
			break;
	}
}