var _userAgent_ = navigator.userAgent;
var isIe6 = (/msie 6/i).test(_userAgent_);
var isIe9 = (/msie 9/i).test(_userAgent_);

document.write ("<script type='text/javascript' SRC='http://web.cs21.com/_Js/formcheck.js' charset='utf-8'></script>");


//document.write ("<script type='text/javascript' SRC='http://web.cs21.com/_Js/mobile.js' charset='utf-8'></script>");

function sprintf2(zero,text){

	len = zero.length;
	r_txt = zero + text;
	f_len = r_txt.length;
	s_len = f_len - len;
	r_txt = r_txt.slice(s_len,f_len);
	return r_txt;
}

function sprintf(format1, v) {
       var fmt0, s0;
       fmt0 = format1;

       if (typeof(v) == "number")
           return formatNumber(fmt0, v);

       s0 = "" + v;
       return format(fmt0, "" + s0);

       function spaces(cnt) {
           var count = Math.floor(cnt);
           var t = "";
           for (var i = 0; i < count; i++) {
               t += ' ';
           }
           return t;
       }

       function sharps(cnt) {
           var count = Math.floor(cnt);
           var t = "";
           for (var i = 0; i < count; i++) {
               t += '#';
           }
           return t;
       }

       function zeros(cnt) {
           var count = Math.floor(cnt);
           var t = "";
           for (var i = 0; i < count; i++) {
               t += '0';
           }
           return t;
       }

       function byteLength(s) {
           var n = 0;
           var c;
           for (var i = 0; i < s.length; i++) {
               c = s.charAt(i);
               if (c.charCodeAt(0) > 0xFF)
                   n += 2;
               else
                   n++;
           }
           return n;
       }


       function format(fmt, s) {
           var t = "";
           var NORMAL_STATE = 0;
           var PERCENT_STATE = 1;
           var L_STATE = 2;
           var WIDTH_DIGIT_STATE = 3;
           var POINT_DIGIT_STATE = 4;
           var state = NORMAL_STATE;
           var width = 0;
           var pwidth = 0;
           var blen = 0;
           var align = 'left';
           var pos = 0;
           var str = "";
           var a;
           for (var i = 0; i < fmt.length; i++) {
               a = fmt.charAt(i);
               switch (state) {
                   case NORMAL_STATE:
                       if (a != '%')
                           t += a;
                       else {
                           width = 0;
                           pwidth = 0;
                           align = 'left';
                           state = PERCENT_STATE;
                       }
                       break;
                   case PERCENT_STATE:
                       if (a == '%') {
                           t += a;
                           state = NORMAL_STATE;
                       }
                       else if (a == '+') {
                           align = 'right';
                           state = WIDTH_DIGIT_STATE;
                       }
                       else if (a == '-') {
                           align = 'left';
                           width = 0;
                           state = WIDTH_DIGIT_STATE;
                       }
                       else if (a == '@') {
                           align = 'center';
                           width = 0;
                           state = WIDTH_DIGIT_STATE;
                       }
                       else if (a >= '0' && a <= '9') {
                           alignRight = true;
                           width = a.charCodeAt(0) - '0'.charCodeAt(0);
                           state = WIDTH_DIGIT_STATE;
                      }
                      else if (a == '.') {
                          align = 'left';
                          width = 0;
                          pwidth = 0;
                          state = POINT_DIGIT_STATE;
                      }
                      else if (a == 's' || a == 'S') {
                          str = "" + s;
                          blen = byteLength(str);    //
                          if (width >= blen) {       //
                              if (align == 'right')
                                  t += spaces(width - blen) + str;
                              else if (align == 'left')
                                  t += str + spaces(width - blen);
                              else
                                  t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                          }
                          else
                              t += str;
                          state = NORMAL_STATE;
                      }
                      else {
                          t += a;
                          state = NORMAL_STATE;
                      }
                      break;
                  case WIDTH_DIGIT_STATE:
                      if (a == '.') {
                          pwidth = 0;
                          state = POINT_DIGIT_STATE;
                      }
                      else if (a >= '0' && a <= '9') {
                          width = 10*width + (a.charCodeAt(0) - '0'.charCodeAt(0));
                      }
                      else if (a == 's' || a == 'S') {
                          str = "" + s;
                          blen = byteLength(str);
                          if (width >= blen) {    //
                              if (align == 'right') {
                                  t += spaces(width - blen) + str;
                              }
                              else if (align == 'left')
                                  t += str + spaces(width - blen);
                              else
                                  t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                          }
                          else
                              t += str;
                          state = NORMAL_STATE;
                      }
                      else {
                          t += a;
                          state = NORMAL_STATE;
                      }
                      break;
               }
           }
           return t;
       }


   function formatNumber(fmt, d) {
       var t = "";
       var NORMAL_STATE = 0;
       var PERCENT_STATE = 1;
       var L_STATE = 2;
       var WIDTH_DIGIT_STATE = 3;
       var POINT_DIGIT_STATE = 4;
       var state = NORMAL_STATE;
       var width = 0;
       var pwidth = 0;
       var blen = 0;
       var align = 'left';
       var pos = 0;
       var str = "";
       var a;
       for (var i = 0; i < fmt.length; i++) {
           a = fmt.charAt(i);
           switch (state) {
               case NORMAL_STATE:
                  if (a != '%')
                      t += a;
                  else {
                      width = 0;
                      pwidth = 0;
                      align = 'left';
                      state = PERCENT_STATE;
                  }
                  break;
               case PERCENT_STATE:
                  if (a == '%') {
                      t += a;
                      state = NORMAL_STATE;
                  }
                  else if (a == '+') {
                      align = 'right';
                      state = WIDTH_DIGIT_STATE;
                  }
                  else if (a == '-') {
                      align = 'left';
                      width = 0;
                      state = WIDTH_DIGIT_STATE;
                  }
                  else if (a == '@') {
                      align = 'center';
                      width = 0;
                      state = WIDTH_DIGIT_STATE;
                  }
                  else if (a >= '0' && a <= '9') {
                      align = 'left';
                      width = a.charCodeAt(0) - '0'.charCodeAt(0);
                      state = WIDTH_DIGIT_STATE;
                  }
                  else if (a == '.') {
                      align = 'left';
                      width = 0;
                      pwidth = 0;
                      state = POINT_DIGIT_STATE;
                  }
                  else if (a == 'x' || a == 'X') {
                      str = "" + d.toString(16);
                      if (a == 'X')
                          str = str.toUpperCase();
                      t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'l' || a == 'L') {
                      state = L_STATE;
                  }
                  else if (a == 'o' || a == 'O') {
                      str = "" + d.toString(8);
                      t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'd' || a == 'u' || a == 'D' || a == 'U') {
                      str = "" + Math.round(d);
                      t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'e' || a == 'E') {
                      state = NORMAL_STATE;
                  }
                  else if (a == 'f' || a == 'g' || a == 'F' || a == 'G') {
                      str = "" + d;
                      blen = byteLength(str);   //
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else {
                      t += a;
                      state = NORMAL_STATE;
                  }
                  break;
               case L_STATE:
                  if (a == 'x' || a == 'X') {
                      str = "" + d.toString(16);
                      blen = byteLength(str);   //
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'd' || a == 'u' || a == 'D' || a == 'U') {
                      str = "" + Math.round(d);
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else {
                      t += a;
                      state = NORMAL_STATE;
                  }
                  break;
               case WIDTH_DIGIT_STATE:
                  if (a == '.') {
                      pwidth = 0;
                      state = POINT_DIGIT_STATE;
                  }
                  else if (a >= '0' && a <= '9') {
                      width = 10*width + (a.charCodeAt(0) - '0'.charCodeAt(0));
                  }
                  else if (a == 'd' || a == 'u' || a == 'D' || a == 'U') {
                      str = "" + Math.round(d);
                      if (a == 'D')
                          str = str.toUpperCase();
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'x' || a == 'X') {
                      str = "" + d.toString(16);
                      if (a == 'X')
                          str = str.toUpperCase();
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'o' || a == 'O') {
                      str = "" + d.toString(8);
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'l' || a == 'L') {
                      state = L_STATE;
                  }
                  else if (a == 'f' || a == 'g' || a == 'F' || a == 'G') {
                      str = "" + d.toFixed();
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else {
                      t += a;
                      state = NORMAL_STATE;
                  }
                  break;
               case POINT_DIGIT_STATE:
                  if (a >= '0' && a <= '9') {
                      pwidth = 10*pwidth + (a.charCodeAt(0) - '0'.charCodeAt(0));
                  }
                  else if (a == 'l' || a == 'L') {
                      state = L_STATE;
                  }
                  else if (a == 'e' || a == 'E') {
                      var str = d.toExponential(pwidth);
                      blen = byteLength(str);
                      if (width >= blen) {   // Fix a bug of 1.1
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'd' || a == 'u' || a == 'D' || a == 'U') {
                      str = "" + Math.round(d);
                      if (a == 'D')
                          str = str.toUpperCase();
                      blen = byteLength(str);
                      if (width >= blen) {    //
                          if (align == 'right')
                              t += spaces(width - blen) + str;
                          else if (align == 'left')
                              t += str + spaces(width - blen);
                          else
                              t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                      }
                      else
                          t += str;
                      state = NORMAL_STATE;
                  }
                  else if (a == 'f' || a == 'g' || a == 'F' || a == 'G') {
                      if (pwidth > 0) {
                          var str = d.toFixed(pwidth);
                          blen = byteLength(str);
                          if (width >= blen) {   // Fix a bug of 1.1
                              if (align == 'right')
                                  t += spaces(width - blen) + str;
                              else if (align == 'left')
                                  t += str + spaces(width - blen);
                              else
                                  t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                          }
                      }
                      else {
                          str = "" + Math.round(d);
                          blen = byteLength(str);
                          if (width >= blen) {    //
                              if (align == 'right')
                                  t += spaces(width - blen) + str;
                              else if (align == 'left')
                                  t += str + spaces(width - blen);
                              else
                                  t += spaces(Math.floor((width - blen)/2)) + str + spaces((width - blen) - Math.floor((width - blen)/2));
                          }
                      }
                      state = NORMAL_STATE;
                  }
                  else {
                      t += a;
                      state = NORMAL_STATE;
                  }
                  break;
           }
       }
           return t;
       }
}



/*함수모음 외 기본 js파일 링크 설정*/

//transparent
function printSWF(fn, w, h)
{
 var arg = arguments;
 var argc =  arguments.length;

 str   = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"width=\""+w+"\" height=\""+h+"\">";
 str += "        <param name=\"SRC\" value=\""+fn+"\">";
 str += "        <param name=\"wmode\" value=\"transparent\">";
 str += "        <param name=\"quality\" value=\"high\">";
 str += "  <param name=\"loop\" value=\"true\">";
 str += "  <param name=\"menu\" value=\"false\">";
 str += "        <embed src=\""+fn+"\" pluginspage=\"http://www.macromedia.com/shockwave/download/\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\" wmode=\"transparent\">";
 str += "        </embed> ";
 str += "</object>";

 document.write(str);
}



//전체선택
function check_all(obj1,obj2){
	$(obj2).attr("checked",obj1.checked);
}
function SelectAll(form) {
  var fm = form;
  var fme = fm.elements;

  var chkVal = fm.selectall.checked;

  for(i = 0; i < fme.length; i++) {
    if(fme[i].type == "checkbox" && fme[i].name == "chk[]" && fme[i].disabled == false) {
		fme[i].checked = chkVal;
	}
  }
}


//체크된 체크박스 확인
function chk_select(f,chk_name,num){
	
		if (typeof f!="object") var obj = document.getElementById(f);
		else var obj = f;
		
		var cnt=0;
		
		for(var i=0;i < obj.elements.length;i++) { 
			var currEl = obj.elements[i]; 
			if (currEl.getAttribute("type")  =="checkbox" && currEl.name==chk_name && currEl.checked==true ){
				cnt++;
			}
		}
		if (cnt<num) return false;
		else return true;

}
//선택된 값을 문자열로 연결
function make_select_list(frm_obj,select_name,split){
	var full_chk_list  ="";
	var split_str="";
	if (split=="") split=",";
	for(var i = 0;i < frm_obj.elements.length;i++) { 
			var currEl = frm_obj.elements[i]; 
			if (currEl.name==select_name && currEl.checked==true){
				full_chk_list = full_chk_list + split_str +currEl.value;
				split_str = split;
			}
	}
	return full_chk_list;
}

function initRollOverImg(){
$(".isRollOver").mouseover(function(){
	var obj = $("img",this);
	obj.attr("orgSrc",$(obj).attr("src"));
	if(!obj.attr("ovImg")){
		var fileExt = obj.attr("orgSrc").substr(obj.attr("orgSrc").lastIndexOf("."));
		obj.attr("ovImg", obj.attr("orgSrc").replace(fileExt,"_o"+fileExt));
	}
	$(obj).attr("src",obj.attr("ovImg"));
});
$(".isRollOver").mouseout(function(){
	var obj = $("img",this);
	$(obj).attr("src",obj.attr("orgSrc"));
});

}

function initTabMenu(){
	var tabObj = $("[isTab]");
	if(tabObj.length>0){
		for(i=0; i<tabObj.length;i++){
			if($(tabObj[i]).attr("initTab")>0) var initTab = $(tabObj[i]).attr("initTab");
			else var initTab = 1;
			setTabMenu(	$(tabObj[i]).attr("isTab"),initTab);
		}
	}
}
//탭메뉴 설정
function setTabMenu(tab_id,n){
		$("li[id^='" + tab_id + "_tab'] a").click(function(){
			var tabStr = $(this).attr("href");
			var n  = tabStr.replace("#"+tab_id + "_sub","");
			setTabContents(tab_id,n);
			return false;
		});	

		if(n>0) setTabContents(tab_id,n);
}

//탭메뉴 컨텐츠 활성
function setTabContents(tab_id,n){
	if(n==undefined || n<1) n = 1;
	
	//메뉴 활성
	$("[id^='" + tab_id + "_tab']:not(#"+tab_id+"_tab"+n+")").removeClass("over");
	$("#"+tab_id+"_tab"+n).addClass("over");

	//컨텐츠 활성
	$("[id^='" + tab_id + "_sub']:not(#"+tab_id+"_sub"+n+")").hide();
	$("#"+tab_id+"_sub"+n).show();

}

function setTab2(obj_id,num){

	var obj = document.getElementById(obj_id);
	var seq = 0;

	var tabs = Array();
	for (i=0; i<obj.childNodes.length; i++){
		if (obj.childNodes[i].tagName=="DL"){
			seq++;
			tabs[seq] = obj.childNodes[i];
		}
		
	}


	for (i=1; i<tabs.length; i++){
		var btnimg = document.getElementById(obj_id +"img_" + i);

		if (i==num){ 
			if (btnimg!=undefined) btnimg.src = $(btnimg).attr("ovImg");
			tabs[i].className="on"; 
		}
		else{
			if (btnimg!=undefined) btnimg.src = $(btnimg).attr("outImg");
			tabs[i].className="";
		}

	}
}


function file_size(num){
	var n = parseInt(num);
	var n1 = n;
	var u = "KB";
	
	 if (n < 1048576)	n1 =  n / 1024;
	 else if(n<1073741824) { n1 = n/1048576;  u = "MB"; }
	 else {n1 = n/1073741824 ; u = "GB";} 
	
	n1 = parseInt(n1 * 100)/100;
	return n1 + u;
}


function image_window(img)
{
	var _charset = "UTF-8";
	var imgsrc	= ($(img).attr("orgSrc"))? $(img).attr("orgSrc") : img.tmp_src;
	
	var w = img.tmp_width; 
	var h = img.tmp_height; 
	var winl = (screen.width-w)/2; 
	var wint = (screen.height-h)/3; 

	if (w >= screen.width) { 
		winl = 0; 
		h = (parseInt)(w * (h / w)); 
	} 

	if (h >= screen.height) { 
		wint = 0; 
		w = (parseInt)(h * (w / h)); 
	} 

	var js_url = "<script language='JavaScript1.2'> \n"; 
		js_url += "<!-- \n"; 
		js_url += "var ie=document.all; \n"; 
		js_url += "var nn6=document.getElementById&&!document.all; \n"; 
		js_url += "var isdrag=false; \n"; 
		js_url += "var x,y; \n"; 
		js_url += "var dobj; \n"; 
		js_url += "function movemouse(e) \n"; 
		js_url += "{ \n"; 
		js_url += "  if (isdrag) \n"; 
		js_url += "  { \n"; 
		js_url += "    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; \n"; 
		js_url += "    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y; \n"; 
		js_url += "    return false; \n"; 
		js_url += "  } \n"; 
		js_url += "} \n"; 
		js_url += "function selectmouse(e) \n"; 
		js_url += "{ \n"; 
		js_url += "  var fobj      = nn6 ? e.target : event.srcElement; \n"; 
		js_url += "  var topelement = nn6 ? 'HTML' : 'BODY'; \n"; 
		js_url += "  while (fobj.tagName != topelement && fobj.className != 'dragme') \n"; 
		js_url += "  { \n"; 
		js_url += "    fobj = nn6 ? fobj.parentNode : fobj.parentElement; \n"; 
		js_url += "  } \n"; 
		js_url += "  if (fobj.className=='dragme') \n"; 
		js_url += "  { \n"; 
		js_url += "    isdrag = true; \n"; 
		js_url += "    dobj = fobj; \n"; 
		js_url += "    tx = parseInt(dobj.style.left+0); \n"; 
		js_url += "    ty = parseInt(dobj.style.top+0); \n"; 
		js_url += "    x = nn6 ? e.clientX : event.clientX; \n"; 
		js_url += "    y = nn6 ? e.clientY : event.clientY; \n"; 
		js_url += "    document.onmousemove=movemouse; \n"; 
		js_url += "    return false; \n"; 
		js_url += "  } \n"; 
		js_url += "} \n"; 
		js_url += "document.onmousedown=selectmouse; \n"; 
		js_url += "document.onmouseup=new Function('isdrag=false'); \n"; 
		js_url += "//--> \n"; 
		js_url += "</"+"script> \n"; 

	var settings;

   // if (g4_is_gecko) {
   //     settings  ='width='+(w+10)+','; 
  //  } else {
		settings  ='width='+w+','; 
		settings +='height='+h+','; 
  //  }
	settings +='top='+wint+','; 
	settings +='left='+winl+','; 
	settings +='scrollbars=no,'; 
	settings +='resizable=yes,'; 
	settings +='status=no'; 


	win=window.open("","image_window",settings); 
	win.document.open(); 
	win.document.write ("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset="+_charset+"'>\n"); 
	var size = "이미지 사이즈 : "+w+" x "+h;
	win.document.write ("<title>"+size+"</title> \n"); 
	if(w >= screen.width || h >= screen.height) { 
		win.document.write (js_url); 
		var click = "ondblclick='window.close();' style='cursor:move' title=' "+size+" \n\n 이미지 사이즈가 화면보다 큽니다. \n 왼쪽 버튼을 클릭한 후 마우스를 움직여서 보세요. \n\n 더블 클릭하면 닫혀요. '"; 
	} 
	else 
		var click = "onclick='window.close();' style='cursor:pointer' title=' "+size+" \n\n 클릭하면 닫혀요. '"; 
	win.document.write ("<style>.dragme{position:relative;}</style> \n"); 
	win.document.write ("</head> \n\n"); 
	win.document.write ("<body leftmargin=0 topmargin=0 bgcolor=#dddddd style='cursor:arrow;'> \n"); 
	win.document.write ("<table width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=middle><img src='"+imgsrc+"' width='"+w+"' height='"+h+"' border=0 class='dragme' "+click+"></td></tr></table>");
	win.document.write ("</body></html>"); 
	win.document.close(); 

	if(parseInt(navigator.appVersion) >= 4){win.window.focus();} 

}

function img_resize(obj,w){

	for (i=0; i<obj.length;i++){
		if (parseInt($(obj[i]).width()) > w){
			$(obj[i]).width(w);
		}		
	}
}

function contBoxView(id,type){
	$("." + id + "_sub").hide();
	$("#" + id + type+ "_sub").show();

}
//이메일 주소 선택
function email_domain(email_domain,value){
	var f_obj = document.getElementById(email_domain);
	f_obj.value=value;
	if(value=="") f_obj.style.display="";
	else f_obj.style.display="none";
}


//쿠키////////////////////////////////////////////////
function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function setCookie( name, value, expiredays ){ 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" +		todayDate.toGMTString() + ";" 
}

///////////////////////////////////////////////////////////

//레이어팝업
function popHide(pop_id){
	if (document.getElementById("chk"+pop_id).checked==true)
	{
		setCookie( pop_id, "done" , 24); 
	}
	document.getElementById(pop_id).style.display = "none";
}
function popClose(pop_id){
	if (document.getElementById("chk"+pop_id).checked==true)
	{
		setCookie( pop_id, "done" , 1); 
	}
	this.close();
}

function checkPop(pop_id) {
	if ( getCookie(pop_id) != "done" ) {
		document.getElementById(pop_id).style.display = "";
	}else{
		document.getElementById(pop_id).style.display = "none";
	}
}

function goUrlClose(u){
	if(window.opener){
		opener.document.location=u;
	}else{
		window.open(u);	
	}
	window.close();
}
///////////////////////////////////////////////////////////

/*레이어팝업 */
var msgPopupWin;
if (msgPopupWin == undefined) {
	msgPopupWin = function (settings) {

		this.init(settings);
	};
}
msgPopupWin.prototype.init = function (settings) {


	var this_s = this;
	var msg_wrap = document.createElement("div");
	msg_wrap.className="pop_windoc";
	
	var msg_pan = document.createElement("div");
	msg_pan.className = "pop_windoc_bg";
	$(msg_wrap).append(msg_pan);
	$("body").prepend(msg_wrap);
	
	this.backPannel = msg_pan;
	this.backPannel.onclick=function(){
		$(this.parentNode).remove();
	}

	var msg_body = document.createElement("div");
	msg_body.className="pop_windoc_box";
	
	//$(msg_body).draggable({ handle: 'div.pop_winTop',scroll: true,helper: 'original'});
	//$("div").disableSelection();

	if(settings.w!=undefined) msg_body.style.width =settings.w ;
	if(settings.h!=undefined) msg_body.style.height =settings.h ;
	
	$(msg_wrap).append(msg_body);
	setCenterPos(msg_wrap,msg_body);
	this.title = "";

	if(settings.title)  this.title = settings.title;
	if(settings.setStyle){

		var winDocWrap = document.createElement("div");
		var winDocTop = document.createElement("div");

		$(winDocWrap).addClass("pop_winWrap");
		$(winDocTop).addClass("pop_winTop");
		$(winDocTop).css("cursor","move");
		$(winDocTop).append("<span class='pop_title'>"+this.title+"</span>");

		var winCloseBtn = document.createElement("span");
		$(winCloseBtn).addClass("pop_close");
		$(winCloseBtn).css("cursor","pointer");
		$(winCloseBtn).html("<img src='http://web.cs21.com/_Img/Common/sbtn_close.gif'http://web.cs21.com/>");
		$(winCloseBtn).click(function(){this_s.close();	});
		$(winDocTop).append(winCloseBtn);

		$(winDocWrap).append(winDocTop);
		$(winDocWrap).append("<div class='pop_winBody'><div class='pop_body'></div></div>");
		//$(winDocWrap).append("<div class='pop_body'></div>");

		$(winDocWrap).append("<div class='pop_winFoot'></div>");

		$(msg_body).append($(winDocWrap));
		this.bodyPannel = $(".pop_winBody ",$(winDocWrap));
		//this.bodyPannel = $(".pop_body ",$(winDocWrap));
		
		var tmpTopH =$(winDocWrap).height() -  ($(winDocTop).height() + $(".pop_winFoot",winDocWrap).height());
		var tmpTopW =$(winDocWrap).width() -  20;
		$(".pop_winBody ",$(winDocWrap)).height(tmpTopH-10);
		//$(".pop_body ",$(winDocWrap)).height(tmpTopH-10);
		//
		//$($(this.bodyPannel)).width($(".pop_winBody").width()-20);
		//this.bodyPannel.height(tmpTopH-10);
		
	}else{
		this.bodyPannel = msg_body;
	}

	$(this.bodyPannel).append(settings.msgWinDoc);

	if(settings.closeBtns){
		for(var i=0; i<settings.closeBtns.length;i++){
			$(settings.closeBtns[i]).click(function(){this_s.close();	});
		}
	}
	this.settings = settings;
	this.obj = msg_wrap;
	this.setShow();
}

msgPopupWin.prototype.setContents = function(html){	$(this.bodyPannel).html(html); this.setCloseBtns();}
msgPopupWin.prototype.setContSize =  function(){$(".contents",this.bodyPannel).width($(this.bodyPannel).width()-20)}
msgPopupWin.prototype.addContents = function(html){	$(this.bodyPannel).append(html); this.setCloseBtns();}
msgPopupWin.prototype.setTitle = function(str){	this.title = str; $(".pop_title",$(this.obj)).html(str);}
msgPopupWin.prototype.setShow = function(){	$(this.obj).show();}
msgPopupWin.prototype.setHide = function(){	$(this.obj).hide();}
msgPopupWin.prototype.close = function(){	$(this.obj).remove();}
msgPopupWin.prototype.setCloseBtns = function(){
	var this_s = this;
	if(this.settings.closeBtns){
		for(var i=0; i<this.settings.closeBtns.length;i++){
			$(this.settings.closeBtns[i]).click(function(){this_s.close();	});
		}
	}
	$(".closeBtn",this_s.bodyPannel).click(function(){this_s.close();	});
	//this.setContSize();
}

/*
function setCenterPos(doc,obj){
	obj.style.left = ((doc.offsetWidth-obj.offsetWidth)/2)  + "px";
	var _top = ((doc.offsetHeight-obj.offsetHeight)/2);
	 _top =  (parseInt(_top)>0) ? _top : 0 ;
	obj.style.top =_top + "px";
}
*/



//메인 이미지 배너
function initBanner(banImgObj,num){

	banImgObj.style.filter="blendTrans(duration=1)";
	banImgObj.subItem = new Array();
	banImgObj.numObj = document.getElementById(banImgObj.id + "_num");
	banImgObj.numItem = new Array();
	banImgObj.len = 0;


	if (num==undefined || num<1)	banImgObj.seq = 1;
	else 	banImgObj.seq = num;

	for (i=1;i<= banImgObj.childNodes.length;i++){
		if ( banImgObj.childNodes[i-1].tagName != "LI") continue;
		banImgObj.len ++;
		banImgObj.subItem[banImgObj.len] = banImgObj.childNodes[i-1];

	}
	var tmp_n =0;
	for (i=1;i<= banImgObj.numObj.childNodes.length;i++){
		if ( banImgObj.numObj.childNodes[i-1].tagName != "LI") continue;
		tmp_n++;
		banImgObj.numItem[tmp_n] = banImgObj.numObj.childNodes[i-1];
		banImgObj.numObj.childNodes[i-1].parentObj = banImgObj;
		banImgObj.numObj.childNodes[i-1].seq = tmp_n;
		banImgObj.numItem[tmp_n].childNodes.item(0).onmouseover = banImgObj.numItem[tmp_n].childNodes.item(0).onfocus = function () {
			this.parentNode.parentObj.seq = this.parentNode.seq;
			setBanner (this.parentNode.parentObj);

		}
	}

}

/*팝업존 등 배터 */
function setBanner(obj,num,fun){

	clearTimeout(obj.Timer);
	if (num!=undefined)	obj.seq = num;

	if (obj.seq > obj.len) {
		obj.seq = 1;
	}
	if(obj.filters!=undefined) 		obj.filters.blendTrans.apply();
	//alert(obj.instName+":"+obj.len)
	for (i=1; i<=obj.len; i++){
		if (obj.seq ==i){
			obj.subItem[i].style.display="";
			obj.numItem[i].childNodes.item(0).className = obj.numItem[i].childNodes.item(0).className.replace(" out "," over ");
		}else{
			obj.numItem[i].childNodes.item(0).className =obj.numItem[i].childNodes.item(0).className.replace(" over "," out ");
			obj.subItem[i].style.display="none";
		}
	}
	
	if(obj.filters!=undefined) 		obj.filters.blendTrans.play();

	var tmp_n = obj.seq+1;
	if (tmp_n > obj.len ) {		
		obj.Timer = setTimeout(obj.instName + ".setNextBanImgs()",3000);
	}else{
		obj.Timer = setTimeout("setBanner(document.getElementById('"+obj.id+"'),"+tmp_n+")",3000);
	}
}


function setCenterPos(doc,obj){
	obj.style.left = ((doc.offsetWidth-obj.offsetWidth)/2)  + "px";
	obj.style.top = ((doc.offsetHeight-obj.offsetHeight)/2)  + "px";

}
function getCenterPos(doc,obj){
	return {"left":((doc.offsetWidth-obj.offsetWidth)/2),"top":((doc.offsetHeight-obj.offsetHeight)/2) };

}

//PNG 이미지출력
function setPng24(obj) { 

  obj.width=obj.height=1; 
  //obj.style.visibility="hidden";
  obj.className=obj.className.replace(/\bpng24\b/i,''); 
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
  obj.src=''; 
 
  return ''; 
}

//새창열기
function openWindow(href,w,h,title){ window.open(href,'','width='+w+',height='+h+",scrollbars=yes");}

//창크기로 화면 중앙 좌표 구하기
function getWinCenter(w,h){

	var top = parseInt((screen.availHeight)/2-h/2); 
	var left = parseInt((screen.availWidth)/2-w/2); 
	var obj = {"top":top,"left":left};
	return obj;
}

function openIframeLayer(url,width,height,page_title){
	frmWin = new msgPopupWin({w:width+"px",h:height+"px",setStyle:true,title:page_title});
	frmWin.setContents("<iframe width=100% height=100% frameborder=0 src='"+url+"'></iframe>");

}
function openLayerPage(url,width,height,page_title){
	frmWin = new msgPopupWin({w:width+"px",h:height+"px",setStyle:true,title:page_title});
	$(frmWin.bodyPannel).load(url,function (){frmWin.setCloseBtns();});
}



function OpenZipSearch(zip_id,addr1_id,addr2_id){
	window.open("/zipsearch.php?zip_id="+ zip_id +"&addr1_id=" + addr1_id + "&addr2_id=" + addr2_id,"winZip", "left=50,top=50,width=400,height=350,scrollbars=1");
}


function editorSet(){
	if (editor_type=="SmartEditor")
	{
		for (i=0; i<oEditors.length;i++){
			oEditors[i].exec("UPDATE_IR_FIELD", []);
		}
	}
}


function in_array(arr,str){
	for ( var i=0;i<arr.length;i++ )
	{
		if(arr[i]==str) return true;
	}
	return false;
}


function min_height(obj,h){
	if (obj.readyState!="complete") return "auto";
	if (obj.offsetHeight<h)
	{
		obj.style.height=h + "px";
	}
}

function min_width(obj,w){
	if (obj.readyState!="complete") return "auto";
	if (obj.offsetWidth<w)
	{
		obj.style.width=x + "px";
	}
}


function setDisableLayer(objid,val){
	var obj1 = $("#"+objid+"_box");
	var obj2 = $("#"+objid+"_layer");

	if(val){
		obj2.hide();
		
	}else{
		obj2.show();
		
		$(obj2).width(obj1.width());
		$(obj2).height(obj1.height());
	}
}


function setIframeSize(obj,w,h){
		$("#" +obj).width(w).height(h);
}


