/*******************************
	slide Ã³¸® ÇÔ¼ö
*******************************/
/* slide ÀÏ°ýÃ³¸®(1°³¸¸) : div¸í, ÇöÀç°ª,this */
function slide_click(divname,now,th) {
	var css = "";
	var to = document.getElementsByName(divname+'[]');

	for(i=0;i < to.length; i++) {
		if(i == now) {
			if(to[i].style.display == "block") {
				to[i].style.display = "none";
			}
			else {
				to[i].style.display = "block";
			}
		}
		else {to[i].style.display = "none";}
	}

}


/*******************************
	css Ã³¸® ÇÔ¼ö
*******************************/
/* css ÀÏ°ýÃ³¸®(1°³¸¸) : div¸í, ÇöÀç°ª,this,css on¸í, css off¸í,¹æ½Ä,¼±ÅÃ¿©ºÎ */
function css_click(divname,now,th,con,coff,how,xval) {
	var css = "";
	var to = document.getElementsByName(divname+'[]');
	if(con == undefined) { var con = "x_td_on";}
	if(coff == undefined) { var coff = "x_td_off";}
	if(how == "multi") {
		if(xval == true) {css	= con;} else {css = coff}
		to[now].className = css;	
	}
	else {
		for(i=0;i < to.length; i++) {
			if(i == now) {css	= con;} else {css = coff}
			to[i].className = css;		
		}
	}
}


//============================================================================
// ajax send (form post)
function sendAjaxForm(xurl,xform,loading) {
	if(xurl) {
		var params = Form.serialize($(xform));
		if(loading == "loading") {
			var myAjax = new Ajax.Request(xurl,{method: 'post',parameters: params,onCreate: getAjaxLoading(div),onComplete: getAjaxSuccess});
		}
		else if(loading == "alertsave") {
			var myAjax = new Ajax.Request(xurl,{method: 'post',parameters: params,onCreate: getAjaxLoading(div),onComplete: getAjaxSuccessSave});
		}		
		else {
			var myAjax = new Ajax.Request(xurl,{method: 'post',parameters: params});
		}
	}
}

// ajax view
function getAjaxViewOld(div,xurl,xpost) {
	if(div && xurl) {
		if(xpost == undefined) { var xpost = "post";}
		new Ajax.Updater(div, xurl+'&ajax=1', { method: xpost });
	}
}
function getAjaxView(div,xurl,xpost,loading) {
	if(div && xurl) {
		xurl	= xurl+'&ajax=1';
		if(loading == "loading") {
			new Ajax.Updater(div, xurl, { asynchronous:true,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccess});			
		}
		else if(loading == "alertsave") {
			new Ajax.Updater(div, xurl, { asynchronous:true,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccessSave});			
		}		
		else if(loading == "alertdel") {
			new Ajax.Updater(div, xurl, { asynchronous:true,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccessDel});			
		}	
		else {
			new Ajax.Updater(div, xurl, { asynchronous:true,method:'post'});		
		}
	}
}
// ajax view (form post)
function getAjaxViewForm(div,xurl,xform,loading) {
	if(div && xurl) {
		var params = Form.serialize($(xform));
		if(loading == "loading") {
			new Ajax.Updater(div, xurl, { asynchronous:true,parameters:params,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccess});			
		}
		else if(loading == "alertsave") {
			new Ajax.Updater(div, xurl, { asynchronous:true,parameters:params,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccessSave});			
		}		
		else if(loading == "alertdel") {
			new Ajax.Updater(div, xurl, { asynchronous:true,parameters:params,method:'post',onCreate: getAjaxLoading(div),onComplete: getAjaxSuccessDel});			
		}	
		else {
			new Ajax.Updater(div, xurl, { asynchronous:true, parameters:params,method:'post'});			
		}
	}
}
/* ·ÎµùÁß */
function getAjaxLoading(div){ 
	if(document.all.loadingBar) {	Element.show('loadingBar');}

} 
/* ·Îµù¿Ï·á */
function getAjaxSuccess(){ 
	if(document.all.loadingBar) {
		Element.hide('loadingBar');
	}
}
/* ·Îµù¿Ï·áÈÄ ÀúÀå¸Þ¼¼Áö */
function getAjaxSuccessSave(){ 
	if(document.all.loadingBar) {
		Element.hide('loadingBar');
		alert("ÀúÀåµÇ¾ú½À´Ï´Ù.");
	}
}
/* ·Îµù¿Ï·áÈÄ »èÁ¦¸Þ¼¼Áö */
function getAjaxSuccessDel(){ 
	if(document.all.loadingBar) {
		Element.hide('loadingBar');
		alert("»èÁ¦µÇ¾ú½À´Ï´Ù.");
	}
}


