/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.org

請仔細閱讀以下許可協議。當您使用本軟體，您將自動成為本協議的一方並受到本協議的約束。

軟體和文檔受到臺灣及中國大陸著作權法及國際條約的保護。您不得：
a)營利、出租或者出借軟體或文檔的任何部分。
b)反向工程、分解、反編譯或者企圖察看軟體的源代碼作為商業用途。
c)修改或者改變軟體，或者與其他程式結合。

許可人保留軟體及文檔的所有權利和權益。您不能通過本許可協定獲得軟體的任何所有權和知識產權。
===================================================== */
//###### 分頁 begin #####
function pagesplit(saletotal,page,type)
{
	var temp_html="";
	temp_html+=page_table1+'<tr><td>分頁:';
	var totalpage=0;
	if(saletotal%8==0)
	{
		totalpage=saletotal/8;
	}else
	{
		totalpage=(saletotal/8)+1;
	}
	for(var i=1;i<=totalpage;i++)
	{
		if(i==page)
		{
			temp_html+=' '+i+' ';
		}else
		{
			temp_html+=' <a href="javascript:parent.page_jump(\''+i+'\')" >'+i+'</a> ';
		}
	}
	temp_html+='</td></tr>'+temp_table2;
	if(type==null)
	{
		w_c(temp_html);
	}
	else
	{
		return temp_html;
	}
};
function page_jump(s)
{
	parent.wog_view.document.pageform.page.value=s;
	parent.wog_view.document.pageform.submit();
};
function sel_type(s)
{
	var fp=parent.wog_view.document.pageform;
	if(fp.key != null){fp.key.value='';}
	fp.type.value=s;
	fp.submit();
};
function system_view(s1,s2,type)
{
	if(type!=null)
	{
		w_c(temp_table1+group_menu+temp_table2);
		w_c(hr);
	}
	w_c(temp_table1);
	w_c('<tr class="head_td"><td>內容</td><td>發生時間</td></tr>');
	if(s1!="")
	{
		var a1=s1.split(";");
		var a2=s2.split(";");
		for(var i=0;i<a1.length;i++)
		{
			w_c('<tr><td class=b1>'+a1[i]+'</td><td>'+a2[i]+'</td></tr>');
		}
	}else
	{
		w_c('<tr><td colspan="8" >尚未發生任何事件</td></tr>');
	}
	w_c('<tr bgcolor="#4B689E"><td>更改狀態</td></tr>');
    w_c('<tr><td><input type="text" name="p_status" value="" size="60">　<input type="button" value="改變狀態" onClick="parent.act_click(\'store\',\'status_save\',p_status.value)"></td></tr>');
    w_c('<tr><td><font color="red"><b>請勿輸入不雅文字，經查證將【沒有警告】的情況下刪除該帳號(可以輸入30個字元)</b></font></td></tr>');
	w_c(temp_table2);
	p_c();
};
function pk_view(s,money,win,lost)
{
	if(s==1)
	{
		var pk_yes="checked";
		var pk_no="";
	}else
	{
		var pk_yes="";
		var pk_no="checked";
	}
	w_c(build_table1);
	w_c('<tr><td >參加PK</td><td >PK金額</td></tr>');
	w_c('<tr><td ><input type="radio" name="pk_setup" value="1" '+pk_yes+'>YES <input type="radio" name="pk_setup" value="0" '+pk_no+'>NO </td><td ><input type="text" name="pk_money" value="'+money+'" size="7" maxlength="7"></td></tr>');
	w_c('<tr><td colspan="2" ><input type="submit" value="確定"> <input type="button" value="取消" onClick="parent.p_s_close();"></td></tr>');
	w_c('<tr><td colspan="2" >PK戰果紀錄 : WIN '+win+' / LOST '+lost+'</td></tr>');
	w_c('<tr><td colspan="2" >PK金額設定最高100000最低1000,身上現金低於最低金額不能參加PK,系統會自動設定不參加PK賽</td></tr>');
	w_c(temp_table2);
	w_c('<input type="hidden" name="f" value="pk">');
	w_c('<input type="hidden" name="act" value="setup">');
	p_as();
};

