//------------------------------------------------------------------
// ÀÛ¼ºÀÚ : °íµ¿Àº
// ÆÄÀÏ¸í : function.js
// »ý¼ºÀÏ : 2011³â 1¿ù 14ÀÏ
//------------------------------------------------------------------

//------------------selectURL----------------------------------------
// method : selectURL
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// return : URL ½ºÆ®¸µ
//-------------------------------------------------------------------

var divName;
var togle=1;
var objPopup;
function selectURL(urlIndex){
	var URL = null;
	switch(urlIndex) {
		case 0 : URL="/member/login.asp";
			break;
		case 1 : URL="/member/signup.asp";
			break;
		case 2 : URL="/member/checkId.asp";
			break;
		case 3 : URL="/Include/SendAjax/rgame/INCRecordBreak.asp";
			break;
		case 4 : URL="/Include/Member/INCAjaxCheck.asp";
			break;
		case 5 : URL="/member/logout.asp";
			break;
		case 6 : URL="/Include/Rgame/INCRgameGallery.asp";
			break;
		case 7 : URL="/Popup/checkPopup.asp";
			break;
		case 8 : URL="/Popup/popupControl.asp";
			break;
		case 9 : URL="/Popup/messageAfterInvite.asp";
			break;
		case 10 : URL="/Include/Popup/INCRequestRgameCirm.asp";
			break;
		case 11 : URL="/Include/Rgame/Ajax/AjxRgameGallery.asp";
			break;
		case 12 : URL="/Include/Rgame/Ajax/AjxRgameMyGallery.asp";
			break;
		case 13 : URL="/Include/Rgame/popup/BuyInPoket.asp";
			break;
		case 14 : URL="/Include/Rgame/popup/PoketInGift.asp";
			break;
		case 15 : URL="/Include/Rgame/popup/NagFriendToSendGift.asp";
			break;
		case 16 : URL="/Include/Rgame/popup/BuyProc.asp"
			break;
		case 17 : URL="/Include/Rgame/popup/GiftProc.asp"
			break;
		case 18 : URL="/Include/Rgame/popup/NagFriendToSendGiftProc.asp"
			break;
		case 19 : URL="/Include/popup/INCRequestRgameCirmProc.asp"
			break;
		case 20 : URL="/Include/Rgame/Ajax/AjxRank.asp"
			break;
		case 21 : URL="/Include/Today/GameTalk/Ajax/AjxGameTalkList.asp"
			break;
		case 22 : URL="/Include/Today/GameTalk/Ajax/AjxGameTalkSearchList.asp"
			break;
		case 23 : URL="/Include/Common/CheckFile.asp"
			break;
		case 24 : URL="/Include/Support/Ajax/AjxNoticeList.asp"
			break;
		case 25 : URL="/Include/Support/Ajax/AjxFAQList.asp"
			break;
		case 26 : URL="/Include/profile/popup/ChangePw.asp"
			break;
		case 27 : URL="/Include/profile/popup/ChangePwProc.asp"
			break;
		case 28 : URL="/Include/profile/popup/Withdrwal.asp"
			break;
		case 29 : URL="/Include/profile/popup/WithdrwalProc.asp"
			break;
		case 30 : URL="/Include/popup/UserProfile.asp"
			break;
		case 31 : URL="/Include/popup/INCMessage.asp"
			break;
		case 32 : URL="/Include/popup/INCMessageProc.asp"
			break;
		case 33 : URL="/Include/popup/INCBuddyReq.asp"
			break;
		case 34 : URL="/Include/popup/INCBuddyReqProc.asp"
			break;
		case 35 : URL="/Include/profile/AjaxFriendList.asp"
			break;
		case 36 : URL="/Include/profile/AjaxFriendSent.asp"
			break;
		case 37 : URL="/Include/profile/AjaxFriendRev.asp"
			break;
		case 38 : URL="/Include/profile/AjaxDeleteMessage.asp"
			break;
		case 39 : URL="/Include/profile/AjaxSaveMessage.asp"
			break;
		case 40 : URL="/Include/profile/AjaxMessageList.asp"
			break;
		case 41 : URL="/Include/profile/AjaxSentMessageList.asp"
			break;
		case 42 : URL="/Include/profile/AjaxSaveMessage.asp"
			break;
		case 43 : URL="/Include/profile/AjaxDeleteDepo.asp"
			break;
		case 44 : URL="/Include/profile/popup/MessagePopup.asp"
			break;
		case 45 : URL="/Include/profile/AjaxInquiryList.asp"
			break;
		case 46 : URL="/Include/popup/INCSendCoin.asp"
			break;
		case 47 : URL="/Include/popup/INCSendCoinProc.asp"
			break;
		case 48 : URL="/Include/popup/Password.asp"
			break;
		case 49 : URL="/Include/popup/INCMyRecordScore.asp"
			break;
		case 50 : URL="/Include/profile/popup/Sendmessage.asp"
			break;
		case 51 : URL="/Include/profile/popup/SendmessageProc.asp"
			break;
		case 52 : URL="/Include/profile/popup/AjaxFindUser.asp"
			break;
//----------buy gift send item------------------
		case 53 : URL="/Include/shop/INCDispay.asp"
			break;
		case 54 : URL="/Include/shop/INCErasorProc.asp"
			break;
		case 55 : URL="/Include/shop/Avatar/INCboyish.asp"
			break;
		case 56 : URL="/Include/shop/Avatar/INCgirlish.asp"
			break;
		case 57 : URL="/Include/shop/Avatar/INCnonhuman.asp"
			break;
		case 58 : URL="/Include/shop/INCItemProc.asp"
			break;
		case 59 : URL="/Include/shop/INCItemUse.asp"
			break;
		case 60 : URL="/Include/shop/INCSendItem.asp"
			break;
		case 61 : URL="/Include/shop/AjaxFindUser.asp"
			break;
		case 62 : URL="/Include/shop/INCSendGiftProc.asp"
			break;
		case 63 : URL="/Include/shop/INCNagItem.asp"
			break;
		case 64 : URL="/Include/shop/INCNagItemProc.asp"
			break;
//-------------------RgameRanking in gametoday-----------
		case 65 : URL="/Include/today/ranking/INCRgameRank.asp"
			break;
		case 66 : URL="/Include/today/ranking/INCRankingView.asp"
			break;
		case 67 : URL="/Include/common/LikeProc.asp"
			break;
		case 68 : URL="/Include/Today/event/AJXEventList.asp"
			break;
//------------------tail------------------------------------
		case 69 : URL="/Include/Common/AJXTailList.asp"
			break;
		case 70 : URL="/Include/Common/AJXTailInput.asp"
			break;
//-----------------------------------------------------------
		case 71 : URL="/Include/Member/INCService.asp"
			break;
		case 72 : URL="/Include/Popup/INCNagItemProc.asp"
			break;
		case 73 : URL="/Include/Popup/INCNagList.asp"
			break;
		case 74 : URL="/Include/Rgame/popup/AjaxFindUser.asp"
			break;
		case 75 : URL="/Include/Popup/INCNagItem.asp"
			break;
		case 76 : URL="/Include/Popup/INCNagItemSendOK.asp"
			break;
		case 77 : URL="/Include/Popup/INCNagItemDelete.asp"
			break;
		case 78 : URL="/Include/Popup/Password/INCCheckEmail.asp"
			break;
		case 79 : URL="/Include/Popup/Password/INCChoice.asp"
			break;
		case 80 : URL="/Include/Popup/Password/INCFindUserName.asp"
			break;
		case 81 : URL="/Include/Today/cartoon/INCCartoonSList.asp"
			break;
		case 82 : URL="/include/today/gametalk/ajax/incbesttalk.asp"
			break;
		case 83 : URL="/Popup/Reject.asp"
			break;
		case 84 : URL="/include/profile/INCChangeRevType.asp"
			break;
		case 85 : URL="/popup/loginPopup.asp"
			break;
		case 86 : URL="/Include/popup/INCMyOnlineScore.asp"
			break;
		case 87 : URL="/Include/common/AJXPerson.asp"
			break;
		case 88 : URL="/Include/shop/payment/INCPaymet.asp"
			break;
		case 89 : URL="/Include/profile/INCMyAvatar.asp"
			break;	
		case 90 : URL="/Popup/messageAfterInvite2.asp"
			break;
		case 91 : URL="/Include/Ngame/INCPlay.asp"
			break;
		case 92 : URL="/Include/Ngame/AJXPokerRank.asp"
			break;
		case 93 : URL="/Include/Popup/BoosterProc.asp"
			break;
		case 94 : URL="/Include/Common/BlockWEB.asp"
			break;
		case 95 : URL="/Include/Popup/AJXNagDeleteCheck.asp"
			break;
		//-------------------Ranking in gametoday-----------
		case 96 : URL="/Include/today/ranking/INCNgameRank.asp"
			break;
		case 97 : URL="/Include/today/ranking/INCNRankingView.asp"
			break;
		case 98 : URL="/Include/ngame/AJXPokerPlayRank.asp"
			break;
		case 99 : URL="/data/poker/iframe_sendMessage.asp"
			break;
		case 100 : URL="/data/poker/iframe_sendMessageProc.asp"
			break;
		case 101 : URL="/data/poker/iframe_revMessage.asp"
			break;
		case 102 : URL="/include/shop/payment/INCOnlineLink.asp"
			break;
		case 103 : URL="/include/common/INCGameplaing.asp"
			break;
		case 104 : URL="/include/ngame/popup/INCScreenShot.asp"
			break;
		case 105 : URL="/include/common/INCGameplaingNow.asp"
			break;
		case 106 : URL="/eventPopup/eventCheck.asp"
			break;
		case 107 : URL="/include/ngame/AJXPerson.asp"
			break;
		case 108 : URL="/include/shop/payment/INCComplete.asp"
			break;
		case 109 : URL="/include/shop/payment/INCComplete2.asp"
			break;
		case 110 : URL="/popup/loginpopup.asp"
			break;
		case 111 : URL="/Include/Rgame/Ajax/AjxMRank.asp"
			break;
		case 112 : URL="/Include/Ngame/Poker/AJXPokerRank.asp"
			break;
		case 113 : URL="/Include/Ngame/Snake/AJXSnakeRank.asp"
			break;
		case 114 : URL="/Include/Common/ReadUpdate.asp"
			break;
		case 115 : URL="/Include/ngame/AJXSnakePlayRank.asp"
			break;
		case 116 : URL="/Include/ngame/mahjong/AJXMahjongRank.asp"
			break;
		case 117 : URL="/Include/ngame/shooting/AJXShootingRank.asp"
			break;
		case 118 : URL="/Include/ngame/bingo/AJXBingoRank.asp"
			break;
		case 119 : URL="/Include/Ngame/INCPlayer.asp"
			break;
		case 120 : URL="/Include/Ngame/INCPlayer2.asp"
			break;
		default : URL="";
	}	
	return URL;
}


