
function ToBirthdayPage()
{
	top.location = 'mygift.html';
	setCookie("target", 'mygift_birthday_new.html');;
}

function ToTX()
{
	top.location = 'mygift.html';
	setCookie("target", 'mygift_remind.html');
	return;
}

function goMall(mallno)
{
	top.location="giftshop.html?mallno=" + mallno;
}

function RemindTips()
{
	RemindTips.prototype.ShowRsp= function()
	{
		//alert(top.g_XDoc["fresh_remind"].xml);
		//alert('In ShowRsp')
		var tmpObj = document.all.id_remind_tips;
		if (!tmpObj)
		{
			//alert('html is modified');
			return;
		}

		//err process
		var err = top.g_XDoc["fresh_remind"].getElementsByTagName("error");
		if (err[0])
		{
			tmpObj = tmpObj.getElementsByTagName("a");
			if (tmpObj.length > 0)
			{
				tmpObj[0].innerHTML = "";//err[0].text;
			}
			return;
		}

		//success
		//alert(top.g_XDoc["fresh_remind"].xml);

		var recs = top.g_XDoc["fresh_remind"].getElementsByTagName("Record");
		if (recs.length  == 0)
		{
			return;
		}

		tmpObj = document.all.id_remind_tips;
		tmpObj = tmpObj.getElementsByTagName("li");
		//alert(tmpObj.length);

		for (var i = 0; i< recs.length; ++i)
		{
			//alert(recs[i].childNodes[0].text);
			switch (parseInt(recs[i].childNodes[0].text))
			{
				case 1:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "我的生日！！"
					tmpObj[i].childNodes[1].title="我在这天过生日";
					tmpObj[i].childNodes[1].href="javascript:ToBirthdayPage();"
					break;
				}
				case 2:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "好友的生日"
					tmpObj[i].childNodes[1].title="我的好友" + recs[i].childNodes[1].text + "的生日！";
					tmpObj[i].childNodes[1].href="javascript:goOther(" +  recs[i].childNodes[3].text + ");"
					break;
				}
				case 3:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = recs[i].childNodes[4].text
					tmpObj[i].childNodes[1].title="这天是" + recs[i].childNodes[4].text;
					tmpObj[i].childNodes[1].href="javascript:goMall(1);"
					break;
				}
				case 4:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "我的纪念日";
					tmpObj[i].childNodes[1].title="好友：" + recs[i].childNodes[1].text + "提醒语：" + recs[i].childNodes[4].text;
					tmpObj[i].childNodes[1].href="javascript:ToTX();"
					break;
				}
			}
		}
	}

	RemindTips.prototype.ShowRsp_Top= function()
	{
		//alert(top.g_XDoc["fresh_remind"].xml);
		//alert('In ShowRsp_Top')
		var tmpObj = document.all.id_remind_tips;
		if (!tmpObj)
		{
			//alert('html is modified');
			return;
		}

		//err process
		var err = top.g_XDoc["fresh_remind"].getElementsByTagName("error");
		if (err[0])
		{
			tmpObj = tmpObj.getElementsByTagName("a");
			if (tmpObj.length > 0)
			{
				tmpObj[0].innerHTML = "";//err[0].text;
			}
			return;
		}

		//success
		//alert(top.g_XDoc["fresh_remind"].xml);

		var recs = top.g_XDoc["fresh_remind"].getElementsByTagName("Record");
		if (recs.length  == 0)
		{
			return;
		}

		tmpObj = document.all.id_remind_tips;
		tmpObj = tmpObj.getElementsByTagName("li");
		//alert(tmpObj.length);

		for (var i = 0; i< 1; ++i)
		{
			//alert(recs[i].childNodes[0].text);
			//alert(tmpObj[i].innerHTML)
			switch (parseInt(recs[i].childNodes[0].text))
			{
				case 1:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "是我的生日!"
					//tmpObj[i].childNodes[1].title="我在这天过生日";
					tmpObj[i].childNodes[1].href="javascript:ToBirthdayPage();"
					break;
				}
				case 2:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "是" + formatNick(recs[i].childNodes[1].text) +  "的生日!";
					//tmpObj[i].childNodes[1].title="我的好友" + recs[i].childNodes[1].text + "的生日！";
					tmpObj[i].childNodes[1].href="javascript:goOther(" +  recs[i].childNodes[3].text + ");"
					break;
				}
				case 3:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "是" + recs[i].childNodes[4].text;
					//tmpObj[i].childNodes[1].title="这天是" + recs[i].childNodes[4].text;
					tmpObj[i].childNodes[1].href="javascript:goMall(1);"
					break;
				}
				case 4:
				{
					tmpObj[i].childNodes[0].innerText = recs[i].childNodes[2].text
					tmpObj[i].childNodes[1].innerText = "是和" + formatNick(recs[i].childNodes[1].text) + "的纪念日";
					//tmpObj[i].childNodes[1].title="好友：" + recs[i].childNodes[1].text + "提醒语：" + recs[i].childNodes[4].text;
					tmpObj[i].childNodes[1].href="javascript:ToTX();"
					//alert(tmpObj[i].innerHTML)
					break;
				}
			}
		}
	}

	RemindTips.prototype.AppReq = function(flag)
	{
			var xUrl = new String;
			xUrl = "/cgi-bin/cgi_fresh_remind";
			//alert(top.loader.loadXMLAsyncNoCache);
			//alert(RemindTips.prototype.ShowRsp);
			//alert(tmp)

			//have response
			if (top.g_XDoc["fresh_remind"])
			{
				if (flag)
				{
					RemindTips.prototype.ShowRsp_Top();
				}
				else
				{
					RemindTips.prototype.ShowRsp();
				}
				return;
			}

			//have already send http request
			if (top.g_sendReq)
			{
				setTimeout(function(){RemindTips.prototype.AppReq(flag)}, 600);
				return;
			}

			if (flag)
			{

				//alert(flag + 'pre ShowRsp_Top');
				top.loader.loadXMLAsyncNoCache("fresh_remind", xUrl, RemindTips.prototype.ShowRsp_Top, null, null)
				top.g_sendReq = true;
			}
			else
			{
				//alert('pre ShowRsp');
				top.loader.loadXMLAsyncNoCache("fresh_remind", xUrl, RemindTips.prototype.ShowRsp, null, null)
				top.g_sendReq = true;
			}
	}
};



function InitPage(flag)
{
	var stRemindTips  = new RemindTips();
	stRemindTips.AppReq(flag);
};


