// session timeout
function sessionTimeout() {
	try{
		new mino.request("/common/sessionCheck.php?hash="+Math.random(),"GET","","");
	} catch (e) {
		return;
	}
}

// session check every 3000 seconds.
setInterval("sessionTimeout()",60*5*1000);

//docircle.com debug mode disable
if(document.location.host=="docircle.com" || document.location.host=="www.docircle.com") mino.debugView=0;

/*-------------------------------------

function - openUrl

author: hanulis
date: 2007-12-03
desc: URL을 새 창으로 연다

-------------------------------------*/
function openUrl(url) {
	window.open(url,"","");
}

/*-------------------------------------

function - black_bg

author: hanulis
date: 2007-12-03
desc: 배경화면을 까만 레이어로 덮어씀

-------------------------------------*/
function black_bg() {
	$("__BG__").style.display="";
	$("__BG__").style.height=mino.screen.height;

}

/*-------------------------------------

function - white_bg

author: hanulis
date: 2007-12-03
desc: 배경화면을 원상태로 복구

-------------------------------------*/
function white_bg() {
	$("__BG__").style.display="none";
}

/*-------------------------------------

function - close_alert

author: hanulis
date: 2007-12-03
desc: alert layer창을 닫음

-------------------------------------*/
function close_alert(e) {

	if(mino.isIE) e=event;

	if(e.keyCode==13) {
		if($('div_alertpopup').style.display!="none") {
			mino.event.del(document,"keyup",close_alert);
//			del_close_event();
			
			var exe=$('_ok').getAttribute("onclick").toString();
			if(mino.isIE) {
				exe=exe.replace(/function anonymous\(\)/,"");
				exe=exe.replace(/\{\s(.*?)\s\}/,"$1");
			}

			eval(exe);
		}
	}
}


function add_close_event() {
	$("_ok").focus();
	mino.event.add(document,"keyup",close_alert);
}

var _alert_msg;
var _alert_args;

function alert_layer(msg) {

	if(_alert_msg) msg=_alert_msg;
	if(_alert_args) var args=_alert_args;
	else var args=arguments;

	var layer=$('div_alertpopup');

	if(layer.style.display!="none") return;

	if(!mino.screen.height) {
		_alert_msg=msg;
		_alert_args=args;
		setTimeout("alert_layer(1)",100);
		return;
	} else {
		_alert_msg=null;
		_alert_args=null;
	}

	hideSelectBox();

	layer.style.zIndex=200;
	$('span_alertpopup_msg').innerHTML = msg ; //메시지를 보여 줍니다.

	//bg layer
	var bg=$("__BG__");
	bg.style.display="";
	bg.style.height=mino.screen.height+document.body.scrollTop;

	layer.style.display="";
	mino.layer.moveCenter(layer);

	var id_or_name;

	if(args[3]=="byname"){
		id_or_name="try {document.getElementsByName('"+args[2]+"').item(0).focus();} catch (e) {}";
	}else{
		id_or_name="try {$('"+args[2]+"').focus();} catch (e) {}";
	}

	if(args[1]=="focus"){
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();"+id_or_name+"\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="confirm"){//("msg","confirm","submit_form")

		if(args[2]){
			nextfunction=args[2]+"()";
		}else{
			nextfunction="";
		}

		$("popok").innerHTML  ="<img id='_ok' onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();"+nextfunction+";\" src=\"../../images/common/alertpopup/yes_btn.gif\" name=\"Image10\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image10\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image10','','../../images/common/alertpopup/yes_btn_.gif',1)\" />";
		$("popok").innerHTML +="<img id='_ok' onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();\" src=\"../../images/common/alertpopup/no_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/no_btn_.gif',1)\" />";

	} else if(args[1]=="confirm_ok_cancle"){//("msg","confirm_ok_cancle","submit_form(aa,bb)")

		_confirm_fnc=args[2];
		if(args[2]) _confirm_cancel=args[3];

		$("popok").innerHTML  ="<img onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();do_confirm();\" src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image10\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image10\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image10','','../../images/common/alertpopup/ok_btn_.gif',1)\" />";
		$("popok").innerHTML +="<img onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();cancel_confirm()\" src=\"../../images/common/alertpopup/cancel_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/cancel_btn_.gif',1)\" />";
			
	} else if(args[1]=="reload") {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';location.reload();showSelectBox();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="back") {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';history.go(-1);showSelectBox();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="back2") {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"history.back();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="function") {
		_confirm_fnc=args[2];
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();do_confirm();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="layershow") {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';mino.layer.show($('"+args[2]+"'));showSelectBox();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="layershow2") {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('div_alertpopup').style.display='none';mino.layer.show($('"+args[2]+"'));showSelectBox();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	} else if(args[1]=="nobtn") {
		$("popok").innerHTML ="";
	} else {
		$("popok").innerHTML ="<span id=\"popok\"><img id='_ok' src=\"../../images/common/alertpopup/ok_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/ok_btn_.gif',1)\" /></span>";
	}

	setTimeout("add_close_event()",500);
}