//-------------------login------------------------------------------
// method : login
// parameter : 
// return : 
//-------------------------------------------------------------------
function login(){
	
	 id = document.loginForm.Username.value;
	 password = document.loginForm.Passwd.value;
	 if(document.loginForm.remember.checked == true)
	 {
		setsave("userid", id, 7);
	 }else{
		setsave("userid", id, -1);
	 }
	var id,password;
	

	if(id.length < 4 || id.length > 13){
		alert("Username should be 4~12 characters.");
		document.loginForm.Username.focus();
		return;
	}
	if(password.length < 6 || password.length > 19){
		//alert("Password should be 6~18 characters.");
		//document.loginForm.Passwd.focus();
		//return;
	}
	var postString;
	postString = "username="+encodeURIComponent(id);
	postString +="&passwd="+encodeURIComponent(password);
	divName="personInfo";
	//document.getElementById(divName).innerHTML="please wait";;
	ajaxPostSend(0,postString);
	//alert(document.cookie);
	//eval("popupCheck();");
	
}
//-------------------popup------------------------------------------
// method : 
// parameter : 
// return : 
//-------------------------------------------------------------------
function popupCheck(){
		
		
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  84);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10);
		ajaxGetSend(7);
}

function callPopup(urlIndex,postString){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();

		var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  maskHeight/ 2 - (height / 2);
              
		//Set the popup window to center
		$(id).css('top',  top);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
		ajaxPostPageSend(urlIndex,postString);
}
function callStaticPopup(){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  maskHeight/ 2 - (height / 2);
              
		//Set the popup window to center
		$(id).css('top',  top);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
		
		ajaxPostPageSend(urlIndex,postString);
}
function openPopupTop(){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  200;
              
		//Set the popup window to center
		$(id).css('top',  top);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
}

function openPopupScreen(){
		divName = "dialogScreen";
		var id = "#dialogScreen"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (800/ 2);
		var top =  200;
        
		//Set the popup window to center
		$(id).css('top',  30);
		$(id).css('left',(winW -$(id).width())/4 );
		//transition effect
		$(id).fadeIn(10); 
}

function openPopupShop(){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  700;
              
		//Set the popup window to center
		$(id).css('top',  top);
		
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
}
function openPopup(){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  maskHeight/ 2 - (height / 2);
              
		//Set the popup window to center
		$(id).css('top',  top);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
}
function openPopupMiddle(){
		divName = "dialog";
		var id = "#dialog"

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//
		//var obj
		//obj = document.getElementById("boxes");
		//obj.style.display="";

		//transition effect		
		$('#mask').fadeIn(10);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        var height = screen.height;
		var width = screen.width;
		var left =  width/ 2 - (500/ 2);
		var top =  maskHeight/ 2 - (height / 2);
              
		//Set the popup window to center
		$(id).css('top',  top);
		$(id).css('left', winW/4-$(id).width()/2);
		//transition effect
		$(id).fadeIn(10); 
}

