﻿// JScript 파일

var popup_data;
var popup_name;
var popup_code;

function create_poplayer(o_id,title,content,left,top,width,height)
{
	var sb = new StringBuilder();
    sb.append('<style type="text/css">');
    sb.append('<!--');
    sb.append('img {border:none}');
    sb.append('.style5 {color: #525252; font-size:12px; font-family:돋움; text-align:left; font-weight:bold; letter-spacing:-1px; padding-top:2px; }');
    sb.append('.stop { color:#CCCCCC; font-size:12px; font-family:돋움; text-align:left; }');
    sb.append('-->');
    sb.append('</style>');
	
	sb.append("<table border='0' cellpadding='0' cellspacing='0' >");
    sb.append("<tr>");
    sb.append("<td>");
    sb.append("<table width='100%' border='0' cellpadding='0' cellspacing='0'>");
    sb.append("<tr>");
    sb.append("<td width='2' style='background:url("+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg1_left.jpg) no-repeat;' nowrap></td>");
    sb.append("<td width='100%' height='28' style='background:url("+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg1_center.jpg) repeat-x;; padding-top:2px;'>");
    sb.append("<table border='0' cellpadding='0' cellspacing='0' >");
    sb.append("<td width='12' nowrap></td>");
    sb.append("<td><img src='" + _IMG_URL + "/images/news/event/090422_4th/images/popup/logo.gif' /></td>");
    sb.append("<td width='8' nowrap></td>");
    sb.append("<td width='5'><img src='" + _IMG_URL + "/images/news/event/090422_4th/images/popup/vetical_line.jpg' /></td>");
    sb.append("<td width='9' nowrap></td>");
    sb.append("<td width='100%' class='style5'>DEKARON 4TH Anniversary Festival</td>");
    sb.append("<td width='28' align='right' style='padding-right:9px;'><a href='javascript:close_poplayer(\"div_"+o_id+"\")'><img src='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/btn_close_top.jpg' /></a></td>");
    sb.append("</table>");
    sb.append("</td>");
    sb.append("<td width='3' style='background:url("+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg1_right.jpg) no-repeat;' nowrap></td>");
    sb.append("</tr>");
    sb.append("<tr>");
    sb.append("<td width='2' height='9' style='background:url("+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg2_left.jpg) no-repeat;' nowrap></td>");
    sb.append("<td width='100%'  background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg2_center.jpg' style='background-repeat:repeat-x;'></td>");
    sb.append("<td width='2'  background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/top_bg2_right.jpg' style='background-repeat:no-repeat;' nowrap></td>");
    sb.append("</tr>");
    sb.append("</table>");
    sb.append("</td>");
    sb.append("</tr>");
    sb.append("<tr>");
    sb.append("<td href='/app/news/news_event/news_event_detail/090422_4th/intro.aspx'>");
    sb.append("<table width='100%'  border='0' cellpadding='0' cellspacing='0'>");
    sb.append("<tr>");
    sb.append("<td><a href='/app/news/news_event/news_event_detail/090422_4th/intro.aspx'><img src='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/popup_4th_img.jpg' border='0' /></a></td>");
    sb.append("</tr>");
    sb.append("</table>");
    sb.append("</td>");
    sb.append("</tr>");
    sb.append("<tr>");
    sb.append("<td>");
    sb.append("<table width='100%' border='0' cellpadding='0' cellspacing='0' >");
    sb.append("<tr>");
    sb.append("<td width='3' background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/bottom_bg_left.jpg' style='background-repeat:no-repeat;' nowrap></td>");
    sb.append("<td align='left' valign='top' background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/bottom_bg_center.jpg'   height='32' width='50%' style='padding:10px 0px 0px 8px; background-repeat:repeat-x; ' class='stop' ><a href='javascript:close_today(\"div_"+o_id+"\")'>오늘은 이 팝업 그만보기</td>");
    sb.append("<td align='right' valign='top' background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/bottom_bg_center.jpg'   height='32' width='50%' style='padding:4px 4px 0px 0px; background-repeat:repeat-x;' ><a href='javascript:close_poplayer(\"div_"+o_id+"\")'><img src='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/btn_close_bottom.jpg' /></a></td>");
    sb.append("<td width='3' background='"+_IMG_URL+"/images/news/event/090422_4th/images/popup/bottom_bg_right.jpg' style='background-repeat:no-repeat;' nowrap></td> ");
    sb.append("</tr>");
    sb.append("</table>");
    sb.append("</td>");
    sb.append("</tr>");
    sb.append("</table>");
    
	
	create_div("div_"+o_id)
	$("#div_"+o_id).css({width:width+"px", height:height+"px", display:"", position:"absolute",left:"50%",top:top+"px","z-index":"99999","margin-left":(-502+left)+"px"});
	$("#div_"+o_id).html(sb.toString());
	//$("#div_"+o_id).draggable();
}

function close_poplayer(id)
{
	$("#"+id).css("display","none");
}