// ÆË¾÷Ã¢ °¡¿îµ¥ À§Ä¡ÇÏ±â
function autoWindowSize(width,height)
{
	window.resizeTo(width, height);
	windowX = (window.screen.width-width)/2;
	windowY = (window.screen.height-height)/2;
	if(width>screen.width){
		width = screen.width;
		windowX = 0;
		bLargeImage = 1;
	}
	if(height>screen.height){
		height = screen.height;
		windowY = 0;
		bLargeImage = 1;
	}
	x = width/2;
	y = height/2;
	window.moveTo(windowX,windowY);
	window.resizeTo(width, height);	
}

// ÀÎ¼â(»õÃ¢ ¶ç¿ì±â)
function open_print(name , url , x , y) {
	
	if(x == "undefined" || x =="") { x = "770";}
	if(y == "undefined" || y =="") { y = "700";}
	var winl 	= (screen.width - x) / 2; 
	var wint 	= (screen.height - y) / 2;  	
	var sc	= 1;
	var rs	= 1;
	var me	= 1;
	var fu	= 0;
	
	var w=window.open( url ,name,'fullscreen='+fu+',titlebar=no,toolbar=no,directories=no,status=no,menubar='+me+',scrollbars=' + sc + ',resizable=' + rs + ',width=' + x + ',height=' + y + ',top='+wint+',left='+winl);
	getPopUpFlag(w);

}

// ¿ìÆí¹øÈ£°Ë»ö
function OpenZipcode(pwd,z1,z2,ad,ad1) 
	{
		var gpwd = (pwd) ? pwd : '.';
		var url = gpwd+'/lib/module/zipsearch/zipcode.php?zip1='+z1+'&zip2='+z2+'&address='+ad+'&address1='+ad1;
		window.open(url,'zip_win','width=460,height=550,statusbar=no,scrollbars=yes,toolbar=no');
	}

//============================================================================
// µµ¿ò¸»¼¾ÅÍ
function help_center(hotkey){
	if(hotkey) {
	var u = root_path+"/lib/module/help/index.php?hotkey="+hotkey;
	open_popup("help_center" , u ,"710","540" ,"no","no","no","no");
	}
}


function doDivResize(el,h) {
		if(document.getElementById(el)) {
			el = typeof el == 'string' ? document.getElementById(el) : el;
			try
			{
				el.style.height = Math.max(document.body.clientHeight - h, 100);
				el.style.width = "100%";
			}
			catch ( e ) { }
		}
	}

