    var useragent = navigator.userAgent;

    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_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_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 ChkInput(Object,Name) {
    	if (typeof(Object)!="undefined") {
    		if(Object.value=="") {
    			alert(Name);
    			eval(Object.focus());
    			return false;
    		}
    	}
    }


    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }

	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='/HFR/images/common/blank.gif';
		return '';
	}

    function show(object) {
     if(document.getElementById(object).style.display == "none") {
      document.getElementById(object).style.display = "block";
     } else {
      document.getElementById(object).style.display = "none";
     }
    }

	function bluring(){
		if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	}
	document.onfocusin=bluring;


	var persistmenu="yes"
	var persisttype="sitewide"

	if (document.getElementById){
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('</style>\n')
	}

	function SwitchMenu(obj){
		if(document.getElementById){
		var el = document.getElementById(obj);
		var ar = document.getElementById("masterdiv").getElementsByTagName("span");
			if(el.style.display != "block"){
				for (var i=0; i<ar.length; i++){
					if (ar[i].className=="submenu")
					ar[i].style.display = "none";
				}
				el.style.display = "block";
			}else{
				el.style.display = "none";
			}
		}
	}

	function get_cookie(Name) {
		var search = Name + "="
		var returnvalue = "";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset);
		if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
	}

	function onloadfunction(){
		if (persistmenu=="yes"){
		var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
		var cookievalue=get_cookie(cookiename)
		if (cookievalue!="")
			document.getElementById(cookievalue).style.display="block"
		}
	}

	function savemenustate(){
		var inc=1, blockid=""
		while (document.getElementById("sub"+inc)){
		if (document.getElementById("sub"+inc).style.display=="block"){
			blockid="sub"+inc
		break
		}
		inc++
	}
		var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
		var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
		document.cookie=cookiename+"="+cookievalue
	}

	if (window.addEventListener)
		window.addEventListener("load", onloadfunction, false)
	else if (window.attachEvent)
		window.attachEvent("onload", onloadfunction)
	else if (document.getElementById)
		window.onload=onloadfunction

	if (persistmenu=="yes" && document.getElementById)
	window.onunload=savemenustate


  /*=========================================================
	function Name : assert_msglen
	Description   : ÅØ½ºÆ®ÀÚ¸®¼ö¸¦ maximum Å©±â¸¸Å­ ¹ÝÈ¯ÇÑ´Ù.
	Parameter     : phone - Æù¹øÈ£
	Write  Date   : 2008.03.18
	Modify Date   :
	=========================================================*/
	function assert_msglen(message, maximum) {
		var inc = 0;
		var nbytes = 0;
		var msg = "";
		var msglen = message.length;

		for (i=0; i<msglen; i++) {
			var ch = message.charAt(i);
			if (escape(ch).length > 4) {
				inc = 2;
			}
			else {
				inc = 1;
			}

			if ((nbytes + inc) > maximum) {
				break;
			}
			nbytes += inc;
			msg += ch;
		}
		return msg;
	}


	// ±ÛÀÚ¼ö Ã¼Å©
	function textCounter(field, maxlimit){
		var nCnt;
		nCnt = getStrLength(field.value)

		if (nCnt > maxlimit) {
			alert('Á¦ÇÑµÈ ±ÛÀÚ¼ö '+(maxlimit/2)+'ÀÚ¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù.');
			field.value = assert_msglen(field.value, maxlimit);
			field.focus();
		}
		else {
			//document.all.textlimit1.innerText = nCnt
		}
	}

	function textCounter2(field, maxlimit){
		var nCnt;
		nCnt = getStrLength(field.value)

		if (nCnt > maxlimit) {
			alert('Á¦ÇÑµÈ ¿¬¶ôÃ³ '+(maxlimit)+'ÀÚ¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù.');
			field.value = assert_msglen(field.value, maxlimit);
			field.focus();
		}
		else {
			//document.all.textlimit1.innerText = nCnt
		}
	}


	/*=========================================================
	function Name : getStrLength
	Description   : ¹®ÀÚ¿­¿¡¼­ ÇÑ±ÛÀÇ ±æÀÌ¸¦ 2¹ÙÀÌÆ®·Î °è»êÇØ¼­ ¹®ÀÚ¿­ÀÇ ±æÀÌ¸¦ ±¸ÇÏ´Â ÇÔ¼ö
					½ÇÁ¦·Î´Â ÇÑ±ÛÀÇ ±æÀÌ¸¸ 2¹ÙÀÌÆ®·Î °è»êÇÏ´Â °ÍÀÌ¾Æ´Ï¶ó,
					ISO Latin-1(0~255)¿¡ ÀÖ´Â ¹®ÀÚ¸¦ Á¦¿ÜÇÑ À¯´ÏÄÚµåÀÇ ¸ðµç ¹®ÀÚ¸¦ 2·Î °è»êÇÑ´Ù.
	Parameter     : str:´ë»óÀÌµÇ´Â ¹®ÀÚ¿­
	Write  Date   : 2008.03.18
	Modify Date   :
	=========================================================*/
	function getStrLength(str){
		len = 0;

		for(i=0;i<str.length;i++){
			if(str.charCodeAt(i) < 256)
				len++;
			else
				len = len+2;
		}


		return len;
	}


	/*=========================================================
	function Name : isTelNum
	Description   : ÀüÈ­¹øÈ£ Çü½ÄÀÎÁö Ã¼Å©
	Parameter     : isTelNum - ÀüÈ­¹øÈ£
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function isTelNum(tel){
		flag = true;	// ¼º°ø
		head = tel.substr(0, 3);
		tel = delNum(tel);

		if(isNumber(tel)==-1 || tel.length > 11 || tel.length < 10){
			flag = false;	// ½ÇÆÐ
		}
		else if (head!="011" && head!="016" && head!="017" && head!="018" && head!="019" && head!="010"){
			flag = false;	// ½ÇÆÐ
		}

		return flag;
	}

	/*=========================================================
	function Name : delNum
	Description   : ÀüÈ­¹øÈ£ÀÇ Áß°£¹øÈ£ÀÇ 0À» »©ÁØ´Ù
	Parameter     : phone - Æù¹øÈ£
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function delNum(phone){
		retValue = "";

		if(phone.length == 11 && phone.substr(3, 1) == "0"){
			retValue = phone.substr(0, 3) + parseInt(phone.substr(4, 3)) + phone.substr(7, 4);
		}
		else{
			retValue = phone;
		}
		return retValue;
	}


	/*=========================================================
	function Name : isNumber
	Description   : ¹®ÀÚ¿­ ÀüÃ¼°¡ ¼ýÀÚÀÎÁö Ã¼Å©
	Parameter     : num - ¹®ÀÚ¿­
	Write  Date   : 2008.03.18
	Modify Date   :
	=========================================================*/
	function isNumber(num){
		for(i=0; i<num.length; i++){
			if(isDigit(num.charAt(i)) == -1){
				return -1;
			}
		}

		return num;
	}


	/*=========================================================
	function Name : isDigit
	Description   : 1°³ÀÇ ¹®ÀÚ°¡ ¼ýÀÚÀÎÁö Ã¼Å©
	Parameter     : digit - 1°³ÀÇ ¹®ÀÚ
	Write  Date   : 2008.03.18
	Modify Date   :
	=========================================================*/
	function isDigit(digit){
		if(parseInt(digit) || parseInt(digit)==0){
			return digit;
		}
		else{
			return -1;
		}
	}


	/*=========================================================
	function Name : fcOnKeyPress
	Description   : ÀÔ·Â ¹®ÀÚ¿­ÀÌ ¼ýÀÚÇüÀÎÁö Ã¼Å©
	Parameter     : div - ¼ýÀÚ
	Write  Date   : 2008.03.18
	Modify Date   :
	=========================================================*/
	function fcOnKeyPress( div ){
		var sKeyCode = escape(event.keyCode);

		if( div == "phone" ){
			if ( sKeyCode != 13 && (( sKeyCode >= 112 && sKeyCode <= 123 ) || sKeyCode < 48 || sKeyCode >= 58))
				event.returnValue = false;
		}
		else{
			if ( sKeyCode != 13 && (( sKeyCode >= 32 && sKeyCode <= 47 ) ||( sKeyCode >= 58 && sKeyCode <= 64 ) || ( sKeyCode >= 91 && sKeyCode <= 96 ) || ( sKeyCode >= 123 && sKeyCode <= 127 )))
				event.returnValue = false;
		}
	}

	/*=========================================================
	function Name : chkRadio
	Description   : ¶óµð¿À¹öÆ° ÀÔ·ÂÃ¼Å©
	Parameter     : document.form.name
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function chkRadio(obj){
		var j=0;
		var zz= obj.length;
		for(i=0;i<zz;i++){
			if(obj[i].checked==true){
				j=j+1;
			}
		}
		return j;
	}

	/*=========================================================
	function Name : chkEmail
	Description   : ÀÔ·Â ¹®ÀÚ¿­ Ã¼Å©
	Parameter     : ¹®ÀÚ¿­
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function chkEmail(str){
		var ck="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-";
		//var ck="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-@";
		var j=0;
		for(i=0; i<str.length; i++){
			km=str.charAt(i);
			if(ck.indexOf(km)==-1){
				j=j+1;
			}else{
				j=j+0;
			}
		}
		return j;
	}

	/*=========================================================
	function Name : chkPhone
	Description   : ÀÔ·Â ¼ýÀÚ Ã¼Å©
	Parameter     : div - ¼ýÀÚ
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function chkPhone(str){
		var ck="0123456789-.";
		var j=0;
		for(i=0; i<str.length; i++){
			km=str.charAt(i);
			if(ck.indexOf(km)==-1){
				j=j+1;
			}else{
				j=j+0;
			}
		}
		return j;
	}

	/*=========================================================
	function Name : chkNum
	Description   : ÀÔ·Â ¼ýÀÚÇüÀÎÁö Ã¼Å©
	Parameter     : div - ¼ýÀÚ
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
	function chkNum(str){
		var ck="0123456789";
		var j=0;
		for(i=0; i<str.length; i++){
			km=str.charAt(i);
			if(ck.indexOf(km)==-1){
				j=j+1;
			}else{
				j=j+0;
			}
		}
		return j;
	}
  
  function Limit(obj) {
    var maxLength = parseInt(obj.getAttribute("maxlength"));
    if ( obj.value.length > maxLength ) {
     //alert(obj.value.length);
     obj.value = assert_msglen(obj.value, maxLength);
    }
   }


	/*=========================================================
	function Name : ShowProgress
	Description   : ¾÷·Îµå ÁøÇà Bar
	Parameter     : div - ¼ýÀÚ
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
    function ShowProgress() {
			strAppVersion = navigator.appVersion;

			if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) {
				winstyle = "dialogWidth=400px; dialogHeight:200px; center:yes";
				window.showModelessDialog("/INCLUDE/COMMON/progress.asp?Progressid=<%=ProgID%>",null,winstyle);
			}
			else {
				winpos = "left=" + ((window.screen.width-380)/2) + ",top=" + ((window.screen.height-110)/2);
				winstyle="width=400,height=200,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,copyhistory=no," + winpos;
				window.open("/INCLUDE/COMMON/progress.asp?Progressid=<%=ProgID%>","_blank",winstyle);
			}

		return true;
	}


  /*=========================================================
	function Name : fileCheck
	Description   : ÆÄÀÏ ¾÷·Îµå À¯È¿¼º Ã¼Å©
	Parameter     : fGbn - ÆÄÀÏ±¸ºÐ , fObj - ¿ÀÇÁÁ§Æ®
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
  var fileFlag = true;
  function fileCheck(fGbn, fObj) {

      var ck = ".." ;
      if(fObj.value.indexOf(ck) > 2) {
        alert("ÆÄÀÏ¸íÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");

        fileFlag = false;
        return false;
      }

      if(fGbn == "IMG") {
          if(fImgFormat.indexOf(getExtName(fObj.value)) == -1) {
            alert(fImgFormat + " ÆÄÀÏ¸¸ µî·ÏÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù..");

            fObj.select();
            //document.selection.clear();
            //fObj.focus();

            fileFlag = false;
            return false;
          }
          else {
            fileFlag = true;
          }
      }
      else if(fGbn == "VOD") {
          if(fVodFormat.indexOf(getExtName(fObj.value)) == -1) {
            alert(fVodFormat + " ÆÄÀÏ¸¸ µî·ÏÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");

            //document.selection.clear();
            //fObj.focus();

            fileFlag = false;
            return false;
          }
          else {
            fileFlag = true;
          }
      }
      else if(fGbn == "ETC") {
          if(fEtcFormat.indexOf(getExtName(fObj.value)) == -1) {
            alert(fEtcFormat + " ÆÄÀÏ¸¸ µî·ÏÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");

            //document.selection.clear();
            //fObj.focus();

            fileFlag = false;
            return false;
          }
          else {
            fileFlag = true;
          }
      }
  }
  /*=========================================================
	function Name : getExtName
	Description   : È®ÀåÀÚ¸í ÃßÃâ
	Parameter     : fname - ÆÄÀÏ¸í
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
  function getExtName(fname) {

    var m = fname.lastIndexOf(".");
    var e = fname.length;
    var extName = fname.substring(m+1,e);

    return extName.toUpperCase();
  }

  /*=========================================================
	function Name : goToUrl
	Description   : ÆäÀÌÁö ÀÌµ¿
	Parameter     : sGubun - ÆË¾÷±¸ºÐ, sUrl - ÀÌµ¿ÇÒ ÆäÀÌÁö Url
	Write  Date   : 2010.04.08
	Modify Date   :
	=========================================================*/
    function goToUrl(sGubun, sUrl) {

        if(sGubun == "P") {
            opener.document.location.href = sUrl;
            self.close();
        } else {
            return;
        }
    }

    function FileDownload(str1, str2, str3) {

      var sUrl;
      var w = 600;
      var h = 400;

      /*if(fImgFormat.indexOf(getExtName(str3)) == -1) {
        w = 400;
        h = 200;
      }*/
      sUrl = "/INCLUDE/COMMON/DOWNLOAD.ASP?sFilePath="+str2+"&sFileName="+str3;

      if(str1 == "DOWN"){
		   location.href = sUrl;
			
          //window.open(sUrl,'down_win','scrollbars=yes,width='+w+',height='+h+',top=300,left=300');
        } else {
	      window.open(sUrl,'','scrollbars=yes,width=860,height=620,top=0,left=0');
      }
    }
    
    function detailView(sPath, type) {
      var fm = document.imgfrm;
      window.open("", 'w_detail', 'width=620, height=600, top=100, left=100, resizable=1, scrollbars=1, toolbar=0, location=0, directories=0, menubar=0, status=1');

      fm.imgFilePath.value = sPath;
      fm.action = "/HTML/POPUP/POPUP_DetailView.ASP";
      fm.target = "w_detail";
      fm.submit();
    }
    
    function vodWin(sPath) {
      var fm = document.vodfrm;
      window.open("", 'w_vodplay', 'width=620, height=454, top=100, left=100, resizable=0, scrollbars=1, toolbar=0, location=0, directories=0, menubar=0, status=1');

      fm.vodFilePath.value = sPath;
      fm.action = "/HTML/POPUP/POPUP_VODPLAY.ASP";
      fm.target = "w_vodplay";
      fm.submit();
    }

    function vodPlay(sGubun, sPath) {

        var sUrl = "/Upload/"+sPath;
        var sWidth = 620;
        var sHeight = 454;

        vodObj  ="<object style='filter: gray()' id='mpp' name='mpp' width='"+sWidth+"' height='"+sHeight+"' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'>"
                + "  <param name='URL'                value='"+sUrl+"'>                                                                                           "
                + "  <param name='rate'               value='1'>                                                                                                  "
                + "  <param name='balance'            value='0'>                                                                                                  "
                + "  <param name='currentPosition'    value='0'>                                                                                                  "
                + "  <param name='defaultFrame'       value>                                                                                                      "
                + "  <param name='playCount'          value='1'>                                                                                                  "
                + "  <param name='autoStart'          value='1'>                                                                                                  "
                + "  <param name='currentMarker'      value='0'>                                                                                                  "
                + "  <param name='invokeURLs'         value='-1'>                                                                                                 "
                + "  <param name='baseURL'            value>                                                                                                      "
                + "  <param name='volume'             value='100'>                                                                                                "
                + "  <param name='mute'               value='0'>                                                                                                  "
                + "  <param name='uiMode'             value='full'>                                                                                               "
                + "  <param name='stretchToFit'       value='0'>                                                                                                  "
                + "  <param name='windowlessVideo'    value='0'>                                                                                                  "
                + "  <param name='enabled'            value='-1'>                                                                                                 "
                + "  <param name='enableContextMenu'  value='0'>                                                                                                  "
                + "  <param name='fullScreen'         value='0'>                                                                                                  "
                + "  <param name='SAMIStyle'          value>                                                                                                      "
                + "  <param name='SAMILang'           value>                                                                                                      "
                + "  <param name='SAMIFilename'       value>                                                                                                      "
                + "  <param name='captioningID'       value>                                                                                                      "
                + "  <param name='enableErrorDialogs' value='0'>                                                                                                  "
                + "  <param name='_cx'                value='6350'>                                                                                               "
                + "  <param name='_cy'                value='1191'>                                                                                               "
                + "</object>                                                                                                                                      ";
        document.write(vodObj);
    }

    function vodPlay2(sGubun, sPath) {

        var sUrl = "/Upload/"+sPath;
        var sWidth = 620;
        var sHeight = 454;
        
        vodObj  ="<object style='filter: gray()' id='mpp' name='mpp' width='"+sWidth+"' height='"+sHeight+"'>"
                + "  <param name='movie'              value='"+sUrl+"'>                                                                                           "
                + "  <param name='allowFullScreen'    value='true'>                                                                                               "
                + "  <param name='allowscriptaccess'  value='true'>                                                                                               "
                + "  <embed src='"+sUrl+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='500' height='405'></embed>"
                + "</object>                                                                                                                                      ";
        document.write(vodObj);
    }
    
    function hideStatus() {
      window.status = "";
      return true;
    }
    
    
