function restring(st){
newstr = st.split("]");
return document.write(newstr[1]);
}
/////제목괄호빼기

// XMLHttpRequest 관련 시작
var req;

function loadXMLDoc(url) {
	req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        }
        catch(e) {
			req = false;
        }
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	}
      	catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) {
          		req = false;
        	}
		}
    }
	if (req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
		req.send("");
	}
}

function loadXMLDocPost(url, queryString) {
	req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        }
        catch(e) {
			req = false;
        }
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	}
      	catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) {
          		req = false;
        	}
		}
    }
	if (req) {
		req.open("POST", url, true);
		req.onreadystatechange = processReqChange;
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; Charset=utf-8");
        //req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(queryString);
	}
}

var debug_mode = false;

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (debug_mode)
        {
           document.write(req.responseText);
        }
				//alert(req.responseText);
        eval (req.responseText);

    }
}
///////////////////////////////////////////////////////////

function mov(src,w,h,vol,scon){
	html = '';

	//showcontrols
	if(scon == "") {
		scon = "true";
	}	else {
		scon = "false";
	}

	//width
	if(w == "") {
		w = '';
	}	else {
		w = '" width="'+w+'"';
	}

	//height
	if(h == "") {
		h = '';
	}	else {
		h = '" height="'+h+'"';
	}

	//volume
	if(vol == "") {
		vol = '';
	}	else {
		vol = '" volume="'+vol+'"';
	}

	html = '<embed src="'+src+'" showcontrols="'+scon+'" autostart="true" enablecontextmenu="false" '+w+' '+h+' '+vol+'></embed>';
	document.write(html);
}
function setEmbed()
{
  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;


  this.init = function( getType , s ,w , h ) {

      if ( getType == "flash")
      {

        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      else if ("moviethumnail")
      {
        clsid = "EBE61D01-76D5-479A-8318-9492887EECFA";
        codebase = "/js/editor/PlayEditor.cab#version=1,0,0,4";
		pluginspage = "";
        embedType = "";
      }

      parameter += "<param name='movie' value='"+ s + "'>\n";
      parameter += "<param name='quality' value='high'>\n";

      src = s;
      width = w;
      height = h;
  }

  this.parameter = function( parm , value ) {
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
      allParameter += " "+parm + "='"+ value+"'";
  }

  this.show = function() {
      if ( clsid )
      {
        obj = "<object classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n";
      }

      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n";

      if ( obj )
      {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;

      document.write( html );
  }

}
//////////////////////////////////////////////////
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 "";
}
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function FontSizeUp(id)
{
	var obj = document.getElementById(id);
	var size = obj.style.fontSize.split('pt')[0];

	if(!size)
		size = 12;
	size++;
	if(size > 20)
		return;
	obj.style.fontSize = size+'pt';
}
function FontSizeDown(id)
{
	var obj = document.getElementById(id);
	var size = obj.style.fontSize.split('pt')[0];

	if(!size)
		size = 12;
	size--;
	if(size < 8)
		return;
	obj.style.fontSize = size+'pt';
}

// 글자 수 제한
function textareacheck(aro_name,ari_max) // 텍스트박스, 제한글자수
{
   var ls_str     = aro_name.value; // 이벤트가 일어난 컨트롤의 value 값
   var li_str_len = ls_str.length;  // 전체길이

   // 변수초기화
   var li_max      = ari_max; // 제한할 글자수 크기
   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);

      // 한글이면 2를 더한다.
      if (escape(ls_one_char).length > 4)
      {
         li_byte += 2;
      }
      // 그밗의 경우는 1을 더한다.
      else
      {
         li_byte++;
      }

      // 전체 크기가 li_max를 넘지않으면
      if(li_byte <= li_max)
      {
         li_len = i + 1;
      }
   }
   
   // 전체길이를 초과하면
   if(li_byte > li_max)
   {
      alert("내용은 한글 " + li_max/2 + "자 영문 " + li_max + "자 까지만 허용됩니다.");
      ls_str2 = ls_str.substr(0, li_len);
      aro_name.value = ls_str2;
   }
   aro_name.focus();   
}

