//yuzhibing

function applyClubContent(clubId){
	//背景
	var bgObj = document.getElementById("bgDivs");
	bgObj.style.width = document.body.offsetWidth + "px";
	bgObj.style.height = document.body.offsetHeight+ "px";
	//定义窗口
	var msgObj = document.getElementById("msgDivs");
	msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
		
	//关闭
	document.getElementById("msgShut").onclick = function () {
		bgObj.style.display = msgObj.style.display = "none";
	};
	msgObj.style.display = bgObj.style.display = "block";
	document.getElementById("msgSubmit").onclick = function () {
		applyClub(clubId);
	};
}

function joinClubContent(clubId){
	joinClub(clubId);
}
//直接加入率圈
function joinClub(clubId)
{
	var param = {"clubId":clubId};
		$.ajax({url:"/clubsaction/clubsaction!applyClub.do",data:param, type:"post", dataType:"json",success:function (data) {
				var  statu = data.status;
				if (statu == "success") {
					alert("加入成功");
					window.location = parent.window.location;//'/lvmama2/clubsaction/clubsaction!showClub.do'
					return true;
				} else if(statu == "apply") {
					alert("管理员正在审核中");
					//var bgObj = document.getElementById("bgDiv");
					//var msgObj = document.getElementById("msgDiv");
					//bgObj.style.display = msgObj.style.display = "none";
					return true;
				}else if(statu == "isLogin"){
					alert("你尚未登陆");
					return true;
				}else if(statu == "clubUser"){
					alert("你已加入该驴圈");
					return true;
				}else
				{
					alert("该驴圈拒绝任何人加入");
					return true;
				}
				return false;
			}});
}

function applyClub(clubId){
		var param = {"clubId":clubId,"content":document.getElementById("content").value};
		$.ajax({url:"/clubsaction/clubsaction!applyClub.do",data:param, type:"post", dataType:"json",success:function (data) {
				var  statu = data.status;
				if (statu == "success") {
					alert("加入成功");
					window.location = parent.window.location;//'/lvmama2/clubsaction/clubsaction!showClub.do'
					return true;
				} if(statu == "apply") {
					alert("管理员正在审核中");
					close();
					return true;
				}else if(statu == "isLogin"){
					alert("你尚未登陆");
					close();
					return true;
				}else if(statu == "clubUser"){
					alert("你已加入该驴圈");
					close();
					return true;
				}
				return false;
			}});
	}
	
		function close(){
					var bgObj = document.getElementById("bgDivs");
					var msgObj = document.getElementById("msgDivs");
					document.getElementById("content").innerHTML = "";
					bgObj.style.display = msgObj.style.display = "none";
	}