function close_today(id)
{
	setCookie(id, "done");
	close_poplayer(id);
}

function openlayer(o_id)
{
	if(o_id=="20090423")
	{
		$.get("/common/getcookie.ashx", {name: "div_"+o_id}, function(data){
			if(data!="done")
			{
				create_poplayer(o_id,"DEKARON 4TH Anniversary Festival",data.html,10,36,400,500);
			}
		});
	}
}

//loginCheck

function mainPageLogInCheck()
{
	if (is_login)
	{
		Open_WIndow(_SecureUrl + '/app/pop/pop_coupon/main.aspx?gamesite=DKR&gameservice=PM', 'coupon_pop', '450', '460');
	}
	else
	{
		if (confirm("로그인이 필요한 서비스입니다.\r\n로그인 하시겠습니까?"))
		{
			window.location.href = _SecureUrl + "/App/member/member_login/member_login_form.aspx?ret_url=" + escape(location);
		}
	}
}


var time_flag = false;
var time_flag_update = false;
var i_play = 0;
var i_update_play = 0;
var i_debate_play = 0;

function tabauto (type,my_select)
{
  if(type == "update")
  {
        switch (my_select)
        {
            case "start" :          
                time_flag_update = true;
                time_id_update = setInterval("tabauto_s_update()", 5000);
            break;

            case "end" :
                if (time_flag_update == true)
                {
                    clearInterval(time_id_update);
                    time_flag_update=false;
                }
            break;
        }
  }
  else if(type == "debate")
  {
        switch (my_select)
        {
            case "start" :          
                time_flag = true;
                time_id = setInterval("tabauto_s()", 5000);
            break;

            case "end" :
                if (time_flag == true)
                {
                    clearInterval(time_id);
                    time_flag=false;
                }
            break;
        }
  }
  
}
function tabauto_s()
{
    display_show('debate',i_debate_count,'right');
}
function tabauto_s_update()
{
    display_show('update',i_count,'right');
}
function display_show(type, cnt , position)
{
    var s_str = "";
    var i_count = 0;
    if(type == "update")
    {
        i_play = i_update_play;
    }
    else
    {
        i_play = i_debate_play;
    }
    
    for(var i=0 ; i< cnt ; i++)
    {
        $("#"+type + "_" +i).css("display","none");
    }
    
    if(position == "right")
    {
        i_play = i_play + 1;
        if(i_play >= cnt)
        {
            i_play = 0;
        }
    }
    else if(position == "left")
    {
        i_play = i_play - 1;
        if(i_play < 0 )
        {
            if(cnt > 0)
            {
                i_play = cnt - 1;
            }
            else
            {
                i_play = 0;
            }
            
        }
        
    }
    else
    {
        i_play = i_play;
    }
 
    $("#"+type + "_" + i_play).css("display","block");
    
    if(type == "update")
    {
        i_update_play = i_play;
    }
    else
    {
        i_debate_play = i_play;
    }
}

function tab_Click(type, position)
{
    if(type == "update")
    {
        display_show(type, i_count , position)
    }
}


function _popupdata()
{
		$.ajax({
			type: "GET"
		,	url: "/common/popup_banner.ashx"
		,	dataType: "json"
		,	async: false
		,	cache: false
		,	success: function(data){
					var rand = Math.floor(Math.random()*data.length);
					popup_name=data[rand].eventname;
					popup_code=data[rand].eventcode;
					var sb = new StringBuilder();
					sb.append("<img src='" + C_POPUP_XML_IMAGE_URL+'/' +data[rand].imgname+"' border='0' usemap='#Map' alt='"+data[rand].alt+"' />");
					sb.append("<map name='Map' id='Map'>");
					sb.append(data[rand].link);
					sb.append("</map>");
				
					popup_data=sb.toString();
					
					create_poplayer(popup_code, popup_name, popup_data, 50, 38, data[rand].width,data[rand].height);


	
			}
		,	error: function(XMLHttpRequest, textStatus, errorThrown){
//				alert(textStatus);
			}
		});	
}

