function processNewMemo ()
{
  var p_memo_up = 200;
  if ('string'!=typeof(my_memo_newcount.innerHTML))
  {
    setTimeout("processNewMemo()", p_memo_up);
    p_memo_up *= 2;
    return;
  }
  p_memo_up = 200;

  if ('object'==typeof(AppletSession) && ''!=AppletSession.getvalue('memo_cnt_new') && AppletSession.getvalue('memo_cnt_new') > 0)
    my_memo_newcount.innerHTML = AppletSession.getvalue('memo_cnt_new')+"Åë";
  else
    my_memo_newcount.innerHTML = "¾øÀ½";
}

//setPNG
function setPng(obj) {
	if ( window.XMLHttpRequest ) return;
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng\b/i,'');
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
	obj.src='';
	return '';
}

// ·Î±×ÀÎ ¿µ¿ª BG (IEÀü¿ë)
function LoginBgChange() {
	var ThisInput = event.srcElement;
	ThisInput.style.backgroundImage = "none";
}

function setMainFlash() {
	window.setInterval('checkMainFlash()',100);
}
function checkMainFlash() {
	var flashDiv = document.getElementById('mainFlashImg');
	var bodyWidth = document.body.clientWidth;
	if ( bodyWidth > 980) {
		flashDiv.style.width = Math.round(bodyWidth/2-27)+'px';
	}	else { flashDiv.style.width = '463px'; }
}

function setSubImg() {
	window.setInterval('checkSubImg()',100);
}
function checkSubImg() {
	var subDiv = document.getElementById('subLayoutImg');
	var bodyWidth = document.body.clientWidth;
	if ( bodyWidth > 968) {
		subDiv.style.width = Math.round(bodyWidth/2+301)+'px';
	}	else { subDiv.style.width = '860px'; }
}

// ·¹ÀÌ¾îÅä±Û
function toggleLayer(id) {
  if(!document.getElementById(id)) return false;
  
  var Layer = document.getElementById(id);
  
  if(Layer.style.display == 'block') Layer.style.display = 'none';
  else Layer.style.display = 'block'; 
}


// ÅÇµ¿ÀÛ
function TabMove(name,num) {
	if(!document.getElementsByName(name)) return;
	
	var TabGroup = document.getElementsByName(name);
	var TabThis = num-1;
	
	for(i=0; i<TabGroup.length; i++) {
		var TabName = name+(i+1);
		var TabContents = document.getElementById(TabName);
		if (TabContents) {
			if(i==TabThis) {
				TabContents.style.display = "block";
				TabGroup[TabThis].parentNode.className = "on";
			}
			else {
				TabContents.style.display = "none";
				TabGroup[i].parentNode.className = "";
			}
		}
	}
}

// labelµ¿ÀÛ
function clicklabel(id) {	
	if(navigator.appVersion.indexOf('MSIE') != -1){
		document.getElementById(id).click()}
}

// ·¹ÀÌ¾î º¸±â
function LayerView(layer) {
	if(document.getElementById(layer)) 	document.getElementById(layer).style.display = "block";
}

// ·¹ÀÌ¾î ´Ý±â 
function LayerClose(layer) {
	if(document.getElementById(layer)) 	document.getElementById(layer).style.display = "none";
}

// flash
function printFlashObject(flash_src,name,width,height,option_param_tag, vars){
	obj_html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+width+"' height='"+height+"' id='"+name+"' align='middle'>\
	<param name='allowScriptAccess' value='always' />\
	<param name='movie' value='"+flash_src+"' />\
	<param name='quality' value='high' />\
	<param name='bgcolor' value='#ffffff' />\
	<param name='wmode' value='transparent'>\
	<param name='menu' value='false'>";
	obj_html = obj_html + option_param_tag;
	obj_html = obj_html + "<embed src='"+flash_src+"' quality='high' bgcolor='#ffffff' width='"+width+"' height='"+height+"' name='"+name+"' wmode='transparent' FlashVars='"+vars+"' allowscriptaccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	obj_html = obj_html + "</embed></object>";
	document.write(obj_html);
}

// ¹Ìµð¾îÇÃ·¹ÀÌ¾î ½ºÅ©¸³Æ®
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);
}





//replaceselect ------------------------------------------------------------

function OnloadReplace() {  
	clearReplace();
  GetReplaceSelects();
}

//select box ¹è¿­°ú Ä¡È¯ÇÒ Æ¯Á¤ className ¼³Á¤
//sslectBasicÀ» ±âº»À¸·Î, ÁöÁ¤µÈ class°¡ ¿À´Â °æ¿ì¿¡¸¸ select DIV Ä¡È¯À» ½ÇÇà
var REPLACE_SELECTS = new Array();
var REPLACE_SELECTS_CLASSNAME = new Array("SelectBasic","SelectPopup","SelectMoney","SelectType1","SelectType2","SelectType3");

function clearReplace() {
	if(REPLACE_SELECTS != null) {
		for(i=0; i<REPLACE_SELECTS.length; i++) {
			document.getElementById('selectDIV'+i).removeNode(true);
			document.getElementById('optionsDiv'+i).removeNode(true);
		}
		REPLACE_SELECTS = new Array();
	}
}

//Ä¡È¯ÇÒ select¹Ú½º ¼±º°
function GetReplaceSelects() {
   
  //ÆäÀÌÁö³» ¸ðµç selectbox, textarea
  var GetAllSelects = document.getElementsByTagName('select');
  
  var 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();
}

//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.id = "selectDIV"+i;
    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';
		
		
		if (REPLACE_SELECTS[i].disabled == true) {
			selectArea.className += " SelectDisable";
			//textArea.disabled = true;
			textArea.href = '#';
		}
  }
}

// ¿É¼Ç 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;
}


