
    //添加评分和顶踩到数据库，同时更新显示
    function addRating(type, articleid) {
        var cookiename, account;
        if (type == 0) {
            addFen(type, articleid)
        }
        else if (type == 6 || type == 7) {
            cookiename = "td" + articleid;
            account = jQuery.cookie(cookiename);
            if (account == "UpDownOK") {
                alert("很抱歉，您今天已经发表了观点！");
            }
            else {
                addFen(type, articleid)
                jQuery.cookie(cookiename, "UpDownOK", { path: '/', expires: 1 }); 	//添加成功，写入cookie
            }
        }
        else {
            cookiename = "rate" + articleid;
            account = jQuery.cookie(cookiename);
            if (account == "RateOK") {
                alert("很抱歉，您今天已经打过分了！");
            }
            else {
                addFen(type, articleid)
                jQuery.cookie(cookiename, "RateOK", { path: '/', expires: 1 }); 	//添加成功，写入cookie
            }
        }
    }

    //加分
    function addFen(type, articleid) {
   
        jQuery.ajax
		({
		    type: "Post",
		    url: "/ArtHander/Rating.aspx?type=" + type + "&articleid=" + articleid,
		    dataType: 'json',
		    cache: false,
		    beforeSend: function(data) { },
		    success: function(data) {
	        
	        jQuery("#sumTop").html(data.sumtop);
	        jQuery("#sumDown").html(data.sumdown);
	        jQuery("#aScore").html(data.ascore);
		    },
		    error: function() {
		    jQuery("#sumTop").html("0");
		    jQuery("#sumDown").html("0");
		    jQuery("#aScore").html("0.0");
		    }
		});
}


//初始化页面地址

function InitiPage(objAID,objTypeId,objContainer)
{
//^_^()^_^　　TypeId=0初始化页面；TypeId=1计算此页面的浏览次数；TypeId=2置顶；TypeId=3写进blog；TypeId=4添加至我的收藏
   var url="/ArtHander/ArtFunction.ashx?Tem="+Math.random()+"&AID="+objAID+"&TypeId="+objTypeId;
   var myAjax=new Ajax.Request(url,{method:'get',asynchronous:false,onComplete: function(transport)
   {
    if(transport.status==200 && transport.responseText!="")
                {
                var str = transport.responseText;
               
                    switch(objTypeId)
                    {
                        case '0':
                        {
                         
                            if(str.indexOf('ReturnUrl')==-1)
                            {
                                
                                myArray=str.split(',');
                                $("ArtHit").innerHTML=myArray[3];
                                $("HDingCount").innerHTML=myArray[1];
                                $("HWriteBlogCount").innerHTML=myArray[2];
                               
                                
                            }
                            else
                            {
                                window.location.href=str;
                            }
                            break;
                        }
                        case '2':
                        {
                            $(objContainer).innerHTML=str;
                            break;
                        }
                        case '3':
                        {
                            $(objContainer).innerHTML=str;
                            break;
                        }
                    }
                }
   }});
   
   if(objTypeId != '0')
   {
	 
/*
文章末尾加icon
*/
(function(){
	var TrimLeft = function(str)
	{
		var whitespace = '\t\r\n 　';
		while(str.length > 0 && whitespace.indexOf(str.substr(0, 1)) != -1)
		{
			str = str.substr(1);
		}
		return str;
	};
 
	var TrimRight = function(str)
	{
		var whitespace = '\t\r\n 　';
		while(str.length > 0 && whitespace.lastIndexOf(str.substr(str.length - 1, 1)) != -1)
		{
			str = str.substr(0, str.length - 1);
		}
		return str;
	};
 
	var Trim = function(str)
	{
		return TrimLeft(TrimRight(str));
	};
 
	var GetLastAvaNode = function(nodes)
	{
		for(var i=nodes.length-1; i>=0; --i)
		{
			var itemNode = nodes[i];
			if(itemNode.nodeName != "#text")
				return itemNode;
			else
			{
				if(Trim(itemNode.nodeValue) != "")
					return itemNode;
				else
				{
					continue;
				}
			}
		}
		return null;
	};
 
	var contentEleObj = document.getElementById("zoom");
	//alert(contentEleObj);
	if(contentEleObj.childNodes.length>0)
	{
		var lastEleObj = contentEleObj.children[contentEleObj.children.length-1];

		if(lastEleObj.tagName.toLowerCase() == "p")
		{
					
var avaNode = GetLastAvaNode(lastEleObj.childNodes);
			if(avaNode && 
				avaNode.nodeName == "#text" && Trim(avaNode.nodeValue).length > 15)
			{
				
				var iconEleObj = document.createElement("img");
				iconEleObj.src = "http://youzhi.cngrain.com/favicon.gif";
				iconEleObj.border="0"
				iconEleObj.height="16"
				iconEleObj.width="16"
				var linkEleObj = document.createElement("a");
				linkEleObj.href = "http://youzhi.cngrain.com/";
				linkEleObj.target = "_blank";
				linkEleObj.alt = "点击进入中华油脂网首页";
				linkEleObj.title = "点击进入中华油脂网首页";
				linkEleObj.id = "backqqcom";
				linkEleObj.bossZone = "backqqcom";
				linkEleObj.appendChild(iconEleObj);
				lastEleObj.appendChild(linkEleObj);
			}
		}
	}
})();

   }
}

        //获取文章列表
        function getHotArtList(objContainer,objAID,objTypeID)
        {
            var url="/ArtHander/HotNewsList.ashx?AID="+objAID+"&TypeId="+objTypeID;
            var myAjax=new Ajax.Updater(objContainer,url);
           
           /*
            var handle = {
            onCreate: function() {Element.show('loading');},
            onComplete: function() {
                if (Ajax.activeRequestCount == 0) {

                    Element.hide('loading');
                }
            }
            };
            Ajax.Responders.register(handle);
            */
        }
        
        //Set Tab
        function setTab(name,cursel,n){
         for(i=1;i<=n;i++){
          var menu=document.getElementById(name+i);
          var con=document.getElementById("con_"+name+"_"+i);
          menu.className=i==cursel?"hover":"";
          con.style.display=i==cursel?"block":"none";
         }
        }


//Set font size
 function doZoom(size)
        {
		    $('zoom').style.fontSize=size+'px'
	    }


