var aaw=null;
var msgw=null;
var remsgw=null;
var gfw=null;
var gfid=null;
var gfpid=null;
var ywebid=null;
var mw=null;
var resid=null;


function msgDev(code)
	{

		var ce = parseInt(code);
		switch(ce)
			{
				case 999:
				alert("請登入會員");
				location.replace("bm/?hr="+location.href);
				return false;
				break;
				case 700:
				alert("留言回覆完成");	
				return false;
				break;						
			}
	return true;
	}

function showMsg(o,b)
{
	if(msgw!=null)return;

	location.replace("members/smsg");
	if(b==0)return;
/*
	var w = new aiviki.ui.window();

	w.setWidth(100);
	w.setHeight(100);
	w.setContent("<table width='200' style='border:1px solid #dcdcdc;' bgcolor='white'><TR><TD><div id='msgvv'>讀取中..</div></TD></TR><TR><TD><input type='button' value='管理訊息' onclick='location.replace(\"members/smsg\");'></TD></TR></table>");
	w.setX(aiviki.util.getEX(o));
	w.setY(aiviki.util.getEY(o));
	w.show();
	msgw=w;
	aiviki.ax.manage.post("ax/msglist",msgs,"",null);
	*/
}
function showMsgView(ix)
{
	aiviki.ax.manage.post("ax/msgview",msgsv,"",eval("[['a','"+ix+"']]"));
}
function msgback()
{
		aiviki.ax.manage.post("ax/msglist",msgs,"",null);
}
function msgsv(data)
{

	if(data=="999")
	{
		alert("請登入會員");
		return;
	}


var html="<table width='100%' style='padding:10px;'>";
var vv = data.split(",");
	html+="<tr ><td>"+vv[0]+" 說</td><td align=right width=50><input type='button' value='back' onclick='msgback()'></td></tr>";
	html+="<tr><td colspan=2 style='border:1px solid #cccccc'>"+vv[1]+"</td></tr>";
	html+="</table>";
	document.getElementById("msgvv").innerHTML=html;

}
function msgs(data)
{

	if(data=="999")
	{
		alert("請登入會員");
		return;
	}

var html="<table width='100%' style='padding:10px;'>";

if(data!="000")
	{
	var vv = data.split("#");
	for(var i=0;i<vv.length;i++)
		{


		var tmp=vv[i].split(",");
		html+="<tr ><td style='border:1px solid #cccccc' ><span style='padding-right:10px;'>"+tmp[0]+"</span><a href='#' onclick='showMsgView("+tmp[0]+");'>"+tmp[1]+"</a></td></tr>";
		}
	}
	html+="</table>";

	document.getElementById("msgvv").innerHTML=html;
}



function aa(o)
{
	if(aaw!=null)return;
	var w = new aiviki.ui.window();

	w.setWidth(100);
	w.setHeight(100);
	w.setContent("<table width='300' height=200 style='border:2px solid #111111;' bgcolor='#efe8ca'><TR><TD align=center><B >檢舉不適當圖文<B></TD></TR><TR><TD>針對您舉報的圖文，選取您覺得最符合的問題類別，可以加速審查速度。濫用此功能屬違反服務條款，請謹慎。<BR><div align=center>原因：<select id='aaselect' ><option value=1>暴力有惡意</option><option value=2>廣告內容</option><option value=3>侵犯權利</option><option value=4>色情內容</option></select></div></TD></TR><TR><TD align=center><input type='button' value='檢舉' onclick='aago()'> <input type='button' value='取消' onclick='aaclose();'></TD></TR></table>");
	w.center();
	w.show();
	aaw=w;
//	aiviki.ax.manage.post("ax/msglist",msgs,"",null);

}
function aago()
{

if(aaw==null)return;
	var tp = document.getElementById("aaselect").options[document.getElementById("aaselect").selectedIndex].value;
	aiviki.ax.manage.post("ax/aago",aav,"",eval("[['a','"+bid+"'],['b','"+tp+"']]"));

}
function aaclose()
{
if(aaw==null)return;

aaw.destory();
aaw=null;
}
function aav(data)
{
msgDev(data);
aaclose();
}


