function docWrite(msg) {
	document.write(msg);
}

function WriteEmbed(emb_id){ //IE7ÆÐÄ¡¿ë
    try{document.write(document.getElementById(emb_id).value);
	}catch(e){alert(emb_id+'¾ø½¿')}
}

function goURL(url) {
	location.href=url;
};


function chkDate_str(str) {
  var input = str.replace(/-/g,"");
  var inputYear = input.substr(0,4);
  var inputMonth = input.substr(4,2) - 1;
  var inputDate = input.substr(6,2);
  var resultDate = new Date(inputYear, inputMonth, inputDate);
  if ( resultDate.getFullYear() != inputYear ||
       resultDate.getMonth() != inputMonth ||
       resultDate.getDate() != inputDate) {
	  return ""	;
  }else {
	  return inputYear + "-" + input.substr(4,2) + "-" + inputDate;
  }
};


function chkDate(obj) { //³¯Â¥ ÀÔ·Â Á¤È®ÇÑ°¡ ÇÏ´Â °Í(20040601·ÎÀÔ·ÂÇÏ¸é 2004-06-01·ÎÇØÁÜ,onChange¿¡ÀÌ¿ëÇÒ°Í
  if (obj.value.length <8) { obj.value=""; return ;}

  var s=chkDate_str(obj.value)
  if (s=="") {
	obj.select();
	obj.focus();
	return false;
  } else {
    obj.value = s;
  }
}


function xxxchkDate(obj) { //³¯Â¥ ÀÔ·Â Á¤È®ÇÑ°¡ ÇÏ´Â °Í(20040601·ÎÀÔ·ÂÇÏ¸é 2004-06-01·ÎÇØÁÜ,onChange¿¡ÀÌ¿ëÇÒ°Í
  if (obj.value.length <8) { obj.value=""; return ;}

  var input = obj.value.replace(/-/g,"");
  var inputYear = input.substr(0,4);
  var inputMonth = input.substr(4,2) - 1;
  var inputDate = input.substr(6,2);
  var resultDate = new Date(inputYear, inputMonth, inputDate);
  if ( resultDate.getFullYear() != inputYear ||
       resultDate.getMonth() != inputMonth ||
       resultDate.getDate() != inputDate) {
    //obj.value = "";
//	alert('¿Ã¹Ù¸¥³¯Â¥°¡ ¾Æ´Õ´Ï´Ù');
	obj.select();
	obj.focus();
	return false;
  } else {
    obj.value = inputYear + "-" + input.substr(4,2) + "-" + inputDate;
  }
}



function number_comma(numstr) { //¼¼ÀÚ¸®¸¶´Ù ÄÞ¸¶
  var numstr = String(numstr);
  var re0 = /(\d+)(\d{3})($|\..*)/;
  if (re0.test(numstr))
    return numstr.replace(
      re0,
      function(str,p1,p2,p3) { return number_comma(p1) + "," + p2 + p3; }
    );
  else
    return numstr;
}


function getSelectedText(sel) { //select ¼±ÅÃµÈ ÅØ½ºÆ®
   return sel.options[sel.selectedIndex].text;
}

function openCal(obj) { //´Þ·Â¿­±â
  var top=event.screenY
	  if (top+185>= screen.availheight) top=screen.availheight-185
  var left=event.screenX;
  window.showModalDialog("../util/calendar_modal.htm", obj,
    "dialogWidth=190px;dialogHeight=195px;dialogTop:"+top+"px; dialogLeft:"+left+"px;resizable=yes;status=no;scroll=no;center;no;help:no");
}

function show_modal(htm,arglist,w,h,re){ //dhtmlÀ» ÀÌ¿ëÇÑ Ã¢ 
	return window.showModalDialog(htm, arglist,
      "dialogWidth:"+w+"px;dialogHeight:"+h+"px;status:no;resizable:"+re+";help:no") ;
}


function modal_win_reload(src,w,h,re) { //°»½ÅµÇ¸é ´Ù½Ã¿­±â
	var a=0;
	a=modal_win(src,w,h,re);
//alert(a+'/'+(a!=0 && typeof(a)!="undefined"))
	if (a!=0 && typeof(a)!="undefined"){
		//return fn_winReloader(a)
		try	{window.returnValue=a}catch(e){} 
		fn_winReloader(a)
	} //else return false;
}

