//博客首页 2011-7-15
var objAjax = new JAjax();
function createObject(){
	return function(){
		this.load.apply(this,arguments);	
	}
}
//专辑信息类
var baseClass=null;
//博客首页 2011-7-19
setTimeout("loadPagebase()",500);
function loadPagebase(){
	baseClass=new baseObject();	
}
var baseObject=new createObject();

//初始化执行
baseObject.prototype.load=function(){
	this.typeMenuID=urlPar("typeMenuID");
	this.menuPhotoDiv=$("menuPhotoDiv");
	if(isBunch=="0"){
		this.useType="0"	
	}else{
		this.useType=homeUserID;	
	}
	this.user=urlPar("user");
	if(this.user==null){		
		this.user=userName;
	}	
	this.pagesize=16;
	this.page=1;
	this.pages=0;
	this.pagecount=0;		
	this.loadMenuBase();
}

//加载专辑的内容信息
baseObject.prototype.loadMenuPhoto=function(){
	var objResponse=new JHttpResponse();
	objResponse.write("typeMenuID",this.typeMenuID);	
	objResponse.write("typeid",this.typeid);
	objResponse.write("page",this.page);	
	objResponse.write("pagesize",this.pagesize);	
	objResponse.write("serValue",$("serValue").value);
	var out=objAjax.getText("post","./cs/indexServer.aspx?type=loadMenuData&useType="+this.useType+"&user="+this.user,objResponse,null);
	if(out.indexOf(c1)>-1){
		out=out.split(c3);
		this.pagecount=out[0];
		this.pages=parseInt(this.pagecount)/parseInt(this.pagesize);
		if(parseInt(this.pages)<parseFloat(this.pages)){
			this.pages=parseInt(this.pages)+1;	
		}	
		if(this.typeid=="2"){
			this.loadPhoto(out[1]);
		}else{
			this.loadMusic(out[1]);
		}
		var font=$("font");
		var font_1=$("font_1");
		var sel_1=$("sel_1");
		var sel=$("sel");
		font.innerHTML=this.page+"/"+this.pages+"页";
		font_1.innerHTML=this.page+"/"+this.pages+"页";
		if(parseInt(this.pages)>1){			
			if(this.page=="1"||parseInt(this.pages)>parseInt(this.page)){
				var nSpan=document.createElement("span");
				nSpan.style.cssText="cursor:pointer;color:blue;"
				nSpan.innerHTML="下一页";
				nSpan.onclick=function(){
					baseClass.page=parseInt(baseClass.page)+1;
					baseClass.loadMenuPhoto();
				}
				font.appendChild(nSpan);
				var nSpan_1=document.createElement("span");
				nSpan_1.style.cssText="cursor:pointer;color:blue;"
				nSpan_1.innerHTML="下一页";
				nSpan_1.onclick=function(){
					baseClass.page=parseInt(baseClass.page)+1;
					baseClass.loadMenuPhoto();
				}
				font_1.appendChild(nSpan_1);
			}
			if(parseInt(this.page)>1){
				var nSpan=document.createElement("span");
				nSpan.style.cssText="cursor:pointer;color:blue;"
				nSpan.innerHTML="上一页";
				nSpan.onclick=function(){
					baseClass.page=parseInt(baseClass.page)-1;
					baseClass.loadMenuPhoto();
				}
				font.appendChild(nSpan);
				var nSpan_1=document.createElement("span");
				nSpan_1.style.cssText="cursor:pointer;color:blue;"
				nSpan_1.innerHTML="上一页";
				nSpan_1.onclick=function(){
					baseClass.page=parseInt(baseClass.page)-1;
					baseClass.loadMenuPhoto();
				}
				font_1.appendChild(nSpan_1);
			}
			sel_1.innerHTML="";
			sel.innerHTML="";
			for(var i=1;i<=parseInt(this.pages);i++){
				sel_1.options.add(new Option("跳转到第"+i+"页",i));
				if(i==parseInt(this.page)){
					sel_1.options[i-1].selected=true;	
				}
			}
			sel_1.onchange=function(){
				baseClass.page=parseInt(this.options[this.selectedIndex].value);
				baseClass.loadMenuPhoto();
			}
			
			for(var i=1;i<=parseInt(this.pages);i++){
				sel.options.add(new Option("跳转到第"+i+"页",i));
				if(i==parseInt(this.page)){
					sel.options[i-1].selected=true;	
				}
			}
			sel.onchange=function(){
				baseClass.page=parseInt(this.options[this.selectedIndex].value);
				baseClass.loadMenuPhoto();
			}
		}	
	}else{
		this.menuPhotoDiv.innerHTML=out;	
	}
}

