//后台javascript



/*标签生成器*/
function tagcontent(){
	var tempstr;
	var trid;
	var thisid,cid,moduleid;
	//var mycid; //当前频道ID
	var moduleid;
	//接收检测频道ID
	cid = document.getElementById("content_cid").value;
	if (cid==-1)
	{
		cid=mycid; 
	}

	if (cid==0)
	{
		alert("请选择频道");
		return false;
	}
	//get moduleid
	var i;
	for (i=1;i<subcatchannel.length ;i++ )
	{
		if (subcatchannel[i][0]==cid)
		{
			moduleid=subcatchannel[i][1];
		}
	}

	switch (moduleid)
	{
	case "3":
		trid="articleli";
		break;
	case "4":
		trid="productli";
		break;
	case "5":
		trid="funli";
		break;
	case "6":
		trid="logli";
		break;
	case "7":
		trid="bbsli";	
		break;
	}
	tempstr = "{$li(listitem,main," + document.getElementById("content_cid").value;
	tempstr += "," + document.getElementById("class").value;
	tempstr += "," + document.getElementById("topicid").value;
	tempstr += "," + document.getElementById("count").value;
	tempstr += "," + document.getElementById("showtype").value;
	tempstr += "," + getobj("date1").value;
	tempstr += "," + getobj("date2").value;
	tempstr += "," + getobj("timeunit").value;
	tempstr += "," + getobj("timetype").value;
	tempstr += ","+trid;
	tempstr += ")}";
	document.getElementById("tags").value = tempstr;
}

function admin_Size(num,objname){
	var obj=getobj(objname);
	if (parseInt(obj.rows)+num>=3) {
		obj.rows = parseInt(obj.rows) + num;	
	}
	if (num>0)
	{
		obj.width="90%";
	} 
}

//标签生成器二级联动菜单
function   changeselect1(obj,locationid){  
	document.getElementById(obj).length   =   0;  
	document.getElementById(obj).options[0]   =   new   Option('无分类限制','0');  

	/*当前页时反回不变*/
	/*if((locationid.split("$")[0])=="当前频道"){return false}*/

	/*非首页页时显示当前分类选项*/
	if((0+locationid.split("$")[1])!=1){
	document.getElementById(obj).options[1]   =   new   Option('--当前分类--','-1'); 
	}
	for   (i=1;   i<subcat.length;   i++)  
	{  
		if   (subcat[i][0]   ==   locationid)  
		{ 
			document.getElementById(obj).options[ document.getElementById(obj).length]   =   new   Option(subcat[i][2],subcat[i][1]);}  
		}  

	document.getElementById("topicid").length   =   0;  
	document.getElementById("topicid").options[0]   =   new   Option('无专题限制','0');  
	document.getElementById("topicid").options[1]   =   new   Option('--当前专题--','-1'); 
	for   (i=1;   i<subcattopic.length;   i++)  
	{  
		if   (subcattopic[i][0]   ==   locationid)  
		{ 
			document.getElementById("topicid").options[ document.getElementById("topicid").length]   =   new   Option(subcattopic[i][2],subcattopic[i][1]);}  
		} 
}  

function tagclass(){
	var tempstr;
	var cid;

	//接收检测频道ID
	cid = document.getElementById("class_cid").value;
	if (cid==-1)
	{
		cid=mycid; 
	}
	if (cid==0)
	{
		alert("请选择频道");
		return false;
	}
	tempstr = "{$li(listclass,main," + document.getElementById("class_cid").value;
	tempstr = tempstr + "," + document.getElementById("classtype").value;
	tempstr = tempstr + ",classli)}";
	document.getElementById("tags").value = tempstr;		
}

function tagtopic(){
	var tempstr;
	var trid;
	var cid;

	//接收检测频道ID
	cid = document.getElementById("topic_cid").value;
	if (cid==-1)
	{
		cid=mycid; 
	}
	if (cid==0)
	{
		alert("请选择频道");
		return false;
	}
	trid="topicli";
	

	tempstr = "{$li(listtopic,main," + document.getElementById("topic_cid").value;;
	tempstr = tempstr + ","+trid+")}";
	document.getElementById("tags").value = tempstr;
}

