function delmolihe(id){
	if(!confirm("您确定要删除吗？")){
		return;
	}
	var url = "./index.asp?action=delmolihe&id="+id;
	var _ajax = new ajax;
	_ajax.StartRequest(url,"text","");
	location.href = location.href;
}

function edit(t,id,v,ov){
	//v = encodeURIComponent(v);
	if(v==""){
		display(t,id,ov);
	}else{
		var v1 = v;
		v1 = v1.replace(/&/g,"asc(38)");
		v1 = v1.replace(/#/g,"asc(35)");
		v1 = v1.replace(/\|/g,"asc(124)");
		//alert(v1);
		var parm = "";
		switch(t){
			case 'title':
				parm = "name="+v1;
				break;
			case 'tags':
				parm = "tags="+v1;
				break;
			case 'desc':
				parm = "instruction="+v1;
				break;
			case 'cate':
				parm = "cate="+v1;
				break;
			case 'share_set':
				parm = "share_set="+v1;
				break;
		}
		var url = "./index.asp?action=editmoliheinfo&moliheid="+id+"&"+parm;
		var _ajax = new ajax; 
		_ajax.StartRequest(url,"text","");
		//v = decodeURIComponent(v);
		display(t,id,v);
	}
	return false;
}

function display(t,id,v){
	var str;
	switch(t){
		case 'title':
			str = "<span class=\"f110 fweight\">"+v+"</span> <a href=\"javascript:edit_s('title','"+id+"','"+v+"')\">[编辑作品名称]</a>";
			break;
		case 'tags':
			str = "作品标签："+v+" <a href=\"javascript:edit_s('tags','"+id+"','"+v+"')\">[编辑]</a>";
			break;
		case 'desc':
			str = "作品描述："+v+" <a href=\"javascript:edit_s('desc','"+id+"','"+v+"')\">[编辑]</a>";
			break;
		case 'cate':
			str = "作品分类："+v+" <a href=\"javascript:edit_s('cate','"+id+"','"+cate(v-1)+"')\">[编辑]</a>";
			break;
		case 'share_set':
			str = "分享设置：";
			str += v=="1" ? "公开" : "私密";
			str += " <a href=\"javascript:edit_s('share_set','"+id+"','"+v+"')\">[编辑]</a>";
			break;
	}
	document.getElementById(t+id).innerHTML = str;
}

function edit_s(t,id,v){
	switch(t){
		case 'title':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit(\"title\",\""+id+"\",this.name.value,\""+v+"\");'><input type='text' name='name' maxlength='30' value='"+v+"'> <input type='submit' value='修改作品名称'></form>";
			break;
		case 'desc':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit(\"desc\",\""+id+"\",this.name.value,\""+v+"\");'><input type='text' name='name' value='"+v+"'> <input type='submit' value='修改作品描述'></form>";
			break;
		case 'tags':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit(\"tags\",\""+id+"\",this.name.value,\""+v+"\");'><input type='text' name='name' value='"+v+"'> <input type='submit' value='修改作品标签'></form>";
			break;
		case 'cate':
			var cateid = ["1","2","3","4","5","6","7"];
			var str = "<form class='fm' onsubmit='return edit(\"cate\",\""+id+"\",this.cate.options[this.cate.selectedIndex].value,\""+v+"\");'><select name=\"cate\">";
			for(var i=0;i<cate.length;i++){
				str += "<option value="+cateid[i];
				if(cateid[i]==v){str+=" selected"}
				str += ">"+cate[i]+"</option>"
			}
			str += "</select><input type='submit' value='修改作品分类'></form>";
			
			document.getElementById(t+id).innerHTML = str;
			break;
		case 'share_set':
			var str = "<form class='fm' onsubmit='return edit(\"share_set\",\""+id+"\",this.name.value,\""+v+"\");'>";
			str += "<input onclick=\"if(this.checked){this.form.name.value=this.value;}\" type=\"radio\" name=\"t\" value=\"1\"";
			if(v=="1"){str+=" checked";}
			str += ">公开 ";
			str += "<input onclick=\"if(this.checked){this.form.name.value=this.value;}\" type=\"radio\" name=\"t\" value=\"0\"";
			if(v=="0"){str+=" checked";}
			str += ">私密 ";
			str += "<input type=\"hidden\" name=\"name\" value=\""+v+"\"><input type='submit' value='修改分享设置'></form>";
			document.getElementById(t+id).innerHTML = str;
			break;
	}
}

function edit_s_myspace(t,id,v, myspaceid){
	switch(t){
		case 'title':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit_myspace(\"title\",\""+id+"\",this.name.value,\""+v+"\", \""+myspaceid+"\");'><input type='text' name='name' maxlength='30' value='"+v+"'> <input type='submit' value='修改作品名称'></form>";
			break;
		case 'desc':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit(\"desc\",\""+id+"\",this.name.value,\""+v+"\");'><input type='text' name='name' value='"+v+"'> <input type='submit' value='修改作品描述'></form>";
			break;
		case 'tags':
			document.getElementById(t+id).innerHTML = "<form class='fm' onsubmit='return edit(\"tags\",\""+id+"\",this.name.value,\""+v+"\");'><input type='text' name='name' value='"+v+"'> <input type='submit' value='修改作品标签'></form>";
			break;
		case 'cate':
			var cateid = ["1","2","3","4","5","6","7"];
			var str = "<form class='fm' onsubmit='return edit(\"cate\",\""+id+"\",this.cate.options[this.cate.selectedIndex].value,\""+v+"\");'><select name=\"cate\">";
			for(var i=0;i<cate.length;i++){
				str += "<option value="+cateid[i];
				if(cateid[i]==v){str+=" selected"}
				str += ">"+cate[i]+"</option>"
			}
			str += "</select><input type='submit' value='修改作品分类'></form>";
			
			document.getElementById(t+id).innerHTML = str;
			break;
		case 'share_set':
			var str = "<form class='fm' onsubmit='return edit(\"share_set\",\""+id+"\",this.name.value,\""+v+"\");'>";
			str += "<input onclick=\"if(this.checked){this.form.name.value=this.value;}\" type=\"radio\" name=\"t\" value=\"1\"";
			if(v=="1"){str+=" checked";}
			str += ">公开 ";
			str += "<input onclick=\"if(this.checked){this.form.name.value=this.value;}\" type=\"radio\" name=\"t\" value=\"0\"";
			if(v=="0"){str+=" checked";}
			str += ">私密 ";
			str += "<input type=\"hidden\" name=\"name\" value=\""+v+"\"><input type='submit' value='修改分享设置'></form>";
			document.getElementById(t+id).innerHTML = str;
			break;
	}
}
function edit_myspace(t,id,v,ov, myspaceid){
	//v = encodeURIComponent(v);
	if(v==""){
		display(t,id,ov);
	}else{
		var v1 = v;
		v1 = v1.replace(/&/g,"asc(38)");
		v1 = v1.replace(/#/g,"asc(35)");
		v1 = v1.replace(/\|/g,"asc(124)");
		//alert(v1);
		var parm = "";
		switch(t){
			case 'title':
				parm = "name="+v1;
				break;
			case 'tags':
				parm = "tags="+v1;
				break;
			case 'desc':
				parm = "instruction="+v1;
				break;
			case 'cate':
				parm = "cate="+v1;
				break;
			case 'share_set':
				parm = "share_set="+v1;
				break;
		}
		var url = "./index.asp?action=editmoliheinfo&moliheid="+id+"&myspaceid="+myspaceid+"&"+parm;
		var _ajax = new ajax; 
		_ajax.StartRequest(url,"text","");
		//v = decodeURIComponent(v);
		display(t,id,v);
	}
	return false;
}