/********************************************
 function Name : resize_img
 Description   : ÀÌ¹ÌÁö Á¤ÇØÁø »çÀÌÁî´ë·Î ¸®»çÀÌÁî
 Parameter     : maxWidth , maxHeight , img_url
 Write  Date   : 2010.05.01
 Modify Date   :
 writer		   : ÃÖ´ë¸®
*********************************************/
	
function resize_img(img_width,img_height,img_url){
	var img = new Image();
	img = img_url;
  // ¿øº» ÀÌ¹ÌÁö »çÀÌÁî ÀúÀå
   var width = img.width;
   var height = img.height;

   // °¡·Î, ¼¼·Î ÃÖ´ë »çÀÌÁî ¼³Á¤
   var maxWidth = img_width;   
   var maxHeight = img_height;   

   // °¡·Î³ª ¼¼·ÎÀÇ ±æÀÌ°¡ ÃÖ´ë »çÀÌÁîº¸´Ù Å©¸é ½ÇÇà  
   if(width > maxWidth || height > maxHeight){
      // °¡·Î°¡ ¼¼·Îº¸´Ù Å©¸é °¡·Î´Â ÃÖ´ë»çÀÌÁî·Î, ¼¼·Î´Â ºñÀ² ¸ÂÃç ¸®»çÀÌÁî
      if(width > height){
         resizeWidth = maxWidth;
         resizeHeight = Math.round((height * resizeWidth) / width,1);
      // ¼¼·Î°¡ °¡·Îº¸´Ù Å©¸é ¼¼·Î´Â ÃÖ´ë»çÀÌÁî·Î, °¡·Î´Â ºñÀ² ¸ÂÃç ¸®»çÀÌÁî
      }else{
         resizeHeight = maxHeight;
         resizeWidth = Math.round((width * resizeHeight) / height,1);
      }
   // ÃÖ´ë»çÀÌÁîº¸´Ù ÀÛÀ¸¸é ¿øº» ±×´ë·Î
   }else{
      resizeWidth = width;
      resizeHeight = height;
   }
  // ¸®»çÀÌÁîÇÑ Å©±â·Î ÀÌ¹ÌÁö Å©±â ´Ù½Ã ÁöÁ¤
   img.width = resizeWidth;
   img.height = resizeHeight;
}