//生成音乐信息
baseObject.prototype.loadMusic=function(out){
	if(isBunch=="0"){
		this.tab=menuTabMusic;
	}else{
		this.tab=menuTabBunMusic;	
	}	
	var isBool=false;		
	if(parseInt(homeUserID)==parseInt(userID)||parseInt(cUserID)==parseInt(userID)){
			isBool=true;	
	}
	this.menuPhotoDiv.innerHTML="";
	// 0     1         2     3       4          5       6         7       8            9
	//ID,Count_Click,title,SourceUrl,menuid,TabImage,SaveUser,SaveUserID,SaveDate,competenceID
	out=out.split(c2);
	var cTab=document.createElement("table");
	cTab.setAttribute("border",0);
	cTab.setAttribute("cellSpacing",0);
	cTab.setAttribute("cellPadding",0);
	cTab.style.cssText="width:98%;margin:5px;";

	this.menuPhotoDiv.appendChild(cTab);
	
	var tr=cTab.insertRow(cTab.rows.length);
	var td=tr.insertCell(-1);
	td.className="musicLstTitleCss"
	td.innerHTML="歌曲名称";
	
	td=tr.insertCell(-1);
	td.className="musicLstTitleCss_1"
	td.innerHTML="创建日期";
	
	td=tr.insertCell(-1);
	td.className="musicLstTitleCss_1"
	td.innerHTML="创建者";
	
	td=tr.insertCell(-1);
	td.className="musicLstTitleCss_1"
	td.innerHTML="状态";
	
	td=tr.insertCell(-1);
	td.setAttribute("colSpan",3)
	td.className="musicLstTitleCss_1"
	td.innerHTML="&nbsp;";
	
	for(var i=0;i<out.length;i++){
		var vp=out[i].split(c1);
		tr=cTab.insertRow(cTab.rows.length);
		tr.onmouseover=function(){this.style.backgroundColor="#efefef";}
		tr.onmouseout=function(){this.style.backgroundColor="";}
		td=tr.insertCell(-1);
		td.className="musicLstBodyCss";
		td.innerHTML="<a href='./musicContent.aspx?menuid="+vp[4]+"&tab="+this.tab+"&tabid="+vp[0]+"'>"+vp[2]+"</a>";
		
		td=tr.insertCell(-1);
		td.className="musicLstBodyCss_1";
		td.innerHTML=vp[8];
		
		td=tr.insertCell(-1);
		td.className="musicLstBodyCss_1";
		td.innerHTML=vp[6];

		td=tr.insertCell(-1);
		td.className="musicLstBodyCss_1";
		if(isBunch=="1"){
			td.innerHTML=(vp[9]=="0"?"全部可见":"群内可见");
		}else{
			td.innerHTML=(vp[9]=="0"?"全部可见":vp[9]=="1"?"好友可见":"自己可见");
		}		
		td=tr.insertCell(-1);
		td.className="musicLstBodyCss_1";
		td.innerHTML="<a href='./musicContent.aspx?menuid="+vp[4]+"&tab="+this.tab+"&tabid="+vp[0]+"'><div class='musicItemEditotCss' style='background-image:url(./img/st.gif);' title='试听'>&nbsp;</div></a>";
		
		if(!isBool){
			td.setAttribute("colSpan",3);
		}else{
			td=tr.insertCell(-1);
			td.className="musicLstBodyCss_1";		
			var cA=document.createElement("a");
			cA.href="./updataArticles.aspx?menuindex=2&pType=modi&menuid="+vp[4]+"&asTab="+this.tab+"&useType="+this.useType+"&typeId=3&id="+vp[0];
			td.appendChild(cA);
			var cDiv=document.createElement("div");
			cDiv.className="musicItemEditotCss";
			cDiv.setAttribute("title","编辑");
			cDiv.style.backgroundImage="url('./img/editor.gif')";
			cA.appendChild(cDiv);
			
			td=tr.insertCell(-1);
			td.className="musicLstBodyCss_1";
			var cDiv=document.createElement("div");
			cDiv.className="musicItemEditotCss";
			cDiv.setAttribute("title","删除");
			cDiv.setAttribute("id",vp[0])
			cDiv.onclick=function(){
				if(confirm("数据删除后将无法恢复,确认要执行该操作吗?")){					
						var out=delUserBolgContent(this.id,tab,baseClass.user,baseClass.useType);
						if(out=="ok"){
							alert("删除成功");
							baseClass.page=1;
							baseClass.loadMenuPhoto();
						}else{
							alert(out);	
						}
				}	
			}
			cDiv.style.backgroundImage="url('./img/del.gif')";
			td.appendChild(cDiv);
		}
	}	
}

