/////////////////////////////////////////////////
// 오프라인 강의 신청 및 결제 시 로그인 체크 STD
/////////////////////////////////////////////////
function fn_loginCheck(refurl, userid, lec_key, title){
	if(userid == 'guest'){
		var obj = 'uniq||'+lec_key+'|'+title;
		fn_move(obj);
	}else if(userid){
//		alert(title);return false;
		fn_dupCheck(userid, lec_key, title);
	}else{
		location.href = '/v4/member/login/login?refurl='+refurl;
	}
}

function fn_dupCheck(userid, lec_key, title){
	var url = '/v2/bid_edu2/lecture_schedule/model/dupCheck.php';			
	var pars = "exec=dupCheck&userid="+userid+"&lec_key="+lec_key+"&title="+title;
	
//	alert(title);return false;
	var myAjax = new Ajax.Request
	(
		url,
		{
			method:'post',
			parameters:pars,
			onComplete:function(AjaxRtn){
				var resp = AjaxRtn.responseText;
				fn_move(resp);

			}
		}
	);
}

function fn_move(obj){
	obj = obj.split('|');
	
	var exec = obj[0];
	var userid = obj[1];
	var lec_key = obj[2];
	var title = obj[2];
	var classes = obj[4].replace(/\n/g, '');
	
	if (exec == 'dup' && classes == 'polytec') {
		document.location.href ='/v2/bid_edu2/lecture_schedule/lec_payment.php?lec_key='+lec_key+'&title='+title+'&state=continu';
		
	}else if(exec == 'dup' && classes != 'polytec'){
		if(confirm('이미 신청하셨습니다. 결제를 하여 접수를 완료하시겠습니까?')){	
			document.location.href ='/v2/bid_edu2/lecture_schedule/lec_payment.php?lec_key='+lec_key+'&title='+title+'&state=continu';
		}else return;
	}else if(exec == 're'){
		document.location.href ='/v2/bid_edu2/lecture_schedule/lec_payment.php?lec_key='+lec_key+'&title='+title+'&state=re';
	}else if(exec == 'uniq'){
		document.location.href ='/v2/bid_edu2/lecture_schedule/lec_payment.php?lec_key='+lec_key+'&title='+title;	
	}
	
}
/////////////////////////////////////////////////
// 오프라인 강의 신청 및 결제 시 로그인 체크 END
/////////////////////////////////////////////////

/////////////////////
// 나의 수강내역 STD
/////////////////////
function f_apply_down(obj){
		window.open('pop_receipt.php?no='+obj,'','width=587, height=700, scrollbars=yes');
	}
//<!-- 신용카드 영수증 연동 스크립트 -->
	function receiptView(tno)
	{
		receiptWin = "http://admin.kcp.co.kr/Modules/Sale/Card/ADSA_CARD_BILL_Receipt.jsp?c_trade_no=" + tno
		window.open(receiptWin , "" , "width=420, height=670")
	}

	function f_tax(ordno, division, pum_name){
		var x=window.open('/v2/support/tax/pop_payTaxStep1.php?sess='+ordno+'&division='+division+'&pum_name='+pum_name,'tax','width=510, height=800');
		x.focus();
	}

	function f_money(pltid, ordno){
		var x=window.open('/v2/support/payment/payment_money_receipt.php?pltid='+pltid+'&ordno='+ordno,'tax','width=610,height=600');
		x.focus();
	}

	function f_money_prt(ymd, pltid, ordno, payerid, txamt){
		//var x=window.open('http://pg1.payletter.com:9999/Receipt/ReceiptPrint.asp?ymd='+ymd+'&cid='+cid+'&usestate=0','tax','width=610,height=600');
		var x=window.open('http://pg1.payletter.com:9999/Daesa/ReceiptPrint4Info.asp?clientid=info21c&ymd='+ymd+'&pltid='+pltid+'&ordno='+ordno+'&payerid='+payerid+'&txamt='+txamt,'tax','width=610,height=600');
		x.focus();
	}
/////////////////////
// 나의 수강내역 END
/////////////////////

function f_cateclick(obj){ // top cate clicked
	var _cate = (obj+'').split('/');
	switch(_cate[3]){
		case 'edu_intro': 
			cate = 'top_m01'; break;
		case 'lecture_intro': 
			cate = 'top_m02'; break;
		case 'lecture_schedule': 
			cate = 'top_m03'; break;
		case 'lecture_postscript': 
			cate = 'top_m04'; break;
		case 'edu_myinfo': 
			cate = 'top_m05'; break;
		default :
			cate = 'top_m01'; break;
	}

	document.getElementById('top_m01').src = '/v4/assets/image/edu/top_m01.gif';
	document.getElementById('top_m02').src = '/v4/assets/image/edu/top_m02.gif';
	document.getElementById('top_m03').src = '/v4/assets/image/edu/top_m03.gif';
	document.getElementById('top_m04').src = '/v4/assets/image/edu/top_m04.gif';
	document.getElementById('top_m05').src = '/v4/assets/image/edu/top_m05.gif';

	document.getElementById(cate).src = '/v4/assets/image/edu/'+cate+'_.gif';
}

function toNumber(str){
	str = str.toString();
	var len = str.length;
	var num = "";
	
	for(i=0; i<len; i++){
		int = parseInt(str.charAt(i));
		if(int >= 0 && int <= 9) num += str.charAt(i);
	}
	return parseInt(num);
}
 
function Number_Format(val){
	if(val){
		val = toNumber(val).toString();
		var len = val.length;
		var str = "";

		if(len > 3){
			var in_c = len % 3;
			if(!in_c) in_c = 3;
			
			for(n = 0; n < len; n++){
				if(n == in_c){
					str += ",";
					in_c = 3 + in_c;
				}
				str += val.charAt(n);
			}		
			return str;
		}else{return val;}
	}
}