function fn_winReloader(returnV) { //
		try{
			var href2="";
			href2=location.href;
			if (g_orgHref>"") {href2=g_orgHref	} //Àü¿ªº¯¼öÀÖÀ¸¸é

			href=href2.replace( /tttmp=[0-9]*[&]*/,"")

			var s=href.substr(href.length-3,3) ;
			if (s=='asp') {s='?' }	
			else if (href.substr(href.length-1,1)!='&') { s='&' }
			else s='';

			if (href.indexOf('returnValue=')<0) { s=s+"returnValue="+returnV+"&"  }
			s=href+ s +"tttmp="+(new Date()).getTime();
//alert(href2+"\n"+href+'\n'+s)
			try { location.replace(s); } catch(e) {alert(e+'|'+s);location.reload(); }
			//location.replace(s)
			return true;
		}catch(e){alert(e); return false }
}

function fn_before(str,deli) {
	var i=str.indexOf(deli);
	if (i>=0) { return str.substring(0,i ) }
		else return str
}
function fn_after(str,deli) {
	var i=str.indexOf(deli);
	return str.substring(i+deli.length, str.length )
}


function modal_win(src,w,h,re){ //dhtmlÀ» ÀÌ¿ëÇÑ Ã¢ 
	return window.showModalDialog("../util/modal_win.asp", src,
      "dialogWidth:"+w+"px;dialogHeight:"+h+"px;status:no;edge;raised;resizable:"+re+";help:no") ;
}

function modeless_win(src,w,h,re){ //dhtmlÀ» ÀÌ¿ëÇÑ Ã¢ 
	return window.showModelessDialog("../util/modeless_win.asp", src,
      "dialogWidth:"+w+"px;dialogHeight:"+h+"px;status:no;edge;raised;resizable:"+re+";help:no") ;
}

function alert_modal(msg){
	show_modal("../util/alert_modal.htm",msg,400,150,"no") ;
}

function fn_confirm(msg) {
	return show_modal("../util/confirm_modal.htm?tmp="+(new Date()).getTime(),msg,400,150,"no") ;
}

function shorten(txt,n) { //ÁÙÀ» n±ÛÀÚ·Î ÁÙ¿©ÁÜ n
   return txt.substring(0, n-1)
}

