/****************************************************************************
'-- 
'-- Java script 
'---------------------------------------------------------------------------
'-- 작성일 : 2007/04/09
'-- 작성자 : 김민구(rear99@nate.com)
'****************************************************************************/

/*1.******************************** 플래시 삽입 스크립트 ***************************/
function ActiveX(objects){
	var objects = document.getElementById(objects);
	if(navigator.appName == "Microsoft Internet Explorer"){
		document.write(objects.text);
		objects.id = "";
	}
}
/******************************** 플래시 삽입 스크립트 ***************************/


/*2.******************************** IMAGE_ROLLOVER 스크립트 ***************************/
function menuOn(imgEl)
{
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}

function menuOut(imgEl)
{
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}
function menuOnjpg(imgEl)
{
	imgEl.src = imgEl.src.replace(".jpg", "_on.jpg");
}

function menuOut(imgEl)
{
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}
function menuOutjpg(imgEl)
{
	imgEl.src = imgEl.src.replace("_on.jpg", ".jpg");
}
/********************************* IMAGE_ROLLOVER 스크립트 ***************************/

/********************************* moving banner 스크립트 ***************************/
function Move_Banner(obj,t_position){
	var	speed = 25; 
	document.getElementById(obj).style.top = parseInt(document.getElementById(obj).style.top)+((document.body.scrollTop+t_position)-parseInt(document.getElementById(obj).style.top))/speed;
}
/********************************* moving banner 스크립트// ***************************/


/*********************************동영상 제어하는 함수 ***************************/
/*
c_id= 제어하려는 동영상 id
c_type= 제어 타입(play,pause,stop)
*/
function control_movie_F(c_id,c_type){
	if (c_type == "play"){
		 document.all[c_id].play();//영상 플레이
	}else if (c_type == "pause"){
		 document.all[c_id].pause();//영상 잠시멈춤
	}else if (c_type == "stop"){
		 document.all[c_id].stop();//영상 멈춤
	}
}
/*********************************동영상 제어하는 함수 //***************************/

/********************************* 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 ''; 
}
/********************************* png이미지 처리 스크립트// ***************************/

/***********************  팝업 리스이즈 **************************/
function resize_pop(){
	w = document.getElementById('table').clientWidth;
	h = document.getElementById('table').clientHeight;
	resizeTo(w+10,h+55);
}
/***********************  팝업 리스이즈// **************************/


/***********************  팝업 **************************/
function pop_open(p_src,pname)
{
	window.open(p_src, pname, 'toolbar=no, scrollbars=no, menubars=no, width=100, height=100, left=0, top=0');
	return;
}
/***********************  팝업// **************************/



/* 메인 로고 위치 */
function mlogo_position(){
	var obj = document.getElementById('mainlogo');
	var logosize = parseInt(obj.style.width);
	var body_Weight = parseInt(document.body.clientWidth);
	
	logo_Y = ((body_Weight/2) + ((962 / 2)-logosize))-1;
	if (body_Weight <= 962){
		logo_Y = 962 - logosize;
		obj.style.left = logo_Y;
		return;
	}else{
		obj.style.left = logo_Y;
	}
}

function sub_position(){
	var obj = document.getElementById('sublogo');
	var logosize = parseInt(obj.style.width);
	var body_Weight = parseInt(document.body.clientWidth);
	
	logo_Y = ((body_Weight/2) + ((962 / 2)-logosize))-1;
	if (body_Weight <= 962){
		logo_Y = 962 - logosize-1;
		obj.style.left = logo_Y;
		return;
	}else{
		obj.style.left = logo_Y;
	}
}

function fnJavaSearch(search_choice,search_text)
{
	if(search_text=="" || search_text=="검색")
	{
		alert('검색어를 써주세요.');
		return;
	}
	if(search_choice=="1")
	{
		location.href = "/search/list.php?cmd=search&find_key_1=subject&find_key_2=content1&find_area=all&find_value="+encodeURI(search_text);
	}else if(search_choice=="2"){
		location.href = "/search/list.php?cmd=search&find_key_1=subject&find_area=all&find_value="+encodeURI(search_text);
		
	}else if(search_choice=="3"){
		location.href = "/search/list.php?cmd=search&find_key_2=content1&find_area=all&find_value="+encodeURI(search_text);
	}



}


