function setlv2(val,set){
	var len = termSheet[val][1].length; var op = '';
	if(len){
		for (i=0; i<len; i++){
			if(set && set==termSheet[val][1][i][0]){ op = op+'<option selected="selected" value="'+termSheet[val][1][i][0]+'">'+termSheet[val][1][i][1]+'</option>';
			}else{ op = op+'<option value="'+termSheet[val][1][i][0]+'">'+termSheet[val][1][i][1]+'</option>'; }
		}
	}else{ alert('该分类下无子分类，请先添加子分类'); } $("select[name=lv2]").empty().append(op);
}

function nv(val){
	var v = "a"; if(val=="0"){ $("#conShowType").show(); }else{ $("#conShowType").hide(); v = termSheet[val]; }
	$("input:radio[name=showType][value="+v+"]").attr("checked", true); ins(v);
}
function ins(val){ catinit(val); }

function panelInitCn(val){ if(val=="txt"){ $("#CDTc").show(); $("#CDIc").hide(); } if(val=="img"){ $("#CDTc").hide(); $("#CDIc").show(); }};
function panelInitEn(val){ if(val=="txt"){ $("#CDTe").show(); $("#CDIe").hide(); } if(val=="img"){ $("#CDTe").hide(); $("#CDIe").show(); }};
function coninit(val){
	$("input[name=descSizeWidth]").val(styleSheet[val][4]);
	$("input[name=descSizeHeight]").val(styleSheet[val][5]);
	$("input[name=thumbSizeWidth]").val(styleSheet[val][9]);
	$("input[name=thumbSizeHeight]").val(styleSheet[val][10]);
	$("input[name=imageSizeWidth]").val(styleSheet[val][12]);
	$("input[name=imageSizeHeight]").val(styleSheet[val][13]);
	$("#styleScreen").attr("src","/Public/uploads/style/"+styleSheet[val][0]);
	(styleSheet[val][1]=="1") ? $("#conUrl").fadeIn() : $("#conUrl").fadeOut();
	(styleSheet[val][7]=="1") ? $("#conTime").fadeIn() : $("#conTime").fadeOut();
	if(styleSheet[val][8]=="0"){ $("div#conThumb").fadeOut(); }else{ $("div#conThumb").fadeIn();
		$("span.tipThumb").replaceWith("<span class=\"tipThumb\">"+styleSheet[val][9]+" × "+styleSheet[val][10]+"<\/span>");
	}
	if(styleSheet[val][11]=="0"){ $("div#conImage").fadeOut(); }else{ $("div#conImage").fadeIn();
		$("span.tipImage").replaceWith("<span class=\"tipImage\">"+styleSheet[val][12]+" × "+styleSheet[val][13]+"<\/span>");
	}
	if(styleSheet[val][2]==1 && styleSheet[val][3]==1){
		$(".CFW, #CDTc, #CDTe").show(); $("#CDIc, #CDIe").hide();
		$("input:radio[name=conFillWithCn], input:radio[name=conFillWithEn]").attr("disabled", false);
		$("input:radio[name=conFillWithCn][value=txt], input:radio[name=conFillWithEn][value=txt]").attr("checked", true);
		$("span.tipIMG").replaceWith("<span class=\"tipIMG\">"+styleSheet[val][4]+" × "+styleSheet[val][5]+"px<\/span>");
	}else{
		$("input:radio[name=conFillWithCn], input:radio[name=conFillWithEn]").attr("disabled", true);
		if(styleSheet[val][2]==0 && styleSheet[val][3]==0){
			$(".CFW, #CDIc, #CDTc, #CDIe, #CDTe").hide();
		}else if(styleSheet[val][2]==1 && styleSheet[val][3]==0){
			$("#CDTc, #CDTe").show(); $(".CFW, #CDIc, #CDIe").hide();
		}else if(styleSheet[val][2]==0 && styleSheet[val][3]==1){
			$("#CDIc, #CDIe").show(); $(".CFW, #CDTc, #CDTe").hide();
			$("span.tipIMG").replaceWith("<span class=\"tipIMG\">"+styleSheet[val][4]+" × "+styleSheet[val][5]+"px<\/small>");
		}
	}
};
function catinit(val){
	$("input[name=thumbSizeWidth]").val(styleSheet[val][3]);
	$("input[name=thumbSizeHeight]").val(styleSheet[val][4]);
	$("input[name=imageSizeWidth]").val(styleSheet[val][6]);
	$("input[name=imageSizeHeight]").val(styleSheet[val][7]);
	$("#styleScreen").attr("src","/Public/uploads/style/"+styleSheet[val][0]);
	if(styleSheet[val][2]=="0"){ $("div#conThumb").fadeOut(); }else{ $("div#conThumb").fadeIn();
		$("span.tipThumb").replaceWith("<span class=\"tipThumb\">"+styleSheet[val][3]+" × "+styleSheet[val][4]+"<\/span>");
	}
	if(styleSheet[val][5]=="0"){ $("div#conImage").fadeOut(); }else{ $("div#conImage").fadeIn();
		$("span.tipImage").replaceWith("<span class=\"tipImage\">"+styleSheet[val][6]+" × "+styleSheet[val][7]+"<\/span>");
	}
	if(styleSheet[val][1]=="0"){ $("#CDTc, #CDTe").hide(); }else{ $("#CDTc, #CDTe").show(); }
};