function popupClose(tableVal,updateVal,pkid){
		var postString = "pkid="+encodeURIComponent(pkid);
		postString += "&tableVal="+encodeURIComponent(tableVal);
		postString += "&updateVal="+encodeURIComponent(updateVal);
		ajaxPostSend(8,postString);
		//document.getElementById("boxes").innerHTML="";
		$('#mask'). hide();
		$('.window').hide();
		popupCheck();
}
function inviteControl(updateVal,pkid,fkmember,orderType,rpage){
	divName = "dialog";
	var resultVal = Number(document.getElementById("newFriendVal").value) - 1;
	document.getElementById("newArea").innerHTML = "New: "+resultVal;
	
	//resultVal = Number(document.getElementById("rightFriendVal").value) - 1;
	//document.getElementById("rightFriend").innerHTML = "<a href='/profile/FriendList.asp'>"+resultVal+"</a><INPUT TYPE='hidden' id='rightFriendVal' name='rightFriendVal' value='"+resultVal+"'>"
	if (updateVal == 2)
	{
		resultVal = Number(document.getElementById("rejectFriendVal").value) + 1;
		document.getElementById("rejectedtArea").innerHTML = "Rejected: "+resultVal
		divName="FriendList"
		var postString = "pkid="+encodeURIComponent(pkid);
		postString += "&fkmember="+encodeURIComponent(fkmember);
		postString += "&updateVal="+encodeURIComponent(updateVal);
		postString += "&orderType="+encodeURIComponent(orderType);
		postString += "&page="+encodeURIComponent(rpage)
		ajaxPostSend(83,postString);
	}else{
		resultVal = Number(document.getElementById("aceptFriendVal").value) + 1;
		document.getElementById("aceptArea").innerHTML = "Accepted: "+resultVal
		openPopup();
		var postString = "pkid="+encodeURIComponent(pkid);
		postString += "&fkmember="+encodeURIComponent(fkmember);
		postString += "&updateVal="+encodeURIComponent(updateVal);
		postString += "&orderType="+encodeURIComponent(orderType);
		postString += "&page="+encodeURIComponent(rpage)
		ajaxPostSend(90,postString);
	}

}
function inviteControl2(updateVal,pkid,fkmember,orderType,rpage){
	
	if (updateVal == 2)
	{
		divName="FriendList"
		var postString = "pkid="+encodeURIComponent(pkid);
		postString += "&fkmember="+encodeURIComponent(fkmember);
		postString += "&updateVal="+encodeURIComponent(updateVal);
		postString += "&orderType="+encodeURIComponent(orderType);
		postString += "&page="+encodeURIComponent(rpage)
		ajaxPostSend(83,postString);
	}else{
		openPopup();
		var postString = "pkid="+encodeURIComponent(pkid);
		postString += "&fkmember="+encodeURIComponent(fkmember);
		postString += "&updateVal="+encodeURIComponent(updateVal);
		postString += "&orderType="+encodeURIComponent(orderType);
		postString += "&page="+encodeURIComponent(rpage)
		ajaxPostSend(9,postString);
	}

}
function linkToRequestItem(giftpkid,table){
	var postString = "giftpkid="+encodeURIComponent(giftpkid);
	if (table=="rgame"){
		ajaxPostSend(10,postString);
	}else if(table=="item"){
		ajaxPostSend(72,postString);
	}
}
function sendNagOK(giftPkid,type){
	alert("succes.");
	var postString="pkid="+giftPkid+"&type="+type
	ajaxPostSend(76,postString);
	openNagList();
	//ajaxPostPageSend(73,'');

}

function deleteNagItem(pkid,giftType){
	 if(confirm('do you want delete?')){ 
		var postString="pkid="+pkid+"&giftType="+giftType;
		ajaxPostSend(77,postString);
		openNagList();
	 }
}
function popupHide(){
	$('#mask'). hide();
	$('.window').hide();	
	divName="personInfo";
	ajaxPostSend(87,'');
}
function popupHideforGame(){
	$('#mask'). hide();
	$('.window').hide();	
	divName="personPop";
	ajaxPostSend(107,'');
}
function popupHide2(){
	$('#mask'). hide();
	$('.window').hide();	
	//divName="personInfo";
	//ajaxPostSend(87,'');
}
function popupHideAfterCheck(){
	popupHide2();
	document.getElementById("mask").display="";
	document.getElementById("dialog").innerHTML="";
	popupCheck();
}
//-------------------logout------------------------------------------
// method : logout
// parameter : 
// return : 
//-------------------------------------------------------------------
function logout(){
	
	//var Gval = gamecloseForLogout();

	alert("You are now signed out. Don't forget to add AYOgames in your bookmarks. Thank you");
	window.location.href="/member/logout.asp"
	//divName="personInfo";
	//ajaxGetSend(5);
	//ajaxPostSend(5,'');
}
//------lengh check--------------------------------------------

function memoLen(obj){
	document.getElementById("memocnt").innerHTML = obj.value.length+"/500 byte";
	if(500 < obj.value.length){
		alert("Self introduction should be written less than 500 bytes.");
		obj.value = obj.value.substr(0,500);
	}
}

function memoLen2(obj){
	document.getElementById("memocnt2").innerHTML = obj.value.length+"/500 byte";
	if(500 < obj.value.length){
		alert("Self introduction should be written less than 500 bytes.");
		obj.value = obj.value.substr(0,500);
	}
}
//-------------------changeMainCentent-------------------------------
// method : changeMainCentent
// parameter :
// return : 
//-------------------------------------------------------------------

function idCheck(){
	divName = "valiedId";
	var id;
	id = document.signForm.userName.value;
	if(id.length > 3){
		var postString;
		postString = "username="+encodeURIComponent(id);
		ajaxPostSend2(2,postString);
	}else{
		ajaxGetSend2(2);
	}
}

//-------------------changeMainCentent-------------------------------
// method : changeMainCentent
// parameter :
// return : 
//-------------------------------------------------------------------

function goToURL(urlIndex){
	window.location.href=selectURL(urlIndex);
}

