﻿	function ShowWalkthrough_CallBack(response)
	{
		//if the server side code threw an exception
		if (response.error != null)
		{    
			alert(response.error); //we should probably do better than this
			return;
		}

		var ds = response.value; 
		if (ds == null)
		{
			alert("获取攻略出错！");
			return;
		}

		if (typeof(ds) == "object" && ds.Tables != null) 
		{
			// 更新人
			document.getElementById("WTAuthor").innerHTML = "更新人：<a href=\"/orzbbs/UserInfoview.aspx?id=" 
				+ ds.Tables[0].Rows[0].UID + "\" target=\"_blank\">" + ds.Tables[0].Rows[0].NickName + "</a>";
			
			// 攻略Iframe
			var tContentFrame = document.getElementById("WTContent");
			
			tContentFrame.setAttribute("src", "Walkthrough/" 
				+ ds.Tables[0].Rows[0].StrategyFile);
		}
	}
	
	// 根据内容动态调整IFrame的高度
	function AdjustFrameHeight(tContentFrame)
	{
		tContentFrame.style.display = "block";
		if (tContentFrame.Document && tContentFrame.Document.body.scrollHeight) //如果用户的浏览器是IE
			{
				tContentFrame.height = tContentFrame.Document.body.scrollHeight;
			}
			else if (tContentFrame.contentDocument && tContentFrame.contentDocument.body.offsetHeight) //如果用户的浏览器是NetScape
			{
				tContentFrame.setAttribute("height", tContentFrame.contentDocument.body.offsetHeight);
			}
	}

	function ShowWalkthrough(vID)
	{
		GameWalkthrough.GetWalkthrough(document.Form1.action.substring(document.Form1.action.indexOf("=") + 1), vID, 			ShowWalkthrough_CallBack);
	}

	function addFavourte_CallBack_Walkthrough(response)
	{
		//if the server side code threw an exception
		if (response.error != null)
		{    
			alert(response.error); //we should probably do better than this
			return;
		}  

		if (response.value == true)
		{
			alert("添加成功！在你的个人空间里边可以直接看到它了。");
		}
		else
		{
			alert("该游戏已经在你的收藏里边了。");
		}
	}
	
	function addGameToFavourite_Walkthrough()
	{
		// 如果没有注册
		if (cookies["UserID"] == null)
		{
			alert("对不起！你还没有注册或登陆！");
			return;
		}
		
		GameWalkthrough.AddToFavourite(document.Form1.action.substring(document.Form1.action.indexOf("=") + 1), 
			cookies["UserID"], addFavourte_CallBack_Walkthrough);
	}