///////////////////////// hamt scroller
var hamtScroller = function (objname, parentid, width, height, type)//type left:왼쪽으로 right:오른쪽으로 top:위로 bottom:아래로
{
    this.tanspeed = 0.9;//탄성계수. 1미만 소수점으로. 클수록 부드럽게~
    this.speed = 10;//스크롤 스피드. X/1000초. 작을수록 빠름
    this.duration = 200;//스크롤 후 대기시간. 클수록 오래머뭄.speed값에따라 적절히~
    
    height += 10;
    this.width = width+10;
    this.height = height;
    this.type = type;
    
    this.objname = objname;
    this.parentid = parentid;
    this.durationcount = 0;
    this.stopflag = 0;
    this.outbox = document.createElement('div');
    this.outbox.style.position = 'relative';
    this.outbox.style.overflow = 'hidden';
    this.outbox.style.width = width+'px';
    this.outbox.style.height = height+'px';
    
    this.items = [];
    this.direction = type;
    this.interrupt = 0;
    this.viewnode = 0;
    
    this.remain;
    
    this.add = function(item)
    {
        

		if(this.type != 'top' && this.type != 'bottom')
		{
			var itembox = document.createElement('span');

			this.outbox.appendChild(itembox);
			itembox.style.position = 'absolute';
			itembox.style.left = (this.width*this.items.length)+'px';
		}
		else
		{
			var itembox = document.createElement('div');

			this.outbox.appendChild(itembox);

			itembox.style.position = 'absolute';
			itembox.style.top = (this.height*this.items.length)+'px';
			itembox.style.left = '0px';

			itembox.style.width = this.width-10+'px';
			//itembox.style.height = this.height+'px';
			//itembox.style.backgroundColor = 'red';
			
		}

        itembox.innerHTML = item;
        
        
        this.items[this.items.length] = itembox;
    }
    this.moveTo = function(dir)
    {
        if(this.remain > 0)
            return;
        this.interrupt = 1;
        
        this.direction = dir;
        this.durationcount = this.duration;
    }
    this.print = function()
    {
		
        this.add(this.items[0].innerHTML);
        
        var parent = document.getElementById(this.parentid);
		
        parent.appendChild(this.outbox);
		
        this.run();
    }
    this.stop = function()
    {
        this.stopflag = 1;
    }
    this.endstop = function()
    {
        this.stopflag = 0;
    }
    
    
    /// private
    this.move = function()
    {
        if(this.remain == 0 && this.interrupt==0 && this.stopflag)
            return;
        
        if(!this.remain)
        {
            if(this.durationcount >= this.duration)
            {
                this.durationcount = 0;
            }
            else
            {   
                this.durationcount++;
                return;
            }
        }
        if(this.direction == 'left')
            this.goleft();
        else if(this.direction == 'right')
            this.goright();
		else if(this.direction == 'top')
            this.gotop();
		else if(this.direction == 'bottom')
            this.gobottom();

    }
    this.goleft = function()
    {
        if(this.viewnode == this.items.length-1)
        {
            for(var i = 0 ; i < this.items.length ; i++)
            {
                this.items[i].style.left = this.width*i+'px';
            }
            this.viewnode = 0;
        }
        var lastflag = 0;
        var itemlast = 0;
        var obj = this.items[this.items.length-1];
        
        if(!this.remain)
            this.remain = this.width;
        var ori = this.remain;
        this.remain *= this.tanspeed;
        var minus = ori - this.remain;
        
        if(minus < 1)
        {   
            this.remain = 0;
            this.durationcount = 0;
            minus = 0;
            this.direction = this.type;
            this.interrupt = 0;
            this.viewnode++;
            itemlast = 1;
            if(this.viewnode == this.items.length-1)
            {
                lastflag = 1;
            }
        }
        
        for(var i = 0 ; i < this.items.length ; i++)
        {
            if(!lastflag)
            {
                if(!itemlast)
                    this.items[i].style.left = (this.items[i].style.left.split('px')[0]-minus)+'px';
                else
                    this.items[i].style.left = this.width*(i-this.viewnode)+'px';
            }
            else
            {   
                this.items[i].style.left = this.width*i+'px';
                this.viewnode = 0;
            }
        }
    }
    this.goright = function()
    {
        if(this.viewnode == 0)
        {
            for(var i = 0 ; i < this.items.length ; i++)
            {
                this.items[i].style.left = -1*this.width*(this.items.length-1-i)+'px';
            }
            this.viewnode = this.items.length-1;
        }
        var lastflag = 0;
        var itemlast = 0;
        
        if(!this.remain)
            this.remain = this.width;
        var ori = this.remain;
        this.remain *= this.tanspeed;
        var plus = ori - this.remain;
        
        if(plus < 1)
        {   
            this.remain = 0;
            this.durationcount = 0;
            plus = 0;
            this.direction = this.type;
            this.interrupt = 0;
            this.viewnode--;
            itemlast = 1;
            if(this.viewnode == 0)
                lastflag = 1;
        }
        
        for(var i = 0 ; i < this.items.length ; i++)
        {
            if(!lastflag)
            {
                if(!itemlast)
                { 
                    this.items[i].style.left = (parseInt(this.items[i].style.left.split('px')[0])+plus)+'px';
                }
                else
                {   
                    this.items[i].style.left = this.width*(i-this.viewnode)+'px';
                }
            }
            else
            {   
                this.items[i].style.left = -1*this.width*(this.items.length-1-i)+'px';
                this.viewnode = this.items.length-1;
            }
        }
    }
	this.gotop = function()
    {
        if(this.viewnode == this.items.length-1)
        {
            for(var i = 0 ; i < this.items.length ; i++)
            {
                this.items[i].style.top = this.height*i+'px';
            }
            this.viewnode = 0;
        }
        var lastflag = 0;
        var itemlast = 0;
        var obj = this.items[this.items.length-1];
        
        if(!this.remain)
            this.remain = this.height;
        var ori = this.remain;
        this.remain *= this.tanspeed;
        var minus = ori - this.remain;
        
        if(minus < 1)
        {   
            this.remain = 0;
            this.durationcount = 0;
            minus = 0;
            this.direction = this.type;
            this.interrupt = 0;
            this.viewnode++;
            itemlast = 1;
            if(this.viewnode == this.items.length-1)
            {
                lastflag = 1;
            }
        }
        
        for(var i = 0 ; i < this.items.length ; i++)
        {
            if(!lastflag)
            {
                if(!itemlast)
                    this.items[i].style.top = (this.items[i].style.top.split('px')[0]-minus)+'px';
                else
                    this.items[i].style.top = this.height*(i-this.viewnode)+'px';

            }
            else
            {   
                this.items[i].style.top = this.height*i+'px';
                this.viewnode = 0;
            }
        }
    }
	this.gobottom = function()
    {
        if(this.viewnode == 0)
        {
            for(var i = 0 ; i < this.items.length ; i++)
            {
                this.items[i].style.top = -1*this.height*(this.items.length-1-i)+'px';
            }
            this.viewnode = this.items.length-1;
        }
        var lastflag = 0;
        var itemlast = 0;
        
        if(!this.remain)
            this.remain = this.height;
        var ori = this.remain;
        this.remain *= this.tanspeed;
        var plus = ori - this.remain;
        
        if(plus < 1)
        {   
            this.remain = 0;
            this.durationcount = 0;
            plus = 0;
            this.direction = this.type;
            this.interrupt = 0;
            this.viewnode--;
            itemlast = 1;
            if(this.viewnode == 0)
                lastflag = 1;
        }
        
        for(var i = 0 ; i < this.items.length ; i++)
        {
            if(!lastflag)
            {
                if(!itemlast)
                { 
                    this.items[i].style.top = (parseInt(this.items[i].style.top.split('px')[0])+plus)+'px';
                }
                else
                {   
                    this.items[i].style.top = this.height*(i-this.viewnode)+'px';
                }
            }
            else
            {   
                this.items[i].style.top = -1*this.height*(this.items.length-1-i)+'px';
                this.viewnode = this.items.length-1;
            }
        }
    }
    
    this.run = function()
    {
       this.move();
       setTimeout(this.objname+".run()", this.speed);
    }
    
}

