String.prototype.trim = function() {
		  return this.replace(/(^\s*)|(\s*$)|($\s*)/g, "");
}

String.prototype.getByte = function () {
	var len = 0;
	var itill = this.length;
	for (var idx=0 ; idx < itill ; idx++, len++){
		if ( (this.charCodeAt(idx)<0) || (this.charCodeAt(idx)>127) ) len ++;
	}
	return len;
}

//플래시출력
function getFlash(id,url,w,h,t,bg){
	if(!t) var t='transparent'; if(!bg) var bg='none';
	var flashOut='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width='+w+' height='+h+' id='+id+'>';
	flashOut+='<param name="movie" value='+url+' /><param name="wmode" value='+t+' /><param name="base" value="." /><param name="bgcolor" value='+bg+' />';
	flashOut+='<param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="menu" value="false" />';
	flashOut+='<embed base="." src='+url+' width='+w+' height='+h+' name='+id+' wmode='+t+' bgcolor='+bg+' swLiveConnect="true" allowScriptAccess="sameDomain" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashOut+='</object>';
	document.write(flashOut);
}

//**   img change **//
function imgchange(imgobj){
 if(imgobj.src.indexOf('on.gif')==-1){
  imgobj.src=imgobj.src.replace('.gif','on.gif');
  imgobj.parentNode.onmouseout=function(){if(this.childNodes[0].src.indexOf('on.gif')!=-1) this.childNodes[0].src=this.childNodes[0].src.replace('on.gif','.gif');}
 }
}

function openPopup( url, w, h ) {
	var hdr = "handler";
	var width = w;   
	var height = h;
	var popupLeft = (window.screen.availWidth - width) / 2;
	var popupTop = (window.screen.availHeight - height) / 2;
	var popupWidth = width - 10;
	var popupHeight = height - 30;

	var newwin = window.open(url, hdr , 'width='+width+',height='+height+', left =' + popupLeft + ', top=' + popupTop + ',scrollbars=yes')	
	newwin.focus();
}

/** 글자 수 체크 */
function onkeylengthMax(formobj, maxlength, objname) {  
    var li_byte     = 0;  
    var li_len      = 0;  
    for(var i=0; i< formobj.value.length; i++){  
        if (escape(formobj.value.charAt(i)).length > 4){  
            li_byte += 1;  
        } else {  
            li_byte++;  
        }  
        if(li_byte <= maxlength) {  
            li_len = i + 1;  
        }  
    }      
    if(li_byte > maxlength){  
        alert('최대 글자 입력수를 초과 하였습니다.\n초과한 글자는 삭제 됩니다.');  
        formobj.value = formobj.value.substr(0, li_len);  
    }

	span = document.getElementById(objname+"TextCount");
	span.innerHTML=li_len + "/" + maxlength + "자";
} 

/** 국가법령 링크 팝업*/
function openLaw(lsNm, lsId, ancYd, ancNo) {
	var url = "/jsp/common/LawLink.jsp?OC=inglaw";
	if(lsNm == '') {
		url = url + "&ID="+lsId+"&LD="+ancYd+"&LN="+ancNo;
		
 	} else {
 		var LM = encodeURIComponent(lsNm.replace('ㆍ','')) ;
 		url =  url + "&LM="+LM ;
 	}
 	
  	openPopup( url , 960, 730);
}

/*
NAME:	SetCookie()
DESC: 	쿠키에 값을 설정한다.
param:  name, value, expries
return: 
author: 정태섭
*/
function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   
   document.cookie = name + "=" + escape (value) + "; path=/" +
      ((expires == null) ? "" : 
         ("; expires=" + expires.toGMTString()));
} 

/*
NAME:	GetCookie()
DESC: 	쿠키의 값을 가져온다.
param:  name
return: 
author: 정태섭
*/
function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;

   while (i < clen) {	//while open
      var j = i + alen;

      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
   }	//while close
   return null;
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

/*
NAME:	popupIdlCert()
DESC: 	서울신용평가 실명인증 팝업
author: 정재윤
*/
function popupIdlCert(){
	CBA_window=window.open('','CbaWindow', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
	document.reqCBAForm.action="https://name.siren24.com/vname/jsp/vname_j10.jsp";
	document.reqCBAForm.submit();
}

function visibleMyScrap(){
	myScrLoad();
	document.getElementById('myScrapList').style.visibility = '';
	
}

function disableMyScrap(){
	document.getElementById('myScrapList').style.visibility = 'hidden';
}

function myScrLoad(form){

	sendData = "";
	
	url = "ItrAstMyScrR.do"; 
	
	sendRequestSearch(url,sendData) ;

}

var xmlHttp;

function sendRequestSearch(url,dt) {

    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }

    xmlHttp.onreadystatechange = handleStateChange;
	
    xmlHttp.open("POST", url, true);
    
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	
    xmlHttp.send(dt);
	
}
function handleStateChange() {
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {  
			if(xmlHttp.responseText.length > 564){
				document.getElementById("myScrapList").innerHTML = xmlHttp.responseText;				
			}
		}else{
			
		}
	}else{
	
	}
}

function searchValueNull(){
	document.getElementById("qry").value
	if ( document.getElementById("qry") && document.getElementById("qry").value ) {
		if ( document.getElementById("qry").value == "통합검색" || document.getElementById("qry").value == "입안심사기준검색" ) {
			document.getElementById("qry").value = "";
		}
	}
}

function searchScList(form){
	var path = document.location.pathname;
	
	if(document.getElementById("headSearchParam").value == ""){
		alert("검색어를 입력하십시오.");
		return;
	}
	if(path == "/StdInfInfoR.do" || path == "/AstListR.do"){
		var newWhere = document.createElement("INPUT");
		newWhere.type = "hidden";
		newWhere.name = "where";
		newWhere.value= "mgl_ast"
		form.appendChild(newWhere);
		form.action = "StdInfAstScListR.do";		
	}else{
		form.action = "StdInfScListR.do";
	}
	
	form.submit();
}

function setFocus(){
	document.getElementById("label").style.display = "none";
	document.searchScForm.qry.focus();
}