function buygf(id)
{
	if(gfw!=null)return;
	var w = new aiviki.ui.window();
	gfid=id;
	w.setWidth(500);
	w.setHeight(300);
	var html ="<table width='568'  border=0 cellspacing=0 cellpadding=0><TR><TD><img src='demo/gf_top.gif'></TD></TR><TR><TD bgcolor='#ededed' background='demo/gf_bg.jpg'>";
	html+="<div style='padding:10px;'>"+document.getElementById("gf_mmy").innerHTML+"</div>";
	html+="<table cellspacing=5 cellpadding=10><TR><TD width=120 align=center><img src='"+document.getElementById("gf_image"+id).src+"' width=100 height=100></TD>";
	html+="<TD valign=top style='line-height:25px;><span style='font-size:18px;'>"+document.getElementById("gf_name"+id).innerHTML+"</span><BR><img src='demo/mys.jpg'>"+document.getElementById("gf_money"+id).innerHTML+"<BR>"+document.getElementById("gf_info"+id).innerHTML+"</TD></TR></table>";
	html+="</TD></TR><TR><TD background='demo/gf_down.jpg' height=359 style='padding:20px;'>留言內容：(最多500個字)<br><BR><textarea id='gftext' style='height:130px;width:350px;'></textarea><BR><BR>是否公開身分 <input type='radio' value='1' name='gf1' id='gf11' checked> 公開 <input type='radio' value='0' name='gf1' id='gf10'> 不公開  <BR><BR>是否公開留言內容 <input type='radio' value='1' name='gf2' id='gf21' checked> 公開 <input type='radio' value='0' name='gf2' id='gf20'> 不公開 <BR><BR><input type='button' value='確認送出' onclick='buygfsend()'> <input type='button' value='取消'  onclick='buygfclose()'></TD></TR></table>";
	w.setContent(html);
	w.center();
	w.show();
	gfw=w;
}
function buygfclose()
{
	if(gfw==null)return;

gfw.destory();
gfw=null;
}

function buygfsend()
{
if(gfw==null)return;

var t = document.getElementById("gftext").value;


aiviki.ax.manage.post("ax/gfbuy",bfv,"",eval("[['a','"+gfid+"'],['b','"+gfpid+"'],['c','"+t+"']]"));
}
function bfv(data)
	{
	if(!msgDev(data))
	{
location.reload();
	}
	}
function pgfv(data)
{
	if(msgDev(data))
		location.replace("blog_gf.jsp?a="+ywebid);
	
}
function pgf(id)
{

	aiviki.ax.manage.post("ax/pugf",pgfv,"",eval("[['a','"+id+"']]"));
}

function pushBook(id)
{
		aiviki.ax.manage.post("ax/pushb",msgDev,"",eval("[['a','"+bid+"'],['b','"+id+"']]"));
}

function loveBook(id)
{
	aiviki.ax.manage.post("ax/loveb",msgDev,"",eval("[['a','"+bid+"'],['b','"+id+"']]"));
}
function rmolove(id)
{
	aiviki.ax.manage.post("ax/revloveb",relovems,"",eval("[['a','"+id+"']]"));
}
function relovems(data)
	{
	if(!msgDev(data))
	{
	location.reload();
	}
	}
function showMenu(o)
{
	if(mw!=null)return;
	var w = new aiviki.ui.window();

	w.setWidth(50);
	w.setHeight(300);
	w.setContent("<table width=50 bgcolor='white' style='border:1px solid #111111;'><tr><TD align=center><a href='blog_bs.jsp?a="+ywebid+"'>繪本</a><BR><a href='blog_img.jsp?a="+ywebid+"'>圖庫</a><BR><a href='blog_love.jsp?a="+ywebid+"'>收藏</a><BR><a href='blog_mf.jsp?a="+ywebid+"'>好友</a><BR><a href='blog_gf.jsp?a="+ywebid+"'>禮物</a><BR><a href='blog_msg.jsp?a="+ywebid+"'>留言</a><BR></TD></tr></table>");

	w.setX(aiviki.util.getEX(o)-100);
	w.setY(aiviki.util.getEY(o));
	w.show();
	aaw=w;
}

function remsg(id)
{
	if(remsgw!=null)return;
	resid=id;
	var w = new aiviki.ui.window();

	w.setWidth(100);
	w.setHeight(100);
	w.setContent("<table width='300' height=200 style='border:2px solid #111111;' bgcolor='#efe8ca'><TR><TD align=center><B >回覆留言<B></TD></TR><TR><TD><textarea style='width:100%' id='remsgtext'></textarea></TD></TR><TR><TD align=center><input type='button' value='回覆' onclick='remsggo()'> <input type='button' value='取消' onclick='remsgclose();'></TD></TR></table>");
	w.center();
	w.show();
	remsgw=w;
}
function remsgDev(data)
{
	
if(!msgDev(data))
	{
	location.reload();
	}
}
function remsggo()
{

	if(remsgw==null)return;
	aiviki.ax.manage.post("ax/remsg",remsgDev,"",eval("[['a','"+resid+"'],['b','"+document.getElementById("remsgtext").value+"']]"));
}
function remsgclose()
{
	if(remsgw==null)return;
	remsgw.destory();
	remsgw=null;
}