// iframe Resize
function resizeiFrame(ifr_id,re){
	//°¡·Î±æÀÌ´Â À¯µ¿ÀûÀÎ °æ¿ì°¡ µå¹°±â ¶§¹®¿¡ ÁÖ¼®Ã³¸®!
	var ifr= document.getElementById(ifr_id) ;
	var innerBody = ifr.contentWindow.document.body;
	var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
	//var innerWidth = document.body.scrollWidth + (document.body.offsetWidth - document.body.clientWidth);

	if (ifr.style.height != innerHeight) //ÁÖ¼®Á¦°Å½Ã ´ÙÀ½ ±¸¹®À¸·Î ±³Ã¼ -> if (ifr.style.height != innerHeight || ifr.style.width != innerWidth)
	{
		ifr.style.height = innerHeight;
		//ifr.style.width = innerWidth;
	}

	if(!re) {
		try{
			innerBody.attachEvent('onclick',parent.do_resize);
			innerBody.attachEvent('onkeyup',parent.do_resize);
			//±ÛÀÛ¼º »óÈ²¿¡¼­ Å¬¸¯¾øÀÌ Å¸ÀÌÇÎÇÏ¸é¼­ Ã¢ÀÌ ´Ã¾î³ª´Â »óÈ²ÀÌ¸é À­ÁÙ ÁÖ¼®Á¦°Å
		} catch(e) {
			//innerBody.addEventListener("click", parent.do_resize, false);
			//innerBody.addEventListener("keyup", parent.do_resize, false);
			//±ÛÀÛ¼º »óÈ²¿¡¼­ Å¬¸¯¾øÀÌ Å¸ÀÌÇÎÇÏ¸é¼­ Ã¢ÀÌ ´Ã¾î³ª´Â »óÈ²ÀÌ¸é À­ÁÙ ÁÖ¼®Á¦°Å
		}
	}
}


// »õÃ¢ ¶ç¿ì±â
function open_popup( name , url , x , y , sc , rs, me, fu ) {
	
	var winl = (screen.width - x) / 2; 
	var wint = (screen.height - y) / 2;  	
	if(sc == "undefined") { sc = "1";}
	if(rs == "undefined") { sc = "1";}
	if(me == "undefined") { me = "0";}
	if(fu == "undefined") { me = "0";}
	
	if(sc == "") { sc =0;}
	if(rs == "") { rs =0;}
	if(me == "") { me =0;}
	if(fu == "") { fu =0;}
	
	var w=window.open( url ,name,'fullscreen='+fu+',titlebar=no,toolbar=no,directories=no,status=no,menubar='+me+',scrollbars=' + sc + ',resizable=' + rs + ',width=' + x + ',height=' + y + ',top='+wint+',left='+winl);
	getPopUpFlag(w);

}


function getPopUpFlag(win)
{
	try{ win.focus(); return win; }
	catch(e)
	{
		alert('\nÆË¾÷(PopUp)ÀÌ Â÷´ÜµÇ¾î ÀÖ½À´Ï´Ù.\n\nÆË¾÷Â÷´ÜÀ» Ç®¾îÁÖ¼Å¾ß ¿äÃ»ÇÏ½Å ±â´ÉÀ» ¼öÇàÇÒ ¼ö ÀÖ½À´Ï´Ù.               ');
	}
}

// ÇÁ¸°ÅÍÃ¢¿­±â
function Print_Popup(title,obj) {
	
	var Url = "./lib/module/print/print.php?title="+title+"&obj="+obj;
	var Width = 650;
	var Height = 600;
	var Scroll = "auto";
	var Resize = "no";
	window.open(Url, 'print', 'width='+Width+', height='+Height+', scrollbars='+Scroll+', resizable='+Resize+',status=no');
}

function TypeCheck (s, spc) 
{
	var i;

	for(i=0; i< s.length; i++) 
	{
		if (spc.indexOf(s.substring(i, i+1)) < 0) 
		{
			return false;
		}
	}        
	return true;
}
//ÄÞ¸¶»ðÀÔ (number_format)
function commaSplit(srcNumber) 
{ 
	var txtNumber = '' + srcNumber; 

	var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])'); 
	var arrNumber = txtNumber.split('.'); 
	arrNumber[0] += '.'; 
	do { 
		arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2'); 
	} 
	while (rxSplit.test(arrNumber[0])); 
	if (arrNumber.length > 1) { 
		return arrNumber.join(''); 
	} 
	else { 
		return arrNumber[0].split('.')[0]; 
	} 
}
//ÄÞ¸¶Á¦°Å
function filterNum(str) 
{ 
	re = /^\$|,/g; 
	return str.replace(re, ""); 
}

// ¼ýÀÚÀÔ·Â ex : onkeyup="commaInsert(this)"
function commaInsert(field)
{
	if (!TypeCheck(field.value , "0123456789,"))
	{
		alert('¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.       ');
		field.value = '';
		field.focus();
		return false;
	}
	field.value = commaSplit(filterNum(field.value));
}

