﻿// JScript 文件
$(document).ready(function(){
   TypeCountNum();
   changePage();
   changePage1();
   changePage2();
   changePage3();
   changePage4();
   changePage5();
   changePage6();
  
});

//初始化点击数
function TypeCountNum()
{
    var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=7&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){  
        $("#NUM").html(data[0].countNum);    
    });
}

function changePage()
{
    var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=0&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy="<p><select id=\"aa\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy+=BuildStrLy(item.CP_id,item.CP_name);
        });       
        strLy+="</select>";     
        $("#aa").html(strLy);    
    });
}

//构造字符串
function BuildStrLy(CP_id,CP_name)
{
    var strLy="<option id=\""+CP_id+"\" value=\""+CP_name+"\" >"+CP_name+"</option>";
    return strLy;
}


function changePage1()
{
    var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=1&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy1="<p><select id=\"select1\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy1+=BuildStrLy1(item.CP_id,item.CP_name);
        });        
        strLy1+="</select>";           
        $("#bb").html(strLy1);        
    }); 
}

function BuildStrLy1(CP_id,CP_name)
{ 
    var strLy1="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy1;
}

function changePage2()
{
    var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=2&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy2="<p><select id=\"select2\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy2+=BuildStrLy2(item.CP_id,item.CP_name);
        });
        strLy2+="</select>";   
        $("#cc").html(strLy2);
    });
}

function BuildStrLy2(CP_id,CP_name)
{ 
    var strLy2="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy2;
}

function changePage3()
{
 var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=3&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy3="<p><select id=\"select3\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy3+=BuildStrLy3(item.CP_id,item.CP_name);
        });
        strLy3+="</select>";   
        $("#dd").html(strLy3);
    });
    
}

function BuildStrLy3(CP_id,CP_name)
{ 
    var strLy3="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy3;
}

function changePage4()
{
 var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=4&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy4="<p><select id=\"select4\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy4+=BuildStrLy4(item.CP_id,item.CP_name);
        });
        strLy4+="</select>";   
        $("#ee").html(strLy4);
    });
}

function BuildStrLy4(CP_id,CP_name)
{ 
    var strLy4="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy4;
}

function changePage5()
{
 var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=5&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy5="<p><select id=\"select5\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy5+=BuildStrLy5(item.CP_id,item.CP_name);
        });
        strLy5+="</select>";   
        $("#ff").html(strLy5);
    });
}

function BuildStrLy5(CP_id,CP_name)
{ 
    var strLy5="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy5;
}

function changePage6()
{
 var s=document.getElementById("dName").value;
    var url=BaseLink()+"/jiancaiku/libiao/xiala.aspx?t=6&p="+s;
    $.getJSON(url+"&format=json&jsoncallback=?",function(data){
    var strLy6="<p><select id=\"select6\" style=\"width:120px;font-size:12px;\" onchange=\"urlopen(this.options[this.selectedIndex].id,this.options[this.selectedIndex].value);\"></p>";
        $.each(data,function(i,item)
        {
            strLy6+=BuildStrLy6(item.CP_id,item.CP_name);
        });
        strLy6+="</select>";   
        $("#gg").html(strLy6);
    });   
}

function BuildStrLy6(CP_id,CP_name)
{ 
    var strLy6="<option id=\""+CP_id+"\" value=\""+CP_name+"\">"+CP_name+"</option>";
    return strLy6;
}

//显示下拉列表
function urlopen(CP_id,ZG_name)
{
    if(CP_id!="0")
    {
        AddNums(CP_id);
    }
}

//点击数
function AddNums(CP_id)
{
    var url=BaseLink()+"/jiancaiku/tongyong/addcount.aspx?CP_id="+CP_id;
    $.getJSON(url+"&T=1&format=json&jsoncallback=?",function(data){
    });
   GetJCCName(CP_id);
}

//下拉列表显示名称
function GetJCCName(CP_id)
{
    var url=BaseLink()+"/jiancaiku/tongyong/addcount.aspx?CP_id="+CP_id;
    $.getJSON(url+"&T=2&format=json&jsoncallback=?",function(data){
        var addr="../JCCMC/"+data[0].tpPY+""+data[0].gongsiPY+".html";
        window.open(addr,'_blank');
    });
}