function taggroup()	{
	var tempstr;
	var cid;
	//接收检测频道ID
	cid = document.getElementById("topic_cid").value;
	if (cid==-1)
	{
		cid=mycid; 
	}
	if (cid==0)
	{
		alert("请选择频道");
		return false;
	}

	tempstr = "{$li("+getobj("groupname").value+",main," + document.getElementById("topic_cid").value+","+getobj("count").value;
	tempstr = tempstr + ",group,groupli)}";
	document.getElementById("tags").value = tempstr;
}

function tagblog(){
	var tempstr;
	var thisid;

	tempstr = "{$li(blog,main,"+getobj("blogtype").value+","+getobj("count").value;
	tempstr = tempstr + ",blogli)}";
	document.getElementById("tags").value = tempstr;
}

function tagvote(){getobj("tags").value = "{$li(vote,main,"+getobj("thisclassid").value+",vote,voteli)}";}

function tagform(){
	{getobj("tags").value = "{$li(showform,main,"+getobj("form_cid").value+",form)}";}
}
function tagitem(){
	var tempstr;
	var thisid;

	tempstr = "{$li(item,main,"+getobj("itemid").value;
	tempstr = tempstr + ",item)}";
	document.getElementById("tags").value = tempstr;
}

function showform(id,title){
	var editform;
	editform = "<form method=post action='?act=savereadme&id=" + id + "' style='display:inline;'>";
	editform += "<input type='text' name='readme' value='" + title + "' size='30'>";
	editform += "<input type='submit' value='修改'>";
	editform += "</form>";
	document.getElementById('readme'+id).innerHTML=editform;
}