//-------------------ajax Action -----------------------------------
var request = null;
function moveAjax(urlIndex,div){
	divName = div;
	ajaxPostSend(urlIndex,'');
}
//-------------------createRequest----------------------------------
// method : selectURL
// parameter : 
// note : XMLrequest °´Ã¼ »ý¼º
//------------------------------------------------------------------
	function createRequest(){
		try{
			request = new XMLHttpRequest();
		}catch(trymicrosoft){
			try{
				request = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(othermicrosoft){
				try{
					request = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(failed){
					request = null;
				}
			}
		}
		if(request == null) alert("failed request object");
	}
//-------------------ajaxGetSend----------------------------------
// method : ajaxGetSend
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : get¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxGetSend2(urlIndex){
		//document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		createRequest
		var url = selectURL(urlIndex);
		request.open("GET",url,true);
		request.onreadystatechange = updatePoint; 
		request.send(null);
		
	}
//-------------------ajaxGetSend----------------------------------
// method : ajaxGetSend
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : get¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxGetSend(urlIndex){
		document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		createRequest
		var url = selectURL(urlIndex);
		request.open("GET",url,true);
		request.onreadystatechange = updatePoint; 
		request.send(null);
		
	}
//-------------------ajaxPostSend----------------------------------
// method : ajaxPostSend
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : post¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxPostSend2(urlIndex,postString){
		  createRequest();
		  var url = selectURL(urlIndex);
		  // var postString = "";		  
		  // postString = "userId=" + encodeURIComponent(document.getElementById("userId").value);
		  // postString += "&pwd=" + encodeURIComponent(document.getElementById("pwd").value);
		  // postString += "&userName=" + encodeURIComponent(document.getElementById("userName").value);
		  request.open("POST",url,true);   
		  request.onreadystatechange = updatePoint;
		  request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=euc-kr");
		  request.send(postString);
		  
	}
//-------------------ajaxPostSend----------------------------------
// method : ajaxPostSend
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : post¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxPostSend(urlIndex,postString){
		if (urlIndex == 0){
			document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		}else{
			document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		}
		  createRequest();
		  var url = selectURL(urlIndex);
		  // var postString = "";		  
		  // postString = "userId=" + encodeURIComponent(document.getElementById("userId").value);
		  // postString += "&pwd=" + encodeURIComponent(document.getElementById("pwd").value);
		  // postString += "&userName=" + encodeURIComponent(document.getElementById("userName").value);
		  request.open("POST",url,true);   
		  request.onreadystatechange = updatePoint;
		  request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=euc-kr");
		  request.send(postString);
		  
	}
//-------------------updatePoint----------------------------------
// method : updatePoint
// parameter : 
// note : ajax·Î ºÒ·¯¿Â ÆäÀÌÁö display À§Ä¡ ÁöÁ¤
//------------------------------------------------------------------
	function updatePoint() {
		
	  if(request.readyState == 4){    // ¿äÃ»ÀÀ´ä»óÅÂ°¡ 4ÀÎÁö È®ÀÎÇØÁÖ°í
		if(request.status == 200){     // HTTP»óÅÂ°¡ ¿Ï·áÀÎÁö Ã¼Å©ÇØÁÝ´Ï´Ù.
		  var newPoint = request.responseText;
		  //alert(newPoint);
		 // var arry_Temp = newPoint.split("&&");  // ¹ÞÀ» °ªÀ» ¸Â°Ô ÂÉ°¸´Ï´Ù
		//  var varFreeCnt   = arry_Temp[0];
		//  var varFreePoint = arry_Temp[1];
		//alert(newPoint)
		
		if(newPoint==""){
			window.location.reload();
		}else{
		  document.getElementById(divName).innerHTML = newPoint;
		 // alert(newPoint)
		  if(newPoint.indexOf("qwerqwerqwerasdfasdfasdf") > 0){
			//	popuphide();
				dinName="dialog";
				eval("popupCheck();");
		  }else if(newPoint.indexOf("opqwirquiwerknbvzuxcvyhuizh") > 0){
				divName="gamePlay";
				eval("ajaxGetSend(91)");
				eval("popupHide2()");
				if(newPoint.indexOf("qweriousdfsdfnjskdfn78vhjksnfuisdh") > 0){
					//eval("alert('t')");
					if(newPoint.indexOf("xcvmskldfjiowf89slfkjne3nffvchnsduf") > 0){
						eval("popupHide()");
						eval("popupHide()");
						
					  }else{
						dinName="dialog";
						eval("eventCheck();");
					  }
				 }
				
		  }else if(newPoint.indexOf("opieurklwenjasdkflvnjasdvnasdjbhas") > 0){
				init();
				clock(StaticTime);
		  }
		  else if(newPoint.indexOf("qweriousdfsdfnjskdfn78vhjksnfuisdh") > 0)
		  {
			  if(newPoint.indexOf("xcvmskldfjiowf89slfkjne3nffvchnsduf") > 0){
				eval("popupHide()");
				eval("popupHide()");
				
			  }else{
					dinName="dialog";
					eval("eventCheck();");
			  }
		  }
		  else if(newPoint.indexOf("xcvmskldfjiowf89slfkjne3nffvchnsduf") > 0){
			eval("popupHide()");
			
		  }

		}
		  //eval("popupCheck();");
		 
		//  document.getElementById("freePoint").innerHTML = varFreePoint ;
		}
	  }
	}

//-------------------------------------------------------------------------------------

//-------------------ajaxLikeIt----------------------------------
// method : ajaxLikeIt
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : post¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxLikeIt(urlIndex,postString){
		//document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		  createRequest();
		  var url = selectURL(urlIndex);
		  // var postString = "";		  
		  // postString = "userId=" + encodeURIComponent(document.getElementById("userId").value);
		  // postString += "&pwd=" + encodeURIComponent(document.getElementById("pwd").value);
		  // postString += "&userName=" + encodeURIComponent(document.getElementById("userName").value);
		  //alert(urlIndex);
		 // alert(url);
		  //alert(postString);
		  request.open("POST",url,true);   
		  request.onreadystatechange = updateLikt;
		  request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=euc-kr");
		  request.send(postString);
	}
//-------------------updatePagePoint----------------------------------
// method : updateLikt
// parameter : 
// note : ajax·Î ºÒ·¯¿Â ÆäÀÌÁö display À§Ä¡ ÁöÁ¤
//------------------------------------------------------------------
	function updateLikt() {
	  if(request.readyState == 4){    // ¿äÃ»ÀÀ´ä»óÅÂ°¡ 4ÀÎÁö È®ÀÎÇØÁÖ°í
		if(request.status == 200){     // HTTP»óÅÂ°¡ ¿Ï·áÀÎÁö Ã¼Å©ÇØÁÝ´Ï´Ù.
		  var newPoint = request.responseText;
		  //alert(newPoint);
		 // var arry_Temp = newPoint.split("&&");  // ¹ÞÀ» °ªÀ» ¸Â°Ô ÂÉ°¸´Ï´Ù
		//  var varFreeCnt   = arry_Temp[0];
		//  var varFreePoint = arry_Temp[1];
		//alert(newPoint)
		  alert(newPoint);
		  //alert(newPoint.indexOf("qwerqwerqwerasdfasdfasdf"));

		  //eval("popupCheck();");
		 
		//  document.getElementById("freePoint").innerHTML = varFreePoint ;
		}
	  }
	}





//-------------------ajaxPostPageSend----------------------------------
// method : ajaxPostSend
// parameter : urlIndex - ÁöÁ¤µÈ url ¹øÈ£
// note : post¹æ½Ä ajaxpage È£Ãâ
//------------------------------------------------------------------
	function ajaxPostPageSend(urlIndex,postString){
		document.getElementById(divName).innerHTML="<center><br/><br/><br/><br/><img src='/Share/images/common/loading.gif'></center>";
		  createRequest();
		  var url = selectURL(urlIndex);
		  // var postString = "";		  
		  // postString = "userId=" + encodeURIComponent(document.getElementById("userId").value);
		  // postString += "&pwd=" + encodeURIComponent(document.getElementById("pwd").value);
		  // postString += "&userName=" + encodeURIComponent(document.getElementById("userName").value);
		  //alert(urlIndex);
		 // alert(url);
		  //alert(postString);
		  request.open("POST",url,true);   
		  request.onreadystatechange = updatePagePoint;
		  request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=euc-kr");
		  request.send(postString);
	}
//-------------------updatePagePoint----------------------------------
// method : updatePagePoint
// parameter : 
// note : ajax·Î ºÒ·¯¿Â ÆäÀÌÁö display À§Ä¡ ÁöÁ¤
//------------------------------------------------------------------
	function updatePagePoint() {
	  if(request.readyState == 4){    // ¿äÃ»ÀÀ´ä»óÅÂ°¡ 4ÀÎÁö È®ÀÎÇØÁÖ°í
		if(request.status == 200){     // HTTP»óÅÂ°¡ ¿Ï·áÀÎÁö Ã¼Å©ÇØÁÝ´Ï´Ù.
		  var newPoint = request.responseText;
		  //alert(newPoint);
		 // var arry_Temp = newPoint.split("&&");  // ¹ÞÀ» °ªÀ» ¸Â°Ô ÂÉ°¸´Ï´Ù
		//  var varFreeCnt   = arry_Temp[0];
		//  var varFreePoint = arry_Temp[1];
		//alert(newPoint)

		  document.getElementById(divName).innerHTML = newPoint;
		  //alert(newPoint.indexOf("qwerqwerqwerasdfasdfasdf"));

		  //eval("popupCheck();");
		 
		//  document.getElementById("freePoint").innerHTML = varFreePoint ;
		}
	  }
	}

//-------------------------------------------------------------------------------------
//-------------------changeDiv-----------------------------------------
// method : changeDiv
// parameter : index - ½ºÀ§Ä¡ °ª, divName1 - div¸í1, divName2 - div¸í2
// note : ajax·Î ºÒ·¯¿Â ÆäÀÌÁö display À§Ä¡ ÁöÁ¤
//---------------------------------------------------------------------

	function changeDiv(index,divName1,divName2){
		if (index==1){
			var obj;
			var obj2;
			obj = document.getElementById(divName1);
			obj2= document.getElementById(divName2);
			obj.style.display="none";
			obj2.style.display="";
		}else{
			var obj;
			var obj2;
			obj = document.getElementById(divName1);
			obj2= document.getElementById(divName2);
			obj2.style.display="none";
			obj.style.display="";
		}
	}
//-------------------setsave-----------------------------------------
// method : setsave
// parameter : 
// note : 
//---------------------------------------------------------------------
	function setsave(name, value, expiredays)
	{
		 var today = new Date();
		 today.setDate( today.getDate() + expiredays );
		 document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";"
	}


	function getLogin()
	{
		
		 // userid ÄíÅ°¿¡¼­ id °ªÀ» °¡Á®¿Â´Ù.
		 var cook = document.cookie + ";";
		 var idx = cook.indexOf("userid", 0);
		 var val = "";
		 if(idx != -1)
		 {
			  cook = cook.substring(idx, cook.length);
			  begin = cook.indexOf("=", 0) + 1;
			  end = cook.indexOf(";", begin);
			  val = unescape( cook.substring(begin, end) );
		 }
		 //alert(cook);
		 // °¡Á®¿Â ÄíÅ°°ªÀÌ ÀÖÀ¸¸é
		 if(val!= "")
		 {
			  document.getElementById("join").style.display="none";
			  document.getElementById("login").style.display="";
			  document.loginForm.Username.value = val;
			  document.loginForm.Passwd.value = "";
			  document.loginForm.Passwd.focus();		  
			  document.loginForm.remember.checked = true;

		 }
	}
//--------------------div hide------------------------
	function showHideDiv(divName){
		if (togle==1){
			document.getElementById(divName).style.display="";
			togle = 0;
		}else{
			document.getElementById(divName).style.display="none";
			togle = 1;
		}
	}
//----------gift record break game----------
	function rgameGift(gameId,gameType){
				//alert(document.giftForm.friend.value);
				//alert(document.giftForm.message.value);
		divName="dialog"
		if (document.getElementById("notEnough").value=="1")
		{
			alert("Sorry, your credit is not enough");
			return;
		}
		if(document.getElementById("friend").value=="Choose friend" || document.getElementById("friend").value=="Empty"){
			alert("please select your friend");
			return;
		}
		if(document.getElementById("message").value==""){
			alert("please input message");
			return;
		}
		var postString;
		divName="dialog";
		postString = "gameId="+gameId+"&gameType="+gameType+"&friend="+document.giftForm.friend.value;
		document.getElementById("creditArea").innerHTML=getouterHtml(document.getElementById("afterDiv"))
		if(document.giftForm.messagehidden.value==3){
			ajaxPostPageSend(19,postString);
		}else{
			ajaxPostPageSend(17,postString);
		}
	}

function rgameGift2(){
	//tabClick(1);
	if (document.getElementById("notEnough").value=="1")
	{
		alert("Sorry, your credit is not enough");
		return;
	}
	
				
	divName="dialog";
	var friendPkid,memo,itempkid,gameType,gameId;
	gameId = document.getElementById('gameIdVal').value;
	friendPkid = document.getElementById('frinedPkid').value;
	memo = document.getElementById('memo').value;
	gameType = document.getElementById("rgamePrice").value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	document.getElementById("creditArea").innerHTML=getouterHtml(document.getElementById("afterDiv"))
	postString = "gameId="+gameId+"&gameType="+gameType+"&friend="+encodeURIComponent(friendPkid)+"&message="+encodeURIComponent(memo);
	if(document.giftForm.messagehidden.value==3){
		ajaxPostPageSend(19,postString);
	}else{
		ajaxPostPageSend(17,postString);
	}

}
//---user profile popup-------------------------------
	function openUserFile(userPkid){	
		openPopup();
		var postString;
		postString = "pkid="+userPkid;
		ajaxPostPageSend(30,postString);
	}
	function openUserFile1(userPkid){	
		//openPopup();
		var postString;
		postString = "pkid="+userPkid;
		ajaxPostPageSend(30,postString);
	}
	function closeGame(){
		popupHide();
	}
	function ProfileTab(id,pkid){
		document.getElementById("profileDiv").style.display="none";
		document.getElementById("OnlineDiv").style.display="none";
		document.getElementById("RecordDiv").style.display="none";
		var postString;
		if (id==1){
			document.getElementById("profileDiv").style.display="";
			document.getElementById("PMenu").innerHTML ="<ul class='tabs'><li id='Profileli' name='Profileli' class='active wdlifix'><a href='javascript:ProfileTab(1,"+pkid+");'>Profile</a></li><li id='Onlineli' name='Onlineli' class='wdlifix'><a href='javascript:ProfileTab(2,"+pkid+");'>Online Battle Info</a></li><li id='Recordli' name='Recordli' class='wdlifix'><a href='javascript:ProfileTab(3,"+pkid+");'>Record Break Info</a></li></ul>"
			divName="profileDiv";
		}else if(id==2){
			document.getElementById("OnlineDiv").style.display="";
			document.getElementById("PMenu").innerHTML ="<ul class='tabs'><li id='Profileli' name='Profileli' class='wdlifix'><a href='javascript:ProfileTab(1,"+pkid+");'>Profile</a></li><li id='Onlineli' name='Onlineli' class='wdlifix active'><a href='javascript:ProfileTab(2,"+pkid+");'>Online Battle Info</a></li><li id='Recordli' name='Recordli' class='wdlifix'><a href='javascript:ProfileTab(3,"+pkid+");'>Record Break Info</a></li></ul>"
			divName="OnlineDiv";
			postString = "pkid="+pkid;
			ajaxPostPageSend(86,postString);
		}else{
			document.getElementById("RecordDiv").style.display="";
			document.getElementById("PMenu").innerHTML ="<ul class='tabs'><li id='Profileli' name='Profileli' class='wdlifix'><a href='javascript:ProfileTab(1,"+pkid+");'>Profile</a></li><li id='Onlineli' name='Onlineli' class='wdlifix'><a href='javascript:ProfileTab(2,"+pkid+");'>Online Battle Info</a></li><li id='Recordli' name='Recordli' class='wdlifix active'><a href='javascript:ProfileTab(3,"+pkid+");'>Record Break Info</a></li></ul>"
			divName="RecordDiv";
			postString = "pkid="+pkid;
			ajaxPostPageSend(49,postString);
		}
	}
	function sendMessage(pkid){
		//openPopup();
		var postString;
		postString = "fkmember="+pkid;
		ajaxPostPageSend(31,postString);
	}
//----------gift coin---------------------------------
	function sendCoin(pkid){
		//openPopup();
		var postString;
		postString = "fkmember="+pkid;
		ajaxPostPageSend(46,postString);
	}
	function sendCoinProc(pkid){
		//openPopup();
		var sender,reciever,sendCoin,recieverCoin,recieverCoin2,coinVal,coinForSend;
		var postString;
		
		coinForSend=document.getElementById("coinForSend").value;
		sender=document.getElementById("sender").value;
		reciever=document.getElementById("reciever").value;
		sendCoin=document.getElementById("sendCoin").value;
		recieverCoin=document.getElementById("recieverCoin").value;
		recieverCoin2=document.getElementById("recieverCoin2").value;
		coinVal=document.getElementById("coinVal").value;
		if(document.getElementById("o").checked!=true){
			alert("Please read the condition and check the box.");
		}
		if(coinVal==""){
			alert("Please input the amount of coin you want to gift");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		if(isNaN(coinVal)) {
			alert("Please enter the amount of coin using numeric");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		 }
		if(Number(coinForSend) - Number(coinVal) <= 5000)
		{
			alert("Your coin is not ");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		if(Number(recieverCoin)>=5000)
		{
			alert("Oops, your friend has already reached maximum gifts for one day");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		//if(recieverCoin2>=5000)
		//{
		//	alert("over");
		//	document.getElementById("coinVal").value = "";
		//	document.getElementById("coinVal").focus();
		//	return;
		//}
		if(Number(coinVal)>5000)
		{
			alert("You can send up to 5000 coins");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		if(Number(coinVal)<1000)
		{
			alert("You can send minimum of 1000 coins");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		if(Number(sendCoin)>=50000)
		{
			alert("Save your gifts for tomorrow, now you've reached maximum of 50,000 coins");
			document.getElementById("coinVal").value = "";
			document.getElementById("coinVal").focus();
			return;
		}
		postString = "sender="+sender+"&reciever="+reciever+"&coinVal="+coinVal;
		ajaxPostPageSend(47,postString);
	}
//----request friend-------------------------
	function FriendReq(pkid){
		//openPopup();
		divName = "dialog";
		var postString;
		postString = "fkmember="+pkid;
		ajaxPostPageSend(33,postString);
	}
//---------------------------------------------	
	function EditProfile(){
		var postString;
		ajaxPostPageSend(48,postString)
	}

	function checkPWforEdit(){
		var pwcheck,pw;
		divName="dialog";
		pwcheck=document.getElementById("pw").value;
		pw=document.getElementById("password").value;
		if(pw==pwcheck){
			document.Frmpw.action = "/profile/ProfileEdit.asp"
			document.Frmpw.submit();
		}else{
			alert("wrong password");
			document.getElementById("password").value="";
			document.getElementById("password").focus();
		}
	}

	function messageProc(){
		var sender,reciever,messageVal
		sender = document.getElementById("sender").value;
		reciever = document.getElementById("reciever").value;
		messageVal = escape(document.getElementById("messageVal").value);
		var postString;
		postString = "sender="+sender;
		postString +="&reciever="+reciever;
		postString +="&messageVal="+messageVal;
		ajaxPostPageSend(32,postString);
	}
	function FriendReqProc(){
		var sender,reciever,messageVal
		sender = document.getElementById("sender").value;
		reciever = document.getElementById("reciever").value;
		messageVal = escape(document.getElementById("messageVal").value);
		var postString;
		postString = "sender="+sender;
		postString +="&reciever="+reciever;
		postString +="&messageVal="+messageVal;
		ajaxPostPageSend(34,postString);
	}

	function searchPeople(){
		var inputval = document.PeopleSerchForm.pepleSerchInput.value;
		if (inputval.length < 3){
			alert("Please input more than 3 characters to search users.");
			return;
		}
		document.PeopleSerchForm.submit();
	}
	function deleteInviteRecord(pkid,page,oder){
		divName="FriendList"
		var postString;
		var divURL ;
		divURL = document.getElementById('pageView').value;
		postString = "page="+page;
		postString +="&orderType="+oder;
		postString +="&pkid="+pkid;
		ajaxPostPageSend(parseInt(divURL),postString);
	}


//---------link-------------------------
function buyTimeReceive(){
	if(document.getElementById("gmt").value=="0")
	{
		alert("please select time zone");
		return;
	}
	if(document.getElementById("timeSelector").value=="100")
	{
		alert("please select boosting hours");
		return;
	}
	var postString;
	openPopupMiddle();
	postString = "itempkid="+encodeURIComponent(document.getElementById("boosterpkid").value);
	postString = postString+"&startTime="+encodeURIComponent(document.getElementById("timeSelector").value);
	postString = postString+"&gmt="+encodeURIComponent(document.getElementById("gmt").value);
	postString = postString+"&giftpkid="+encodeURIComponent(document.getElementById("giftpkid").value);
	//alert(postString);
	ajaxPostPageSend(93,postString);

				
}
function ajaxPagingCom(urlIndex,page,pkid,divnameVal){
	divName = divnameVal;
	var postString;
	postString = "page="+encodeURIComponent(page);
	postString += "&pkid="+encodeURIComponent(pkid);
	ajaxPostPageSend(urlIndex,postString);
}
function sendNewMessage(){
	openPopup();
	ajaxPostPageSend(50,'');
}
function sendNewGiftItem(){
	openPopup();
	ajaxPostPageSend(60,'');
}
function sendNewMessageProc(){
	var friendPkid,memo;
	friendPkid = document.getElementById('frinedList').value;
	memo = document.getElementById('memo').value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	postString = "memo="+encodeURIComponent(memo);
	postString += "&pkid="+encodeURIComponent(friendPkid);
	ajaxPostPageSend(51,postString);

}
function sendNewGiftProc(){
	var friendPkid,memo,itempkid;
	friendPkid = document.getElementById('frinedList').value;
	memo = document.getElementById('memo').value;
	itempkid = document.getElementById('avatarItemVal').value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	postString = "memo="+encodeURIComponent(memo);
	postString += "&pkid="+encodeURIComponent(friendPkid);
	postString += "&itempkid="+encodeURIComponent(itempkid);
	ajaxPostPageSend(62,postString);

}
function sendNewGiftProc2(){
	tabClick(1);
	divName="dialog";
	var friendPkid,memo,itempkid;
	friendPkid = document.getElementById('frinedPkid').value;
	memo = document.getElementById('memo1').value;
	itempkid = document.getElementById('avatarItemVal').value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	postString = "memo="+encodeURIComponent(memo);
	postString += "&pkid="+encodeURIComponent(friendPkid);
	postString += "&itempkid="+encodeURIComponent(itempkid);
	ajaxPostPageSend(62,postString);

}
function sendNewMessageProc2(){
	tabClick(1);
	divName="dialog";
	var friendPkid,memo;
	friendPkid = document.getElementById('frinedPkid').value;
	memo = document.getElementById('memo').value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	postString = "memo="+encodeURIComponent(memo);
	postString += "&pkid="+encodeURIComponent(friendPkid);
	ajaxPostPageSend(51,postString);

}
function sendNagProc(){
	var friendPkid,memo,itempkid;
	friendPkid = document.getElementById('frinedList').value;
	memo = document.getElementById('memo').value;
	itempkid = document.getElementById('avatarItemVal').value;
	if(friendPkid == ""){
		alert("please select user"); 
		return;
	}
	if(memo == ""){
		alert("please write message");
		return;
	}
	postString = "memo="+encodeURIComponent(memo);
	postString += "&pkid="+encodeURIComponent(friendPkid);
	postString += "&itempkid="+encodeURIComponent(itempkid);
	ajaxPostPageSend(64,postString);

}

function gamePlay(gameid){
	var folderName
	switch(gameid) {
		case 1 : folderName="poker";
			break;
		case 2 : folderName="snake";
			break;
		case 3 : folderName="mahjong";
			break;
		case 4 : folderName="bubble";
			break;
		case 5 : folderName="bingo";
			break;

	}
	//openPopupTop();
	//ajaxPostPageSend(103,'');
	//window.location.href="playNow.asp?id="+folderName
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	var winH = $(window).height();
	var winW = $(window).width();
    var height = screen.height;
	var width = screen.width;
	var left =  width/2-1030/2
	var top =  height/ 2 - (1000 / 2);
	if (height < 610)
	{
		objPopup = window.open("/data/"+folderName+"/intro.asp","AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}else{
		objPopup = window.open("/data/"+folderName+"/intro.asp","AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}
	
}
function tutoPlay(gameid){
	var folderName
	switch(gameid) {
		case 1 : folderName="poker";
			break;
		case 2 : folderName="snake";
			break;
		case 3 : folderName="mahjong";
			break;
		case 4 : folderName="bubble";
			break;
		case 5 : folderName="bingo";
			break;

	}
	//openPopupTop();
	//ajaxPostPageSend(103,'');
	//window.location.href="playNow.asp?id="+folderName
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	var winH = $(window).height();
	var winW = $(window).width();
    var height = screen.height;
	var width = screen.width;
	var left =  width/2-1030/2
	var top =  height/ 2 - (1000 / 2);
	if (height < 610)
	{
		objPopup = window.open("/data/"+folderName+"/tuto.asp","AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}else{
		objPopup = window.open("/data/"+folderName+"/tuto.asp","AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}
	
}

function PlayChannel(gameid,channel){
	var folderName;
	var gamePopup;
	switch(gameid) {
		case 1 : folderName="poker";
			break;
		case 2 : folderName="snake";
			break;
		case 3 : folderName="mahjong";
			break;
		case 4 : folderName="bubble";
			break;
		case 5 : folderName="bingo";
			break;

	}
	//window.location.href="playNow.asp?id="+folderName
	//openPopupTop();
	//ajaxPostPageSend(103,'');
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	var winH = $(window).height();
	var winW = $(window).width();
    var height = screen.height;
	var width = screen.width;
	var left =  width/2-1030/2
	var top =  height/ 2 - (1000 / 2);
	//alert(height+"  "+width+"  ")
	if (height < 610)
	{
		objPopup = window.open("/data/"+folderName+"/intro.asp?channelNo="+channel,"AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}else{
		objPopup = window.open("/data/"+folderName+"/intro.asp?channelNo="+channel,"AyoGame",'width=1030,height=833,left='+left+',top='+top+', scrollbars=yes, resizable=no');
	}
}

function ajaxPagingTail(urlIndex, page,tableName, boardPkid){
	var postString;
	var tName;
	divName = "tailList";
	postString = "page="+encodeURIComponent(page);
	postString = postString + "&pkid="+encodeURIComponent(boardPkid);
	postString = postString + "&tName="+encodeURIComponent(tableName);
	ajaxPostPageSend(urlIndex,postString);
}

function tailInput(tableName){
	var postString;
	var tName;	
	divName = "tailList";
	var validate = document.getElementById("tailTxt").value;
	if((validate.trim()).length < 3)
	{
		alert("Please input more than 3 characters to upload your comment.");
		return;
	}
	postString = "page="+encodeURIComponent(1);
	postString = postString + "&pkid="+encodeURIComponent(document.getElementById("tailpkid").value);
	postString = postString + "&tName="+encodeURIComponent(tableName);
	postString = postString + "&tailTxt="+encodeURIComponent(document.getElementById("tailTxt").value);
	ajaxPostPageSend(70,postString);
}

function tailInputLogin(){
	alert("need login");
}

function openNagList(){
	openPopup();
	ajaxPostPageSend(73,'');	
}
function SelectNBox()
{
	
	var obj  = document.getElementsByName("chko");
	var obj2 = document.getElementById("chkAll");
	
	var item;
	for (var t = 0; t <= obj.length; t++)
	{
		item = obj.item(t);
		item.checked = obj2.checked;
	}
}

function selectRgamePrice(obj,gameId){
	document.getElementById("rbuyLink").href="javascript:RgamebuyNow('"+gameId+"','"+obj.value+"');";
	var price,myMoney;
	myMoney = document.getElementById("myCreadit").value;
	price = getRgamePrice(Number(obj.value));
	document.getElementById("needDiv").innerHTML=price+" credit";
	if(Number(myMoney) - Number(price) > 0){
		document.getElementById("afterDiv").innerHTML=(Number(myMoney) - Number(price))+" credit<INPUT TYPE='hidden' NAME='notEnough' id='notEnough' value='0'>";
	}else{
		document.getElementById("afterDiv").innerHTML="Not enough<INPUT TYPE='hidden' NAME='notEnough' id='notEnough' value='1'>";
	}	
}
function selectRgameNagPrice(obj,gameId){
	document.getElementById("rbuyLink").href="javascript:rgameNag('"+gameId+"','"+obj.value+"');";
}
function selectRgameGiftPrice(obj,gameId){
	document.getElementById("rbuyLink").href="javascript:rgameGift('"+gameId+"','"+obj.value+"');";
	var price,myMoney;
	myMoney = document.getElementById("myCreadit").value;
	price = getRgamePrice(Number(obj.value));
	document.getElementById("needDiv").innerHTML=price+" credit";
	if(Number(myMoney) - Number(price) > 0){
		document.getElementById("afterDiv").innerHTML=(Number(myMoney) - Number(price))+" credit<INPUT TYPE='hidden' NAME='notEnough' id='notEnough' value='0'>";
	}else{
		document.getElementById("afterDiv").innerHTML="Not enough<INPUT TYPE='hidden' NAME='notEnough' id='notEnough' value='1'>";
	}	
}

function getRgamePrice(gameType){
	var price;
	switch(gameType) {
		case 1 : price=3;
			break;
		case 2 : price=4;
			break;
		case 3 : price=6;
			break;
	}
	return price;
}

function toggle() {
    var ele = document.getElementById("toggleText");
    var text = document.getElementById("displayText");
    if(ele.style.display == "block") {
         ele.style.display = "none";
         text.innerHTML = "see all games &#9660;";
    }
    else {
         ele.style.display = "block";
         text.innerHTML = "&nbsp;&nbsp;close panel &#9650;";
    }
}
function openFindPassword(){
	openPopup();
	ajaxPostPageSend(78,"");
}
function checkEmailForPassword(){
	var postString;
	postString = "email="+document.getElementById("inputPW").value;
	ajaxPostPageSend(79,postString);
}
function findUsername(pkid){
	var postString;
	postString = "pkid="+pkid;
	ajaxPostPageSend(80,postString);
}
function inviceFinish(orderType){
	popupHide2();
	var postString;
	divName="FriendList"
	postString = "orderType="+encodeURIComponent(orderType);
	ajaxPostPageSend(37,postString);
	document.getElementById("oder3").style.display="";	
}
function signInNow(){
	javascript:changeDiv(1,'join','login');
	document.getElementById("Username").focus();
	popupHide2();
}

function parsTopic(text){
	var parsString;
	switch(Number(text)) {
		case 1 : parsString="Online Battle";
			break;
		case 2 : parsString="Record Break";
			break;
		case 3 : parsString="General Suggestion";
			break;
		case 4 : parsString="Information Share";
			break;
		case 5 : parsString="Free Talking";
			break;
	}
	return parsString;
}
function getouterHtml(obj){
	var html = null;
			 //³ÎÃ³¸®
	if (obj == null) return null;
			 
	if (typeof(obj.outerHTML) == "string"){
	//½ºÆ®¸µ°ªÀ» °¡Á®¿Â´Ù¸é IE·Î °¡Á¤ÇÔ
		html =  obj.outerHTML;
			  //alert("ie"); //µð¹ö±×¿ë
	}
	else
	{
		html = (new XMLSerializer).serializeToString(obj);
			  //alert("ff"); //µð¹ö±×¿ë
	}
	var endC = html.indexOf(" credit") - html.indexOf(">")
	html = html.substr(html.indexOf(">")+1,endC);
	return html;
}
function FlashDown(){
	window.open("http://get.adobe.com/flashplayer/","");
}
function deleteNagCheck(){
	 if(confirm('do you want delete?')){ 
		var obj  = document.getElementsByName("chko");
		var item;
		var pkid="";
		try{
			if (obj.length==0)
			{
				alert("please select item");
				return;
			}
		}catch(e){
			alert("please select item");
			return;
		}
		for (var i = 0; i < obj.length; i++)
		{
			item = obj.item(i);
			if (item.checked == true){
				pkid +="a"+item.value; 	
			//	alert(item.value)
			}
			//item.checked = obj.chkA.checked;
		}
		var postString;
		//divName = "MessageList";
		//postString = "page="+encodeURIComponent(<%=page%>);
		postString ="pkid="+encodeURIComponent(pkid);
		//alert(postString);
		ajaxPostPageSend(95,postString);
		openNagList();
	 }

	
}
function sendMessageInGame(userName){
	document.getElementById("buddyDiv").style.display="none"
	document.getElementById("MessageDiv").style.display=""
	divName="MessageDiv"
	postString = "username="+userName
	ajaxPostSend(99,postString);
}
function sendMessageInGameProc(){
	document.getElementById("buddyDiv").style.display="none"
	document.getElementById("MessageDiv").style.display=""
	memo = document.getElementById("memo").value;
	userName = document.getElementById("username").value;
	
	divName="MessageDiv"
	postString = "username="+userName
	postString = postString + "&memo=" + encodeURIComponent(memo)
	ajaxPostSend(100,postString);
}
function hiddenMessage(){
	document.getElementById("buddyDiv").style.display=""
	document.getElementById("MessageDiv").style.display="none"
}
function revMessageIngame(){
	document.getElementById("buddyDiv").style.display="none"
	document.getElementById("MessageDiv").style.display=""
	divName="MessageDiv"
	ajaxPostPageSend(101,"");
}
var StaticTime;
function init(){
				 window.setInterval("clock(StaticTime)","1000");  
			}
			function clock(HourVal){
				var ttt = document.getElementById("ttt");
				var d = new Date();
				StaticTime = HourVal;
				  var s =
					leadingZeros(HourVal,2) + ':' +
					leadingZeros(d.getMinutes(), 2) + ':' +
					leadingZeros(d.getSeconds(), 2);
				ttt.innerHTML = "Current time: "+ s;   
			}
			function leadingZeros(n, digits) {
			  var zero = '';
			  n = n.toString();

			  if (n.length < digits) {
				for (i = 0; i < digits - n.length; i++)
				  zero += '0';
			  }
			  return zero + n;
			}
function chageBoosterTime(){
				var timeVal;
				var StartVal;
				var EndVal;
				timeVal = document.getElementById("timeSelector").value;
				if(Number(timeVal) >= 23){
					StartVal = timeVal+":00"
					EndVal = (Number(timeVal)-22)+":00"
					
				}else{
					StartVal = timeVal+":00"
					EndVal = (Number(timeVal)+2)+":00"
					
					
				}
				document.getElementById("changeTime").innerHTML=StartVal+" ~ "+EndVal;
			}
function onlineLinkPopup(){
	openPopupShop();
	ajaxPostPageSend(102,'');
}

function loginGameCheck(UnameState){
	if(UnameState != "")
	{
		openPopupTop();
		ajaxPostPageSend(103,'');
	}
}
function gamePlayNow(){

		//openPopupTop();
		//ajaxPostPageSend(105,'');

}
function gameclose(){
	//alert(objPopup)
	
	if(objPopup!=null){
		try{
			var tt = objPopup.document.frm.a.value;
			var a = confirm("do you want finish the game?");
			if(a==true){
				if(objPopup!= null) objPopup.close(); 
				popupHide();
			}else{
				
				return;
			}
		}catch(err){
			if(objPopup!= null) objPopup.close(); 
				popupHide();
		}
		
		
	}else{
		window.location.reload();
	}
	
}
function gameclosePoker(){
	//alert(objPopup)
	
	if(objPopup!=null){
		try{
			var tt = objPopup.document.frm.a.value;
			var a = confirm("do you want finish the game?");
			if(a==true){
				if(objPopup!= null) objPopup.close(); 
				popupHide();
				window.location.href="/ngame/play.asp?id=poker"
			}else{
				
				return;
			}
		}catch(err){
			if(objPopup!= null) objPopup.close(); 
				popupHide();
				window.location.href="/ngame/play.asp?id=poker"
		}
		
		
	}else{
		window.location.href="/ngame/play.asp?id=poker"
	}
	
}
function gamecloseForLogout(){
	//alert(objPopup)
	
	if(objPopup!=null){
		try{
			var tt = objPopup.document.frm.a.value;
			var a = confirm("do you want finish the game?");
			if(a==true){
				if(objPopup!= null) objPopup.close(); 
				popupHide();
			}else{
				
				return;
			}
		}catch(err){
			if(objPopup!= null) objPopup.close(); 
				popupHide();
		}
		
		
	}else{
		return 1;
	}
	
}
function eventCheck(){
	openPopup();
	ajaxPostSend(106,'');
}

//--------------------voucher--------------------------

function offlineSubmit(){

	var postString
	var off1 = document.getElementById("off1").value;
	var off2 = document.getElementById("off2").value;
	var off3 = document.getElementById("off3").value;
	var off4 = document.getElementById("off4").value;

	document.getElementById("off1").value="";
	document.getElementById("off2").value="";
	document.getElementById("off3").value="";
	document.getElementById("off4").value="";

	postString = "offs1="+encodeURIComponent(off1);
	postString += "&offs2="+encodeURIComponent(off2);
	postString += "&offs3="+encodeURIComponent(off3);
	postString += "&offs4="+encodeURIComponent(off4);
	openPopupShop();
	ajaxPostPageSend(108,postString);
}

function onlineSubmit(){

	var postString
	var online1 = document.getElementById("online1").value;
	var online2 = document.getElementById("online2").value;
	var online3 = document.getElementById("online3").value;
	var online4 = document.getElementById("online4").value;
	var online5 = document.getElementById("online5").value;

	document.getElementById("online1").value="";
	document.getElementById("online2").value="";
	document.getElementById("online3").value="";
	document.getElementById("online4").value="";
	document.getElementById("online5").value="";

	postString = "onlines1="+online1;
	postString += "&onlines2="+online2;
	postString += "&onlines3="+online3;
	postString += "&onlines4="+online4;
	postString += "&onlines5="+online5;
	openPopupShop();
	ajaxPostPageSend(109,postString);
}

function firstClick(){
	
	if ((document.getElementById("memo").value).trim()=="Message in here...")
	{
		document.getElementById("memo").value = "";
	}
}
function firstClick2(obj){
	
	if (obj.value=="Message in here...")
	{
		obj.value = "";
	}
}

function SpecialCategory(num,category){
	divName="itemDisplayDiv";
	postString = "categoryVal="+category;
	ajaxPostPageSend(53,postString);
}

function tailDelete(tname,pkid,parentPKid){
	alert(tname+"  "+pkid);
	window.location.href="/include/common/deleteTail.asp?tname="+tname+"&pkid="+pkid+"&parent="+parentPKid;
}

function readUpdate(){
	document.getElementById("showNotice").style.display="none";
	divName="showNotice"
	ajaxPostSend(114,"");
}
function activateSnakes(){
	divName="showNotice"
	ajaxPostSend(114,"");
	window.location.href="/ngame/play.asp?id=shooting";
}
var vplayer;
vplayer = 1
function hiddenPlayer(){
	document.getElementById("enjoymusicwraper").style.visibility="hidden";
	vplayer = 0;
	
}
function enjoymusic(){
	if (vplayer==0)
	{
			document.getElementById("enjoymusicwraper").style.visibility="hidden";
			vplayer = 1;
	}else{
			document.getElementById("enjoymusicwraper").style.visibility="";
			vplayer = 0;
	}
	
}
function MusicOn(){
	document.getElementById("enjoymusicwraper").style.display="";
	divName="enjoymusicwraper"
	ajaxPostSend(119,"");
}
function MusicOff(){
	document.getElementById("enjoymusicwraper").style.display="";
	divName="enjoymusicwraper"
	ajaxPostSend(120,"");
}

function OffBtnOn(imgEl){
	imgEl.src="/share/images/Mplayer/PowerOff2.png"
}

function OffBtnOff(imgEl){
	imgEl.src="/share/images/Mplayer/PowerOff.png"
}
function OnBtnOn(imgEl){
	imgEl.src="/share/images/Mplayer/PowerOn2.png"
}

function OnBtnOff(imgEl){
	imgEl.src="/share/images/Mplayer/PowerOn.png"
}
