
if (!gamepub) var gamepub = new function() {};

//




//ÆË¾÷Ã¢À» ¶ç¿ì±âÀü »ç¿ëÀÚÀÇ ÄíÅ°¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö
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 "";
}

// expire´Â ÀÏ´ÜÀ§
function setCookie(name,value,expire)
{
  var ExpDate = new Date();

  if (typeof(expire) == "undefined")
  {
    ExpDate.setDate(ExpDate.getDate() + 1);
  }
  else
  {
    ExpDate.setDate(ExpDate.getDate() + expire);
  }

  document.cookie = name + "=" + escape(value) + "; path=/; expires=" + ExpDate.toGMTString() + ";"
}


function print_user_info_div_layer()
{
  layer = eval("document.all.pub_user_popup");
  frame = eval("document.all.virtual_user_popup_fr");

  if (typeof(layer) == "undefined")
    document.body.insertAdjacentHTML("afterBegin", "<div id='pub_user_popup' style='position:absolute;visibility:hidden;z-index:100;'></div>");

  if (typeof(layer) == "undefined")
    document.body.insertAdjacentHTML("afterBegin", "<iframe src='http://"+document.location.hostname+"/guild/virtual_frame.nwz' width=0 height=0 name='virtual_user_popup_fr' style='display:none'></iframe>");
}


function print_user_popup(ssn, usn)
{
  print_user_info_div_layer();
  document.all["pub_user_popup"].innerHTML = "";
  document.all["pub_user_popup"].style.visibility = "visible";

  this.sz_top  = parseInt(document.body.scrollTop + event.clientY - 5);
  this.sz_left = parseInt(document.body.scrollLeft + event.clientX - 5);

  var oAjax = new Ajax();

  var arrParam = new Array();
  arrParam["ssn"] = ssn;
  arrParam["usn"] = usn;

  oAjax.sendRequest("http://"+document.location.hostname+"/gamepub/gamepub_get_user_popup.nwz", arrParam, "GET", "print_user_popup.print", "TEXT", false);

  function print_user_popup.print(data)
  {
    arrResult = data.split("");

    var html = arrResult[1];

    //alert(data);

    document.all["pub_user_popup"].innerHTML = html;

    if ((document.body.scrollHeight - sz_top) < document.all["pub_user_popup"].scrollHeight)
      document.all["pub_user_popup"].style.top = document.body.scrollHeight - document.all["pub_user_popup"].scrollHeight - 5;
    else
      document.all["pub_user_popup"].style.top = sz_top;

    if ((document.body.scrollWidth - sz_left) < document.all["pub_user_popup"].scrollWidth)
      document.all["pub_user_popup"].style.left = document.body.scrollWidth - document.all["pub_user_popup"].scrollWidth - 5;
    else
      document.all["pub_user_popup"].style.left = sz_left;
  }
}

function hide_user_popup_menu()
{
  document.all["pub_user_popup"].style.visibility = "hidden";
}
function view_user_popup_menu()
{
  document.all["pub_user_popup"].style.visibility = "visible";
}


function openNewWindow(url)
{
  window.open( url );
}

function resize_contents(frame)
{
  if (parent.resize_frame != "undefined")
  {
    addOnloadHandle("parent.resize_frame('"+frame+"')");
    setTimeout("parent.resize_frame('"+frame+"')", 1500);
  }
}

// ´Ù¿î·Îµå ¸µÅ© °ü¸®¿¡¼­ ½ÇÇà ÆÄÀÏ ¸µÅ©½Ã 2008-06-19 modified by iprid123
function goDownloadLink(url) {
  // document.location.href = url;   // ½ÇÇàÆÄÀÏ, ¸µÅ© ¸ðµÎ °¡´É
  var downLinkWin = window.open(url , "downwin", "");


}

var layer_popup_index = 0;
var posX = 0;
var posY = 0;
var move_index = 0;
var layer_zindex = 99999;
var runtime = true;


