﻿var pinCode = ""

function worldcupCode(c){
 
if(!confirm("코드 입력 후 즉석 추첨으로 4등(맥도날드 쿠폰)에 당첨될 경우\n반드시 바로 출력하셔야 합니다.\n\n현재 PC에 쿠폰 출력을 위한 프린터기가 준비되어 있지 않으시면 \n프린터기가 준비된 PC에서 코드를 입력하시기 바랍니다.\n\n확인 버튼을 누르면 즉석 추첨이 진행됩니다.\n계속 진행하시겠습니까?")){
	return;
}


var code = c;
if (code == undefined){
	 code = $("input#pinCode").val();
}
code = code.replace(/\s/g,"");
if (code.length != 10){
alert("잘못된 코드입니다.\n다시 확인 후 입력해 주세요.");
return;
}



//로딩이미지...
$("div#loding_div").show();
$.post("/event/1002_WorldcupPincode.aspx", {"code" : code},function(data){
//alert(data);

switch(data){
	case "-1":
		loginpop();
	break;
	case "0":
		$("div#loding_div").hide();
		alert("잘못된 코드입니다.\n다시 확인 후 입력해 주세요.");
	break;
	case "1":
		$("div#loding_div").hide();
		alert("이미 등록된 코드 입니다.\n다시 확인 후 입력해 주세요.");
	break;
	case "2":
		$("div#loding_div").hide();
		alert("이미 등록된 코드 입니다.\n다시 확인 후 입력해 주세요.");
		//논리적으로 나오면 안됨;
	break;

	case "win_00":
		$("div#loding_div").hide();
		alert("사용자가 많아 이벤트를 진행할 수 없습니다.\n잠시 후 다시 이용해 주시기 바랍니다.");
		//논리적으로 나오면 안됨;
	break;

	case "win_1":
		//alert("1등 당첨!!!");
	    $("div#worldCup_pop").html("").load("/popup/world_cup01.html").show();
 	break;

	case "win_2":
		//alert("2등 당첨!!!");
		$("div#worldCup_pop").html("").load("/popup/world_cup02.html",null,function(){initialPinCodeForm();}).show();
 	break;

	case "win_3":
		//alert("3등 당첨!!!");
		$("div#worldCup_pop").html("").load("/popup/world_cup03.html",null,function(){initialPinCodeForm();}).show();
 	break;

	case "win_4":
		//alert("4등 당첨!!!");
		$("div#worldCup_pop").html("").load("/popup/world_cup04.html",null,function(){initialPinCodeForm();}).show();
		pinCode = code;
 	break;

	case "win_0":
		//alert("다음 기회에...");
		$("div#worldCup_pop").html("").load("/popup/world_cup05.html",null,function(){initialPinCodeForm();}).show();
		
 	break;
}

//로딩이미지 안보이기
$("div#loding_div").hide();
});

}

$(function(){
 initialPinCodeForm();
});

function initialPinCodeForm()
{
	$("input#pinCode").val("제품코드 입력");
 

	$("input#pinCode").keydown(function(ev){
		if(ev.keyCode == "13"){
			worldcupCode();
		}
	});
	$("input#pinCode").focus(function(ev){
		if (this.value == "제품코드 입력" ){
			this.value = "";
		}
	});

}

function worldcupWinner()
{

	window.open("/popup/southafrica_winnerList.html","popup", "width=511, height=555; status=0,resizable=1").focus();
}

// 1010603 추가
function worldcupsongdown()
{

$("div#worldCup_pop").html("").load("/popup/worldcup_song_100603.html").show();

//	window.open("/popup/worldcup_song_100603.html","popup_worldcup_song", "width=605, height=441; status=0,resizable=1").focus();
}

function worldcupsongclose(){
	$("div#worldCup_pop").html("").hide();
}





function otherEvent()
{

	alert("서비스 준비중입니다.");
}

function printCoupon()
{
	window.open("/event/1002_WorldCup_coupon.aspx?code="+pinCode,"wc_coupon","width=446; height=582; resizable=1").focus();

}

$(function(){
 // window.open("/popup/inpin_helper.html","popup1","width=528, height=585, status=0, left=0, top=0");

// window.open("/popup/event_suprise_winnerlist.html","popup2","width=511, height=635, status=0, left=570,top=0");

// window.open("/popup/service_stop.html","popup3","width=499, height=387, status=0, left=777, top=0");

// window.open("/popup/winnerlist_coke_100408.html","popup_coke","width=511, height=615, status=0, left=535, top=0"); //2010.05.06 까지

// window.open("/popup/winnerlist_ipad_100408.html","popup_ipad","width=471, height=488, status=0, left=1053, top=0"); //2010.05.06 까지

// window.open("/popup/southafrica_winnerList.html","popup_southafrica","width=511, height=555, status=0, left=0, top=0");

// window.open("/popup/celebration_winner.html","popup_celebration","width=511, height=580, status=0, left=516, top=0");

// window.open("/popup/worldcup_song_100616.html","worldcupSong","width=605, height=441, status=0, left=0, top=0"); // 월드컵송팝업

// window.open("/popup/event_multi_v.html","multi_v","width=672, height=524, status=0, left=0, top=0"); // 비타민워터 멀티-브이

// window.open("/popup/winnerlist_cgv_100512.html","cgv","width=511, height=542, status=0, left=0, top=0"); // cgv 당첨자발표

// window.open("/popup/winnerlist_cokecup_100708.html","glaso","width=511, height=618, status=0, left=0, top=0"); // 코크컵 당첨자발표

window.open("/popup/pop_superstar_k.html","glaso","width=600, height=450, status=0, left=0, top=0"); // 슈타스타K의 조건은?


})

function WorldCupLimited(){
 
$.post("/event/1006_WLimited.aspx", null,function(data){
//alert(data);

switch(data){
	case "-1":
		if(confirm("로그인이 필요합니다.\n로그인하시겠습니까?"))
			loginpop();
	break;
	 
	case "1":
		alert("참여가 완료되었습니다. 감사합니다");
	break;
	case "2":
		 
		alert("이미 참여하셨습니다.");
		//논리적으로 나오면 안됨;
	break;

	 
}
}
);
}