String.prototype.cut = function(len) {
	var str = this;
	var s = 0;
	for (var i=0; i<str.length; i++) {
		 s += (str.charCodeAt(i) > 128) ? 2 : 1;
		 if (s > len) return str.substring(0,i);
	}
	return str;
}

String.prototype.isDigit = function() {
	var str = this;
	var dig_check = /[0-9|-]/;
	return dig_check.test(str);
}

function trim(str){
      //정규 표현식을 사용하여 화이트스페이스를 빈문자로 전환
      str = str.replace(/^\s*/,'').replace(/\s*$/, '');
      return str; //변환한 스트링을 리턴.
}

function isValidURL(url){
	//var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	if(RegExp.test(url)){
		return true;
	}else{
		return false;
	}
}

function getRightURL(n) {
    var tmpURL = n.replace(/\s/g, "");
    var tmp = tmpURL.toLowerCase();
    if( tmp.indexOf("http://") == 0 || tmp.indexOf("https://") == 0 )
            return tmpURL;
    else
            return "http://"+tmpURL;
}

function email_chk(email) {
	var invalidChars = "\"|&;<>!*\'\\"   ;
	for (var i = 0; i < invalidChars.length; i++) {
		if (email.indexOf(invalidChars.charAt ) != -1) {
		  return false;
		}
	}
	if (email.indexOf("@")==-1){
		return false;
	}
	if (email.indexOf(" ") != -1){
		 return false;
	}
	if (window.RegExp) {
		var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
		var reg1 = new RegExp (reg1str);
		var reg2 = new RegExp (reg2str);

		if (reg1.test(email) || !reg2.test(email)) {
			return false;
		}
	}
	return true;
}

function clrImg(obj) {       

	obj.style.backgroundImage="";obj.onkeydown=obj.onmousedown=null;
}



function file_browse()
{
	document.all.file_1.click();
	document.all.file_1D.value=document.all.file_1.value; 
}

// PNG 파일 투명
function setPNG24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bPNG24\b/i,'');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}


//문자열의 byte size를 반환한다!
function getByteLength(s){

   var len = 0;

   if ( s == null ) return 0;
   for(var i=0;i < s.length; i++) {
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}

//보안동향 펼치기 감추기
isNS4 = (document.layers) ? true : false;
	isIE4 = (document.all && !document.getElementById) ? true : false;
	isIE5 = (document.all && document.getElementById) ? true : false;
	isNS6 = (!document.all && document.getElementById) ? true : false;
	function getObj(idname) {
		 if (isNS4){
			 elm = document.layers[idname];
		 }
		 else if (isIE4) {
			 elm = document.all[idname];
		 }
		 else if (isIE5 || isNS6) {
			elm = document.getElementById(idname);
		 }
		 return elm;
	}
	
	function toggleTab(tab_id,text_id) {
		var obj =  getObj(tab_id);
		var objText = getObj(text_id);
	
	
		if (obj.style.display == 'block') {
	
			obj.style.display = 'none';
			objText.innerHTML = '<img src="http://image.ahnlab.com/siteguard2/common/btn_view.gif" alt="+" />';
		} else {
			obj.style.display = 'block';
			objText.innerHTML = '<img src="http://image.ahnlab.com/siteguard2/common/btn_hide.gif" alt="-" />';
		}
	}

// popup check!
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 "";
}

// flash file open (colorful bg)
function flashOpen(flashSrc, flashWidth, flashHeight, flashVar){
	var stringVars = flashVar;
	document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" WIDTH="' + flashWidth + '" HEIGHT="' + flashHeight + '" id="flashObject" swLiveConnect="true">  ');
	document.write('<PARAM NAME=flashVars VALUE=getDataURL=/risks/tags  />');
	document.write('<PARAM NAME=movie VALUE="' + flashSrc + '" />');
	document.write('<PARAM NAME=quality VALUE=high />');
	document.write('<PARAM NAME=menu VALUE=false />');
	document.write('<PARAM NAME=allowScriptAccess VALUE=always />');
	document.write('<PARAM NAME=wmode VALUE=transparent />');
	document.write('<EMBED src="' + flashSrc + '" flashVars="getDataURL=/risks/tags" wmode="transparent" allowScriptAccess="always" quality="high"   WIDTH="' + flashWidth + '" HEIGHT="' + flashHeight + '" NAME="flashObject" TYPE = "application/x-shockwave-flash" PLUGINSPAGE = "http://www.macromedia.com/go/getflashplayer"></EMBED>');
	document.write('</OBJECT>');
}

// flash file open (White bg)
function flashOpenWhite(flashSrc, flashWidth, flashHeight, flashVar){
	var stringVars = flashVar;
	document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" WIDTH="' + flashWidth + '" HEIGHT="' + flashHeight + '" id="flashObject" swLiveConnect="true">  ');
	document.write('<PARAM NAME=flashVars VALUE=bgmode=white&getDataURL=/risks/tags  />');
	document.write('<PARAM NAME=movie VALUE="' + flashSrc + '" />');
	document.write('<PARAM NAME=quality VALUE=high />');
	document.write('<PARAM NAME=menu VALUE=false />');
	document.write('<PARAM NAME=allowScriptAccess VALUE=always />');
	document.write('<PARAM NAME=wmode VALUE=transparent />');
	document.write('<EMBED src="' + flashSrc + '" flashVars="bgmode=white&getDataURL=/risks/tags" wmode="transparent" allowScriptAccess="always" quality="high"   WIDTH="' + flashWidth + '" HEIGHT="' + flashHeight + '" NAME="flashObject" TYPE = "application/x-shockwave-flash" PLUGINSPAGE = "http://www.macromedia.com/go/getflashplayer"></EMBED>');
	document.write('</OBJECT>');
}

// rolling script
function scrolling(objId,sec1,sec2,speed,height){
  this.objId=objId;
  this.sec1=sec1;
  this.sec2=sec2;
  this.speed=speed;
  this.height=height;
  this.h=0;
  this.div=document.getElementById(this.objId);
  this.htmltxt=this.div.innerHTML;
  this.div.innerHTML=this.htmltxt+this.htmltxt;
  this.div.isover=false;
  this.div.onmouseover=function(){this.isover=true;}
  this.div.onmouseout=function(){this.isover=false;}
  var self=this;

  this.div.scrollTop=0;

  window.setTimeout(function(){self.play()},this.sec1);
}
scrolling.prototype={
  play:function(){
    var self=this;
    if(!this.div.isover){
      this.div.scrollTop+=this.speed;
      //alert(this.height);
      if(this.div.scrollTop>this.div.scrollHeight/2){
        this.div.scrollTop=0;
      }else{
        this.h+=this.speed;
        if(this.h>=this.height){
          if(this.h>this.height|| this.div.scrollTop%this.height !=0){
            this.div.scrollTop-=this.h%this.height;
          }
          this.h=0;
          window.setTimeout(function(){self.play()},this.sec1);
          return;
        }
      }
    }
    window.setTimeout(function(){self.play()},this.sec2);
  }
};

// SelectBox 선택시 페이지 이동
	function goPage(url) {
	    if(url != "") window.open(url, "", "");
	}