﻿// JScript 文件

var _newTyepId = "0";
function GetNewsForRead()
{
	var data = "action=getnewsforread&id="+getNewsId();
	$.ajax({type:"get",url:"ajax_data.aspx",data:data,success:
	function(r)
	{
		if(r!="")
		{
			var starpos = r.indexOf("*");
			var rc = r.substr(0,starpos);
			if(!isNaN(rc))
			{
			    var r = r.substr(starpos+1);
			    if(r!="")
			    {
				    r = eval("("+r+")");
			        var o = r[0];
			        $("#newsType").html(getNewsType(o.tid));
                    $("#newsTitle").html(o.title);
                    $("#newsTime").html(o.ct);
                    $("#newsHit").html("(已经被浏览"+o.hnum+"次)");
                    $("#newsCont").html(o.cont.replace(/&quot;/g,"\"")+"<br>(完)");
                    
			    }
			    else
			        $("#newsCont").html("<span style='color:red;'>抱歉，要阅读的新闻已不存在！</span>");
			}
			else
			    $("#newsCont").html(r);
		}
		else
		    $("#newsCont").html("数据读取失败！");		
	}	
	
	});	
}

function getNewsType(id)
{
    if(_newTyepId=="0")
        return "新闻中心";
    var typeAry = new Array("公司新闻","行业新闻","焦点新闻");
    return typeAry[id-1000];    
}


function PreLoadNews(id)
{
    _newTyepId = id;    
    getNewsByPager(1);
}

function getNewsByPager(cp)
{
	$("#newsType").html(getNewsType(_newTyepId));
	$("#cp").val(cp);
	$("#hint").html(" " + _iconLoading16 + " 正在读取数据…");
	
	var count = $("#rc").val();	
	if(cp==1 ||(count=="" || isNaN(count)))
		count = -1;	
	var pagesize = 15;
	var start = (cp-1)*pagesize;
	var data = "action=newslist&count="+count+"&cp="+cp+"&tid="+_newTyepId+"&rnd="+Math.random();
	$.ajax({type:"get",url:"ajax_data.aspx",data:data,success:
	function(r)
	{
		var html = "";		
		if(r!="")
		{
			var starpos = r.indexOf("*");
			var rc = r.substr(0,starpos);
			if(!isNaN(rc))
			{
			    $("#rc").val(rc);	
			    var r = r.substr(starpos+1);
			    var ps = 0;
			    if(r!="")
			    {
				    r = eval("("+r+")");
				    for(var i=0;i<r.length;i++)
				    {
				        var o = r[i];
                        html += '· <a href="news_show.html?id='+o.id+'">'+o.title+'</a> ('+o.ct.split(" ")[0]+')';
                        html += '<br /><hr class="hr_line" />';
				    }

			    }
    			
			    $("#_pager").html(getPager(rc,pagesize,"getNewsByPager",cp,"1"));
			}
			else
			    html = r;
		}
		if(html=="")
			html = "<br><br>没有找到符合条件的数据！";
			
		$("#_list").html(html);
		$("#hint").html("");
		
	}	
	
	});	
}