var HamtImgTabControl = function(parentid)
{
	this.parentObj = document.getElementById(parentid);

	this.ChangeTabImg = function(selobj)
	{		
		var imgs = this.parentObj.getElementsByTagName('img');
		for(var i = 0 ; i < imgs.length ; i++)
		{
			this.buttonset(imgs[i], 'out');
		}
		this.buttonset(selobj, 'over');
	}

	this.buttonset = function (obj, mode)
	{
		var filename = obj.src;
		var file = filename.split('/');
		var filepos = '';
		
		for(var i = 0 ; i < file.length-1 ; i++)
			filepos += file[i]+'/';
		
		file = file[file.length-1];

		var exp = file.split('.');
		var contentlayerobj = document.getElementById(exp[0].split('_')[0]);
		

		switch(mode)
		{
			case 'over' :
				obj.src = filepos+exp[0].split('_')[0]+'.gif';
				if(contentlayerobj)
					contentlayerobj.style.display = 'block';
				break;
			case 'out' :
				if(exp[0].split('_')[1] == 'off')
				break;
			obj.src = filepos+exp[0]+'_off.gif';
				if(contentlayerobj)
					contentlayerobj.style.display = 'none';
				break;
		}
	}
}

function button(obj, mode)
{
	var filename = obj.src;
	var file = filename.split('/');
	var filepos = '';
	
	for(var i = 0 ; i < file.length-1 ; i++)
		filepos += file[i]+'/';
	
	file = file[file.length-1];

	var exp = file.split('.');
	
	
	switch(mode)
	{
		case 'over' :
			obj.src = filepos+exp[0].split('_')[0]+'.gif';
			break;
		case 'out' :
			if(exp[0].split('_')[1] == 'off')
				break;
			obj.src = filepos+exp[0]+'_off.gif';
			break;
	}
}
function dpchange(hiddenobj, dpobjid)
{
	hiddenobj.style.display = 'none';
	document.getElementById(dpobjid).style.display = 'block';
	document.getElementById(dpobjid).focus();
}
var SelectControl = function()
{
	this.ChangeIndex = function(id, fromIndex, toIndex, selectedindex)
	{
		var obj = this.GetObj(id);

		if(!this.IndexCheck(obj, fromIndex))
		{
			alert('이동 인덱스 범위가 벗어났습니다.');
			return;
		}
		if(!this.IndexCheck(obj, toIndex))
		{
			alert('목적지 인덱스 범위가 벗어났습니다.');
			return;
		}

		var tempOption = obj[fromIndex];
		obj[fromIndex] = new Option(obj[toIndex].text, obj[toIndex].value);
		obj[toIndex] = tempOption;



		if(selectedindex)
			obj.selectedIndex = selectedindex;
		else
			obj.blur();
	}
	this.ChangeOrderDown = function(id, index)
	{
		this.ChangeIndex(id, index, index+1, index+1);
	}
	this.ChangeOrderUp = function(id, index)
	{
		this.ChangeIndex(id, index, index-1, index-1);
	}
	this.ChangeText = function(id, index, text)
	{
		var obj = this.GetObj(id);
		obj[index].text = text;
	}
	this.ChangeValue = function(id, index, value)
	{
		var obj = this.GetObj(id);
		obj[index].value = text;
	}
	this.ChangeAll = function(id, optionStr, itemCutChar, valueCutChar)
	{
		if(!itemCutChar)
			itemCutChar = '|';
		if(!valueCutChar)
			valueCutChar = ':';

		var obj = this.GetObj(id);
		var items = optionStr.split(itemCutChar);

		obj.length = 0;

		for(var i = 0 ; i < items.length ; i++)
		{
			var item = items[i].split(valueCutChar);
			obj[obj.length] = new Option(item[0], item[1]);
		}
	}
	this.SelectByValue = function(id, val)
	{
		var obj = GetObj(id);

		for(var i = 0 ; i < obj.length ; i++)
		{
			if(obj[i].value == val)
			{
				obj.selectedIndex = i;
				break;
			}
		}

	}
	this.Add = function(id, text, value, index)
	{
		var obj = this.GetObj(id);
		obj[obj.length] = new Option(text, value);

		if(index)
		{
			this.ChangeIndex(id, obj.length-1, index);
		}
	}
	this.Del = function(id, index)
	{
		var obj = this.GetObj(id);
		obj[index] = null;
	}




	//private

	this.IndexCheck = function(obj, index)
	{
		if(index < 0 || index > obj.length-1)
		{
			return false;
		}
		return true;
	}
	this.GetObj = function(id)
	{
		return document.getElementById(id);
	}
}
var HamtGallery = function(imgareaobj, titleobj,  width, height)
{
	this.dpImgObj = document.getElementById(imgareaobj);
	this.dpTitleObj = document.getElementById(titleobj);

	this.width = width;
	this.height = height;
	this.imgObjs = [];
	this.imgObjTitles = [];
	this.viewindex = 0;


	this.add = function(src, title)
	{
		var img = new Image();
		img.src = src;

		this.imgObjs[this.imgObjs.length] = img;
		this.imgObjTitles[this.imgObjTitles.length] = title;
	}
	this.run = function()
	{
		this.viewindex = this.imgObjs.length*100;
		this.draw();
	}
	this.draw = function()
	{
		var index = this.viewindex % this.imgObjs.length;
		if(this.dpImgObj)
		{
			this.dpImgObj.src = this.imgObjs[index].src;
			
			if(this.width)
			{
				this.dpImgObj.width = this.width;
			}
			if(this.height)
			{
				this.dpImgObj.height = this.height;
			}
		}
		if(this.dpTitleObj)
		{
			this.dpTitleObj.innerHTML = this.imgObjTitles[index]+'('+(parseInt(index)+parseInt(1))+'/'+this.imgObjs.length+')';
		}
	}
	this.next = function()
	{
		this.viewindex++;
		this.draw();
	}
	this.prev = function()
	{
		this.viewindex--;
		this.draw();
	}
}
var HamtBanner = function(objname, boxid)
{	
	this.objName = objname;
	this.term = 3000;

	this.ObjID = boxid;
	
	this.srcs = [];
	this.urls = [];	
	this.targets = [];

	this.index = 0;

	this.Add = function(src, url, target)
	{
		this.srcs[this.srcs.length] = src;
		this.urls[this.urls.length] = url;
		this.targets[this.targets.length] = target;
	}

	this.Run = function()
	{
		var obj = document.getElementById(this.ObjID);
		if(!obj)
		{
			alert(this.ObjID+'개체를 찾을 수 없습니다');
			return;
		}
		var idx = this.index % this.srcs.length;
		obj.innerHTML = "<a href='"+this.urls[idx]+"' target='"+this.targets[idx]+"'><img src='"+this.srcs[idx]+"'></a>";
		this.index++;

		if(this.srcs.length > 1)
			setTimeout(this.objName+'.Run()', this.term);
	}
}















//일반 스크립트
function Winpopup(url, w, h)
{
	window.open(url, 'idpwsearch', 'width='+w+' height='+h+' scrollbars=no');
}