function id_admin()
{
	w_c('<form action="wog_act.php" method="post" target="mission">');	
	w_c(temp_table1);
	w_c(temp_table2);
	w_c('</form>');
	w_c('<form action="wog_act.php" method="post" target="mission">');	
	w_c(temp_table1);
	w_c('<tr><td>新密碼</td><td>舊密碼</td><td>操作</td></tr>');
	w_c('<tr><td><input type="text" size="12" maxlength="12" name="new_pw" ></td><td ><input type="password" size="12" name="old_pw"></td><td><input type="submit" value="改變密碼"></td></tr>');
	w_c('<input type="hidden" name="f" value="chara">');
	w_c('<input type="hidden" name="act" value="chpw">');
	w_c(temp_table2);
	w_c('</form>');
	w_c('<form action="wog_etc.php" target="mission">');
	w_c(temp_table1);
	w_c('</form>');
	w_c(temp_table2);
	p_c();
};

function king_menu()
{
    w_c('<form action="wog_etc_king.php" method="post" target="mission">');
	w_c(temp_table1);
	w_c('<tr class=head_td><td colspan="17"><a href=wog_etc.php?f=king&type=win target="mission">勝場</a> <a href=wog_etc.php?f=king&type=1 target="mission">等級</a> <a href=wog_etc.php?f=king&type=hp target="mission">HP</a> <a href=wog_etc.php?f=king&type=3 target="mission">物攻</a> <a href=wog_etc.php?f=king&type=4 target="mission">魔攻</a> <a href=wog_etc.php?f=king&type=5 target="mission">敏捷</a> <a href=wog_etc.php?f=king&type=6 target="mission">PK</a> <a href=wog_etc.php?f=king&type=8 target="mission">好野人</a></tr>');
	w_c('<tr><td colspan="17">..</td></tr>');
	w_c(temp_table2);
	w_c('</form>');
	p_c();
};
//###### event begin ######
//###### event begin ######
function event()
{
	var now_time=new Date();
	w_c('<form action="wog_act.php" method="post" target="mission">');
	w_c(temp_table1);
	w_c('<tr><td>鬼大要考驗大家是否有認真在玩</td></tr>');
	w_c('<tr><td>凡是鬧場-擾亂-經勸阻不聽者，本站有權將該角色刪除不得有議。</td></tr>');
	w_c('<tr><td colspan="2"><img id="enent_code" src="wog_etc.php?f=confirm&time='+now_time.getTime()+'"><br><a href=javascript:parent.recode();>看不清楚，重新獲取驗證碼</a></td></tr>');
	w_c('<tr><td>請輸入安全驗證碼:<input type="text" name="sec_code" size="8">(沒有數字，不分大小寫)</td></tr>');
	w_c('<tr><td colspan="2"><input class="text" type="button" value="填好答案了,放我過關吧!!" onClick="parent.foot_turn(\'event\',\'\',this.form.sec_code.value,\'\')"></td></tr>');
	w_c(temp_table2);
	w_c('</form>');
	p_c();
};
function recode()
{
	var now_time=new Date();
	f.getElementById("enent_code").src='wog_etc.php?f=confirm&time='+now_time.getTime();
}
//###### xmas_happy ######
function xmas_happy(s)
{	
	w_c(temp_table1);
	if(s==1)
	{
		w_c('<tr><td><img border="0" src=http://k53.pbase.com/o5/33/110733/1/69740040.TiqK7YfY.LeeCooperLeeCooper2006_021.jpg></td></tr>');
		w_c('<tr><td>繼續努力</td></tr>');
	}
	if(s==2)
	{
		w_c('<tr><td><img border="0" src=http://i.pbase.com/o4/33/110733/1/65075517.aljuTijO.chiling_artdeco_018.jpg></td></tr>');
		w_c('<tr><td>繼續努力</td></tr>');
	}
	if(s==3)
	{
		w_c('<tr><td><img border="0" src=http://k43.pbase.com/o4/33/110733/1/52936435.chiling_129copy.jpg></td></tr>');
		w_c('<tr><td>繼續努力</td></tr>');
	}
	if(s==4)
	{
		w_c('<tr><td><img border="0" src=http://i.pbase.com/o4/33/110733/1/65075633.1W7My1Cw.chiling_88_023.jpg></td></tr>');
		w_c('<tr><td>繼續努力</td></tr>');
	}
	w_c(temp_table2);
	p_c();
};
//###### xmas_money ######
function xmas_money(s)
{
	w_c(temp_table1);
	w_c('<tr><td>恭喜抽到金錢 '+s+'</td></tr>');
	w_c(temp_table2);
	p_c();
};
//###### xmas_money ######
function xmas_item(s)
{
	arm_link();
	w_c(temp_table1);
	w_c('<tr><td>恭喜抽到 '+s+'</td></tr>');
	w_c(temp_table2);
	p_c();
};
//########## online peo begin ###########
function onlinelist(peo,type)
{
	var boy=0;
	var girl=0;
	var j=0;
	var area_total=0;
	var temp_s=Gookie("wog_set_onlinelist");
	var temp_t=Gookie("wog_set_online_title");
	var display_status="";
	var top_img=""
	var hero_top="";
	switch(type)
	{
		case 1:
			w_o(online_temp_table1+'<tr><td colspan="2"><a href=javascript:parent.online_title_show() target="foot">在線名單</a></td></tr>'+temp_table2);
			if(peo!="")
			{
				display_status=(temp_t=="1")?"block":"none";
				w_o('<div id="area_-1" style="display:'+display_status+'">');
				var s1=peo.split(";");
				for(var temp_p=0;temp_p<sec.length;temp_p++)
				{
					area_total=0;
					w_o('<div id="area_'+temp_p+'" style="display:none">');
					w_o(online_temp_table1+'<tr><td><font color="CC66CC">名稱</font></td><td><font color="CC66CC">重</font></td></tr>');
					j = 0;
					for(var i=0;i<s1.length;i++)
					{
						var s2=s1[i].split(",");
						if(temp_p==s2[5])
						{
							var fcolor=psex(s2[1]);
							(s2[1]=="1")?boy++:girl++;
							(s2[3]==1)?s2[3]="Y":s2[3]="N";
							j++;
							if(s2[6] == "")s2[6]="沒有輸入";
							if(s2[7] == undefined || s2[7] == 10)s2[7]="?";
							if(s2[8] == undefined)s2[8]="9";
							if(s2[9] == undefined)s2[9]="";
							if(s2[10]==1)
	                        {
	                        top_img='<img src="'+s2[9]+'" width="80" height="60">';
	                        }else
	                        {
		                    top_img='';
	                        }
		                 if(s2[1]=="1")
	                     {
		                switch (s2[8])
		                 {
			           case '0':
				          hero_top="新兵";
			              break;
			          case '1':
				          hero_top="副駐點長";
			              break;
			          case '2':
				          hero_top="駐點兵長";
			              break;
			          case '3':
				          hero_top="侍衛長";
			              break;
			          case '4':
				          hero_top="強者";
			              break;
			          case '5':
				          hero_top="猛將";
			              break;
			          case '6':
				          hero_top="修羅";
			              break;
			          case '7':
				          hero_top="達人";
			              break;
			          case '8':
				          hero_top="群藝出眾";
			              break;
			          case '9':
				          hero_top="智勇雙全";
			              break;
			          case '10':
				          hero_top="無雙獵手";
			              break;
			          case '11':
				          hero_top="戰無不勝";
			              break;
			          case '12':
				          hero_top="蠻荒武聖";
			              break;
			          case '13':
				          hero_top="獵魔高手";
			              break;
			          case '14':
				          hero_top="至尊無敵";
			              break;
			          case '15':
				          hero_top="戰技無雙";
			              break;
		                  }
	                      }else
	                      {
		              switch (s2[8])
		                  {
			          case '0':
				          hero_top="女衛兵";
			              break;
			          case '1':
				          hero_top="女副將";
			              break;
			          case '2':
				          hero_top="女衛兵長";
			              break;
			          case '3':
				          hero_top="弓腰姬";
			              break;
			          case '4':
				          hero_top="女達人";
			              break;
			          case '5':
				          hero_top="南蠻女王";
			              break;
			          case '6':
				          hero_top="真戀姬";
			              break;
			          case '7':
				          hero_top="一代美人";
			              break;
			          case '8':
				          hero_top="激鬥舞者";
			              break;
			          case '9':
				          hero_top="俏皮魔女";
			              break;
			          case '10':
				          hero_top="國色天香";
			              break;
			          case '11':
				          hero_top="絕代佳人";
			              break;
			          case '12':
				          hero_top="無雙亂舞";
			              break;
			          case '13':
				          hero_top="霸王瑜姬";
			              break;
			          case '14':
				          hero_top="真女無雙";
			              break;
			          case '15':
				          hero_top="戀姬無雙";
			              break;
		                    }
	                        }
							w_o('<tr><td ><a href=javascript:parent.yesname("'+s2[0]+'") target="foot" title="'+s2[6]+'"><b><font color="'+fcolor+'">'+top_img+'<br>'+s2[0]+'</a></font><br><font color="FF3D8B">LV '+s2[2]+'</font><br><font color="FFB13D">'+hero_top+'</font><font color="B88A00">'+s2[8]+'</font><br><font color="CC6666">━━━━━━</font></b></td><td ><a title="PK:'+s2[3]+',金額:'+s2[4]+'">'+s2[7]+'</td></tr>');
							area_total++;
						}
					}
					w_o(temp_table2+'</div>');
					if(j > 0)
					{
					w_o(online_temp_table1+'<tr><td  background="" colspan="3">↑<a href=javascript:parent.onlinelist_show("'+temp_p+'") target="foot">'+sec[temp_p][0]+'('+area_total+')</a>↑</td></tr>'+temp_table2);
				    }
				}
				w_o(online_temp_table1+'<tr><td  background="" colspan="3"><font color="#66ccff">男生</font> '+boy+' 人</td></tr>');
				w_o('<tr><td colspan="3"><font color="#ff99cc">女生</font> '+girl+' 人</td></tr>');
				w_o('<tr><td colspan="3">線上人數 '+s1.length+' 人</td></tr>'+temp_table2);
				w_o('</div>');
			}else
			{
				w_o(online_temp_table1+'<tr><td colspan="3">線上人數 0 人</td></tr>'+temp_table2);
			}
		break;
		case 2:
		    w_o(online_temp_table1+'<tr><td colspan="3">線上人數 '+peo+' 人</td></tr>'+temp_table2);
		break;
	}

	p_o();
	Drag.init(f.getElementById("wog_online"));
	if(temp_s!=null)
	{
		onlinelist_show(temp_s);
	}
};
function onlinelist_show(a)
{
	var temp_s=Gookie("wog_set_onlinelist");
	for(var temp_p=0;temp_p<sec.length;temp_p++)
	{
		f.getElementById("area_"+temp_p).style.display="none";
	}
	f.getElementById("area_"+a).style.display="block";
	Sookie("wog_set_onlinelist", a);
};
function online_title_show()
{
	var temp_s=Gookie("wog_set_online_title");
	if (temp_s == "1") {
		f.getElementById("area_-1").style.display = "none";
		Sookie("wog_set_online_title", "2");
	}else
	{
		f.getElementById("area_-1").style.display="block";
		Sookie("wog_set_online_title", "1");
	}
};
function psex(s)
{
	if(s=="1")
	{
		return "#66ccff";
	}else
	{
		return "#ff99cc";
	}
};