function replaceSpecial(str) { // Æ¯¼ö ¹®ÀÚ Ã³¸®
	return str.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

function zipSrch() { //¿ìÆí¹øÈ£ È®ÀÎÃ¢ºÒ·¯ÁÜ (ºÎ¸£´ÂÂÊ¿¡zip1,zip2,addr1,addr2°¡ ÀÖ¾î¾ßÈû
	var url="zipserch.htm" ;
	newWindow(url,"¿ìÆí¹øÈ£°Ë»ö",450,500,"yes") ;
}

function modal_zipSrch_frq() { //ÀÚÁÖ¾²´Â¿ìÆí¹øÈ£
	var url="../util/zipserch_frq.asp?tmp=0" ;
	var a="";
	a=modal_win(url,550,400,"yes") ; //zip1=111||zip2=222||addr1=¼­¿ï ÀÌ·±½ÄÀ¸·Î¿È
	__zipSrch(a);
}

function modal_zipSrch() { //¿ìÆí¹øÈ£ È®ÀÎÃ¢ºÒ·¯ÁÜ (ºÎ¸£´ÂÂÊ¿¡zip1,zip2,addr1,addr2°¡ ÀÖ¾î¾ßÈû
	var url="../util/zipserch0.asp?tmp=0" ;
	var a="";
	a=modal_win(url,450,500,"yes") ; //zip1=111||zip2=222||addr1=¼­¿ï ÀÌ·±½ÄÀ¸·Î¿È
	__zipSrch(a);
}

function __zipSrch(a) {
    try
    {
	var ss=a.split("||");
    var zip1=ss[0].split("=")[1] ;
    var zip2=ss[1].split("=")[1] ;
	var add=ss[2].split("=")[1] ;
	document.all["zip1"].value=zip1;
	document.all["zip2"].value=zip2;
	document.all.addr1.value=add ;
	document.all.addr2.focus();
    }
    catch (e) {   }
}


function hideToggle(lay) {
	lay.style.display= (lay.style.display == 'none') ? 'block' : 'none'
}

function getTodayString() { //¿À´Ã³¯Â¥¸¦ ½ºÆ®¸²À¸·Î
	var d  = new Date() ;
	var yy = d.getFullYear();
	var mm = d.getMonth()+1;  mm = (mm<10) ? '0'+mm : mm;
	var dd = d.getDate();     dd = (dd<10) ? '0'+dd : dd;
	//return '' + yy + mm + dd;
	return yy +"-"+ mm +"-"+ dd;
}

function addDay(str,n) { //³¯Â¥¸¦ ÀÔ·Â¹Þ¾Æ ¿Ã¹Ù¸¥°¡ Ã¼Å©ÈÄ ´õÇØÁÜ
  if (str.length<8 ) return "" ;
  var input = str.replace(/-/g,"");
  var inputYear = input.substr(0,4);
  var inputMonth = input.substr(4,2) - 1;
  var inputDate = input.substr(6,2);
  var resultDate = new Date(inputYear, inputMonth, inputDate);

  if ( resultDate.getFullYear() != inputYear ||
       resultDate.getMonth() != inputMonth ||
       resultDate.getDate() != inputDate) {
    str = "";
  } else {
    //str = inputYear + "-" + input.substr(4,2) + "-" + inputDate;
    var d = new Date(inputYear, inputMonth, parseInt(inputDate,10)+n); //parseInt¿¡¼­ 10Áø¼öÇÊ¼ö
	var yy = d.getFullYear();
    var mm = d.getMonth()+1;  mm = (mm<10) ? '0'+mm : mm;
    var dd = d.getDate();     dd = (dd<10) ? '0'+dd : dd;
	//str= d.getFullYear() +"-"+ (d.getMonth()+1) +"-"+ d.getDate() 
	str = yy +"-"+ mm +"-"+ dd;
  }
  return str;
}
// alert(addDay("2003-12-20",20)) ;


function newWindow(mypage, myname, w, h,scroll) {  //°¡¿îµ¥ »õÃ¢À»
	var winl = (screen.width - w) / 2 -5; 
	var wint = (screen.height - h) / 2; 
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,status=yes' 
	win =window.open(mypage, myname, winprops) ;
//	alert(mypage+'/'+ myname);
//	win =window.open(mypage, myname, "") ;
	win.focus();  

    //win=window.showModalDialog(mypage,window, "dialogWidth:"+w+"px; dialogHeight:"+h+"px;status:no;help:no");
} 


function selRecover(sel,obj){  //selectÇÊµå,ÀÚ¹Ù¹è¿­º¯¼ö ¸¦ ¹Þ¾Æ-> select¸¦ »õ·Î°»½Å.¸¸µé¾îÁÜ
  sel.length=obj.length+1
  for (i=0;i<sel.length-1; i++) {
	sel.options[i+1].value=obj[i][0] ;
	sel.options[i+1].text= obj[i][1] ;
  }
  sel.selectedIndex=0;
}

function initSelect(sel,val) { //selectÁß¿¡¼­ ¼±ÅÃÇØÁÜ
  //if (val > 0) { //¼ýÀÚÀÌ°í 0º¸Å¸Å©¸é
 //	for (i=0; i< sel.length ; i++){
  for (i=0; i< sel.length ; i++){
		if (sel.options[i].value==val) sel.selectedIndex=i;
	  }
 // }
}


function setCookie (name, value, expires) {
  document.cookie = name + "=" + escape (value) + 
    ";path=/;expires=" + expires.toGMTString();
}

function getCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // ÄíÅ°°¡ ¼³Á¤µÇ¾î ÀÖ´Ù¸é
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // ÄíÅ°°¡ Á¸ÀçÇÏ¸é
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset)
      // ÄíÅ° °ªÀÇ ¸¶Áö¸· À§Ä¡ ÀÎµ¦½º ¹øÈ£ ¼³Á¤
      if (end == -1)
        end = document.cookie.length
      return unescape(document.cookie.substring(offset, end))
    }
  }
  return "";
}

