//<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">

function getCookieVal (sCookieName)
{
    var sName=sCookieName+"=", ichSt, ichEnd;
    var sCookie=document.cookie;

    if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
    {
        if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
            ichEnd = sCookie.length;
        return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
    }
    
    return null;
}


function OnloadFunction() {		
	//Æ÷Ä¿½º Á¦°Å
	allBlur();

	// ¼¿·ºÆ® Ä¡È¯
	/*var List = document.getElementsByTagName("head")[0].children;
	for(i=0; i<List.length; i++) {
		if(List[i].src == "http://file.pmang.kr/javascript/replaceselect.js") OnloadReplace();
	}*/
}

// ¹Ìµð¾îÇÃ·¹ÀÌ¾î ½ºÅ©¸³Æ®
function printPlayerObject(file_src,name,width,height,file_start,option_param_tag){
  obj_html = "<object CLASSID=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 width='"+width+"' height='"+height+"' id='"+name+"' />\
  <param name='URL' value='"+file_src+"' />\
  <param name='AutoStart' value='"+file_start+"'>";
  obj_html = obj_html + option_param_tag;
  obj_html = obj_html + "</object>";
  document.write(obj_html);
}

function openCommunityPopup()
{
 window.open('http://file.pmang.kr/images/pmang/gamepub/police/community.html', '_policy', 'width=670,height=495,resizable=no,scrollbars=no,scrolling=no' );
}

// ¿ÃÄÞ
function ViewAllCom(id) {
	var list = document.getElementById('RankAllCom');
	var liston = document.getElementById(id);
	if(liston.className == 'mlist_on') { liston.className = 'mlist_off'; }
	else { 
		for(i=0; i<list.children.length; i++) {
			list.children[i].className = 'mlist_off';
		}
		liston.className = 'mlist_on';
	}
	
	try {
	  parent.resize_frame("INFO_DOC");
	} catch(ex) {
	}
}


// Á¢¼ÓÇÑ Ä£±¸º¸±â
function friendView() {
	event.srcElement.outerHTML = '<img src="http://file.pmang.kr/images/pmang/r2beat/renew2007/img/subcon/btn_login_friend_up.gif" class="btn" onClick="friendClose()">';
	document.getElementById('FriendList').style.display = "block";
}
function friendClose() {
	event.srcElement.outerHTML = '<img src="http://file.pmang.kr/images/pmang/r2beat/renew2007/img/subcon/btn_login_friend_down.gif" class="btn" onClick="friendView()">';
	document.getElementById('FriendList').style.display = "none";
}


//½áÅ¬ ¿Ã½ºÅ¸Àü info
function pop_allstar() {
	window.open('http://file.pmang.kr/images/pmang/r2beat/renew2007/html/circle/pop_allstar.html','pop_allstar','resizable=no,scrollbars=no,top=200,left=300,width=397px,height=400px');
}

// ·¹ÀÌ¾î º¸±â
function LayerOpen(name) {
  if(!document.getElementById(name)) return;
  
  var Layer = document.getElementById(name);  
  Layer.style.display = "block";
  
  if(name == 'GmaeInfo') {
    GameInfoShadow();
  }
}
function LayerClose(name) {
  if(!document.getElementById(name)) return;
  
  var Layer = document.getElementById(name);  
  Layer.style.display = "none";
}