function dialogEditMenu(){
	if($("#editMenu").css("display") != "block"){
		$("#editMenu").css("display","block");
		$("#dialogEditMenu").css("display","block");
	}else{
		$("#editMenu").css("display","none");
		$("#dialogEditMenu").css("display","none");
	}
	return false;
}
function uploadconfig(site,file,ac){
	var app = '/index.php';
	var cms = '/Public';
	switch (ac){
		case "l":
			$('#id_weblogo').uploadify({
				'uploader':cms+'/Swf/uploadify.swf', 'auto':true, 'scriptAccess':'always', 'sizeLimit':'1048576', 'script':site+'/core/uploadify.php',
				'buttonImg':cms+'/Images/uploadBTN.png','height':28, 'width':80, 'cancelImg':cms+'/Images/cancel.png',
				'fileDesc':'.gif, .jpg, .jpeg, .png', 'fileExt':'*.gif;*.jpg;*.jpeg;*.png;', 'folder':'/images/'+file,
				'onError':function(event, queueID, fileObj){ alert("文件:" + fileObj.name + " 上传失败"); },
				'onSelect':function (event, ID, fileObj){
					$('#id_weblogo').uploadifySettings('scriptData',{'logo':'true'});
				},
				'onComplete':function(event, queueID, fileObj, response, data){
					$.post(app+"/attachment", {extension:response,action:"setlogo"}, function(data){
						if(data.success="true"){ $("#weblogoImg").attr("src",site+"/images/system/logo."+response+"?"+parseInt(1000*Math.random())); }
					},"json");
				}
			});
		break;
		case "a":
			$('#descICn').uploadify({
				'uploader':cms+'/Swf/uploadify.swf', 'auto':true, 'scriptAccess':'always', 'sizeLimit':'2048000', 'script':site+'/core/uploadify.php',
				'buttonImg':cms+'/Images/uploadBTN.png','height':28, 'width':80, 'cancelImg':cms+'/Images/cancel.png',
				'fileDesc':'.gif, .jpg, .jpeg, .png', 'fileExt':'*.gif;*.jpg;*.jpeg;*.png;', 'folder':'/images/'+file,
				'onError':function(event, queueID, fileObj){ alert("文件:" + fileObj.name + " 上传失败"); },
				'onSelect':function (event, ID, fileObj){
					$('#descICn').uploadifySettings('scriptData',{'width':$("input[name=descSizeWidth]").val(), 'height':$("input[name=descSizeHeight]").val()});
				},
				'onComplete':function(event, queueID, fileObj, response, data){
					$.post(app+"/attachment", {title:response,size:fileObj.size,action:"attachment",type:"desccn"}, function(data){
						if(data.success="true"){ $("#id_CDIcAjax").attr("src",site+"/images/crumbs/"+response); }
					},"json");
				}
			});
			
			$('#descIEn').uploadify({
				'uploader':cms+'/Swf/uploadify.swf', 'auto':true, 'scriptAccess':'always', 'sizeLimit':'2048000', 'script':site+'/core/uploadify.php',
				'buttonImg':cms+'/Images/uploadBTN.png','height':28, 'width':80, 'cancelImg':cms+'/Images/cancel.png',
				'fileDesc':'.gif, .jpg, .jpeg, .png', 'fileExt':'*.gif;*.jpg;*.jpeg;*.png;', 'folder':'/images/'+file,
				'onError':function(event, queueID, fileObj){ alert("文件:" + fileObj.name + " 上传失败"); },
				'onSelect':function (event, ID, fileObj){
					$('#descIEn').uploadifySettings('scriptData',{'width':$("input[name=descSizeWidth]").val(), 'height':$("input[name=descSizeHeight]").val()});
				},
				'onComplete':function(event, queueID, fileObj, response, data){
					$.post(app+"/attachment", {title:response,size:fileObj.size,action:"attachment",type:"descen"}, function(data){
						if(data.success="true"){ $("#id_CDIeAjax").attr("src",site+"/images/crumbs/"+response); }
					},"json");
				}
			});
		default:
			$("#uploadThumb").uploadify({
				'uploader':cms+'/Swf/uploadify.swf', 'auto':true, 'scriptAccess':'always', 'sizeLimit':'1024000', 'script':site+'/core/uploadify.php',
				'buttonImg':cms+'/Images/uploadBTN_thumb.png', 'height':28, 'width':80, 'cancelImg':cms+'/Images/cancel.png',
				'fileDesc':'.gif, .jpg, .jpeg, .png', 'fileExt':'*.gif;*.jpg;*.jpeg;*.png;', 'folder':'/images/'+file,
				'onError':function(event, queueID, fileObj){ alert("文件:" + fileObj.name + " 上传失败"); },
				'onSelect':function (event, ID, fileObj){
					$('#uploadThumb').uploadifySettings('scriptData',{'width':$("input[name=thumbSizeWidth]").val(),'height':$("input[name=thumbSizeHeight]").val()});
				},
				'onComplete':function(event, queueID, fileObj, response, data){
					$.post(app+"/attachment", {title:response,size:fileObj.size,action:"attachment",type:"thumb"}, function(data){
						if(data.success="true"){ $("#id_thumbAjax").attr("src",site+"/images/crumbs/"+response); }
					},"json");
				}
			});
			
			$("#uploadImage").uploadify({
				'uploader':cms+'/Swf/uploadify.swf', 'auto':true, 'scriptAccess':'always', 'sizeLimit':'2048000', 'script':site+'/core/uploadify.php',
				'buttonImg':cms+'/Images/uploadBTN_image.png','height':28, 'width':80, 'cancelImg':cms+'/Images/cancel.png',
				'fileDesc':'.gif, .jpg, .jpeg, .png', 'fileExt':'*.gif;*.jpg;*.jpeg;*.png;', 'folder':'/images/'+file,
				'onError':function(event, queueID, fileObj){ alert("文件:" + fileObj.name + " 上传失败"); },
				'onSelect':function (event, ID, fileObj){
					$('#uploadImage').uploadifySettings('scriptData',{'width':$("input[name=imageSizeWidth]").val(), 'height':$("input[name=imageSizeHeight]").val()});
				},
				'onComplete':function(event, queueID, fileObj, response, data){
					$.post(app+"/attachment", {title:response,size:fileObj.size,action:"attachment",type:"image"}, function(data){
						if(data.success="true"){ $("#id_imageAjax").attr("src",site+"/images/crumbs/"+response); }
					},"json");
				}
			});
	}
}