/********************************************
 function Name : check_login
 Description   : ´Ü¼ø Äí±â °ªÀ¸·Î Ã¼Å© url°ªÀ» ¹Þ¾Æ ÇØ´ç ÆäÀÌÁö ÀÌµ¿
 Parameter     : url
 Write  Date   : 2010.05.01
 Modify Date   :
 writer		   : ÃÖ´ë¸®
*********************************************/

function check_login(cookie,url){
	if(cookie != "")
	{
		location.href=url;
	}
	else
	{
		alert("·Î±×ÀÎÀ» ÇØ¾ßÇÕ´Ï´Ù.");
	}
}

/********************************************
 function Name : checkUrl
 Description   : ÀÔ·Â¹ÞÀº urlÀÌ Çü½Ä¿¡ ¸Â´ÂÁö °Ë»ç
 Parameter     : strUrl
 Write  Date   : 2010.05.01
 Modify Date   :
 writer		   : ÃÖ´ë¸®
*********************************************/
function checkUrl(strUrl) {
    var expUrl = /^(http\:\/\/)?((\w+)[.])+(asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|tw|uk|us)(\/(\w*))*$/i;
    return expUrl.test(strUrl);
}

function checkIP(strIP) {
    var expUrl = /^(1|2)?\d?\d([.](1|2)?\d?\d){3}$/;
    return expUrl.test(strIP);
}