// input onblur
function bgChange(obj, act) {
		if ( act == 'F') {
			obj.style.backgroundColor='#ffffff';
		} else {
			obj.style.backgroundColor='#FCF0E2';	
		}			
}

function roundTable(objID) {
       var obj = document.getElementById(objID);
       var Parent, objTmp, Table, TBody, TR, TD;
       var bdcolor, bgcolor, Space;
       var trIDX, tdIDX, MAX;
       var styleWidth, styleHeight;

       // get parent node
       Parent = obj.parentNode;
       objTmp = document.createElement('SPAN');
       Parent.insertBefore(objTmp, obj);
       Parent.removeChild(obj);

       // get attribute
       bdcolor = obj.getAttribute('rborder');
       bgcolor = obj.getAttribute('rbgcolor');
       radius = parseInt(obj.getAttribute('radius'));
       if (radius == null || radius < 1) radius = 1;
       else if (radius > 6) radius = 6;

       MAX = radius * 2 + 1;
       
       /*
              create table {{
       */
       Table = document.createElement('TABLE');
       TBody = document.createElement('TBODY');

       Table.cellSpacing = 0;
       Table.cellPadding = 0;

       for (trIDX=0; trIDX < MAX; trIDX++) {
              TR = document.createElement('TR');
              Space = Math.abs(trIDX - parseInt(radius));
              for (tdIDX=0; tdIDX < MAX; tdIDX++) {
                     TD = document.createElement('TD');
                     
                     styleWidth = '1px'; styleHeight = '1px';
                     if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
                     else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
                     else if (radius > 2) {
                            if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
                            if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
                     }

                     if (styleWidth != null) TD.style.width = styleWidth;
                     if (styleHeight != null) TD.style.height = styleHeight;

                     if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
                     else if (tdIDX > Space && Space < MAX - tdIDX - 1)  TD.style.backgroundColor = bgcolor;
                     
                     if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
                     TR.appendChild(TD);
              }
              TBody.appendChild(TR);
       }

       /*
              }}
       */

       Table.appendChild(TBody);
       
       // insert table and remove original table
       Parent.insertBefore(Table, objTmp);
}



function onlyNumber(field)
{
	if (!TypeCheck(field.value , "0123456789,"))
	{
		alert('¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.       ');
		field.value = '';
		field.focus();
		return false;
	}
}


function onlyDigit()
{
	var e = window.event;
	
	if      (!e.shiftKey && e.keyCode >= 48 && e.keyCode <= 57)  { return true; } //keyboard's num
	else if (!e.shiftKey && e.keyCode >= 96 && e.keyCode <= 105) { return true; } //pad's num
	else {
		switch(e.keyCode) {
			case 8 : //back  
			case 35: //end   
			case 36: //home  
			case 37: //left
			case 38: //top
			case 39: //right
			case 40: //bottom
			case 45: //insert
			case 46: //delete
			case 9 : //tab
			case 13 : //enter
			//case 188: //comma
			return true;
		}
	}
	return false;
} 



//ÀÌ¹ÌÁö ¿øº»º¸±â
winObj=null; // ÃÊ±âÈ­
function ViewBigImg(Val)
{
	img = new Image(); //ÀÌ¹ÌÁö ·Îµù. ÀÌ¹ÌÁö¸¦ À¥¼­¹ö·ÎºÎÅÍ Àü¼Û. Ãâ·Â ¾ÈÇÔ
	img.src= Val;
	draw();
	return false;
}

