//<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#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#14','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 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() {
		$('.wrap').removeClass('wrap_in');
	}
	
	function gnbOut() {
		$('.wrap').addClass('wrap_in');
	}
	
}