// select replace ============================================

function OnloadReplace() {  
	clearReplace();
  GetReplaceSelects();
}

//select box ¹è¿­°ú Ä¡È¯ÇÒ Æ¯Á¤ className ¼³Á¤
//sslectBasicÀ» ±âº»À¸·Î, ÁöÁ¤µÈ class°¡ ¿À´Â °æ¿ì¿¡¸¸ select DIV Ä¡È¯À» ½ÇÇà
var REPLACE_SELECTS = new Array();
var REPLACE_SELECTS_CLASSNAME = new Array("SelectBasic","SelectPopup","SelectMoney","SelectType1","SelectType2","SelectType3");

var REPLACE_TEXTAREAS = new Array();
var REPLACE_TEXTAREAS_CLASSNAME = new Array("TextareaBasic");


function clearReplace() {
	if(REPLACE_SELECTS != null) {
		for(i=0; i<REPLACE_SELECTS.length; i++) {
			document.getElementById('selectDIV'+i).removeNode(true);
			document.getElementById('optionsDiv'+i).removeNode(true);
		}
		REPLACE_SELECTS = new Array();
	}
}

//Ä¡È¯ÇÒ select¹Ú½º ¼±º°
function GetReplaceSelects() {
   
  //ÆäÀÌÁö³» ¸ðµç selectbox, textarea
  var GetAllSelects = document.getElementsByTagName('select');
  
  var 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();
}

//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.id = "selectDIV"+i;
    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';
		
		
		if (REPLACE_SELECTS[i].disabled == true) {
			selectArea.className += " SelectDisable";
			//textArea.disabled = true;
			textArea.href = '#';
		}
  }
}

// ¿É¼Ç 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;
}
// end of select replace =============================


if (typeof(addOnloadHandle)!="undefined") {
  addOnloadHandle("OnloadReplace()");
}
else {
  window.onload = OnloadReplace;
}

function go_home()
{
  document.location.href = "http://bfo.pmang.com/bfo_home.nwz";
}

function go_menu(param1,param2)
{
    document.location.href = 'http://bfo.pmang.com/bfo_frame.nwz?mKey='+param1+'&sKey='+param2;
}

function join_poll()
{
    document.form_poll.result.value = "Y";
    var chk_cnt = 0;
    document.form_poll.quest_srl.value = "";

    for (i=0;i<document.form_poll.poll_art.length;i++)
    {
      if (document.form_poll.poll_art[i].checked == true)
      {
        document.form_poll.quest_srl.value = document.form_poll.quest_srl.value + document.form_poll.poll_art[i].value + "/";
        chk_cnt++;
      }
    }

    if (chk_cnt == 0)
    {
      document.form_poll.quest_srl.value = "";
      alert("¼³¹®Ç×¸ñÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
      return;
    }

    document.form_poll.target = "virtual_board_fr";
    document.form_poll.action = "http://bfo.pmang.com/gamepub/board/board_poll_join_proc.nwz";
    document.form_poll.submit();
}

function goResultPoll()
{
    var arrParam = new Array();
    var oAjax = new Ajax();
    var result = oAjax.sendRequest( "http://bfo.pmang.com/bfo_poll.nwz", arrParam, "GET", "", "TEXT", true);
    document.all["poll_list"].innerHTML = result;
    document.all["poll_list"].style.display = 'block';
}

function goPolicy()
{
   window.open('http://file.pmang.kr/images/pmang/gamepub/police/bfo.html#7', '_policy', 'width=670,height=495,resizable=no,scrollbars=no,scrolling=no' );
}

function viewScreenshot(type)
{
  if ( type == 1 )
   window.open('http://file.pmang.com/images/pmang/bfo/cb/popup1.html', '_sc', 'width=540,height=380,resizable=no,scrollbars=no,scrolling=no' );
  else
   window.open('http://file.pmang.com/images/pmang/bfo/cb/popup2.html', '_sc', 'width=540,height=380,resizable=no,scrollbars=no,scrolling=no' );  
}

function popTester()
{
   window.open('http://mm.pmang.com/pmang/bfo/event/20090316/index.html', '_tester', 'width=790,height=580,resizable=no,scrollbars=no,scrolling=no' );
}

function openGuide(mKey,sKey)
{
   window.open('http://file.pmang.com/images/pmang/bfo/cb/guide/guide'+mKey+'_'+sKey+'.html', 'popGuide', 'width=897,height=637,resizable=no,scrollbars=no,scrolling=no' );
}

// Æ®·¹ÀÏ·¯ ÆË¾÷
function popTrailer(){
	window.open('http://file.pmang.com/images/pmang/bfo/cb/vod.html', 'trailer', 'width=720,height=574,resizable=no,scrollbars=no,scrolling=no' );
}

function popTesterCheck(){
	window.open('http://bfo.pmang.com/bfo_tester_search.nwz', 'search', 'width=350,height=200,resizable=no,scrollbars=no,scrolling=no' );
}

function popPoll(){
	window.open('http://bfo.pmang.com/gamepub/gamepub_poll_list.nwz?ssn=330&p_serial=52', 'poll', 'width=350,height=400,resizable=no,scrollbars=no,scrolling=no' );
}

function popMailing(){
	window.open('http://bfo.pmang.com/bfo_newsletter.nwz', 'mailing', 'width=415,height=480,resizable=no,scrollbars=no,scrolling=no' );
}

function popOpener(url,widths,heights){
  var param = "width = "+widths+", height="+heights+"resizable=no,scrollbars=no,scrolling=no";
	window.open(url, '_pop', param );
}

function bfo_begin_game()
{
 document.location.href = 'http://bfo.pmang.com/gamepub/game_running.nwz?ssn=330';
}

function bfo_finish_game()
{
    execGameEndProc(330);
}