function draw()
{
	if(img.complete == false) {
		setTimeout("draw()", "200");
		return;
	}
		
	width=img.width;
	height=img.height;
	swidth=screen.width;
	sheight=screen.height;
	scr = "no";
	
	if(width > (swidth-20)) {
		width=swidth-100;
		scr = "yes";
	}
	if(height > (sheight-20)) {
		height=sheight-100;
		scr = "yes";
	}
	var attr = "scrollbars="+scr+",width="+ width+ ",height=" + height;

	// À©µµ¿ì¸¦ ¿­°í ÀÌ¹ÌÁö Ãâ·Â.
	if(winObj != null && winObj.closed == false) {winObj.close();}
	winObj = window.open('',"imgwindow",attr);
	winObj.document.write("<html><head><title>¿øº» ÀÌ¹ÌÁö È®´ëº¸±â</title>");
	winObj.document.write("<s" + "cript>self.moveTo(30,30);</s" + "cript>");
	winObj.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><center>");
	winObj.document.write("<a href='javascript:window.close();'><img src='"+ img.src +"' border='0' alt='´Ý±â'></a>");
	winObj.document.write("</center></body></html>");
}


 
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.0
  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 && document.getElementById) x=document.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];}
}


/*************************************************
* µå·Ó´Ù¿î¸Þ´º
***************************************************/
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=0 //hide menu when user clicks within menu? (1=yes, 0=no)


var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function showhide(obj, e, visible, hidden){
    if (ie5||ns6)
        dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
        obj.visibility=visible
    else if (e.type=="click")
        obj.visibility=hidden
}

function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
    var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else{
    var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
    }
    return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    if (typeof dropmenuobj!="undefined") //hide previous menu
        dropmenuobj.style.visibility="hidden"
        clearhidemenu()
    if (ie5||ns6){
        obj.onmouseout=delayhidemenu
        dropmenuobj=document.getElementById(dropmenuID)
    if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
        dropmenuobj.onmouseover=clearhidemenu
        dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
        showhide(dropmenuobj.style, e, "visible", "hidden")
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
    }
    return clickreturnvalue()
}

function clickreturnvalue(){
    if ((ie5||ns6) && !enableanchorlink) return false
    else return true
}

function contains_ns6(a, b) {
    while (b.parentNode)
    if ((b = b.parentNode) == a)
    return true;
    return false;
}

function dynamichide(e){
    if (ie5&&!dropmenuobj.contains(e.toElement))
        delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    delayhidemenu()
}

function delayhidemenu(){
    delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
    if (typeof delayhide!="undefined")
        clearTimeout(delayhide)
}




function show_hide_box(an, width, height) {
	var href = an.href;
	var boxdiv = document.getElementById(href);
	
	if (boxdiv != null) {
	if (boxdiv.style.display=='none') {
		move_box(an, boxdiv);
		boxdiv.style.display='block';
	} else
		boxdiv.style.display='none';
		return false;
	}
	
	boxdiv = document.createElement('div');
	boxdiv.setAttribute('id', href);
	boxdiv.style.display = 'block';
	boxdiv.style.position = 'absolute';
	boxdiv.style.width = width + 'px';
	boxdiv.style.height = height + 'px';
	boxdiv.style.border = '1px solid cccccc';
	boxdiv.style.backgroundColor = '#fff';
	boxdiv.style.padding = '0';
	
	var txt = "<div align=right style='padding : 3 5 0 0'><a href=\"javascript:show_hide_box_close('"+an+"');\" style='font-size:11px'>´Ý ±â <img src='"+SLB_image+"/btn_exit.gif' border=0 align=absmiddle></a></div>";
	boxdiv.innerHTML = txt; 
	
	var contents = document.createElement('iframe');
	contents.scrolling = 'no';
	contents.frameBorder = '0';
	contents.style.width = width + 'px';
	contents.style.height = height + 'px';
	contents.style.padding = '5';
	contents.src = href;
	
	boxdiv.appendChild(contents);
	document.body.appendChild(boxdiv);
	move_box(an, boxdiv);
	
	return false;
}

function show_hide_box_close(an) {
	var boxdiv = document.getElementById(an);
	boxdiv.style.display='none';   
}

