﻿/***取客户端浏览器类型***/
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : 
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : 
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : 
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
/***简化获取ID方法***/
function $(id){return document.getElementById(id);}
/***获取URL参数***/
function GetUrlParam()
{
    var args = new Object( );
    var query = document.location.search.substring(1);//获取查询字符串
    var pairs = query.split("&");//分割符
    for(var i = 0; i < pairs.length; i++)
    {
        var pos = pairs[i].indexOf('=');//查找"name=value"
        if (pos == -1) continue;//如果没找到则跳过
        var argname = pairs[i].substring(0,pos);//变量名称
        var value = pairs[i].substring(pos+1);//获取变量
        value = decodeURIComponent(value);//解码
        args[argname] = value;//存入数组
    }
    return args;//返回对象
}
/***创建XMLHTTPRequest对象***/
function CreateXmlHttpRequest()
{
    var XHRequest = false;
    try{ XHRequest = new XMLHttpRequest(); }
    catch(trymicrosoft)
    {
        try{ XHRequest = new ActiveXObject("MSXML2.XMLHTTP.3.0"); }
        catch(othermicrosoft)
        {
            try{ XHRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch(failed){ XHRequest = false; }
        }
    }
    if (!XHRequest){ alert("创建对象失败！"); }
    return XHRequest;
}
/***创建XML对象***/
function GetXmlData()
{
    var xmlDoc = null;
    try//IE浏览器
    { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); }
    catch(e)
    {
        try//兼容其他浏览器
        { xmlDoc = document.implementation.createDocument("","",null); }
        catch(e)
        { xmlDoc = false; }
    }
    if(!xmlDoc)
    { alert("创建XML对象失败，请刷新页面重试！") }
    return xmlDoc;
}
/***异步调用方法***/
//opens:值为1时使用GET方式，否则使用POST方式
//urls:请求地址
//params:使用send方法传递的参数，GET方式时应为Null，以免FF报错
//method:回调函数，值为Null时不对返回值进行任何处理
//retype:回调函数的返回类,1、字符串;2、XML数据;3、流数据
function XHReturn(opens,urls,params,method,retype)
{
    var XHRequest = CreateXmlHttpRequest();
    if(opens == 1)
    { XHRequest.open("GET", urls, true); }
    else
    {
        XHRequest.open("POST", urls, true);
        XHRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); 
    }
    if(method != null)
    {
        XHRequest.onreadystatechange = function()
        {
            if(XHRequest.readyState == 4)
            {
                switch(retype)
                {
                    case 1:
                        method(XHRequest.responseText);
                    break;
                    case 2:
                        method(XHRequest.responseXML);
                    break;
                    case 3:
                        method(XHRequest.responseStream);
                    break;
                }
            }
            else
            { method(false); }//回调函数据此做正在获取数据等处理
        }
    }
    XHRequest.send(params);
}
/*****加载外部JS文件，加载成功后执行一个回调函数*****/
//files:文件地址
//callback:回调函数
function IncludeJs(files, callback)
{
    var heads = document.getElementsByTagName("head")[0];
    var jscode = document.createElement("script");
    jscode.setAttribute("type", "text/javascript");
    jscode.setAttribute("src", files);
    heads.appendChild(jscode);
    if(!/*@cc_on!@*/0)//no IE
    { jscode.onload = function(){ callback(); } }
    else//IE
    {
        jscode.onreadystatechange = function()
        {
            if (jscode.readyState == 'loaded' || jscode.readyState == 'complete')
            { callback(); }
        }
    }
    return false;
}
/***去除空格***/
String.prototype.Trim = function()
{ return this.replace(/^\s+/g,"").replace(/\s+$/g,""); }
///截取字符串///
String.prototype.sub = function(n)
{
    var r = /[^\x00-\xff]/g;
    if(this.replace(r, "mm").length <= n)
    { return this; }
    var m = Math.floor(n/2);
    for(var i=m; i<this.length; i++)
    {
        if(this.substr(0, i).replace(r, "mm").length >= n)
        { return this.substr(0, i) +"..."; }
    }
    return this;
};
/***日期格式化***/
Date.prototype.format = function(format)
{
    var o = { "M+" : this.getMonth()+1, "d+" : this.getDate(), "h+" : this.getHours(), "m+" : this.getMinutes(), "s+" : this.getSeconds(), "q+" : Math.floor((this.getMonth()+3)/3), "S" : this.getMilliseconds() };
    if(/(y+)/.test(format))
    { format = format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length)); }
    for(var k in o)
    {
        if(new RegExp("("+ k +")").test(format))
        { format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length)); }
    }
    return format;
};
///Cookie对象///
function Cookies()
{
    this.GetCookie = function(key)
    {
        var cookie = document.cookie;
        var cookieArray = cookie.split(';');
        var getvalue = "";
        for(var i = 0;i<cookieArray.length;i++)
        {
            if(cookieArray[i].Trim().substr(0,key.length) == key)
            {
                getvalue = cookieArray[i].Trim().substr(key.length + 1);
                break;
            }
        }
        return getvalue;
    };
    this.GetChild = function(cookiekey,childkey)
    {
        var child = this.GetCookie(cookiekey);
        var childs = child.split('&');
        var getvalue = "";
        for(var i = 0;i < childs.length;i++)
        {
            if(childs[i].Trim().substr(0,childkey.length) == childkey)
            {
                getvalue = childs[i].Trim().substr(childkey.length + 1);
                break;
            }
        }
        return getvalue;
    };
    this.SetCookie = function(key,value,expire,domain,path)
    {
        var cookie = "";
        if(key != null && value != null)
        { cookie += key + "=" + value + ";"; }
        if(expire != null)
        { cookie += "expires=" + expire.toGMTString() + ";"; }
        if(domain != null)
        { cookie += "domain=" + domain + ";"; }
        if(path != null)
        { cookie += "path=" + path + ";"; }
        document.cookie = cookie;
    };
    this.Expire = function(key)
    {
        expire_time = new Date();
        expire_time.setFullYear(expire_time.getFullYear() - 1);
        var cookie = " " + key + "=e;expires=" + expire_time + ";"
        document.cookie = cookie;
    }
}
/*查找字符串是否包含某值*/
///str=对比查找的字串
///keyword=要查找的字串
function SearchStrInclud(str,keyword)
{
    var reg = new RegExp(keyword,[""]);
    return (str.toString().replace(reg,"§").replace(/[^,§]/g,"")).indexOf("§");
}
/*---------公共JS函数库（表单对象操作）---------*/
///检测表单项是否为空///
///<param=obj>需检测的表单项ID</param>
///<param=tip>提示信息显示控件ID</param>
function IsBlank(obj,tip)
{
    if($(obj).value == "")
    {
        $(tip).innerHTML = "× 此项不能为空！";
        $(tip).style.color = '#CC0000';
    }
    else
    {
        $(tip).innerHTML = "√　验证通过";
        $(tip).style.color = '#339900';
    }
}
///密码一致性检测///
///<param=pwd>原始密码表单项ID</param>
///<param=cpwd>密码确认表单项ID</param>
///<param=tip>提示信息显示控件ID</param>
function CheckPwd(pwd,cpwd,tip)
{
    $(tip).style.color = '#CC0000';
    if($(pwd).value == "" || $(cpwd).value == "")
    { $(tip).innerHTML = "× 请输入密码！"; }
    else if($(cpwd).value != $(pwd).value)
    { $(tip).innerHTML = "× 两次输入的密码不一致！"; }
    else
    {
        $(tip).innerHTML = "√　验证通过";
        $(tip).style.color = '#339900';
    }
}
///清除文本框内默认内容///
///<param=obj>文本框ID</param>
///<param=checktxt>文本框内默认内容</param>
function ImportTxt(obj,checktxt)
{
    var obj = $(obj);
    if(obj.value == checktxt)
    { obj.value = ""; }
}
///文本框限制输入字数///
///<param=obj>文本框ID</param>
///<param=tip>提示标签ID</param>
///<param=max>最大字数</param>
function CheckStrLength(obj, tip, max)
{
    var objs = $(obj);
    var tips = $(tip);
    if(objs.value.length > max)
    {
        objs.value = objs.value.substring(0, max);
        tips.innerHTML = "0";
    }
    else
    { tips.innerHTML = max - objs.value.length; }
}
///CheckBox全选、反选、清空///
///<param=obj>Checkbox所在元素ID</param>
///<param=val>选取结果存储元素ID</param>
///<param=flag>标识，1全选 2清空 3反选 0取选择值</param>
function CheckboxClick(obj,val,flag)
{
    var obj = $(obj);
    var checkboxs = obj.document.getElementsByTagName("input");
    var theval = '';
    for(i = 0; i < checkboxs.length; i++)
    {
        if(checkboxs[i].type == "checkbox")
        {
            switch (flag)
            {
                case 1:
                    checkboxs[i].checked = true;
                break;
                case 2:
                    checkboxs[i].checked = false;
                break;
                case 3:
                    if(checkboxs[i].checked)
                    { checkboxs[i].checked = false; }
                    else
                    { checkboxs[i].checked = true; }
                break;
                case 0:
                break;
            }
            if(checkboxs[i].checked == true)
            { theval += checkboxs[i].value + ','; }    
        }
    }
    $(val).value = theval;
}
/*---------公共JS函数库（界面）---------*/
///加入收藏///
//url：地址
//title：页面标题
function AddFavorite(url, title)
{
    try
    { window.external.addFavorite(url, title); }
    catch (e)
    {
        try
        { window.sidebar.addPanel(title, url, ""); }
        catch (e)
        { alert("加入收藏失败，请使用Ctrl+D进行添加"); }
    }
}
///设为首页///
//obj：对象
//url：地址
function SetHome(obj,url)
{
    try
    { obj.style.behavior='url(#default#homepage)';obj.setHomePage(url); }
    catch(e)
    {
        if(window.netscape)
        {
            try
            { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
            catch (e)
            { alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',url);
        }
    }
}
///对象统一高度
//obj1:对象ID
//obj2:对象ID
function ObjHeight(obj1,obj2)
{
    var lh = $(obj1);
    var rh = $(obj2);
    if(lh.clientHeight > rh.clientHeight)
    { rh.style.height = lh.clientHeight + 'px'; }
    if(rh.clientHeight > lh.clientHeight)
    { lh.style.height = rh.clientHeight + 'px'; }
}
///对象自动居中,兼容IE、FF、Opera///
//obj：对象ID
//obj2：对象ID
//flag：居中方式：1、完全居中，2、横向居中，3、垂直居中
//obj2为null时，obj以页面为参照居中，否则以obj2为参照居中
function ObjCenter(obj,obj2,flag)
{
    var div = $(obj);
    var refer = $(obj2);
    var Twidth;
    var Theight;
    if(refer != null)
    {
        Twidth = refer.offsetWidth;
        Theight = refer.offsetHeight;
    }
    else
    {
        Twidth = document.documentElement.clientWidth;
        Theight = document.documentElement.clientHeight;
    }
    switch(flag)
    {
            case 1:
                div.style.left = (document.documentElement.scrollLeft + (Twidth - div.offsetWidth) / 2) + "px";
                div.style.top = (document.documentElement.scrollTop + (Theight - div.offsetHeight) / 2) + "px";
                break;
            case 2:
                div.style.left = (document.documentElement.scrollLeft + (Twidth - div.offsetWidth) / 2) + "px";
                break;
            case 3:
                div.style.top = (document.documentElement.scrollTop + (Theight - div.offsetHeight) / 2) + "px";
                break;
    }
}
///显示或隐藏对象///
//menuobj：需显示或隐藏对的ID
//obj：需显示或隐藏对的ID
//show：显示时的样式类名
//hidd：隐藏时的样式类名
function SHObj(menuobj,obj,show,hidd)
{
    var menuobj = $(menuobj);
    var obj = $(obj);
    if (obj.style.display != 'none')
    {
        obj.style.display = "none";
        if(menuobj != null)
        {menuobj.className = show;}
    }
    else
    {
        obj.style.display = "block";
        if(menuobj != null)
        {menuobj.className = hidd;}
    }
}
///图片等比例缩放///
//obj：图片所在容器ID
//mwidth：最大宽度
//mheight：最大高度
//lpadding：图片左右边距总和，例左右边距为4，则为8，无边距为0
//tpadding：图片上下边距总和
function ScalingPic(obj,mwidth,mheight,lpadding,tpadding)
{
    var uls = $(obj);
    var imgs = uls.getElementsByTagName('img');
    var igs = new Image();
    for(var i = 0; i < imgs.length; i++)
    {
        igs.src = imgs[i].src;
        if(igs.width / igs.height >= mwidth / mheight)
        {
            if(igs.width > mwidth)
            {
                imgs[i].width = mwidth;
                imgs[i].height = (igs.height * mwidth) / igs.width;
            }
            else
            {
                imgs[i].width = igs.width;
                imgs[i].height = igs.height;
            }
        }
        else
        {
            if(igs.height > mheight)
            {
                imgs[i].height = mheight;
                imgs[i].width = (igs.width * mheight) / igs.height;
            }
            else
            {
                imgs[i].height = igs.height;
                imgs[i].width = igs.width;
            }
        }
        imgs[i].style.left = (mwidth + lpadding - imgs[i].width) / 2 + 'px';
        imgs[i].style.top = (mheight + tpadding - imgs[i].height) / 2 + 'px';
    }
}
///Li隔行变色，点击、移动变色///
//row1：奇数行样式class
//row2：偶数行样式class
//liclick：点击样式class
//limove：移入样式class
///多个指定ul的li///
//obj：多个ul的ID串，以|分隔
function MoreLiBg(obj,row1,row2,liclick,limove)
{
    var theval = obj.split('|');
    for(var i=0; i<theval.length; i++)
    { LiBackground(theval[i],row1,row2,liclick,limove); }
}
///单个指定ul的li///
//obj：ul的Id
function LiBg(obj,row1,row2,liclick,limove)
{
    var uls = $(obj);
    var lis = uls.getElementsByTagName('li');
    for(var i = 0; i < lis.length; i++)
    {
		lis[i].className=(i%2 == 0) ? row1 : row2;
		lis[i].onclick = function()
		{
		    for(var i = 0; i < lis.length; i++)
		    {
				if(lis[i].className == liclick && lis[i] != this)
				{ lis[i].className = (i == 0) ? row1 : row2; }
			}
			this.className = (this.className != liclick) ? liclick : ((Currrow(lis,this)%2 == 0) ? row1 : row2);
		}
		lis[i].onmouseover = function()
		{
			if(this.className != liclick)
			{ this.className = limove; }
		}
		lis[i].onmouseout = function()
		{
			if(this.className != liclick)
			{ this.className = (Currrow(lis,this)%2 == 0) ? row1 : row2; }
		}
	}
}
///页面中指定ID/所有表格隔行换色，移动变色///
//tr1：奇数行样式类
//tr2：偶数行样式类
//intr：鼠标移入行样式类
//click：点击高亮样式类
//obj为指定表格对象ID,tr2无值时不进行隔行换色,click无值时不进行点击高亮
function TrBg(obj,tr1,tr2,intr,click)
{
    var trs;
    if(obj.length > 0)
    {
        obj = $(obj);
        trs = obj.document.getElementsByTagName('tr');
    }
    else
    { trs = document.getElementsByTagName('tr'); }
    if(trs.length > 0)
    {
	    for(var i = 0; i < trs.length; i++)
	    {
	        var th = trs[i].getElementsByTagName('th');
	        if(th.length == 0)
	        {
                if(tr2.length > 0)//隔行变色
                {
		            trs[i].className = (i%2 == 0) ? tr1 : tr2;
		            trs[i].onmouseout = function()
		            {
		                if(click.length == 0 || this.className != click)
		                { this.className = (Currrow(trs,this)%2 == 0) ? tr1 : tr2; }
		            }
		            trs[i].onmouseover = function()
		            {
		                if(click.length == 0 || this.className != click)
		                { this.className = intr; }
		            }
		        }
		        else//不隔行变色
		        {
		            trs[i].className = tr1;
		            trs[i].onmouseout = function()
		            {
		                if(click.length == 0 || this.className != click)
		                { this.className = tr1; }
		            }
		            trs[i].onmouseover = function()
		            {
		                if(click.length == 0 || this.className != click)
		                { this.className = intr; }
		            }
		        }
		        if(click.length > 0 && tr2.length > 0)//隔行变色，且点击高亮
		        {
		            trs[i].onclick = function()
		            {
		                for(var i = 0; i < trs.length; i++)
		                {
				            if(trs[i].className == click && trs[i] != this)
				            { trs[i].className = (i == 0) ? tr1 : tr2; }
			            }
			            this.className = (this.className != click) ? click : ((Currrow(trs,this)%2 == 0) ? tr1 : tr2);
		            }
		        }
		        if(click.length > 0 && tr2.length == 0)
		        {
		            trs[i].onclick = function()
		            { this.className = (this.className != click) ? click : tr1; }
		        }
	     	}
        }
    }
}
///取鼠标所在行行数///
//lis：li对象
//lii：返回对比行数
function Currrow(lis,lii)
{
	for(var i = 0; i < lis.length; i++)
	{
	    if(lis[i] == lii)
	    { return i; }
	}
}
///显示提示窗口///
//tiptxt：提示内容
//flag：显示或隐藏
function ShowTip(tiptxt,flag)
{
    var tip = $("tipcont");
    var txt = $("tiptxt");
    if(flag == true)
    {
        txt.innerHTML = tiptxt;
        tip.style.display = 'block';
    }
    else
    { tip.style.display = 'none'; }
}
///文字大小增减///
//hiddenid：存储当前字体大小的隐藏域
//obj：需要增减字体大小对象的ID
//tags：增加或减少操作标记
function TxtChangeSize(hiddenid,obj,tags)
{
    var hdid = $(hiddenid);
    var obj = $(obj);
    var tsize = hdid.value;
    if(tags == "add")
    { tsize = parseFloat(tsize) + 0.1; }
    if(tags == "minus")
    { tsize = parseFloat(tsize) - 0.1; }
    if(tsize > 1.1 && tsize < 3 )
    {
        tsize = tsize.toFixed(1);
        hdid.value = tsize;
        obj.style.fontSize = tsize + "em";
        obj.style.lineHeight = tsize * 22 + "px";
    }
}
///改变文本内容配色///
//obj：文本内容对象的ID
//clasname：样式类名
function ChangeTextColor(obj,clasname)
{
    var obj = $(obj);
    obj.className = clasname;
}
///返回页面顶部///
function GoTop()
{
    var speed = 1.2;
    var time = 10;
    var dy = 0;
    var by = 0;
    var wy = 0;
    if(document.documentElement)
    { dy = document.documentElement.scrollTop||0; }
    wy = window.scrollY||0;
    var y = Math.max(wy,Math.max(by,dy));
    window.scrollTo(0,Math.floor(y/speed));
    if(y > 0)
    { setTimeout("GoTop()",time); }
}
///自动切换TAB///
///
function AutoSwitchTab(tab)
{
    for(var s in tab)
    {
	    MouseEvents(s);
	    AutoSwitch(s);
    }
}
///添加鼠标事件///
function MouseEvents(s)
{
	if(tab[s][5])
	{
		for(var i = 1;i <= tab[s][0];i++)
		{
			$(s + i).onmouseover = function()
			{
			    clearTimeout(tab[s][2]);
			    SingleSwitch(s,this.attributes.getNamedItem("id").nodeValue.split(s)[1]);
			}
			$(tab[s][6] + s + i).onmouseover = function()
			{
			    clearTimeout(tab[s][2]);
			    SingleSwitch(s,this.attributes.getNamedItem("id").nodeValue.split(tab[s][6] + s)[1]);
			}
			if(tab[s][10])
			{
			    $(s + i).onmouseout = function()
			    {
			        tab[s][4] = 0;
			        AutoSwitch(s);
			    }
			    $(tab[s][6] + s + i).onmouseout = function()
			    {
			        tab[s][4] = 0;
			        AutoSwitch(s);
			    }
			}
		}
	}
}
///单次切换///
function SingleSwitch(s,id)
{
    for(var i = 1;i <= tab[s][0];i++)
    {
        if(i == id)
        {
            $(s + i).className = tab[s][7];
            $(tab[s][6] + s + i).className = tab[s][9];
        }
        else
        {
            $(s + i).className = tab[s][8];
            $(tab[s][6] + s + i).className = tab[s][10];
        }
    }
}
///自动切换///
function AutoSwitch(s)
{
	if(tab[s][3])
	{
		for(var i = 1;i <= tab[s][0];i++)
		{ 
			if($(s+i).className == tab[s][7])
			{
				var id = tab[s][4]?(i%tab[s][0]?i + 1:1):i;
				break;
			}
		}
		SingleSwitch(s,id);
		tab[s][2] = setTimeout("AutoSwitch(\"" + s + "\");",tab[s][1]);
		tab[s][4] = 1;
	}
	else
	{ return false;	}
}
///显示一个弹出窗口，并转向上一页///
//txt：显示的文本
function ShowHistory(txt)
{
    alert(txt);
    var p = document.referrer;
    window.history.go(-1);
}
///显示一个弹出窗口，并重定向到指定页///
//txt：显示的文本
//url：重定向地址
function ShowRedirect(txt,url)
{
    alert(txt);
    window.location.href = url;
}
///导航条鼠标事件///
function NavTowX(obj,obj2,classname)
{
    obj = $(obj);
    obj2 = $(obj2);
    obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
    obj2.className = classname;
}
///下拉二级导航菜单///
//json：json对象名称
function DropDownMenu()
{
    var obj = eval(Navs);
    var lists = obj.lists;
    var menutxt = "";
    var smtxt = "";
    for(var i = 0; i < lists.length; i++)
    {
        var tit = lists[i].Title;
        var url = lists[i].Url;
        var dep = lists[i].Depth;
        if (dep == 1)
        {
            if (smtxt.length > 0)
            {
                smtxt = smtxt.substring(0,smtxt.length - 2);
                menutxt += smtxt + "</div></li>";
                smtxt = "";
            }
            if(tit == "首　页")
            {
                menutxt += "<li><a href=\"" + url + "\" class=\"mmenu\">" + tit + "</a><div id=\"idsdef\"></div></li>";
            }
            else
            {
                var ids = "nav" + i;
                var aid = "snav" + i;
                menutxt += "<li onmouseover=\"NavTowX('" + ids + "','" + aid + "','menuin');\" onmouseout=\"NavTowX('" + ids + "','" + aid + "','mmenu');\"><a href=\"" + url + "\" id=\"" + aid + "\" class=\"mmenu\">" + tit + "</a><div class=\"hidd\" id=\"" + ids + "\">";
            }
        }
        else
        { smtxt += "<a href=\"" + url + "\">" + tit + "</a> | "; }
    }
    menutxt = "<ul class=\"nav\">" + menutxt + "</ul>"
    document.write(menutxt);
}
/*****读取JSON对象输出推荐内容*****/
// json:Json对象名称
// num:输出数量
// head:列表头标签
// loops:重复输出标签
// foot:列表结束标签
// titlen:列表标题长度
// conlen:简要内容长度
// dates:日期格式 0不显示
function TopsList(json, num, head, loops, foot, titlen, conlen, dates)
{
    var obj = eval(json);
    var lists = obj.lists;
    var temp = "";
    var html = head;
    var inum = 0;
    for(var i = 0; i < lists.length; i++)
    {
        if(inum == num)
        { continue; }
        if(lists[i].Tops == "1")
        {
            if(loops.indexOf("infotit") != -1)//如果包含了标题
            {
                if(titlen != 0)
                { temp = loops.replace("infotit", lists[i].Title.sub(titlen)); }
                else
                { temp = loops.replace("infotit", lists[i].Title); }
            }
            if(loops.indexOf("titles") != -1)
            { temp = temp.replace("titles", lists[i].Title); }
            if(loops.indexOf("link") != -1)
            { temp = temp.replace("link",lists[i].Url); }
            if(loops.indexOf("times") != -1)
            {
                var temptime = new Date(lists[i].Time.replace(/-/g,'/'));
                dates = Number(dates);
                if(dates != 0)
                {
                    switch (dates)
                    {
                        case 1://09-01
                            temptime = temptime.format('yy-MM');
                        break;
                        case 2://2009-11-22
                            temptime = temptime.format('yyyy-MM-dd');
                        break;
                        case 3://2009年11月22日
                            temptime = temptime.format('yyyy年MM月dd日');
                        break;
                    }
                    temp = temp.replace("times",temptime);
                }
            }
            if(loops.indexOf("infocont") != -1)
            {
                if(conlen > 0)
                { temp = temp.replace("infocont", lists[i].Cont.sub(conlen)); }
                else
                { temp = temp.replace("infocont", lists[i].Cont); }
            }
            if(loops.indexOf("titplan") != -1)
            {
                temp = temp.replace("titplan", lists[i].TitPlan);
            }
            html += temp;
            inum++;
        }
    }
    html += foot;
    document.write(html);
}
/*****读取JSON对象输出广告*****/
// json:Json对象名称
// head:列表头标签
// foot:列表结束标签
function LoadAd(json,head,foot)
{
    var obj = eval(json);
    var lists = obj.ad;
    var html = head;
    var anner = lists[0].Anner;
    var link = lists[0].Url;
    var width = lists[0].Width;
    var height = lists[0].Height;
    var type = anner.substring(anner.lastIndexOf('.') + 1, anner.length);
    html += "<a href=\"" + link + "\" target=\"_blank\"></a>";
    if(type == "jpg" || type == "gif" || type == "png")
    { html += "<img src=\"" + anner + "\" alt=\"\" style=\"width:" + width + ";height:" + height + "\" />"; }
    if(type == "swf")
    {
        html += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"" + width + "\" height=\"" + height + "\"><param name=\"movie\" value=\"" + anner + "\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"Opaque\" /><embed pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" quality=\"high\" src=\"" + anner + "\" type=\"application/x-shockwave-flash\" wmode=\"Opaque\" width=\"" + width + "\" height=\"" + height + "\"></embed></object>";
    }
    html += foot;
    document.write(html);
}
/*****读取JSON对象输出列表内容*****/
// div：内容输出对象
// obj:回传对象
// json：json对象
// num:输出数量
// head:列表头标签
// loops:重复输出标签
// foot:列表结束标签
// titlen:列表标题长度 如为0则表示不截取
// dates:日期格式 0不显示
function HotList(div, obj, json, num, head, loops, foot, titlen, dates)
{
    if (obj != false)
    {
        var obj1 = eval(obj);
        var obj1 = eval(json);
        var lists = obj1.lists;
        var temp = "";
        var html = head;
        if(num > lists.length)
        { num = lists.length; }
        for(var i = 0; i < num; i++)
        {
            if(loops.indexOf("infotit") != -1)//如果包含了标题
            {
                if(titlen != 0)
                { temp = loops.replace("infotit", lists[i].Title.sub(titlen)); }
                else
                { temp = loops.replace("infotit", lists[i].Title); }
            }
            if(loops.indexOf("titles") != -1)
            { temp = temp.replace("titles", lists[i].Title); }
            if(loops.indexOf("link") != -1)
            { temp = temp.replace("link",lists[i].Url); }
            if(loops.indexOf("times") != -1)
            {
                var temptime = new Date(lists[i].Time.replace(/-/g,'/'));
                if(dates != 0)
                {
                    switch (dates)
                    {
                        case 1://09-01
                            temptime = temptime.format('yy-MM');
                        break;
                        case 2://2009-11-22
                            temptime = temptime.format('yyyy-MM-dd');
                        break;
                        case 3://2009年11月22日
                            temptime = temptime.format('yyyy年MM月dd日');
                        break;
                    }
                    temp = temp.replace("times",temptime);
                }
            }
            html += temp;
        }
        html += foot;
        $(div).innerHTML = html;
    }
}
/*****读取JSON对象输出列表内容*****/
// json:Json对象名称
// tags:内容容器ID
//fparams=fnum,ftitlen,fconlen,dates,fhead,floop,ffoot
//params=num,titlen,conlen,deates,ico,head,loops,foot
// num:输出数量
// head:列表头标签
// loops:重复输出标签
// foot:列表结束标签
// titlen:列表标题长度 如为0则表示不截取
// conlen:简要内容长度，如为0，则表示无简要内容
// ico:新信息是否显示new图标 0不显示，1显示
// dates:日期格式 0不显示
function ExportList(json, tags, fparams, params)
{
    var obj = eval(json);
    var lists = obj.lists;
    var ftemp = "";
    var temp = "";
    var fhtml = "";
    var html = "";
    if(fparams != null)
    {
        var fpval = fparams.split("|");
        var fnum = Number(fpval[0]);
        var ftlen = Number(fpval[1]);
        var fclen = Number(fpval[2]);
    }
    var pval = params.split("|");
    var num = Number(pval[0]);
    var titlen = Number(pval[1]);
    var dates = Number(pval[3]);
    var ico = Number(pval[4]);
    var conlen = Number(pval[2]);
    if(num > lists.length)
    { num = lists.length; }
    for(var i = 0; i < num; i++)
    {
        if((fparams != null && fnum > 0) && i < fnum)
        {
            ftemp = fpval[5];
            if(fpval[5].indexOf("link") != -1)
            { ftemp = ftemp.replace("link",lists[i].Url); }
            if(fpval[5].indexOf("titles") != -1)
            { ftemp = ftemp.replace("titles", lists[i].Title); }
            if(fpval[5].indexOf("infotit") != -1)
            { ftemp = ftemp.replace("infotit", lists[i].Title.sub(ftlen)); }
            if(fpval[5].indexOf("infocont") != -1)
            { ftemp = ftemp.replace("infocont", lists[i].Cont.sub(fclen)); }
            if(fpval[5].indexOf("titplan") != -1)
            { ftemp = ftemp.replace("titplan", lists[i].TitPlan); }
            fhtml += ftemp;
        }
        else
        {
            temp = pval[6];
            if(pval[6].indexOf("infotit") != -1)//如果包含了标题
            {
                if(titlen != 0)
                { temp = temp.replace("infotit", lists[i].Title.sub(titlen)); }
                else
                { temp = temp.replace("infotit", lists[i].Title); }
            }
            if(pval[6].indexOf("titles") != -1)
            { temp = temp.replace("titles", lists[i].Title); }
            if(pval[6].indexOf("link") != -1)
            { temp = temp.replace("link",lists[i].Url); }
            if(pval[6].indexOf("times") != -1)
            {
                var temptime = new Date(lists[i].Time.replace(/-/g,'/'));
                if(dates != 0)
                {
                    switch (dates)
                    {
                        case 1://09-01
                            temptime = temptime.format('yy-MM');
                        break;
                        case 2://2009-11-22
                            temptime = temptime.format('yyyy-MM-dd');
                        break;
                        case 3://2009年11月22日
                            temptime = temptime.format('yyyy年MM月dd日');
                        break;
                    }
                    temp = temp.replace("times",temptime);
                }
            }
            if(ico == 1)
            {
                var dtemp = new Date().getTime() - new Date(lists[i].Time.replace(/-/g,'/'));
                if(dtemp <= 7)//如果发布时间不超过7天算最新
                {  }//显示方式还未想好
            }
            if(pval[6].indexOf("infocont") != -1)
            {
                if(conlen > 0)
                { temp = temp.replace("infocont", lists[i].Cont.sub(conlen)); }
                else
                { temp = temp.replace("infocont", lists[i].Cont); }
            }
            if(pval[6].indexOf("titplan") != -1)
            { temp = temp.replace("titplan", lists[i].TitPlan); }
            if(pval[6].indexOf("logo") != -1)
            { temp = temp.replace("logo", lists[i].Logo); }
            html += temp;
        }
    }
    if(pval[5] != "null")
    { html = pval[5] + html; }
    if(pval[7] != "null")
    { html += pval[7]; }
    if(fparams != null && fnum > 0)
    {
        if(fpval[4] != "null")
        { fhtml = fpval[4] + fhtml; }
        if(fpval[6] != "null")
        { fhtml += fpval[6]; }
        html = fhtml + html;
    }
    if(tags != "null")
    { $(tags).innerHTML = html; }
    else
    { document.write(html); }
}