//生成相册信息
baseObject.prototype.loadPhoto=function(out){
	if(isBunch=="0"){
		this.tab=menuTabPhoto;
	}else{
		this.tab=menuTabBunPhoto;	
	}	
	var isBool=false;		
	if(parseInt(homeUserID)==parseInt(userID)||parseInt(cUserID)==parseInt(userID)){
			isBool=true;	
	}
	this.menuPhotoDiv.innerHTML="";
	// 0     1         2     3       4          5       6         7       8            9
	//ID,Count_Click,title,SourceUrl,menuid,TabImage,SaveUser,SaveUserID,SaveDate,competenceID
	out=out.split(c2);
	for(var i=0;i<out.length;i++){
		var vp=out[i].split(c1);
		var cDiv=document.createElement("div");
		if(isBool){
			cDiv.style.cssText="float:left;margin-left:7px;position:relative;overflow:hidden;width:168px;height:220px;border:solid 2px #e0e0e0;margin-top:6px;"
		}else{
			cDiv.style.cssText="float:left;margin-left:7px;position:relative;overflow:hidden;width:168px;height:205px;border:solid 2px #e0e0e0;margin-top:6px;"	
		}
		cDiv.onmouseover=function(){this.style.border="solid 2px #cccccc";}
		cDiv.onmouseout=function(){this.style.border="solid 2px #efefef";}
		this.menuPhotoDiv.appendChild(cDiv);
		
		var cDivImg=document.createElement("div");
		cDivImg.className="photoalignCss";
		cDiv.appendChild(cDivImg);
		
		var cA=document.createElement("a");
		cA.href="./photoContent.aspx?menuid="+vp[4]+"&tab="+this.tab+"&tabid="+vp[0];
		cDivImg.appendChild(cA);
		
		var cCaDiv=document.createElement("div");
		cCaDiv.style.cssText="height:88px;width:136px;overflow:hidden;";
		var scr=vp[5];
		if(scr==""||scr==null){
			scr="./img/no_photo.gif";	
		}
		cCaDiv.innerHTML="<img  onload='setImgWH(this)'  src='"+scr+"'/>";
		cA.appendChild(cCaDiv);	
		
		var cBodyDiv=document.createElement("div");
		cDiv.appendChild(cBodyDiv);
		var cDivTitle=document.createElement("div");
		cDivTitle.className="photoTitleCss";
		cDivTitle.style.cssText="text-align:left;padding-left:10px;";
		cDivTitle.innerHTML="<a href='"+cA.href+"'>"+(vp[2].length>11?vp[2].substring(0,10)+"...":vp[2])+"</a>";
		cBodyDiv.appendChild(cDivTitle);
		
		var cDivUser=document.createElement("div");
		cDivUser.className="photoUserCss";
		cDivUser.style.cssText="text-align:left;padding-left:10px;";
		cDivUser.innerHTML="用户:"+vp[6]
		cBodyDiv.appendChild(cDivUser);	
		
		var cDivUser=document.createElement("div");
		cDivUser.className="photoUserCss";
		cDivUser.style.cssText="text-align:left;padding-left:10px;";
		if(isBunch=="1"){
			cDivUser.innerHTML="状态："+(vp[9]=="0"?"全部可见":"群内可见");
		}else{
			cDivUser.innerHTML="状态:"+(vp[9]=="0"?"全部可见":vp[9]=="1"?"好友可见":"自己可见");
		}
		cBodyDiv.appendChild(cDivUser);	
		
		
		if(isBool){
			cDivUser=document.createElement("div");
			cDivUser.className="photoUserCss";
			cDivUser.style.cssText="text-align:left;padding-left:7px;width:160px;position:relative;";
			cBodyDiv.appendChild(cDivUser);	
			
			var cDiv=document.createElement("div");
			cDiv.className="musicItemEditotCss";
			cDiv.setAttribute("title","删除");
			cDiv.setAttribute("id",vp[0]);
    		cDiv.style.cssText="background-image:url('./img/del.gif');width:40px;padding-bottom:2px;float:left;height:22px;background-repeat:no-repeat;background-position:top right;";
			cDiv.innerHTML="删除";
			cDiv.onclick=function(){
				if(confirm("数据删除后将无法恢复,确认要执行该操作吗?")){					
						var out=delUserBolgContent(this.id,tab,baseClass.user,baseClass.useType);
						if(out=="ok"){
							alert("删除成功");
							baseClass.page=1;
							baseClass.loadMenuPhoto();
						}else{
							alert(out);	
						}
				}	
			}
			cDiv.style.backgroundImage="url('./img/del.gif')";
			cDivUser.appendChild(cDiv);
			
			
			var cA=document.createElement("a");
			cA.href="./updataArticles.aspx?menuindex=2&pType=modi&menuid="+vp[4]+"&asTab="+this.tab+"&useType="+this.useType+"&typeId=3&id="+vp[0];			
			cA.innerHTML="编辑";
			var cDiv=document.createElement("div");
			cDiv.style.cssText="background-image:url('./img/editor.gif');padding-top:5px;width:40px;height:22px;float:left;text-align:left;background-repeat:no-repeat;background-position:center right;";
			cDiv.appendChild(cA);
			cDivUser.appendChild(cDiv);
			

			
		}
	}		
}