function move_box(an, box) {
	//¸µÅ©µÈ À§Ä¡¿¡¼­ ºÎÅÍÀÇ ¼³Á¤°ª ÁöÁ¤
	var cleft = 0;  //¿ÞÂÊ¸¶Áø  
	var ctop = -5;  //»ó´Ü¸¶Áø
	var obj = an;
	while (obj.offsetParent) {
		cleft += obj.offsetLeft;
		ctop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	box.style.left = cleft + 'px';
	ctop += an.offsetHeight + 8;
	if (document.body.currentStyle && document.body.currentStyle['marginTop']) {
		ctop += parseInt(document.body.currentStyle['marginTop']);
	}
	box.style.top = ctop + 'px';
}


// È­¸éÀá±Ý
function lock_window(URL)
{
	var saveX = top.window.screenLeft - 4;
	var saveY = top.window.screenTop - 100;

	top.window.moveTo(1, window.screen.availHeight + 100);

	var lock_dialog = null;

	while( lock_dialog == null || String(lock_dialog) != "OK")
	{
		lock_dialog = window.showModalDialog(URL, self, "dialogWidth=30; dialogHeight=20; status=no; help=no; scroll=no");
	}
	
	top.window.moveTo(saveX, saveY);

}


//***************************************************
// layer popup start
//****************************************************
document.write('<div id="wzone" style="z-index:999; position: absolute; top:0px;left:0px; width: 0px; height: 0px; border: 0px; display: none;"></div>');
var wzone_opop_c = 0;
var t_c = 1;
var x = 0;
var y = 0;
var move = 0;
var drag = 0;
var clicktop = 0;
var clickleft = 0;
var ft_obj;
var fi_obj;
var top_zindex = 99999;

function doWOpenPopup(url, name_a, wid, hei) {
	var wzone = document.getElementById("wzone");
	wzone.style.display='';
	var iobj = document.createElement("iframe");
	iobj.src=url + '&name_a=' + name_a + '&t_c=' + t_c;
	iobj.id = 'i' + '_' + name_a + '_' + t_c;
	iobj.name = 'i' + '_' + name_a + '_' + t_c;
	iobj.t_c = t_c;
	iobj.style.position="absolute";
	iobj.style.zIndex = top_zindex;
	iobj.style.left = wid / 2 + 13 * wzone_opop_c;
	iobj.style.top = document.body.scrollTop + (document.body.clientHeight / 8) + 13 * wzone_opop_c;
	iobj.style.width = wid + "px";
	iobj.style.height = hei + "px";
	iobj.style.border="0px solid #1347A0";
	iobj.scrolling = 'no';
 	iobj.frameBorder = '0';	

	wzone.appendChild(iobj);

	wzone_opop_c++;
	t_c++;
	top_zindex++;
	return iobj;
}

function doWResizePopup(name_a, t_c, width, height) {
	var iobj = document.getElementById('i' + '_' + name_a + '_' + t_c);
	iobj.style.width = width + "px";
	iobj.style.height = height + "px";
}

function doWClosePopup(name_a, t_c) {
	var wzone = document.getElementById('wzone');
	var iobj = document.getElementById('i' + '_' + name_a + '_' + t_c);
	if(!iobj) return false;
	wzone.style.display = 'none';

	wzone.removeChild(iobj);
	wzone_opop_c--;
	preSet(wzone);
	if(wzone.innerHTML.length > 0) wzone.style.display = 'block';
	return true;
}

function preSet(obj) {
	obj.style.width = '0px';
	obj.style.height = '0px';
}

function mouseUp(e) {
	move = 0;
}

function mouseDown(e) {
	if(drag && fi_obj) {
		if(!e) if(fi_obj) e = fi_obj.contentWindow.window.event;
		if(!e) return;

		if(typeof(e.preventDefault) != 'undefined') e.preventDefault();
		move = 1;
		clickleft = e.clientX;
		clicktop = e.clientY;
		if(top_zindex > parseInt(fi_obj.style.zIndex)) {
			fi_obj.style.zIndex = top_zindex + 1;
			top_zindex = parseInt(fi_obj.style.zIndex);
		}
	}
}

function mouseMove(e) {
	if(move && fi_obj) {
		if(!e) if(fi_obj) e = fi_obj.contentWindow.window.event;
		if(!e) return;

		move = 1;
		fi_obj.style.left = parseInt(fi_obj.style.left) + (e.clientX - clickleft);
		fi_obj.style.top = parseInt(fi_obj.style.top) + (e.clientY - clicktop);
	}
}

function mouseStop(e) {
	if(!e) if(fi_obj) e = fi_obj.contentWindow.window.event;
	if(!e) return;
	e.returnValue = false;
}

function mouseOut(e) {
	drag = 0;
}

var iframeids=new Array();
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0

function push_iframe(iname) {
	iframeids.push(iname);
}

function pop_iframe(iname) {
	if(iframeids.length>0) {
		var p=-1;
		for(var i=0;i<iframeids.length;i++) if(iframeids[i]==iname) { p=i; break; }
		if(p>-1) {
			iframeids[p] = iframeids[0];
			iframeids.shift();
		}
	}
}

function resizeCaller() {
	var dyniframe=new Array()

	if(iframeids.length>0) {
		for (i=0; i<iframeids.length; i++) {
			if (document.getElementById)
				resizeIframe(iframeids[i])

				if ((document.all || document.getElementById) && iframehide=="no") {
				var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
				tempobj.style.display="block"
			}
		}
	}
}

function resizeIframe(name_a, t_c) {
	var currentfr = document.getElementById('i' + '_' + name_a + '_' + t_c);
	if (currentfr && !window.opera){
		currentfr.style.display="block"

		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight)
			currentfr.style.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight)
			currentfr.style.height = currentfr.Document.body.scrollHeight;

		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe)
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement

	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url) {
	if (document.getElementById)
	document.getElementById(iframeid).src=url
}

