function goUrl() //ÇÏ´Ü copyright ¿µ¿ª - Family Site ¸µÅ© ¿¬°áÇÏ´Â ÇÔ¼ö
{
	var familyUrl = document.getElementById("familyGo");
	//alert(familyUrl.value);
	
	if(familyUrl.value != "")
	{
		window.open(familyUrl.value,"win");
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeDate(){
    new Ajax.Updater('calendar_box', 'calendar.jsp',
		{	method:'post',
			encoding: 'euc-kr',
			parameters: {
				year: document.getElementById("year").value,
				month: document.getElementById("month").value
			}
		}
	);	
}

function nextMonth(){
	document.getElementById("month").value = parseInt(document.getElementById("month").value) + 1;
	
	if(document.getElementById("month").value > 12){
		document.getElementById("year").value = parseInt(document.getElementById("year").value) +1;
		document.getElementById("month").value = 1;
	}
	changeDate();
}

function prevMonth(){
	document.getElementById("month").value = parseInt(document.getElementById("month").value) - 1;
	
	if(document.getElementById("month").value < 1){
		document.getElementById("year").value = parseInt(document.getElementById("year").value) -1;
		document.getElementById("month").value = 12;
	}
	changeDate();
}

function toggle_edit(edit_box_name, img){
	var editbox = document.getElementById(edit_box_name);
	
	if(editbox.readOnly) {
		editbox.readOnly = false;
		editbox.className = 'input_edit';
		editbox.focus();
		editbox.select();
	}else {
		editbox.readOnly = true;
		img.focus();
		editbox.className = 'input_noedit';
	}
}


function toggle_view(div_id) {
	var e = Web.isIE ? window.event : event;
	var div_style = document.getElementById(div_id).style.display;
	
	if ("none" == div_style){
		document.getElementById(div_id).style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
		document.getElementById(div_id).style.left = (e.clientX - 5 - 100 + Web.util.Position.deltaX()) + 'px';
		document.getElementById(div_id).style.display = "block";
	}else {
		document.getElementById(div_id).style.display = "none";
	}
}

/* »ç¿ëÇÏÁö ¾ÊÀ½ */
function toggle_view_nomoving(div_id, temp_val, row, obj, year, month, dateleft, dateright) {
	
	var e = Web.isIE ? window.event : event;
	var div_style = document.getElementById(div_id).style.display;
	var temp = document.getElementById(temp_val).value;
  
	if((!dateleft) && (!dateright)){
		return;
	}
	
	if(!dateleft)
		dateleft = "01";
	
	if(!dateright)
		dateright = "31";
		
	month = month.toString();
	if(month.length < 2) month = "0" + month;
	
	if(temp == row){
		document.getElementById(temp_val).value = row;
		return;
	}else
		document.getElementById(temp_val).value = row;
	
	document.getElementById(div_id).style.top = obj.offsetTop - 20 + 'px';
	document.getElementById(div_id).style.left = obj.offsetLeft - 20 + 'px';
	
	if ("none" == div_style){
		document.getElementById(div_id).innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
		document.getElementById(div_id).style.display = "block";
	}
	new Ajax.Updater(div_id, 'course_schedule_cal_popup.jsp',
		{	method:'post',
			encoding: 'UTF-8',
			parameters: {
				datefrom: year + month + dateleft,
				dateto: year + month + dateright
			}
		}
	);
}

function select_educode(educode, name, cost){
	toggle_view('div-code');
	document.getElementById("eduname").value = name;
	document.getElementById("educode").value = educode;
	document.getElementById("cost").value = cost;
	document.getElementById("eduschedule").value = "";
	document.getElementById("eduid").value = "";
}

function loadSchedulebyEducode(div_id, edu_code){
	var e = Web.isIE ? window.event : event;
	if (edu_code != null) {
		
		document.getElementById(div_id).style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
		document.getElementById(div_id).style.left = (e.clientX - 5 - 100 + Web.util.Position.deltaX()) + 'px';
		document.getElementById(div_id).innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
		document.getElementById(div_id).style.display = "block";
		new Ajax.Updater(div_id, 'course_schedule_popup.jsp',
			{	method:'post',
				encoding: 'UTF-8',
				parameters: {
					educode: edu_code
				}
			}
		);
	}
}

function loadSchedulebyEducodeIndex(div_id, edu_code){
	var e = Web.isIE ? window.event : event;
	if (edu_code != null) {
		document.getElementById(div_id).style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
		document.getElementById(div_id).style.left = (e.clientX - 5 - 100 + Web.util.Position.deltaX()) + 'px';
		document.getElementById(div_id).innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
		document.getElementById(div_id).style.display = "block";
		new Ajax.Updater(div_id, 'course_schedule_index_popup.jsp',
			{	method:'post',
				encoding: 'UTF-8',
				parameters: {
					educode: edu_code
				}
			}
		);
	}
}

function loadScheduleByDateFromCalendar(div_id, datefrom){
	var e = Web.isIE ? window.event : event;
	if(datefrom != null) {
		document.getElementById(div_id).style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
		document.getElementById(div_id).style.left = (e.clientX - 5 - 50 + Web.util.Position.deltaX()) + 'px';
		document.getElementById(div_id).innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
		document.getElementById(div_id).style.display = "block";
		new Ajax.Updater(div_id, 'course_schedule_cal_popup.jsp',
			{	method:'post',
				encoding: 'UTF-8',
				parameters: {
					datefrom: datefrom
				}
			}
		);
	}
}

function set_div_and_view(board_no, div_id, src, logged) {
	if(logged == 'false'){
		Web.alert({title:'°æ°í',msg:'·Î±×ÀÎÇÏ¼Å¾ß ÇÕ´Ï´Ù.'});
		return;
	}
	var e = Web.isIE? window.event : e;
	var div = null;
	if ($(div_id)) {
		div = $(div_id);
	}
	else {
		div = document.createElement("div");
		div.setAttribute("id", "filedown");
		document.body.appendChild(div);	
	}
	div.style.left = (e.clientX - 5 - 50 + Web.util.Position.deltaX()) + 'px';
	div.style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
	div.innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
	/*div.style.visibility = 'visible';*/
	div.style.display = "block";
		
	new Ajax.Updater(div, src,
		{	method:'post',
			encoding: 'UTF-8',
			parameters: {
				boardno: board_no
			}
		}
	);	
}

function set_div(div_id, src){
		new Ajax.Updater(div_id, src,
			{	method:'post',
				encoding: 'UTF-8',
				parameters: {
				}
			}
		);
}

function set_div_back(div_id, src, val){
	set_div(div_id, src);
	document.getElementById(div_id).style.background = val;
}

function select_eduid(eduid, eduschedule){
	document.getElementById("eduschedule").value = eduschedule;
	document.getElementById("eduid").value = eduid;
	toggle_view('div-schedule');
}

function show_div(div_id) {
	document.getElementById(div_id).style.display = "block";
}

function close_div(div_id) {
	document.getElementById(div_id).style.display = "none";
}

function alert_semina(educode){
	if(educode == null){
		return;
	}
	if (educode.substring(0,2) == 'SN'){
	    Web.alert({title:'¾Ë¸²',msg:'¼¼¹Ì³ª ½ÅÃ»½Ã¿¡´Â °í¿ëº¸Çè ¹ÌÀû¿ëÀ» ¼±ÅÃÇÏ¼Å¾ß ÇÕ´Ï´Ù.'});
	    return;
  }
}

function apply_check(edu_code, edu_id, login) {
	if (login == 'false') {
		Web.alert({title:'°æ°í',msg:'±³À°À» ½ÅÃ»ÇÏ½Ã·Á¸é ·Î±×ÀÎÇÏ¼Å¾ß ÇÕ´Ï´Ù.'});	
		return;
	}
	document.apply.educode.value = edu_code;
	document.apply.eduid.value = edu_id;
	Web.submit('apply',{method:'post',action:'course-apply.do'});
	return;
}

function apply_check_1() { /* ±âº» ½Å»ó ÀÔ·Â ÈÄ */

		if (!Web.Form.validateValue($fn('reg','educode'))) return;
		if (!Web.Form.validateValue($fn('reg','eduid'))) return;
		if (!Web.Form.validateValue($fn('reg','username'))) return;
		if (!radio_validate_check('insurance')) return;
		
		if (!Web.Form.validateValue($fn('reg','companyname'))) return;
		
		/* °í¿ëº¸Çè È¯±Þ ½ÅÃ» ½Ã */
		if (document.getElementById('insuranceyes').checked) {
			
			if (!Web.Form.validateValue($fn('reg','companyserial1'))) return;
			if (!Web.Form.validateValue($fn('reg','companyserial2'))) return;
			if (!Web.Form.validateValue($fn('reg','companyserial3'))) return;
			
			if (!Web.Form.validateValue($fn('reg','educompanionname'))) return;
			
			/* ÀÏ¹Ý ÀüÈ­¹øÈ£´Â ¹Ýµå½Ã.. ÈÞ´ëÀüÈ­´Â ¼±ÅÃÀûÀ¸·Î ÀÔ·ÂµÇ¾î¾ß ÇÔ */
			if (!Web.Form.validateValue($fn('reg','educompanionphone1'))) return;
			if (!Web.Form.validateValue($fn('reg','educompanionphone2'))) return;
			if (!Web.Form.validateValue($fn('reg','educompanionphone3'))) return;

			/*
			if (!Web.Form.validateValue($fn('reg','educompanioncell1'))) return;
			if (!Web.Form.validateValue($fn('reg','educompanioncell2'))) return;
			if (!Web.Form.validateValue($fn('reg','educompanioncell3'))) return;
			*/
			
			if (!Web.Form.validateValue($fn('reg','companyposition'))) return;
			if (!Web.Form.validateValue($fn('reg','companyjob'))) return;
			if (!Web.Form.validateValue($fn('reg','edustat'))) return;
			if (!Web.Form.validateValue($fn('reg','workhour'))) return;
		}
		
		if (!Web.Form.validateNum($fn('reg','companyserial1'))) return;
		if (!Web.Form.validateNum($fn('reg','companyserial2'))) return;
		if (!Web.Form.validateNum($fn('reg','companyserial3'))) return;
		
		if (!Web.Form.validateNum($fn('reg','educompanionphone1'))) return;
		if (!Web.Form.validateNum($fn('reg','educompanionphone2'))) return;
		if (!Web.Form.validateNum($fn('reg','educompanionphone3'))) return;

		if (!Web.Form.validateNum($fn('reg','educompanioncell1'))) return;
		if (!Web.Form.validateNum($fn('reg','educompanioncell2'))) return;
		if (!Web.Form.validateNum($fn('reg','educompanioncell3'))) return;
	
		Web.submit('reg', {method:'post',action:'course-next.do'});
}
/* ÀÔ±Ý°áÁ¦  */
function apply_check_2() { 
		if (!radio_validate_check('paymentcode')) return;
		/* Ä«µå°áÁ¦¸¦ ¼±ÅÃÇßÀ»¶§¸¸ Ä«µå°áÁ¦ ¼öÇà Ã¢À¸·Î ³Ñ¾î°£´Ù */
		/*if(document.getElementById('paymentcard').checked) {
			Web.submit('reg', {method:'post',action:'payreq.do'});
		}
		else */ 	
		Web.submit('reg', {method:'post',action:'course-next-1.do'});
				
}
/*ÃÖÁ¾ È®ÀÎÇÏ°í DB¿¡ ÀúÀå */
function apply_confirm() { 
	Web.confirm({title:'È®ÀÎ',msg:'À§ÀÇ Á¤º¸·Î ±³À°À» ½ÅÃ»ÇÏ½Ã°Ú½À´Ï±î?',fnok:function() {
		Web.submit('req',{method:'post',action:'course-process.do'});
	}});
}

/*°úÁ¤ Ãë¼Ò È®ÀÎÇÏ°í DB¿¡ ÀúÀå */
function apply_cancel(no) { 
	document.cancel.no.value = no;
	document.cancel.status.value = "D";
	Web.confirm({title:'È®ÀÎ',msg:'ÇØ´ç ±³À°À» Ãë¼ÒÇÏ½Ã°Ú½À´Ï±î?',fnok:function() {
		Web.submit('cancel',{method:'post',action:'course-change.do'});
	}});
}

function apply_payment(oid, amount, productinfo) {
	document.payment.LGD_OID.value = oid;
	document.payment.LGD_AMOUNT.value = amount;
	document.payment.LGD_PRODUCTINFO.value = productinfo;
	
	Web.submit('payment',{method:'post',action:'payment-request.do'});

}
/* ¼³¹® ÀÔ·Â */
function insert_research() {
	if (!radio_validate_check('quest_professor1')) return;
	if (!radio_validate_check('quest_professor2')) return;
	if (!radio_validate_check('quest_professor3')) return;
	if (!radio_validate_check('quest_professor4')) return;
	if (!radio_validate_check('quest_professor5')) return;
	
	if (!radio_validate_check('quest_content1')) return;
	if (!radio_validate_check('quest_content2')) return;
	
	if (!radio_validate_check('quest_book1')) return;
	
	if (!radio_validate_check('quest_operation1')) return;
	if (!radio_validate_check('quest_operation2')) return;
	
	var obj1 = document.getElementsByName('quest_content3_check');
	var obj2 = document.getElementsByName('quest_book2_check');
	
	var obj1_real = "";
	var obj2_real = "";
	for(var i = 0;i < obj1.length;i++){
		if(obj1[i].checked){
			obj1_real += obj1[i].value;
		}
	}
	for(var j = 0;j < obj2.length;j++){
		if(obj2[j].checked){
			obj2_real += obj2[j].value;
		}
	}
	document.getElementById('quest_content3').value = obj1_real;
	document.getElementById('quest_book2').value = obj2_real;
	
	Web.submit('researchForm',{method:'post',action:'research-process.do'});
}


/* ¶óµð¿À ¹öÆ° ´­·È´ÂÁö È®ÀÎ */
function radio_validate_check(_objStr) {
		try {
			var objs = document.getElementsByTagName("input");
			var isChk = false;
			var notObj = false;
			
			for(var i = 0; i < objs.length;i++) {
				if(objs[i].type == "radio" && objs[i].name == _objStr){
					notObj = true;
					if(objs[i].checked){
						isChk = true;
					}
				}
			}
			if(!notObj) {
				Web.alert({title:'°³Ã¼ ¿À·ù', msg:'°³Ã¼°¡ ¾ø½À´Ï´Ù', focus:_objStr});
				return false;
			}
			if(!isChk) {
				Web.alert({title:'ÀÔ·Â°ª Ã¼Å©', msg:'¹Ýµå½Ã ¼±ÅÃÇÏ¼Å¾ß ÇÕ´Ï´Ù.', focus:_objStr});
				return false;
			}
		}catch(ex) {
			alert("¶óµð¿À ¹öÆ° ½ºÅ©¸³Æ® ¿À·ù" + ex);
			return false;
		}
		return true;
}

/*
	»ç¾÷ÀÚ µî·Ï¹øÈ£ À¯È¿¼º Ã¼Å©
*/
function CheckBizNo(strBizNo1, strBizNo2, strBizNo3)
{
	var strXxx = "137137135";
	var intKey = 0 ;
	var strBizNo = strBizNo1 + strBizNo2 + strBizNo3;
	
	if (strBizNo.length != 10) return false;
	if (!CheckNumber(strBizNo)) return false;
	
	for (var i = 0; i < strXxx.length; i++)
	{
	 intKey += strBizNo.charAt(i) * strXxx.charAt(i)
	}
	
	intKey += (strBizNo.charAt(8) * 5) / 10;
	intKey = intKey % 10;
	
	intKey = (intKey == 0) ? 0 : 10 - intKey;
	
	return (intKey != strBizNo.charAt(9)) ? false : true;
}

/* 
	³ëÆ®ºÏ ¹Ý³³ È®ÀÎ
*/
function return_confirm(id) { 
	document.getElementById('returnid').value = id;
	Web.confirm({title:'È®ÀÎ',msg:'ÇØ´ç ¹ÝÃâ°Ç¿¡ »ç¿ëµÈ ³ëÆ®ºÏÀ» ¹Ý³³ÇÕ´Ï±î?',fnok:function() {
		Web.submit('returns',{method:'post',action:'notereturn.do'});
	}});
}
