//博客首页 2011-7-15
var objAjax = new JAjax();
function createObject(){
	return function(){
		this.load.apply(this,arguments);	
	}
}
//保存内容页面
var saveClass=null;
setTimeout("loadSaveObject()",1000);
function loadSaveObject(){
	saveClass=new saveObject();	
	if(EditContent==""||EditContent==null){
		EditContent=" ";
	}
}
var saveObject=new createObject();
saveObject.prototype.load=function(){
	this.saveTab=$("saveTab");	
	this.useType=urlPar("useType");
	this.typeId=urlPar("typeId");
	this.user=urlPar("user");
	this.pType=urlPar("pType");	
	this.selOut=new Array(0,0);
	if(this.user==null){
		this.user=userName;	
	}
	
	if(this.typeId==null){
		this.typeId=1;	
	}
	
	if(this.useType==null){
		this.useType=0
	}
	this.loadMenu();
}
//加载当前文章所在的是否具有权限
saveObject.prototype.loadPower=function(){
	if(this.pType=="modi"){
		var objResponse=new JHttpResponse();
		objResponse.write("tabId",urlPar("id"));
		objResponse.write("tabName",urlPar("asTab"));
		var out=objAjax.getText("post","./cs/saveContent.aspx?type=isPowerContent&useType="+this.useType+"&user="+this.user,objResponse,null); 
		if(out.indexOf(c1)>-1){
			this.selOut=out.split(c1);
			return true;	
		}else{
			alert(out);
			return false;
		}
	}else{
		return true;	
	}
}
//加载栏目分类信息
saveObject.prototype.loadMenu=function(){
	if(!this.loadPower()){		
		window.location.href="./index.aspx";
		return;
	}
	var objResponse=new JHttpResponse();
	objResponse.write("typeId",this.typeId);
    var out=objAjax.getText("post","./cs/saveContent.aspx?type=readMenuLst&useType="+this.useType+"&user="+this.user,objResponse,null); 
	if(out=="no"){
		alert("当前你还没有分类哦,请添加");
        this.addMenu(); 	
	}else if(out.indexOf(c1)>-1){
		out=out.split(c2);
		this.saveTab.deleteRow(this.saveTab.rows.length-1);
		
		var tr=this.saveTab.insertRow(this.saveTab.rows.length);
		var td=tr.insertCell(-1);
		td.className="jishutd";
		td.style.cssText="text-align:right;"
		td.innerHTML="权限：";
		
		td=tr.insertCell(-1);
		td.className="jishutd";
		td.style.cssText=""
		var cSel=document.createElement("select");
		cSel.setAttribute("id","competenceID");
		cSel.style.width="200px";
		cSel.options.add(new Option("全部可见","0"));
		if(this.useType=="0"){
			cSel.options.add(new Option("好友可见","1"));
			cSel.options.add(new Option("自己可见","2"));
		}else{
			cSel.options.add(new Option("群成员可见","1"));
		}
		cSel.options[this.selOut[0]].selected=true;
		td.appendChild(cSel);
		
		tr=this.saveTab.insertRow(this.saveTab.rows.length);
		var td=tr.insertCell(-1);
		td.className="jishutd";
		td.style.cssText="text-align:right;"
		td.innerHTML="分类：";
		
		td=tr.insertCell(-1);
		td.className="jishutd";
		var cSel=document.createElement("select");
		cSel.style.width="200px";
		cSel.setAttribute("id","typeMenuID");
		for(var i=0;i<out.length;i++){
			var vp=out[i].split(c1);			
			cSel.options.add(new Option(vp[1],vp[0]));
			if(parseInt(this.selOut[1])==parseInt(vp[0])){
				cSel.options[i].selected=true;		
			}
		}	
		
		td.appendChild(cSel);
		var cbtn=document.createElement("input");
		cbtn.setAttribute("type","button");
		cbtn.setAttribute("value","添加分类");
		cbtn.onclick=function(){
			saveClass.addMenu();	
		}
		td.appendChild(cbtn);
		
		tr=this.saveTab.insertRow(this.saveTab.rows.length);
		var td=tr.insertCell(-1);
		td.className="jishutd";
		td.innerHTML="&nbsp;";
		
		td=tr.insertCell(-1);
		td.className="jishutd";
		var cbtn=document.createElement("input");
		cbtn.setAttribute("type","button");
		cbtn.setAttribute("value","保存数据");
		cbtn.onclick=function(){
			d.saveArticles()
		}
		td.appendChild(cbtn);		
	}else{
		this.saveTab.innerHTML=out;
	}
}
//跳转到添加栏目信息
saveObject.prototype.addMenu=function(){
     window.location.href="./Management.aspx?typeid="+this.typeId+"&useType="+this.useType;   
} 