function Startgetqi(){
	this.colors=function(){
		var mycars=new Array();
		mycars[0]="#E8F5FF";
		mycars[1]="#FFCEE7";
		mycars[2]="#DFFFDF";
		mycars[3]="#C4ECFF";
		mycars[4]="#B3FFFF";
		mycars[5]="#FFEBE1";
		mycars[6]="#FFFFD7";
		return mycars;
}
this.loadedition = function(sel,qiid,noweditionid,fileurl,isadd) {
    /*加载版面*/
    //色彩变化
    var randomnum = Math.round(Math.random() * 6 + 1) - 1;  //0-6随机数
    var mycolors = this.colors();
    sel.style.backgroundColor = mycolors[randomnum];
    $.ajax({
        type: "POST",
        url: fileurl,
        dataType: "json",
        data: { "qiid": "" + qiid + "", "isadd": "" + isadd + "" },
        success: function (json) {
            if (json != 0) {
                var issel = 0;
                var l = json.classtable.length;
                for (i = 0; i < l; i++) { //json为回传的数据；"classtable"表名在回传的json数据
                    issel = 0
                    if (json.classtable[i].id == noweditionid) {
                        issel = 1;
                    }
                    opt(sel, json.classtable[i].classname, json.classtable[i].id, issel);
                    //opt
                }
                /*if (l == 0 && isadd == "1")
                    opt(sel, "选择版面", "", 0);*/
            }
        }, error: function (json) { alert("error-版面错误" + json); }
    });
}
this.loadqi = function (sel, year, month, nowqiid, fileurl, isadd, isnews) {
    /*加载刊期*/
    //色彩变化
    var randomnum = Math.round(Math.random() * 6 + 1) - 1;  //0-6随机数
    var mycolors = this.colors();
    sel.style.backgroundColor = mycolors[randomnum];
    $.ajax({
        type: "POST",
        url: fileurl,
        dataType: "json",
        data: { "year": "" + year + "", "month": "" + month + "","nowqi": "" + nowqiid + "", "isadd": "" + isadd + "", "isnews": "" + isnews + "" },
        success: function (json) {
            if (json != 0) {
                var issel = 0;
                if (isadd == "1")
                    sel.options.length = 0;
                var l = json.classtable.length;
                for (i = 0; i < l; i++) { //json为回传的数据；"classtable"表名在回传的json数据
                    issel = 0
                    if (json.classtable[i].id == nowqiid) {
                        issel = 1;
                    }
                    opt(sel, json.classtable[i].classname, json.classtable[i].id, issel);
                    //opt
                }
                if (l == 0 && isadd == "1")
                    opt(sel, "选择刊期", "", 0);
                if (isadd == "1" && isnews == "1") {
                    //版面加载第一期选择数据;
                    var tempm = sel.options[sel.selectedIndex].value; //sel.options[0].value;
                    if (tempm != "") {
                        var selpage = document.getElementById("eachpage");
                        selpage.options.length = 0;
                        opt(selpage, "选择版面", "", 0);
                        var initqi2 = new Startgetqi();
                        initqi2.loadedition(selpage, tempm, noweditionid, pageurl, isadd);
                    }
                }

            }

        }, error: function (json) { alert("error-刊期错误" + json); }
    });
}
	this.loadmonth= function(sel, year,nowmonth, fileurl) {
		//加载月份
        $.ajax({
            type: "POST",
            url: fileurl,
            dataType: "json",
            data: { "year": "" + year + "" }, 
            success: function (json) {
                if (json != 0) {
                    var issel = 0;
                    for (i = 0; i < json.classtable.length; i++) { //json为回传的数据；"classtable"表名在回传的json数据
                        issel = 0
                        if (json.classtable[i].month == nowmonth) {
                            issel = 1;
                        }
						//opt
                        opt(sel, json.classtable[i].month+"月", json.classtable[i].month, issel); 
                    }
                }

            }, error: function (json) { alert("error-月份错误" + json); }
        });		
	}
	
	this.loadyear=function(sel,nowyear,fileurl){
		//加载年份
        $.ajax({
            type: "POST",
            url: fileurl,
            dataType: "json",
            success: function (json) {
                if (json != 0) {
                    var issel = 0;
                    for (i = 0; i < json.classtable.length; i++) { //json为回传的数据；"classtable"表名在回传的json数据
                        issel = 0
                        if (json.classtable[i].year == nowyear) {
                            issel = 1;
                        }
                        opt(sel, json.classtable[i].year + "年", json.classtable[i].year, issel); //opt
                    }
                }

            }, error: function (json) { alert("error-年份错误" + json); }
        });
	}
	
	
}

function opt(sel,txt,value,issel){
        var op = document.createElement("option");
        op.value = value;
        op.text = txt;
        if (issel == 1)
            op.setAttribute("selected", "selected");
        sel.options.add(op);
}