/********************************************
 function Name : Tm_numbers 
 Description   : ±Ý¾× ÄÞ¸¶ Ç¥½Ã ¹× Á¤·Ä ¼ýÀÚÀÔ·Â 
 Parameter     : this
 Write  Date   : 2010.05.15
 Modify Date   :
 writer		   : ÃÖ´ë¸®
*********************************************/
function Tm_numbers(object){
  var t=true;
  var str=object.value;
  
  //ÀÏ°ý - ¾ø¾Ö±â
  str=str.replace(/-/gi,'');
  object.value=str;
 
  var isStartWith0=false;
  var lastIndexOf0=0;

  for(var i=0;i<str.length;i++){
    if(str.charAt(i)<'0'||str.charAt(i)>'9'){
      t=false;
    }
    if(str.charAt(0)=='0'){
      isStartWith0=true;
      if(str.charAt(i)=='0'){
        lastIndexOf0=i;
      }
    }
  }

  
  if(isStartWith0){
    str=str.substring(lastIndexOf0+1);
    object.value=str;
  }

  if(!t){
    object.value="";
    object.focus();
   }

  object.value=str;
}

/********************************************
 function Name : Tm_delComma ,Tm_chkSpell
 Description   : ±Ý¾× ÄÞ¸¶ Ç¥½Ã ¹× Á¤·Ä ¼ýÀÚÀÔ·Â 
 Parameter     : this
 Write  Date   : 2010.05.15
 Modify Date   :
 writer		   : ÃÖ´ë¸®
*********************************************/
function Tm_delComma(object){
	 var str=object.value;
  str=str.replace(/,/gi,'');
  object.value=str;
}