//加载专辑基本信息
baseObject.prototype.loadMenuBase=function(){
	var objResponse=new JHttpResponse();
	objResponse.write("typeMenuID",this.typeMenuID);		
	var out=objAjax.getText("post","./cs/indexServer.aspx?type=loadMenuBase&useType="+this.useType+"&user="+this.user,objResponse,null); 
	//    0        1       2       3      4        5    6   7    8
	//groupname,typeid,typename,userid,username,cdate,cip,photo,note
	this.baseDiv=$("baseDiv");
	if(out.indexOf(c1)>-1){
		this.baseDiv.innerHTML="";
		out=out.split(c1);
		var cDiv=document.createElement("div");
		cDiv.className="oushutdTdLeft";
		cDiv.style.cssText="float:left;margin:5px;";
		this.baseDiv.appendChild(cDiv);
		cDiv.innerHTML="<span><div style='height:131px; width:141px;overflow:hidden;'><img onload='setImgWH(this)' src='"+out[7]+"' /></div></span>";
		
		var cBodyDiv=document.createElement("div");
		cBodyDiv.style.cssText="float:left;width:505px;border:solid 1px #cccccc;height:194px;margin:5px;margin-left:0px;overflow:hidden;";
		this.baseDiv.appendChild(cBodyDiv);
		
		var cTab=document.createElement("table");
		cTab.setAttribute("border",0);
		cTab.setAttribute("cellSpacing",0);
		cTab.setAttribute("cellPadding",0);
		cTab.style.cssText="width:100%;margin:0px;padding:0px;"
		cBodyDiv.appendChild(cTab);
		
		var tr=cTab.insertRow(cTab.rows.length);
		var td=tr.insertCell(-1);
		td.className="tdLeftCss";
		td.innerHTML="专辑名称：";
		
		td=tr.insertCell(-1);
		td.className="tdRightCss";
		td.innerHTML=out[0];
		
		tr=cTab.insertRow(cTab.rows.length);
		td=tr.insertCell(-1);
		td.className="tdLeftCss";
		td.innerHTML="创&nbsp;&nbsp;建&nbsp;&nbsp;人：";
		
		td=tr.insertCell(-1);
		td.className="tdRightCss";
		td.innerHTML=out[4];
		
		tr=cTab.insertRow(cTab.rows.length);
		td=tr.insertCell(-1);
		td.className="tdLeftCss";
		td.innerHTML="专辑分类：";
		
		td=tr.insertCell(-1);
		td.className="tdRightCss";
		td.innerHTML=out[2];
		
		tr=cTab.insertRow(cTab.rows.length);
		td=tr.insertCell(-1);
		td.className="tdLeftCss";
		td.innerHTML="创建日期：";
		
		td=tr.insertCell(-1);
		td.className="tdRightCss";
		td.innerHTML=out[5];
		
		tr=cTab.insertRow(cTab.rows.length);
		td=tr.insertCell(-1);
		td.setAttribute("colSpan",2);
		td.className="tdLeftCss";
		td.style.cssText="background-image:url(./img/pn.gif);border-right:none;"
		td.innerHTML="专辑描述：";
		
		tr=cTab.insertRow(cTab.rows.length);
		td=tr.insertCell(-1);
		td.setAttribute("colSpan",2);
		td.style.cssText="height:65px;width:500px;";
		td.innerHTML="<div style='text-indent:2em;padding-top:10px;'>"+out[8]+"</div>";	
		this.typeid=out[1];
		if(this.typeid=="2"){
			if(isBunch=="1"){
				this.tab=menuTabBunPhoto;	
			}else{
				this.tab=menuTabPhoto;	
			}
		}else{
			if(isBunch=="1"){
				this.tab=menuTabBunMusic;	
			}else{
				this.tab=menuTabMusic;	
			}
		}
		setTimeout("baseClass.loadMenuPhoto()",500);
	}else{
		this.baseDiv=out;
	}	
}