/*
	팝업창 띄우기
	url : 팝업창 url
	wnm : 팝업창 명
	winWidth : 팝업창 width
	winHeight : 팝업창 Height
	[sizable] : 팝업창 그키조절여부(yes) 
*/	
function winowPop(url, wnm, winWidth, winHeight, sizable) { 
    var arg = winowPop.arguments;
    var winOption = "width="+winWidth+", height="+winHeight+", left=100, top=10, toolbar=no, directories=no, status=yes, scrollbars=yes, menubar=no";   
    if (arg[4] != null) {
        winOption += ", resizable=yes";
    }
    
    var win = window.open(url, wnm, winOption); 
    win.focus();
    return win;         
}

/*
	문자열 길이
	text : 문자열
*/
function GetTextLength(text){
    return text.length;
}

/*
	입력된 id에 문자열 길이 보여주기
*/
function ViewTextLeng(obj, id) {        
    var obj1 = document.getElementById(id);        
    obj1.innerHTML = GetTextLength(obj.value); 
    return;    
}

/*
	특정 폼내의 체크박스 전체 체크하기
	allObj : 전체 체크를 하는 객체
	targetObj : allObj를 click했을 때 전체 체크되는 객체
*/	
function CheckAll(allObj, targetObj) {
    var is_check = (allObj.checked) ? true : false;
    
    if (targetObj != null) {
        if (targetObj.length == null || targetObj.length == 'undefined') {
            targetObj.checked = is_check;    
        } else {
            for (var i=0; i<targetObj.length; i++) 
                targetObj[i].checked = is_check;           
        }
    }
}

// 숫자 체크
function isComNumeric(s)
{
    var ch, ch2=1;

    for ( k = 0; k < s.length; k++ )
    {
        ch = s.charAt(k);
        if ( ch < '0' || ch > '9' )
        {
            return (false);
        }
    }
    return (true);
}

/*
	문자열 trim
*/
function setStrTrim(strText) {
    // this will get rid of leading spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}

/*
   	입력된 객체가 체크되었는지 체크박스 확인
   	
*/
function CheckBoxConfirm(targetObj) {
    var blnChecked = false;
    
    if (targetObj != null) {
        if (targetObj.length == null || targetObj.length == 'undefined') {
            if (targetObj.checked) 
                blnChecked = true;
        } else {
            for (var i=0; i<targetObj.length; i++) {
                if (targetObj[i].checked) {
                    blnChecked = true;
                    break;
                }
            }
        }
    }
    
    return blnChecked;     
} 

 /*
         이미 선택했는지 검사    
 */        
 function IsAlreadySelected(str, target) {
     var result = false;
     
     if (str != "" && str.indexOf(target) >= 0) {
         result = true;            
     }
     //alert("str.indexOf(target)=>"+str.indexOf(target));
     return result;
 } 
    
 /*
         받는이 정보 append
 */
 function AppendRcverInfo(str, id, ids, imgServer) {
     var result = str;
   
     //if (result != "") result += ",";		 
     if (result != "") result += " ";

     result += "<SPAN id="+id+">"+id+"<a href='#' onClick=\"javascript:DeleteRcver('"+id+"', '"+ids+"');\"> <img src='"+imgServer+"/img/cmm/cmm/cmu/comment_delete.gif'/></a></SPAN>"           

     //alert("result=>"+result);
     return result;
 }

/*
	내용에 맞게 크리조절
*/ 
function getPopWinSize() {
/*
    var Dwidth = parseInt(document.documentElement.scrollWidth);
    var Dheight = parseInt(document.documentElement.scrollHeight);
    var divEl = document.createElement("div");
    divEl.style.position = "absolute";
    divEl.style.left = "0px";
    divEl.style.top = "0px";
    divEl.style.width = "100%";
    divEl.style.height = "100%";
    
    document.body.appendChild(divEl);
    
    window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight+100);
    document.body.removeChild(divEl);
*/

	var obj = navigator.appVersion;
	var height = 40;
	if (navigator.appVersion.indexOf("NT") != -1) 
	{
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") 
		{
			height = 80//120//60;
		}
	}
	
	width = document.documentElement.scrollWidth+10;
	height = document.documentElement.scrollHeight + height;

	if(height > 700) height = 700;
	if(width < 400) width = 400;
	self.resizeTo(width,height);  
	  
}
 
 //글자를 앞에서부터 원하는 바이트만큼 잘라 리턴합니다.
String.prototype.cut = function(len) {
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) {
         l += (str.charCodeAt(i) > 128) ? 2 : 1;
         if (l > len) return str.substring(0,i) + "...";
    }
    return str;
}
  
//해당스트링의 바이트단위 길이를 리턴합니다. (기존의 length 속성은 2바이트 문자를 한글자로 간주합니다)
String.prototype.bytes = function() {
     var str = this;
     var l = 0;
     for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
     return l;
}
 