// layer popup end



/* ÀÚµ¿ comma Ã³¸® START */
function auto_comma(val) 
{
	  if (navigator.userAgent.indexOf("MSIE") != -1) 
	  {
		    var keyCode = window.event.keyCode;
		    if ( ((keyCode>=48) && (keyCode <= 105)) || (keyCode==8) || (keyCode==13) || (keyCode==35) || (keyCode==46) ) 
		    {
			      //0(48)~¼ýÀÚÅ°ÆÐµå9(105), enter(13), bakspace(8), delete(46), end(35) key ÀÏ ¶§¸¸ Ã³¸®ÇÑ´Ù.
			      var str = "" + get_number(val.value); //¼ýÀÚ¸¸ °¡Á®¿Â´Ù
			      if ( (str != null) && (str != "") && (str != "0") ) 			      
				        val.value = add_comma(str); //ÄÞ¸¶»ðÀÔ
			      else 			      
				        val.value = "0";
		    }
	  }
       
	  return;
}

function add_comma(val) 
{
  	var num = val;
	  if( num.length <= 3 )  
	      return num;
	  var loop = Math.ceil(num.length / 3);
	  var offset = num.length % 3;
	  if( offset==0 )
	      offset = 3;
	  var str = num.substring(0, offset);
	  for(i=1;i<loop;i++) 
	  {
		    str += "," + num.substring(offset, offset+3);
    		offset += 3;
	  }
	  return str;
}

function get_number(val) 
{
  	var str = ""+val;
	  var temp = "";
	  var num = "";
	  for(var i=0; i<str.length; i++) 
	  {
		    temp = str.charAt(i);
		    if (temp >= "0" && temp <= "9") 		    
			      num += temp;
		}
	  if ( (num != null) && (num != "") && (num != "0") ) 	  
		    return parseInt(num,10); //½ÊÁø¼ö·Î º¯È¯ÇÏ¿© ¸®ÅÏ
	  else 
		    return "0";	  
} 


function num_check() 
{
  	//¼ýÀÚ¸¸ ÀÔ·Â¹Þ±â.
	  if( navigator.userAgent.indexOf("MSIE") != -1 ) 
	  {
		    var keyCode = window.event.keyCode;
	      // - => 45,
	      if( (keyCode < 48) || (keyCode > 57) )
	      {
 			      event.returnValue=false;
    	  }
	  }
	  
	  return;
}
/* ÀÚµ¿ comma Ã³¸® END */
