﻿// JScript 文件
$(function(){
    $("#load").hide();
    $("#load1").hide();
    $("#template").hide();
    $("#cli").hide();
    bind();           
});
function bind()
{
    $("[@id=ready]").remove();
    $("#load").show();
     $("#load1").show();
    $.ajax({
        type: "get",
        dataType: "json",
        url: "include/recordnews.ashx",
        complete :function(){$("#load").hide();},
        success: function(msg){
            var data = msg.table;
            $.each(data, function(i, n){
                var row = $("#template").clone();
                row.find("#time").text(n.addtime.split(" ")[0]);
                row.find("#title").html("<a href=NewsFiles/"+n.file_path+" target=_bank title="+n.title+">&nbsp;"+curStr(n.title,50)+"</a>");                 
                row.attr("id","ready");
                row.appendTo("#datas");
            });
             $("[@id=ready]").show();   
        }
    });
    $.ajax({
        type: "get",
        dataType: "json",
        url: "include/recordcompany.ashx",
        complete :function(){$("#load1").hide();},
        success: function(msg){
            var data = msg.table;
            $.each(data, function(i, n){
                var row = $("#cli").clone();
                row.find("#qiyemingcheng").html("<a href=credit_info/"+n.cid+".html target=_bank title="+n.c_name+">&nbsp;"+n.c_name+"</a>");  
                row.find("#qiyedengji").html(edit(n.c_leval));   
                row.find("#nian").text(yeare(n.c_year));    
                row.find("#zongfen").text(n.s_total);       
                row.attr("id","ready");
                row.appendTo("#cul");
            });
            $("[@id=ready]").show();      
        }
    });
}
function sub(vstring)
{
    return vstring.Substring(0,15)+"...";
}
function edit(a)
{
    if(a=="1")
     return '<span class=item>A<span class=item2>AA</span></span>';
     else if(a=="2")
     return '<span class=item>AA<span class=item2>A</span></span>';
     else if(a=="3")
     return '<span class=item>AAA</span>';
     else
     return "-";
}
function yeare(times)
{
    var myDate=new Date();
    return ((parseInt(myDate.getFullYear().toString())-parseInt(times.toString()))+1).toString();
}
function curStr(str,length)
{
    var position=0;
    var result=[];
    for (var i = 0; i < str.length; i++)
    {
        if(position>=length)
            break;
        if (str.charCodeAt(i) > 255)
        {
            position += 2;
            result.push(str.substr(i,1));
        }
        else
        {
            position++;
            result.push(str.substr(i,1));
        }
    }
    return result.join("");
}

