﻿function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}



function ck(v){document.body.className=v;}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var ctl_name = 'ctl00_ContentPlaceHolder1_';	
	
function getObject(elementId) { 
    if (document.getElementById) 
        { return document.getElementById(elementId);}
    else if (document.all) { 
        return document.all[elementId];}
    else if (document.layers) {
        return document.layers[elementId];}
    }
    
    function getCookie(name) {
    var flag = document.cookie.indexOf(name + '=');
    if (flag != -1) {
        flag += name.length + 1;
        end = document.cookie.indexOf(';', flag);
        if (end == -1) end = document.cookie.length;
        return document.cookie.substring(flag, end);
    }
    else {
        return "";
    }
}
    
    
    function setCookie(name, value) {
    var MinMilli = 1000 * 60;
    var HrMilli = MinMilli * 60;
    var DyMilli = HrMilli * 24;

    var todayDate = new Date();
    todayDate.setTime(Math.round(todayDate.getTime() / DyMilli + 1) * DyMilli); // 1day
    document.cookie = name + "=" + escape(value) + "; expires=" + todayDate.toGMTString() + ";"
}



// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value) {
    this.strings = new Array("");
    this.append(value);
}

// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function(value) {
    if (value) {
        this.strings.push(value);
    }
}

// Clears the string buffer
StringBuilder.prototype.clear = function() {
    this.strings.length = 1;
}

// Converts this instance to a String.
StringBuilder.prototype.toString = function() {
    return this.strings.join("");
}

String.prototype.bytes = function() {
    var str = this;
    var c = 0;
    for (var i = 0; i < str.length; i++) {
        c += (str.charCodeAt(i) > 128) ? 2 : 1;
    }
    return c;
}


function create_div(target_id) {
    if (getObject(target_id) == null) {
        var NewDiv = document.createElement("Div");
        NewDiv.id = target_id;
        NewDiv.width = NewDiv.height = 0;
        NewDiv.style.display = 'none';
        document.body.appendChild(NewDiv);
    }
}

function _goto(url) {

    if (url == "gamehi") {
        location.href = '/etc/pop_gamehi.aspx';
    }
    else if (url == "invitation") {
        location.href = '/etc/invitation.aspx';
    }
    else {
        location.href = '/clanwar/sa_invitation.aspx#bt_invitation_layout';
    }
}

function create_poplayer(o_id, title, _left, _top, width, height, m_img,m_name, m_crs, url, m_crs2, url2) {
    var sb = new StringBuilder();
    sb.append('<div class="div_container" style="width:' + width + 'px">');    
    sb.append('<div style="background:url(\'' + IMG_URL + '/popup/top_bg1.jpg\');width:' + (width * 1) + 'px; repeat-x left; height:32px;">');
    sb.append('<div style="float:left"><img src="' + IMG_URL + '/popup/logo.jpg" style="margin:10px 10px;"></div>');
    sb.append('<div style="float:left;font-weight: bold;padding-top:9px">' + title + '</div>');
    sb.append('<div style="padding:7px 7px 0 0" align="right"><img src="' + IMG_URL + '/popup/btn_close_top.jpg"  onclick="close_poplayer(\'' + o_id + '\')" class="pointer"></div>');
    sb.append('</div>');
    sb.append('<div style="width:100%; background-color:white; height:' + height + 'px; text-align:center;">');
    sb.append('<img src="' + IMG_URL + m_img + '" border="0" usemap="#'+m_name+'" alt="" />');
    sb.append('<map name="'+m_name+'">');
    sb.append('<area shape="rect" coords="' + m_crs + '" href="javascript:_goto(\'' + url + '\');" alt="자세히 보기">');
    sb.append('<area shape="rect" coords="' + m_crs2 + '" href="javascript:_goto(\'' + url2 + '\');" alt="자세히 보기">');
    sb.append('</map>');
    sb.append('</div>');    
    sb.append('<div style="background:url(' + IMG_URL + '/popup/bottom_bg.jpg); clear:both; width:' + (width * 1) + 'px; repeat-x left; height:32px">');    
    sb.append('<div align="right"><img src="' + IMG_URL + '/popup/btn_close_bottom.jpg" border="0" onclick="close_poplayer(\'' + o_id + '\')" class="pointer"  style="margin:4px 7px 0 0;cursor:pointer;"></div>');
    sb.append('</div>');
    sb.append('</div>');    
    create_div(o_id)    
    $("#" + o_id).css({ width: (width * 1 + 10) + "px", height: (height * 1 + 63) + "px", display: "", position: "absolute", left: _left + "px", top: _top + "px", "z-index": "999", "margin-left": (-502 + _left) + "px" });
    $("#" + o_id).html(sb.toString());
    $("#" + o_id).draggable({ containment: '#div_main', scroll: false });

}

function close_poplayer(id) {
    $("#" + id).css("display", "none");
}