function open_layer_popup(ssn,popupid,src,top,left,width,height)
{
	var nssn = parseInt( ssn );
	var cook = getCookie(popupid);
  if ( 
		(ssn>0 && cook!=popupid) || 
		(ssn==0 && cook!='Y') 
	)
  {
    layer_popup_index++;

    var str_html = "";

    if (width == 0 || height == 0)
      auto_resize = "onload='resize_frame(\"pub_layer_iframe_"+layer_popup_index+"\")";
    else
      auto_resize = "";

    str_html = str_html + "<div id='cmPopAlign'>";
    str_html = str_html + "<div id='pub_layer_popup_"+layer_popup_index+"' style='position:absolute;top:"+top+";left:"+left+";z-index:"+layer_zindex+";'>";
    str_html = str_html + "  <div class='cmPop' onmousedown='layer_popup_move_start(\""+layer_popup_index+"\");' onmouseup='layer_popup_move_end(\""+layer_popup_index+"\");'>";
    str_html = str_html + "    <div class='rb'></div><div class='lb'></div><div class='rt'></div><div class='lt'></div>";
    str_html = str_html + "    <div class='cmTop'>";
//    str_html = str_html + "      <h1></h1>";
		if( nssn > 0 )
//    str_html = str_html + "      <h2></h2>";
//    str_html = str_html + "      <div class='x'><a><img src='/images/popup/btn_x.gif' onclick='close_layer_popup(\""+layer_popup_index+"\");'></a></div>";
    str_html = str_html + "    </div>";
    str_html = str_html + "    <div class='cmBanner'><iframe src='"+src+"' id='pub_layer_iframe_"+layer_popup_index+"' name='pub_layer_iframe_"+layer_popup_index+"' marginwidth='0' hspace='0' vspace='0' frameborder='0' style='margin:0px;' scrolling='no' allowTransparency='true' "+auto_resize+";'></iframe></div>";
    str_html = str_html + "    <div class='cmFoot'>";
		if( nssn > 0 )
    str_html = str_html + "      <a class='today'><img src='/images/popup/btn_today_o.gif' alt='¿À´Ã ÇÏ·çµ¿¾È ÀÌ Ã¢À» ¿­Áö ¾Ê½À´Ï´Ù.' onclick='setCookie(\""+popupid+"\",\""+popupid+"\",1);close_layer_popup(\""+layer_popup_index+"\")'></a>";
    else 
		str_html = str_html + "      <a class='today'><img src='/images/popup/btn_today_o.gif' alt='¿À´Ã ÇÏ·çµ¿¾È ÀÌ Ã¢À» ¿­Áö ¾Ê½À´Ï´Ù.'onclick='setCookie(\""+popupid+"\",\"Y\",1);close_layer_popup(\""+layer_popup_index+"\")'></a>";
    str_html = str_html + "      <a class='close'><img src='/images/popup/btn_close.gif' alt='´Ý±â' onclick='close_layer_popup(\""+layer_popup_index+"\");'></a>";
    str_html = str_html + "    </div>";
    str_html = str_html + "  </div>";
    str_html = str_html + "</div>";
    str_html = str_html + "</div>";

    document.body.insertAdjacentHTML("afterBegin", str_html);

    if (width > 0 && height > 0)
    {
      var o_frame = document.all("pub_layer_iframe_"+layer_popup_index);
      o_frame.style.width = width;
      o_frame.style.height = height;
    }

    layer_zindex++;
  }
}


function layer_popup_move(obj)
{
  if (move_index <= 0)
    return;

  objLayerPopup = document.getElementById("pub_layer_popup_"+move_index);

  objLayerPopup.style.left = posX + event.clientX;
  objLayerPopup.style.top = posY + event.clientY;

  return false;
}

function layer_popup_move_start(index)
{
  objLayerPopup = document.getElementById("pub_layer_popup_"+index);
  objLayerPopup.style.zIndex = layer_zindex;
  layer_zindex++;
  move_index = index;
  posX = parseInt(objLayerPopup.style.left) - event.clientX;
  posY = parseInt(objLayerPopup.style.top) - event.clientY;

  document.onmousemove = layer_popup_move;
}

function layer_popup_move_end(index)
{
  move_index = 0;
}

function close_layer_popup(index)
{
  objLayerPopup = document.getElementById("pub_layer_popup_"+index);
  objLayerPopup.innerHTML = "";
  objLayerPopup.style.display = "none";
}