function hide_alert_layer() {
	$('__BG__').style.display='none';
	$('div_alertpopup').style.display='none';
	showSelectBox();
}


var _confirm_msg;
var _confirm_args;
var _confirm_fnc;
var _confirm_cancel;
function confirm_layer(msg) {

	if(_confirm_msg) msg=_confirm_msg;
	if(_confirm_args) var args=_confirm_args;
	else var args=arguments;

	hideSelectBox();
//	var args=arguments;

	_confirm_fnc=args[1];
	if(args[2]) _confirm_cancel=args[2];

	if(!mino.screen.height) {
		_confirm_msg=msg;
		_confirm_args=args;
		setTimeout("confirm_layer(1)",500);
		return;
	} else {
		_confirm_msg=null;
		_confirm_args=null;
	}

	var layer=$('div_alertpopup');
	layer.style.zIndex=200;
	$('span_alertpopup_msg').innerHTML = msg ; //메시지를 보여 줍니다.

	//bg layer

	var bg=$("__BG__");
	bg.style.display="";
	bg.style.height=mino.screen.height+document.body.scrollTop;

	layer.style.display="";
	mino.layer.moveCenter(layer);

	$("popok").innerHTML  ="<img onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();do_confirm();\" src=\"../../images/common/alertpopup/yes_btn.gif\" name=\"Image10\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image10\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image10','','../../images/common/alertpopup/yes_btn_.gif',1)\" />";
	$("popok").innerHTML +="<img onclick=\"$('__BG__').style.display='none';$('div_alertpopup').style.display='none';showSelectBox();cancel_confirm()\" src=\"../../images/common/alertpopup/no_btn.gif\" name=\"Image9\" width=\"77\" height=\"32\" vspace=\"2\" border=\"0\" id=\"Image9\" style=\"cursor:pointer;\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../../images/common/alertpopup/no_btn_.gif',1)\" />";
		

}

function do_confirm() {
	//alert(_confirm_fnc);
	eval(_confirm_fnc);
	_confirm_fnc="";
}

function cancel_confirm() {
	eval(_confirm_cancel);
	_confirm_cancel="";
}


//modifyed by hanuls 2007.05.25 - for 안의 obj->obj[i] && if체크를 obj[i]와 selectBoxList[i]가 있는 경우로 체크하도록 수정.
function showSelectBox() {//show all select box
	if(!_do_hidden && mino.isIE) {

		var obj;
		obj = document.getElementsByTagName('select');

		for(i=0;i < obj.length ;i++){
			if(obj[i]){
				//obj[i].style.visibility="visible";
				try{
					obj[i].style.visibility = selectBoxList[i];				 
				} catch (e) {}

			}
		}
	}

}

var _do_hidden=0;

//modify by CWMIN 2007.05.22 - select 박스 hide하기 이전 상태 저장
var selectBoxIndex = 0;
var selectBoxList = new Array();

function hideSelectBox() {//show all select box
	if(!_do_hidden && mino.isIE) {
		var obj;
		obj = document.getElementsByTagName('select');

		selectBoxIndex = obj.length;

		for(i=0;i < obj.length ;i++){

			if( obj[i] && obj[i].style.visibility != "hidden" && !obj[i].getAttribute("nohide") ){
				selectBoxList[i] = obj[i].style.visibility;
				obj[i].style.visibility="hidden";
			}
		}
	}

}

/// history control
/*	modify by cwmin 2007.3.9 - html 코드로 정적 iframe 생성함
/*  - historyFrame이 없을때 생성하도록 수정. by hanulis.
*/
function _history_init() {
	if(!$("historyFrame")) {
		var i=document.createElement("IFRAME");
		i.style.display="none";
		i.id="historyFrame";
		document.body.appendChild(i);
	}
}


function _history_add(str,fn) {
	SetCookie("history_save","1");

	historyFrame.location.href="/blank.html?"+str+"#"+str+"|"+fn;
}

//mino.event.add(window,"load",_history_init);

/*-------------------------------------

function - getCookieVal

author: hanulis
date: 2007-12-03
desc: 쿠키값 파싱 - GetCookie에 종속 사용

-------------------------------------*/
function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
} 

/*-------------------------------------

function - GetCookie

author: hanulis
date: 2007-12-03
desc: 쿠키를 get.

-------------------------------------*/
function GetCookie (name) { var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) { //while open 
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	} //while close 
	return null;
} 

/*-------------------------------------

function - SetCookie

author: hanulis
date: 2007-12-03
desc: 쿠키를 set

-------------------------------------*/
function SetCookie (name, value) { 
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : (";expires=" + expires.toGMTString())) + ((path == null) ? "" : (";path=" + path)) + ((domain == null) ? "" : (";domain=" + domain)) + ((secure == true) ? ";secure" : "");
} 