/*是否是预览图片,名称中包含pre的就是预览图*/
function ispreimg(str){
	if (str.indexOf("/pre/")>0){document.write(" <i>预</i> ");}
}
function Preview(obj,str){
	if(obj.length==0) return false;

	if (str){
		var sExt=str.substr(str.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		switch(sExt){
		case "GIF":
		case "JPG":
		case "BMP":
		case "PNG":
			//tdPreview.innerHTML = "<img border=0 src='" + url + "' width='170' height='140'>";
		document.getElementById(obj).innerHTML="<img src='" + str + "' onclick='javascript:window.open(this.src);' style='CURSOR: pointer' onload='rsimg(this,180 )'>";

		//tdPreview.innerHTML = sHTML;
		}
	}
	else 
	{
		tdPreview.innerHTML = "";
	}
}


//预览图显示相应标记
function showprestr(str){
	if (str.indexOf("/pre/")>0)
	{
		document.write("<cite>预</cite>");
	}
}
//编辑title
function toarea(num){
	var obj="t"+num;
	var I;
	for (I=0; I<100; I++){
		if(chkdiv("templatehelp"+I)){getobj("templatehelp"+I).style.color="#000";}
	}	
	if(chkdiv("templatehelp"+num)){
		getobj(obj).focus();
		getobj("templatehelp"+num).style.color="#f00";
		}
}



/*表单部分*/
function showoption(str){
	if (str.length>0)
	{
		str = str.replace(/\|/g,"<br>");
		document.write(str);
	}	
}




/*=============================*/
/*财务明细*/
/*显示款项审核状态*/
function showmoneystate(num){
	num=num+0;
	if (num==0)
	{
		document.write("<img src='../images/check_error.gif' alt='' />");
	}
	else
	{
		document.write("<img src='../images/check_right.gif' alt='' />");	
	}
}


/*===============================*/
/*显示定单状态*/
function showordertype(num){
	var arrordertype = ordertype.split("|")
	num+=0
	document.write(arrordertype[num]);
}
/*是否显示删除定单*/
function delorder(num1,num2){
	num1=0+num1;
	num2=0+num2;
	if (num2==3 || num2==4)
	{
		getobj("ad"+num1).style.display="none";
	}
	
}

/*是一时显示对勾*/
function isright(num){
	num=0+num;
	if(num==1){document.write("<img src=\"../images/check_right.gif\" alt=\"\" />")}
}

/*频道管理*/
function chatype(num){
	num=0+num;
	switch (num)
	{
	case 0 :
		document.write("系统");
		break;
	case 1 :
		document.write("内部");
		break;
	case 2 :
		document.write("外部");
		break;
	}
}
function chaoperate(num1,num2){
	num1=0+num1;num2=0+num2;
	if (num1==1||num1==3||num1==4||num1==5||num1==9){
		document.write("<a href=\"?act=ghost&id="+num1+"\" onclick=\"return showinnew(this,400,450)\">克隆</a>");
	}
	else{
		document.write("<span class=\"gray\">克隆</span>");
	}
	switch(num2){
		case 0:
			document.write("￤<span class=\"gray\">删除</span>");
			break;
		case 1:
			document.write("￤<a href=\"?act=delghost&id="+num1+"\" onClick=\"return confirm('确认要删除ID="+num1+"的这个频道吗!删除后不可恢复')\">删除</a>");
			break;
		case 2:
			document.write("￤<a href=\"?act=delout&id="+num1+"\" onClick=\"return confirm('确认要删除除ID="+num1+"的这个频道吗!删除后不可恢复')\">删除</a>");
	}
}


/*user_blog.asp*/
/*编辑用户分类*/
function edituserclass(num){
	edit("classinfo",200,150);
	getobj("classtitle").value=getobj("title"+num).innerHTML;
	getobj("classcls").value=getobj("cls"+num).innerHTML;
	getobj("classform").action+=num
}
function installed(num){
	if (num==0)
	{
		document.write("<font color=red><b>×</b></font>");
	}
	else {
		document.write("<font color=green><b>√</b></font>");
		}
}
/*数据库类型*/
function mymdb(num){
	if (num==0)
	{
		document.write("Access")
	}
	else
	{
		document.write("MsSQL")
	}
}

function getJVer(){
  //获取JScript 版本
  return ScriptEngineMajorVersion() +"."+ScriptEngineMinorVersion()+"."+ ScriptEngineBuildVersion();
}
//=============================私有函数:admin_template.asp

/*把文件地址追加到指定obj*/
function fileurl(obj,str){
	var originallyvalue;
	var thisgap='';

	if (obj=="myurl")
	{
		thisgap="\n"
		originallyvalue=window.opener.document.getElementById(obj).value;
		if(originallyvalue.length==0){
			window.opener.document.getElementById(obj).value="下载地址|"+str;
		}
		else{
			window.opener.document.getElementById(obj).value+=thisgap+"下载地址|"+str;
		}	
	}

	else{
	window.opener.document.getElementById(obj).value=str;
	}
	window.close();
}


//提交部分模板
function updatetemplate(id,pagename){ 
	var browser = navigator.appName; 
	//var imgbutton = getobj("img"+num)
	//var imgbuttonhtml = imgbutton.innerHTML
	if(browser == "Microsoft Internet Explorer"){ 
		var objAjax = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
	else{ 
		var objAjax = new XMLHttpRequest(); 
		} 
	if(objAjax){
		//msgbox.style.display="block";
		objAjax.onreadystatechange=function(){
			if(objAjax.readyState==4){
				if(objAjax.status==200){
					getobj("imgstate"+id).style.display="inline"
					getobj("img"+id).style.display="none"
					setTimeout("showimgbutton("+id+")",2000);
					//imgbutton.innerHTML=imgbuttonhtml;
					//getobj("msgsubmit").innerHTML=objAjax.responseText;
					//getobj("msgsubmit").style.display="block";
				}
				else{
					getobj("img"+id).innerHTML=objAjax.statusText;
					//getobj("msgsubmit").innerHTML=objAjax.responseText;
					//getobj("msgsubmit").style.display="block";
				}
			}
		//else{imgbutton.innerHTML="Loading..."}
		}

  objAjax.open('POST','admin_template.asp?act=savepart&id='+id+'&pagename='+pagename,true);
  objAjax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

  var SendData = 'templatestr='+encodeURIComponent(getobj("t"+id).value) ; 
  objAjax.send(SendData);
 }
 else{
 imgbutton.innerHTML='不支持XMLHttpRequest' ;
 }
}	

/*添加新记录时,运费部分*/
function showtransprice(){
	if (getobj("projectid").value==-1)
	{
		getobj("transprice").style.display="block";
	}
	else{
		getobj("transprice").style.display="none";
	}
}