function create_poplayer(o_id,title,content,_left,_top,width,height)
{
	if(getCookie(o_id) == "done")
	{
	return;
	}

	var sb = new StringBuilder();
	sb.append('<div 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 class="fl"><img src="'+ IMG_URL +'/popup/logo_deka.gif" style="margin:0 10px;"></div>');
	sb.append('<div class="title_t fl" style="padding-top:7px">'+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(content);
	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 style="float:left; position:relative; padding:7px 0 0 15px"><span onclick="close_today(\''+o_id+'\')" style="color: #000000; text-decoration: underline; font-size: 12px; font-family: dotum;text-align: left;" class="pointer">오늘은 이 창 그만보기</span></div>');
	sb.append('<div align="right"><a href="#"><img src="'+ IMG_URL +'/popup/btn_close_bottom.jpg" border="0" onclick="close_poplayer(\''+o_id+'\')" class="pointer"  style="margin:4px 7px 0 0"></a></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+"%",top:_top+"px","z-index":"999","margin-left":(-502+_left)+"px"});
	$("#"+o_id).html(sb.toString());	
	$("#"+o_id).draggable({ containment: '.main_bg', scroll: false });

}


//function create_poplayer2(o_id,left,top,width,height)
//{
////	if(getCookie("popup_20100111") == "done")
////	{
////	return;
////	}

//	var _url="/App/world/world_serverboard/world_serverboard_main_view_01.aspx";
//	var sb = new StringBuilder();
//	sb.append('<div style="width:'+width+'px">');
//	sb.append('<div style="background:url('+ IMG_URL +'/popup/top_bg1.jpg) no-repeat; height:32px">');
//	sb.append('<div class="fl"><img src="'+ IMG_URL +'/popup/logo_deka.gif" style="margin:0 10px;"></div>');
//	sb.append('<div class="title_t fl" style="padding-top:7px">불법 프로그램 근절 캠페인</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='http://tmfiledekaron.gamehi.co.kr/UPLOAD/popup/popup_campaign.gif' border='0' usemap='#Map' alt='' />");
//	sb.append("<map name='Map' id='Map'>");
//	sb.append('<area shape="rect" coords="349,155,485,178" href="'+_url+'"  alt="보급품 자세히보기">');
//	sb.append('<area shape="rect" coords="141,440,363,474" href="'+_url+'"  alt="불법 프로그램 사용 제재자 명단">');
//	sb.append('<area shape="rect" coords="130,397,250,410" href="mailto:dekaron@gamehi.net" target="_blank" alt="데카론 이메일">');
//	sb.append("</map>");
//	sb.append('</div>');
//	sb.append('<div style="background:url('+ IMG_URL +'/popup/bottom_bg.jpg) no-repeat; clear:both; height:32px">');
//	sb.append('<div style="float:left; position:relative; padding:7px 0 0 15px"><span onclick="close_today(\''+o_id+'\')" style="color: #000000; text-decoration: underline; font-size: 12px; font-family: dotum;text-align: left;" class="pointer">오늘은 이 창 그만보기</span></div>');
//	sb.append('<div align="right"><a href="#"><img src="'+ IMG_URL +'/popup/btn_close_bottom.jpg" border="0" onclick="close_poplayer(\''+o_id+'\')" class="pointer"  style="margin:4px 7px 0 0"></a></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:"50%",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 create_poplayer2(o_id,title,_left,_top,width,height)
{
	if(getCookie(o_id) == "done")
	{
		return;
	}

	var sb_content = new StringBuilder();
	sb_content.append('<table border="0" cellpadding="0" cellspacing="0">');
	sb_content.append('<tr>');
	sb_content.append('<td><img src="'+ IMG_URL +'/news/event/20100211_popup/bg_left.gif"></td>	');
	sb_content.append('<td>');
	sb_content.append('<div><img src="'+ IMG_URL +'/news/event/20100211_popup/20100211_pop.jpg" border="0" usemap="#view">');
	sb_content.append('<map name="view" id="view">');
	sb_content.append('<area shape="rect" coords="135,530,383,558" href="/App/news/news_notice/news_notice_list.aspx?notice_no=10020800000000000004&rn=1970" alt="데카론 게임실행 방법 자세히 보기">');
	sb_content.append('</map>');
	sb_content.append('</div>');
	sb_content.append('<td><img src="'+ IMG_URL +'/news/event/20100211_popup/bg_right.gif">');
	sb_content.append('</tr>');
	sb_content.append('</table>');
	
	var content=sb_content.toString();




	var sb = new StringBuilder();
	sb.append('<div 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 class="fl"><img src="'+ IMG_URL +'/popup/logo_deka.gif" style="margin:0 10px;"></div>');
	sb.append('<div class="title_t fl" style="padding-top:7px">'+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(content);
	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 style="float:left; position:relative; padding:7px 0 0 15px"><span onclick="close_today2(\''+o_id+'\')" style="color: #000000; text-decoration: underline; font-size: 12px; font-family: dotum;text-align: left;" class="pointer">다음부터 이 창 띄우지 않기</span></div>');
	sb.append('<div align="right"><a href="javascript:close_poplayer(\''+o_id+'\')"><img src="'+ IMG_URL +'/popup/btn_close_bottom.jpg" border="0" style="margin:4px 7px 0 0"></a></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:"50%",top:_top+"px","z-index":"999","margin-left":(-502+_left)+"px"});
	$("#"+o_id).html(sb.toString());	
	$("#"+o_id).draggable({ containment: '.main_bg', scroll: false });
	

}

function close_today2(id)
{
	setCookie2(id, "done");
	close_poplayer(id);
}

function setCookie2(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*10);// 1day
	document.cookie = name + "=" + escape( value ) + "; expires=" + todayDate.toGMTString() + ";"
}