﻿function $(id){
  if (typeof(id) != "string" || id == "") return null;
  if (document.all) return document.all(id);
  if (document.getElementById) return document.getElementById(id);
  try {return eval(id);} catch(e){ return null;}
}
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");};
var Request = {QueryString : function(item){var svalue = location.search.match(new RegExp('[\?\&]' + item + '=([^\&]*)(\&?)','i'));return svalue ? svalue[1] : svalue;}};
document.write("<scr"+"ipt language=\"javascript\" src=\"/Js/ModalPopup.js\"></scr"+"ipt>");
document.write("<scr"+"ipt language=\"javascript\" src=\"/Js/getAjax.js\"></scr"+"ipt>");
var Collect = function()
{    
    AjaxMethod.CollectArticle(ArticleID, CollectArticle_CallBack);
};
var CollectArticle_CallBack = function(rs)
{    
    if(rs.value != null)
    {        
        if(rs.value < 0)
        {
            var strMsg = "<table width=\"350\" border=\"0\" cellpadding=\"0\" cellspacing=\"15\">";
            strMsg += "<tr>";
            strMsg += "<td colspan=\"3\">對不起！你未登入，如果你未註冊可以先註冊。</td>";
            strMsg += "</tr>";
            strMsg += "<tr>";
            strMsg += "<td align=\"right\"><input name=\"B1\" type=\"button\" id=\"B1\" onClick=\"JavaScript:window.location='http://www.chinayes.com/Member/Login.aspx?ReturnUrl='+ escape(window.location + '?collect=1');\" value=\" 登 入 \"></td>";
            strMsg += "<td align=\"center\"><input name=\"B2\" type=\"button\" id=\"B2\" onClick=\"JavaScript:window.location='http://www.chinayes.com/Member/Registration.aspx'\" value=\" 註 冊 \"></td>";
            strMsg += "<td align=\"left\"><input name=\"B3\" type=\"button\" id=\"B2\" onClick=\"JavaScript:closediv('MsgDiv');\" value=\" 取 消 \"></td>";
            strMsg += "</tr>";
            strMsg += "</table>";
            CreateMsgContent("您未登入或未註冊",strMsg);
        }
        else
        {
            var Msgs = new Array();Msgs[0] = "收藏文章失敗！";Msgs[1] = "該文章，您已收藏了！";Msgs[2] = "收藏文章成功！";
            CreateTiMsg("收藏文章",Msgs[rs.value].toString());         
        }
    }
};
var modFintsSize = function (mType)
{
	var obj = document.getElementById("newsContent");
	var newsFontSize = parseInt(obj.style.fontSize ? obj.style.fontSize : "114%");
	if(mType.toLowerCase()=="add")
		 obj.style.fontSize = parseInt(newsFontSize + 10).toString() + "%";
	else
	{
		if(newsFontSize>80)
		{
			obj.style.fontSize = parseInt(newsFontSize - 10).toString() + "%";
		}
	}
};
var BindSeriesNoList = function()
{
    obj = $("ddlMagazineSeries");
    obj.onchange = function(){ window.location="../" + this.options[this.selectedIndex].value; }
    var aselect = new taiSonAjaxSelect("AjaxMethod.GetSeriesNoList", "ID", "SeriesNo", obj, SeriesID, null, "");
    aselect.Value = MagazineID;
    //alert(aselect.ajaxMethod);
    aselect.onload();
};
var BindVisitArticle = function()
{
    obj = $("visitAmount");
    var bva = new taiSonAjax("AjaxMethod.VisitArticle", obj, ArticleID.toString());
};
var BindVisitArticlePage = function()
{
    obj = $("ArticlePage");
    var bva = new taiSonAjax("AjaxMethod.GetArticlePage", obj, ArticleID.toString()+"|"+SeriesID.toString());
    var isCollect = (Request.QueryString("collect") && Request.QueryString("collect").trim()) ? parseInt(Request.QueryString("collect").trim()) : 0;    
    if(isCollect > 0){Collect();}
};
function Print()
{
    window.location="/PrintArticle.aspx?id=" + ArticleID.toString();
}