//픽셀단위로 글자 자르기
function __getText(elem)
{ 
    if (elem.innerText) return elem.innerText; 
    if (elem.textContent) return elem.textContent; 
    return elem.innerHTML.replace(/<\/?[^>]+>/gi,""); 
}

function __setText(elem, text)
{
    if (elem.innerText) { elem.innerText = text; return; }
    if (elem.textContent) { elem.textContent = text; return; }
    while (elem.firstChild) elem.removeChild(elem.firstChild);
    elem.appendChild(document.createTextNode(text), elem.childNodes[0]);
}

function stringCut(elem, cutWidth, suffix)
{
    var str = __getText(elem);

    var len;
    if (!str || !(len = str.length))
        return;

    elem.style.whiteSpace = "nowrap";
    elem.style.textOverflow = "ellipsis";
    elem.style.overflow = "hidden";

    var width = elem.offsetWidth;

    if (!width || width < cutWidth - 8)
        return;

    var temp = cutWidth;

    if (suffix)
    {
        elem.innerHTML += suffix;

        cutWidth -= (elem.offsetWidth - width + 4);

        if (cutWidth < 0)
            return;
    }
    else
    {
        suffix = "";
    }

    elem.title = str;

    var cut = parseInt(cutWidth / (width / len)) + 1;

    __setText(elem, str.substr(0, cut));

    if (elem.offsetWidth > cutWidth)
    {
        while (--cut)
        {
            __setText(elem, str.substr(0, cut).replace(/(\s*$)/g, ""));

            if (elem.offsetWidth < cutWidth)
            {
                break;
            }
        }
    }
    else
    {
        while (cut++ < len)
        {
            __setText(elem, str.substr(0, cut));

            if (elem.offsetWidth > cutWidth)
            {
                __setText(elem, str.substr(0, cut - 1).replace(/(\s*$)/g, ""));
                break;
            }
        }
    }

    elem.innerHTML += suffix;
}





function limit_chk(check_string, max_byte_size) { 
 var strLength = check_string.value.length;
 var char_ASCII;
 var i = 0;
 var total_byte = 0;
 var result;
 while(i<check_string.value.length){
  char_ASCII = check_string.value.charCodeAt(i);
        //숫자 
        if (char_ASCII >= 48 && char_ASCII <= 57 ) {
   total_byte++; 
         //영어 
        } else if ((char_ASCII>=65 && char_ASCII<=90) || (char_ASCII>=97 && char_ASCII<=122)) {
   total_byte++;
         //특수기호 스페이스 포함(32)
        } else if ((char_ASCII>=32 && char_ASCII<=47) || (char_ASCII>=58 && char_ASCII<=64) 
                  || (char_ASCII>=91 && char_ASCII<=96)  || (char_ASCII>=123 && char_ASCII<=126)) {
   total_byte++;
         //한글 
        } else if ((char_ASCII >= 12592) || (char_ASCII <= 12687)) {
   total_byte = total_byte + 2;
        }
  i++;
 }
 
 var tmp = total_byte - max_byte_size;
 if (tmp > 0){
	// alert("strLength : " + strLength + " tmp : " + tmp +"\n"+ (strLength - tmp));
	 msg = "한글 " + (max_byte_size/2) + " 자, 영문 " + max_byte_size + " 자 이하만 등록 가능합니다.";				// 출력할 오류 메세지를 정의한다.
	 alert(msg);	
	 result = check_string.value.substr(0, parseInt(strLength - tmp));
	 check_string.value = result;

	 return;
 } else {
  result = check_string;
 }
 check_string = result;
}


//특정 문자 강조
function fnSrchKeywordHighLight(keyword)
{
	var newRng = document.body.createTextRange();
	var i;

	if (keyword.length < 1) {
		return false;
	}
	for (i = 0; newRng.findText(keyword); i++) {
		newRng.execCommand('ForeColor','','#FF0000');
		//newRng.execCommand('BackColor','','#FFFF00');
		newRng.collapse(false);
	}
}


/* 마우스 드레그, 오른쪽 버튼, 제어 스크립트 */
document.oncontextmenu = function(){return false;}
document.ondragstart = function(){return false;}
document.onselectstart = function(){return false;}

// 숫자만 입력받기


function onlyNumber()
{
if((event.keyCode<48)||(event.keyCode>57))
event.returnValue=false;
}