/*-------------------------------------

function - setcookie_f

author: hanulis
date: 2007-12-03
desc: flash를 사용한 cookie사용. 쿠키를 저장한다

-------------------------------------*/
function setcookie_f(obj,d,v) {
	if(mino.isIE) var so=$("sharedObject");
	else var so=$("sharedObject_f");

	so.setData(obj,d,v);

}

/*-------------------------------------

function - getcookie_f

author: hanulis
date: 2007-12-03
desc: flash를 사용한 cookie사용. 저장된 쿠키를 받아온다

@param

-------------------------------------*/
function getcookie_f(obj,d) {
	if(mino.isIE) var so=$("sharedObject");
	else var so=$("sharedObject_f");

	return so.getData(obj,d);
}

/*-------------------------------------

function - clearcookie_f

author: hanulis
date: 2007-12-03
desc: flash 쿠키를 삭제

-------------------------------------*/
function clearcookie_f(obj) {
	if(mino.isIE) var so=$("sharedObject");
	else var so=$("sharedObject_f");

	so.clearData(obj);
}



/*-------------------------------------

function - isAllowStringSMS

author: cwmin
date: 2008-01-22
desc: 메시지 내용에 아스키코드 문자가 아닌게 있으면 0 반환
Update date: 2008-02-13 Thpark (add $,?)
Update date: 2008-10-24 Hanulis (add _)

@param

-------------------------------------*/

function isAllowStringSMS(smsString)
{
	for (i = 0; i < smsString.length; i++)
	{
		if (!(((smsString.charCodeAt(i) >= 32) && (smsString.charCodeAt(i) <= 122)) 
			|| (smsString.charCodeAt(i) == 10) 
			|| (smsString.charCodeAt(i) == 13)))
		{
			//not allow
			return 0;
		}

		//if (((smsString.charCodeAt(i) >= 91) && (smsString.charCodeAt(i) <= 96)) || (smsString.charCodeAt(i) == 36))
		if ((smsString.charCodeAt(i) >= 91) && (smsString.charCodeAt(i) <= 96) && (smsString.charCodeAt(i) !=95))
		{
			//not allow
			return 0;
		}
	}
	//allow
	return 1;
}


/*-------------------------------------

function - isAllowStringSmartBlast

author: cwmin
date: 2008-01-22
desc: 메시지 처음 160byte에 아스키코드 문자가 아닌게 있으면 0 반환

@param

-------------------------------------*/

function isAllowStringSmartBlast(sbString)
{
	stringLength = sbString.length;

	if (stringLength > 160)
		stringLength = 160;


	for (i = 0; i < stringLength; i++)
	{
		if (!(((sbString.charCodeAt(i) >= 32) && (sbString.charCodeAt(i) <= 122)) 
			|| (sbString.charCodeAt(i) == 10) 
			|| (sbString.charCodeAt(i) == 13)))
		{
			//not allow
			return 0;
		}

		//if (((sbString.charCodeAt(i) >= 91) && (sbString.charCodeAt(i) <= 96)) || (sbString.charCodeAt(i) == 36))
		if ((sbString.charCodeAt(i) >= 91) && (sbString.charCodeAt(i) <= 96))
		{
			//not allow
			return 0;
		}
	}
	//allow
	return 1;
}

/*-------------------------------------

function - onlyNumberCheck

author: thpark
date: 2008-01-22
desc: 메시지 처음 160byte에 아스키코드 문자가 아닌게 있으면 0 반환

@param

-------------------------------------*/
function onlyNumberCheck(event)
{
	if (window.event) keyCode = window.event.keyCode;
	else if (event) keyCode = event.which;

	if(keyCode >= 96 && keyCode <= 105) return true;
	
	if((keyCode != 10) && (keyCode != 13) && (keyCode != 8) && (keyCode != 0) && ((keyCode<48) || (keyCode> 57)))
	{

		if(mino.isIE)
			event.keyCode = 0; 
		else
			event.preventDefault();

		event.cancelBubble = true; 
		event.returnValue = false;  

		//alert_layer("That character is not allowed.");
		return false;
	}

	return true;
}



/*-------------------------------------
function - getflash

author: hanulis
date: 2008-07-10
desc: 플래시 파일을 화면에 표시

@param
	name - filename
	wd - width
	ht - height
-------------------------------------*/
function getflash(name, wd, ht){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,39,0" width='+wd+' height='+ht+'>');
	document.write('<param name="movie" value='+name+'>');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src='+name+' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+wd+' height='+ht+' wmode="transparent"></embed>');
	document.write('</object>');
}

/*

드림위버 기본 script

*/
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 setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='';
	return '';
}
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 popup_pastDue() {
	var al=new mino.alert();
	al.message = "Your account has a past due amount.  Please pay the amount by going to <a href='/manageAccount/'>Manage Account</a> and clicking on Make Payment.";
	al.okFnc=function() {location.href="/manageAccount/";}
	al.open();
	
}