// ÁÂÇ¥±¸ÇÔ
function findPosY(obj) {
	var posTop = 0;
	while (obj.offsetParent) {
		posTop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return posTop;
}

function findPosX(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {
		posLeft += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return posLeft;
}

//Background Clear 
function BGClear() {
	event.srcElement.style.backgroundImage = 'none';	
}


// ¹ÂÁ÷ÅäÅ© ¹Ì¸®µè±â
function MPrePlay(musicid, name) {
			
	var posname = "player_"+musicid;
	var posobj = document.getElementById(posname);
	var posY = findPosY(posobj) + 13;
	var player = document.getElementById('MusicPrePlay');
	var imgRoot = "http://file.pmang.kr/images/pmang/r2beat/renew2007/img/community/";

		inHTML = "<p>"+name+"</p>";
		inHTML += "<img src='"+imgRoot+"btn_play_delete.gif' class='btn_delete' onClick='MPrePlayClose();go_stop();'>";
		inHTML += "<img src='"+imgRoot+"btn_play_stop.gif' class='btn_play' id='MPrePlayBtn' onClick='MPrePlayPause()'>";
	
		player.style.top = posY;
		player.style.display = 'block';
		player.innerHTML = inHTML;
	
}

function MPrePlayClose() {
	document.getElementById('MusicPrePlay').style.display = "none";
}

function MPrePlayPause() {
	myObject.pause();	
	var imgRoot = "http://file.pmang.kr/images/pmang/r2beat/renew2007/img/community/";
	document.getElementById('MPrePlayBtn').outerHTML =  "<img src='"+imgRoot+"btn_play_play.gif' class='btn_play' id='MPrePlayBtn' onClick='MPrePlayGo()'>";
}

function MPrePlayGo() {
	myObject.play();	
	var imgRoot = "http://file.pmang.kr/images/pmang/r2beat/renew2007/img/community/";
	document.getElementById('MPrePlayBtn').outerHTML =  "<img src='"+imgRoot+"btn_play_stop.gif' class='btn_play' id='MPrePlayBtn' onClick='MPrePlayPause()'>";
}

function MPrePlayRe() {
	var imgRoot = "http://file.pmang.kr/images/pmang/r2beat/renew2007/img/community/";
	document.getElementById('MPrePlayBtn').outerHTML =  "<img src='"+imgRoot+"btn_play_play.gif' class='btn_play' id='MPrePlayBtn' onClick='MPrePlayGo()'>";
}


// ¸ÞÀÎ ÇªÅÍ ¹è°æ
function setMainWrapBG() {
	var MainWrapH = document.getElementById('MainWrapBG'); 
	if(MainWrapH.clientHeight < 720) {
		MainWrapH.style.backgroundPositionY = '463px';
	}
}


// Æ÷Ä¿½º Á¦°Å
var ForBlurAnchors = document.getElementsByTagName('a');
function allBlur() { 
	for (i=0;i<ForBlurAnchors.length;i++) { 
		ForBlurAnchors[i].onfocus = new Function("ForBlurAnchors["+i+"].blur()"); 
	}
}


//Æ÷Ä¿½º Blur ÇÔ¼ö
function bluring(){ 
  if(event.srcElement.tagName == "A" || event.srcElement.tagName == "IMG") {
    document.body.focus();
	}
} 
document.onfocusin=bluring;

// PC¹æÇýÅÃº¸±â
function openPcbang()
{

  cw=screen.availWidth; //È­¸é ³Êºñ
  ch=screen.availHeight; //È­¸é ³ôÀÌ
  sw=600;//¶ç¿ï Ã¢ÀÇ ³Êºñ
  sh=650;//¶ç¿ï Ã¢ÀÇ ³ôÀÌ
  ml=(cw-sw)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ xÀ§Ä¡
  mt=(ch-sh)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ yÀ§Ä¡
  window.open('http://file.pmang.com/images/pmang/r2beat/renew2007/html/pcbang/popup_guide.html','r2pcbang_guide','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');

}


// ¿î¿µÁ¤Ã¥º¸±â
function openPolicy()
{

  cw=screen.availWidth; //È­¸é ³Êºñ
  ch=screen.availHeight; //È­¸é ³ôÀÌ
  sw=670;//¶ç¿ï Ã¢ÀÇ ³Êºñ
  sh=550;//¶ç¿ï Ã¢ÀÇ ³ôÀÌ
  ml=(cw-sw)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ xÀ§Ä¡
  mt=(ch-sh)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ yÀ§Ä¡
  
  if(location.host.substr(location.host.indexOf(".")+1) == "tooniland.com") {
    window.open('http://tenvifile.tooniland.com/images/pmang/gamepub/police/r2beat_toon_agree.html#14','r2policy_guide','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');
  } else {
    window.open('http://file.pmang.kr/images/pmang/gamepub/police/r2beat.html','r2policy_guide','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');
  }

}
function openPolicyBoard()
{

  cw=screen.availWidth; //È­¸é ³Êºñ
  ch=screen.availHeight; //È­¸é ³ôÀÌ
  sw=670;//¶ç¿ï Ã¢ÀÇ ³Êºñ
  sh=550;//¶ç¿ï Ã¢ÀÇ ³ôÀÌ
  ml=(cw-sw)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ xÀ§Ä¡
  mt=(ch-sh)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ yÀ§Ä¡
  
  if(location.host.substr(location.host.indexOf(".")+1) == "tooniland.com") {
    window.open('http://tenvifile.tooniland.com/images/pmang/gamepub/police/r2beat_toon_agree.html#13','r2policy_guide','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');
  } else {
    window.open('http://file.pmang.kr/images/pmang/gamepub/police/r2beat.html#13','r2policy_guide','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');
  }

}

function openCommunityPopup()
{
 window.open('http://file.pmang.kr/images/pmang/gamepub/police/community.html', '_policy', 'width=670,height=495,resizable=no,scrollbars=no,scrolling=no' );
}


function pop_cs_event(){

  cw=screen.availWidth; //È­¸é ³Êºñ
  ch=screen.availHeight; //È­¸é ³ôÀÌ
  sw=400;//¶ç¿ï Ã¢ÀÇ ³Êºñ
  sh=435;//¶ç¿ï Ã¢ÀÇ ³ôÀÌ
  ml=(cw-sw)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ xÀ§Ä¡
  mt=(ch-sh)/2+70;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ yÀ§Ä¡
  window.open('http://file.pmang.com/images/pmang/r2beat/renew2007/html/event/pop_event_2008022601.html','_r2event','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');

}

function pop_event_20080430(){

  cw=screen.availWidth; //È­¸é ³Êºñ
  ch=screen.availHeight; //È­¸é ³ôÀÌ
  sw=400;//¶ç¿ï Ã¢ÀÇ ³Êºñ
  sh=435;//¶ç¿ï Ã¢ÀÇ ³ôÀÌ
  ml=(cw-sw)/2;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ xÀ§Ä¡
  mt=(ch-sh)/2+70;//°¡¿îµ¥ ¶ç¿ì±âÀ§ÇÑ Ã¢ÀÇ yÀ§Ä¡
  window.open('/event/20080430/popup.nwz','_r2event_20080430','width='+sw+',height='+sh+',top='+mt+',left='+ml+',resizable=no,scrollbars=no');

}


function go_menu(mKey,sKey)
{
  switch (mKey+","+sKey)
  {
    case "5,5":
      linkurl = "/gamepub/cpa/cpa_charge.nwz?ssn=209";
      window.open(linkurl);
      break;
    default:
      linkurl = "r2beat_frame.nwz?mKey="+mKey+"&sKey="+sKey;
      document.location.href = linkurl;
      break;
  }
}

function printUserInfo(user_usn,user_id,user_gamenick,my_guildid,type,str)
{

  document.write(str);
}

function r2_finish_game()
{
  execGameEndProc(209);
}

function r2_begin_game()
{
  //°ÔÀÓ½ÃÀÛ½Ã È£Ãâ
  location.href="/gamepub/game_running.nwz?ssn=209";
}

function rb_finish_game()
{
  execGameEndProc(209);
}

function rb_begin_game()
{
  location.href="/gamepub/game_running.nwz?ssn=209";
}

function item_buyinfo()
{
  _buyinfo = window.open("http://file.pmang.com/images/pmang/r2beat/homepage/shop/buyinfo.htm","_buyinfo","width=460, height=600");
  _buyinfo.focus();
}

function open_memo()
{
  top.virtual_fr.location = "http://www.pmang.com/guild/guild_memo_proc.nwz?ssn=209&act=RESET";
  open_win_noresizable('http://memo.pmang.com/memo_popup_aenv.nwz?reload=Y', 'POPUP_AENV', 355,405);
}

function openGuide(url)
{
  window.open( url, "board_guide", "width=450,height=495");
}

//ÆË¾÷Ã¢À» ¶ç¿ì±âÀü »ç¿ëÀÚÀÇ ÄíÅ°¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö
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 openCouponPopup()
{
  window.open('r2beat_coupon.nwz', 'r2beat_coupon', 'width=450,height=410,toolbar=no,location=no,directories=no,status=no,menuBar=no,scrollbars=no');
}

function goPurchaseCashItem(chargeid)
{
  //var url = "http://www.pmang.com/pmang_purchase_pubgame.nwz?saleinfo_id="+chargeid+"&cat_id=1000006677&ssn=209";
  //open_win(url, '_buy', 430, 400);
  if(!gamepub_check_login()) {
    pub_shop.buy(209,chargeid);
  } else {
    pub_shop.showdetail(209,chargeid);
  }  
}

function gbpcSearch()
{

  if (document.all.gugun.value == "")
  {
    alert("½Ã/±¸/±ºÀ» ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿ä.");
    document.all.gugun.focus();
    return;
  }

  var sido = document.all.sido.value;
  var gugun = document.all.gugun.value;

  document.fo_rb_search.url.value = "/r2beat_pcbang.nwz?sido="+sido+"&gugun="+gugun;
  document.fo_rb_search.action = "/r2beat_frame.nwz?mKey=10&sKey=1";
  document.fo_rb_search.submit();
}

function goPopupItem(itemcode)
{
  var url = "/r2beat_gameitem_popup.nwz?itemcode="+itemcode+"&sellplace=W&ssn=209&iswebshop=Y";
  open_win(url, '_popup', 592, 402);  
}    

function goCashItem(saleinfo_id)
{
  location.href = "/r2beat_frame.nwz?mKey=5&sKey=1&url=http%3A%2F%2Fwww.pmang.com%2Fr2beat%2Fr2beat_iteminfo.nwz%3Fchargeid%3D" + saleinfo_id;
}

function go_cpa(adsrl,site)
{
  window.open( "/gamepub/cpa/cpa_sender.nwz?ad="+adsrl+"&et="+site, "_blank" );
}

//ÀÚ·á½Ç
function btn_download()
{
  go_menu(7, 1);
}

//°í°´¼¾ÅÍ
function btn_support()
{
  go_menu(8, 1);
}

//¸¶ÀÌÆäÀÌÁö
function btn_mypage()
{
  go_menu(9, 1);
}

//°ÔÀÓ½ÇÇà
function game_start()
{
  run_pubgame();

}

//°ÔÀÓ½ÇÇà
function pc_start()
{
  run_pubgame();

}

//¹ÂÁ÷ºñµð¿À
function btn_video()
{

}


//ÇÖ¹ÂÁ÷º¸±â
function btn_hotmusic()
{

}

//È¨ÆäÀÌÁö
function btn_home()
{
  location.href="/r2beat_home.nwz?ssn=209";

}

function goGiftCashItem(chargeid)
{
  //var url = "http://www.pmang.com/gamepub_gift.nwz?saleinfo_id="+chargeid+"&&ssn=209";
  //open_win(url, '_buy', 430, 400);   
  if(!gamepub_check_login()) {
    pub_shop.gift(209,chargeid);
  } else {
    pub_shop.showdetail(209,chargeid);
  }
}
function goPurchaseCashItem(chargeid)
{
  //var url = "http://www.pmang.com/gamepub_purchase.nwz?saleinfo_id="+chargeid+"&&ssn=209";
  //open_win(url, '_buy', 430, 400);   
  if(!gamepub_check_login()) {
    pub_shop.buy(209,chargeid);
  } else {
    pub_shop.showdetail(209,chargeid);
  }
}  
function goPurchaseAlcoinItem(itemid)
{
  //var url = "http://www.pmang.com/game_purchase_gmitem.nwz?bIsTarget=0&itemid="+itemid+"&sellplace=W&ssn=209";
  var url = "/gamepub/pm/game_purchase_gmitem.nwz?bIsTarget=0&itemid="+itemid+"&sellplace=W&ssn=209";
  open_win(url, '_buy', 430, 350);
}
function goPopupItem(itemcode)
{
  var url = "/r2beat_gameitem_popup.nwz?itemcode="+itemcode+"&sellplace=W&ssn=209&iswebshop=Y";
  open_win(url, '_popup', 592, 402);  
}    
function goWebItem(saleinfo_id)
{
  var url = 'r2beat_iteminfo.nwz?chargeid='+saleinfo_id;
  location.href = url;
} 

  function ChangeMenuImg(index)
  {

    document.images["menu_"+index].className="on";

    if (index != SelectedMenu)
      document.images["menu_"+SelectedMenu].className="";

    SelectedMenu = index;

  }

  function ChangeSubMenuImg(index, sub, sub2)
  {

    ChangeMenuImg(index);
    ResetSubMenuImg();

    document.images["sub_menu_"+index+"_"+sub].className="on";

    if (typeof(sub2) != "undefined")     			
			document.images["sub_menu_2_"+index+"_"+sub].className="on";

    if (sub != SelectedSubMenu)
      document.images["sub_menu_"+SelectedMenu+"_"+SelectedSubMenu].className=""; 


    SelectedSubMenu = sub;

  }

  function ResetSubMenuImg()
  {
    
    if (typeof(document.all.sub_menu_img) != "undefined")
    {
      var length = document.all.sub_menu_img.length;

      for (i=0;i<length;i++)
      {
        document.all.sub_menu_img[i].className="";
      }

    }

  }
  
  function resetRecItem()
		{
				document.all.div_subitem_community.style.display = "none";
				document.all.div_subitem_circle.style.display = "none";
				document.all.div_subitem_news.style.display = "none";
				document.all.div_subitem_shop.style.display = "none";
				document.all.div_subitem_all.style.display = "none";
		}
				
		function toggleRecItem(mKey)
		{
			resetRecItem();

      try
      {
				//Ä¿¹Â´ÏÆ¼
				if (mKey == 4)	
					document.all.div_subitem_community.style.display = "";
				else if (mKey == 3) //½áÅ¬
					document.all.div_subitem_circle.style.display = "";
				else if (mKey == 1) //´º½º
					document.all.div_subitem_news.style.display = "";
				else if (mKey == 5) //¾ÆÀÌÅÛ¼¥
					document.all.div_subitem_shop.style.display = "";
				else	//ÀüÃ¼
					document.all.div_subitem_all.style.display = "";

				addOnloadHandle('OnloadReplace()');

			}
      catch(e)
      {
      }

		}
		
		function GotoSubUrl(url){

    if (url != "") {

      document.all.INFO_DOC.src=url;

    }else{

      url = "";
      document.all.INFO_DOC.src=url;

    }

  }

if (typeof jQuery !== 'undefined') {
	
	function gnbOver() {
		$('body').addClass('gnbover');
	}
	
	function gnbOut() {
		$('body').removeClass('gnbover');
	}
	
}



function OnloadReplace() {  
		if (!$.browser.msie) return;
    GetReplaceSelects();
    GetReplaceTextarea();
}

//select box ¹è¿­°ú Ä¡È¯ÇÒ Æ¯Á¤ className ¼³Á¤
//sslectBasicÀ» ±âº»À¸·Î, ÁöÁ¤µÈ class°¡ ¿À´Â °æ¿ì¿¡¸¸ select DIV Ä¡È¯À» ½ÇÇà
var REPLACE_SELECTS = new Array();
var REPLACE_SELECTS_CLASSNAME = new Array("SelectBasic","SelectPopup","SelectMoney","SelectType1","SelectType2","SelectType3","SelectType4");

var REPLACE_TEXTAREAS = new Array();
var REPLACE_TEXTAREAS_CLASSNAME = new Array("TextareaBasic");


//Ä¡È¯ÇÒ select¹Ú½º ¼±º°
function GetReplaceSelects() {
   
  //ÆäÀÌÁö³» ¸ðµç selectbox, textarea
  var GetAllSelects = document.getElementsByTagName('select');
  
  SelectedNum = 0;
  
  //Á¶°Ç¿¡ ¸Â´Â class¸¦ °¡Áø select¸¸ ¼±º°
  for(i=0; i<GetAllSelects.length; i++) {
    for(j=0; j<REPLACE_SELECTS_CLASSNAME.length; j++) {
      if(GetAllSelects[i].className == REPLACE_SELECTS_CLASSNAME[j]) {
        REPLACE_SELECTS[SelectedNum] = GetAllSelects[i];
        SelectedNum++;
      }
    }
  }
  
  //divÄ¡È¯ ½ÇÇà
  replaceSelects();
}
function GetReplaceTextarea() {
   
  //ÆäÀÌÁö³» ¸ðµç selectbox, textarea
  var GetAllTextareas = document.getElementsByTagName('textarea');
  
  TextareaNum = 0;
  
  //Á¶°Ç¿¡ ¸Â´Â class¸¦ °¡Áø select¸¸ ¼±º°
  for(i=0; i<GetAllTextareas.length; i++) {
    for(j=0; j<REPLACE_TEXTAREAS_CLASSNAME.length; j++) {
      if(GetAllTextareas[i].className == REPLACE_TEXTAREAS_CLASSNAME[j]) {
        REPLACE_TEXTAREAS[TextareaNum] = GetAllTextareas[i];
        TextareaNum++;
      }
    }
  }
  
  //divÄ¡È¯ ½ÇÇà
  replaceTextareas();
}


//textarea DIV Ä¡È¯
function replaceTextareas() {
  
   for(var i=0; i < REPLACE_TEXTAREAS.length; i++) {
      
    //±âÁ¸ textareaÀÇ Á¤º¸ ±¸ÇÔ
    var textareaWidth = findObjWidth(REPLACE_TEXTAREAS[i]);
    var textareaHeight = findObjHeight(REPLACE_TEXTAREAS[i]);
    var textareaClassName = REPLACE_TEXTAREAS[i].className;
    
    //±âÁ¸ textarea¿¡ id°¡ ¾øÀ»°æ¿ì ÀÓ½Ãid ºÎ¿©
    if(REPLACE_TEXTAREAS[i].id == "") {
      REPLACE_TEXTAREAS[i].id = "RootTextareaID" + i;   
    }
    
    //textarea ¸¦ DIV±¸¼ºÀ¸·Î Ä¡È¯
    var textAreaBox1 = document.createElement('div');
    var textAreaBox2 = document.createElement('div');
    var textAreaBox3 = document.createElement('div');
    var textAreaBox4 = document.createElement('div');
    var textAreaCopy = document.createElement('textarea');
    
    //¼Ó¼º¹× idºÎ¿©
    textAreaBox1.className = textareaClassName + "_box1";
    textAreaBox2.className = textareaClassName + "_box2";
    textAreaBox3.className = textareaClassName + "_box3";
    textAreaBox4.className = textareaClassName + "_box4";
    textAreaCopy.className = textareaClassName + "_copy";
      
    textAreaBox1.style.position = 'absolute';
    textAreaBox1.style.top = findPosY(REPLACE_TEXTAREAS[i]);
    textAreaBox1.style.left = findPosX(REPLACE_TEXTAREAS[i]);
    textAreaBox1.style.width = textareaWidth;
    textAreaBox1.style.height = textareaHeight;
    textAreaCopy.id = "CopyTextareaID" + i; 
    textAreaCopy.style.width = textareaWidth-6+'px';
    textAreaCopy.style.height = textareaHeight-8+'px';
    textAreaCopy.innerText = REPLACE_TEXTAREAS[i].innerText;
    
    //div Á¤·Ä, »ðÀÔ
    textAreaBox4.appendChild(textAreaCopy);
    textAreaBox3.appendChild(textAreaBox4);
    textAreaBox2.appendChild(textAreaBox3);
    textAreaBox1.appendChild(textAreaBox2);
    
    //µ¿ÀÛ text¿ë
    //REPLACE_TEXTAREAS[i].style.position = 'relative';
    //REPLACE_TEXTAREAS[i].style.left = '-150px';
    
    //±âÁ¸ textarea
    REPLACE_TEXTAREAS[i].style.visibility = 'hidden';
    
    //textarea Div »ðÀÔ
    document.getElementsByTagName("body")[0].appendChild(textAreaBox1);
    
    //DIVÄ¡È¯µÈ textareaÀÇ ÀÔ·Â³»¿ëÀ» º»·¡ textarea¿¡ Àû¿ë
    textAreaCopy.onkeyup = function() {
      for(var k=0; k < REPLACE_TEXTAREAS.length; k++) {
        document.getElementById(REPLACE_TEXTAREAS[k].id).innerText = document.getElementById("CopyTextareaID"+k).innerText;
      }
    }
   }
  
}

//selectbox DIV Ä¡È¯
function replaceSelects() {
  
   for(var i=0; i < REPLACE_SELECTS.length; i++) {
      
    //±âÁ¸ select¹Ú½ºÀÇ Á¤º¸ ±¸ÇÔ
    var selectWidth = findObjWidth(REPLACE_SELECTS[i]);
    var selectHeight = findObjHeight(REPLACE_SELECTS[i]);
    var selectClassName = REPLACE_SELECTS[i].className;
    
    //±âÁ¸ select¹Ú½º¿¡ id°¡ ¾øÀ»°æ¿ì ÀÓ½Ãid ºÎ¿©
    if(REPLACE_SELECTS[i].id == "") {
      REPLACE_SELECTS[i].id = "RootSelectID" + i;
    }
      
    //ÃÖÃÊ ¼±ÅÃµÈ optionÀ» Ç¥½Ã
    var REPLACE_SELECTS_TEXT = REPLACE_SELECTS[i].options[REPLACE_SELECTS[i].selectedIndex].innerHTML;
    
    //select ¸¦ DIV±¸¼ºÀ¸·Î Ä¡È¯
    var selectArea = document.createElement('div');
    var textArea = document.createElement('a');
    var text = document.createTextNode(REPLACE_SELECTS_TEXT);
    
    //¼Ó¼º¹× idºÎ¿©
    selectArea.className = selectClassName + "_selectArea";
    selectArea.style.width = selectWidth;
    selectArea.style.position = 'absolute';
    selectArea.style.top = findPosY(REPLACE_SELECTS[i]);
    selectArea.style.left = findPosX(REPLACE_SELECTS[i]);
    textArea.id = "mySelectText"+i;
    
    //div Á¤·Ä
    textArea.appendChild(text);
    selectArea.appendChild(textArea);
    
    //±âÁ¸ slect¼û±è
    REPLACE_SELECTS[i].style.visibility = 'hidden';
    
    //select div »ðÀÔ
    //REPLACE_SELECTS[i].parentNode.insertBefore(selectArea, REPLACE_SELECTS[i]);
    
    //Å¬¸¯½Ã option div º¸¿©ÁÜ
    textArea.href="javascript:showOptions("+i+")";
    
    //option DIV ±¸¼º,À§Ä¡
    var optionsDiv = document.createElement('div');
    var optionHolder = document.createElement('p');
    optionsDiv.id = "optionsDiv"+i;
    optionsDiv.className = selectClassName + "_optionsDiv";
    optionsDiv.style.display = 'none';
    optionsDiv.style.position = 'absolute';
    optionsDiv.style.width = selectWidth + 'px';
    //optionsDiv.style.height= (REPLACE_SELECTS[i].options.length>=5) ? OptionScroll : 'auto';
    optionsDiv.style.top = findPosY(REPLACE_SELECTS[i])  + 'px';
    optionsDiv.style.left = findPosX(REPLACE_SELECTS[i]) + 'px';
    
    //option ³»¿ë ÀçÇö
    for(var j=0; j < REPLACE_SELECTS[i].options.length; j++) {
      var optionLink = document.createElement('a');
      var optionTxt = document.createTextNode(REPLACE_SELECTS[i].options[j].text);
      optionLink.href = "javascript:showOptions("+i+"); selectMe('"+REPLACE_SELECTS[i].id+"',"+j+","+i+");";
      optionLink.appendChild(optionTxt);
      optionHolder.appendChild(optionLink);
      optionsDiv.appendChild(optionHolder);
    }
    
    //slect Div »ðÀÔ
    document.getElementsByTagName("body")[0].insertBefore(selectArea,document.getElementsByTagName("body")[0].firstChild);
    
    //Option Div »ðÀÔ
    document.getElementsByTagName("body")[0].appendChild(optionsDiv);
		
		//³ôÀÌ(ÀÓ½Ã;)
		var OptionScroll = 83;
		document.getElementById('optionsDiv'+i).style.height= (REPLACE_SELECTS[i].options.length>=5) ? OptionScroll : 'auto';
  }
}

// ¿É¼Ç DIV¸¦ º¸¿©ÁÜ
function showOptions(g) {
    var Element = document.getElementById("optionsDiv"+g);
    if(Element.style.display == 'none') {Element.style.display = 'block';}
    else if(Element.style.display == 'block') {Element.style.display = 'none';}
}

function selectMe(selectFieldId,OptionNo,selectNo) {  
  //¼¿·ºÆ® ¹Ú½º µ¿ÀÛ ÇÇµå¹é
  selectField = document.getElementById(selectFieldId);
  selectField.selectedIndex = OptionNo;
selectField.fireEvent('onchange');
  //selectField.onchange();
  
  //Ä¡È¯µÈ DIV¼¿·ºÆ®¿¡ ¼±ÅÃÇÑ ¿É¼Ç Àû¿ë
  textVar = document.getElementById("mySelectText"+selectNo);
  var newText = document.createTextNode(selectField.options[OptionNo].innerHTML);
  textVar.replaceChild(newText, textVar.childNodes[0]); 
}

//ÁÂÇ¥±¸ÇÔ
function findPosY(obj) {
  var posTop = 0;
  while (obj.offsetParent) {
    posTop += obj.offsetTop;
    obj = obj.offsetParent;
  }
  return posTop;
}

function findPosX(obj) {
  var posLeft = 0;
  while (obj.offsetParent) {
    posLeft += obj.offsetLeft;
    obj = obj.offsetParent;
  }
  return posLeft;
}


//Å©±â±¸ÇÔ
function findObjWidth(obj) {
  if(obj.style.width) return obj.style.width;
  return obj.offsetWidth;
}

function findObjHeight(obj) {
  if(obj.style.height) return obj.style.height;
  else return obj.offsetHeight;
}