function Tm_chkSpell(object){
  var t=true;
  var str=object.value;
  //ÀÏ°ý ÄÞ¸¶ ¾ø¾Ö±â
  str=str.replace(/,/gi,'');
  object.value=str;
 
  var isStartWith0=false;
  var lastIndexOf0=0;

  for(var i=0;i<str.length;i++){
    if(str.charAt(i)<'0'||str.charAt(i)>'9'){
      t=false;
    }
    if(str.charAt(0)=='0'){
      isStartWith0=true;
      if(str.charAt(i)=='0'){
        lastIndexOf0=i;
      }
    }
  }
  if(isStartWith0){
    str=str.substring(lastIndexOf0+1);
    object.value=str;
  }

 if(parseInt(str,10)>1000000000){
    alert("±Ý¾×ÀÌ ÃÊ°ú ÇÏ¿´½À´Ï´Ù.");
    object.value="";
    object.focus();
    return;
  }

  if(!t){
    alert("¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
    object.value="";
    object.focus();
    return;
  }
  //ÀÏ°ý ÄÞ¸¶ ³Ö¾îÁÖ±â
  var tmpStr="";
  var splitchar="";
  for(var i=str.length-1;i>=0;i--){
    splitchar=str.charAt(i);
    tmpStr=splitchar+tmpStr;
    if(i%3==str.length%3&&i!=0){tmpStr=','+tmpStr;}
  }
 
  object.value=tmpStr;
}


/********************************************
 function Name : FnLenChk
 Description   : ÀÔ·Â¹ÞÀº urlÀÌ Çü½Ä¿¡ ¸Â´ÂÁö °Ë»ç
 Parameter     : strUrl
 Write  Date   : 2010.05.01
 Modify Date   :
 writer		   : 
*********************************************/
function  FnLenChk(inThis, inMax){
	var ls_str		= inThis.value;
	var li_str_len	= ls_str.length;

	// º¯¼öÃÊ±âÈ­FnLenChk(inThis, inMax)
	var li_max      = inMax;	// Á¦ÇÑÇÒ ±ÛÀÚ¼ö Å©±â
	var i           = 0;		// for¹®¿¡ »ç¿ë
	var li_byte     = 0;		// ÇÑ±ÛÀÏ°æ¿ì´Â 2 ±×¹Ü¿¡´Â 1À» ´õÇÔ
	var li_len      = 0;		// substringÇÏ±â À§ÇØ¼­ »ç¿ë
	var ls_one_char = "";		// ÇÑ±ÛÀÚ¾¿ °Ë»çÇÑ´Ù
	var ls_str2     = "";		// ±ÛÀÚ¼ö¸¦ ÃÊ°úÇÏ¸é Á¦ÇÑÇÒ¼ö ±ÛÀÚÀü±îÁö¸¸ º¸¿©ÁØ´Ù.

	for(i=0; i< li_str_len; i++) {
		ls_one_char = ls_str.charAt(i);
		if (escape(ls_one_char).length > 4) {
			li_byte += 2;
		} else {
			li_byte++;
		}
		if(li_byte <= li_max) {
			li_len = i + 1;
		}
	}

	if(li_byte > li_max) {
		alert (" ÀÛ¼º °¡´ÉÇÑ ±ÛÀÚ¼ö°¡ ÃÊ°ú µÇ¾ú½À´Ï´Ù. \n\n ÇÑ±Û±âÁØ "+(inMax/2)+" ÀÚ ÀÌ³»·Î ÀÛ¼ºÇØ ÁÖ¼¼¿ä. ");
		ls_str2 = ls_str.substr(0, li_len);
		inThis.value = ls_str2;
		inThis.focus();
		return false;
	} else {
		return true;
	}
}

/********************************************
 function Name : FnKeywordChk
 Description   : ÀÔ·Â¹ÞÀº Keyword°¡ Çü½Ä¿¡ ¸Â´ÂÁö °Ë»ç
 Parameter     : strUrl
 Write  Date   : 2010.05.01
 Modify Date   :
 writer		   : 
*********************************************/
function  FnKeywordChk(inThis){
	var inText  = inThis.value;
	var retText = "";
	if (inText.length == 0) { return "";
	} else {
		var inTextAry = inText.split(",");
		for(i=0;i<inTextAry.length;i++) {
			retTextChk = FnKeywordChk_sub1(inTextAry[i]);
			if (retTextChk.length > 0) {
				retText = retText + "," + FnKeywordChk_sub1(inTextAry[i]);
			} 
		}
		var endAry = (retText.replace(",","")).split(","); 
		var endTxt = "";
		for (i=0;i<endAry.length;i++) {
			if (i>9) {
				return endTxt.replace(",","");
			}
			endTxt = endTxt + "," + endAry[i];
		} return endTxt.replace(",","");
	}
}

function  FnKeywordChk_sub1(inText){
	var re = /[/ ]/g;
	var rv = inText.replace(re,"");
	return rv.substr(0,10);
}



/********************************************
 function Name : checkChars
 Description   : Æ¯¼ö¹®ÀÚ Ã¼Å©
 Parameter     : strUrl
 Write  Date   : 2010.05.13
 Modify Date   :
 writer		   : 
*********************************************/
function checkChars(field){
	var reCode = "[~`!@\#$%<>^&*\()-=+_\'\\\"|,;]/?";
	var strTmp = field.value;
	if(contailChars(strTmp, reCode)) {
		field.value = strTmp.substring(0, strTmp.length-1);
		alert("Æ¯¼ö¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		return false;
	}
	
	return true;
}

function contailChars(input, chars) {
	for(var i=0; i<input.length; i++) {
		if(chars.indexOf(input.charAt(i)) != -1) {
			return true;
		}
	}
	
	return false;
}

/********************************************
 function Name : checkChars
 Description   : Æ¯¼ö¹®ÀÚ Ã¼Å©
 Parameter     : strUrl
 Write  Date   : 2010.05.13
 Modify Date   :
 writer		   : 
*********************************************/
function fnTextAreaChk(inThis, inMaxNum, inMaxLine) {
	var ftaValIn	= inThis.value;
	var ftaValOut	= "";
	var ftaAry		= ftaValIn.split("\n");
	if (inMaxNum == "" || inMaxNum == 0) {
		inMaxNum = 500;
	}
	if (inMaxLine == "" || inMaxLine == 0) {
		inMaxLine = 5;
	}
	if (ftaValIn > inMaxNum) {
		inThis.value = ftaValIn.substr(0, (inMaxNum-1));
		return false;
	} else if (ftaAry.length > inMaxLine) {
		for (i=0;i<inMaxLine;i++) {
			if (i == 0) {
				ftaValOut = ftaAry[i];
			} else {
				ftaValOut = ftaValOut + "\n" + ftaAry[i];
			}
		}
		inThis.value = ftaValOut;
		return false;
	} else {
		return true;
	}
}

/********************************************
 function Name : checkChars2
 Description   : ÇÑ±Û,¿µ¹®,¼ýÀÚ¸¸ Çã¿ë
 Parameter     : strUrl
 Write  Date   : 2010.05.13
 Modify Date   :
 writer		   : 
*********************************************/
function checkChars2(field){

	var strTmp = field.value;
	var regG = /[-a-zA-Z0-9¤¿-¤Ó¤¡-¤¾°¡-ÆR ]/;

	for(i=0;i<strTmp.length;i++)
	{
		var str = strTmp.substr(i,1);

		if(!regG.test(str))
		{
			field.value = strTmp.substring(0, strTmp.length-1);
			alert("¿µ¹®,ÇÑ±Û,¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
			return false;
		}
	}
	return true;
}


function addZero(n) {
	  return n < 10 ? "0" + n : n;
}

function check_date(year,month,day){
		var now = new Date();
		var cur_year = now.getYear(); 
		var cur_month = addZero(now.getMonth()+1); 
		var cur_date = addZero(now.getDate());
		var date1 = new Date(cur_year,cur_month,cur_date).valueOf();
		var date2 = new Date(year,month,day).valueOf();
		 if (date2 - date1 < 0){
		 alert('ÀÔÂû ±â°£ ¹× ³³Ç° ¿ä±¸ÀÏÀÚ´Â\nÇöÀç º¸´Ù ÀÌÀüÀÏ ¼ö ¾ø½À´Ï´Ù.');
		 return false;
		}
		else return true;
}

function check_date2(year,month,day){
		var now = new Date();
		var cur_year = now.getYear(); 
		var cur_month = addZero(now.getMonth()+1); 
		var cur_date = addZero(now.getDate());
		var date1 = new Date(cur_year,cur_month,cur_date).valueOf();
		var date2 = new Date(year,month,day).valueOf();
		 if (date2 - date1 < 0){
		 alert('³³Ç° °¡´ÉÀÏÀÚ´Â\nÇöÀç º¸´Ù ÀÌÀüÀÏ ¼ö ¾ø½À´Ï´Ù.');
		 return false;
		}
		else return true;
}


function check_write(){
		
		if(confirm("Æ®À§ÅÍ ÀÎÁõ½Ã ÀÔ·ÂÁßÀÎ ³»¿ëÀÌ Áö¿öÁö°Ô µË´Ï´Ù.\nÆ®À§ÅÍ ÀÎÁõ ÈÄ ¾ÆÀÌµð¾î¸¦ ÀçÀÔ·ÂÇØÁÖ¼¼¿ä."))
		{
			window.open(
				'/INCLUDE/TWEET/twitter/authenticate.asp',
				'signIn',
				'width=800,height=420,left=' + ((screen.width/2) - 420) + ',top=' + ((screen.height/2) - 210) + ',location=0,toolbar=0,menubar=0,scrollbars=0,resizable=1'
				);
		}
		
}
