﻿// JScript 文件// JScript 文件
var AddNotice = 
{
    group_id:0,
    createDiv:function( groupid )
	 {
	    this.group_id = groupid;
		Body = document.getElementsByTagName("body").item(0);
		var Overlay = document.createElement("div");
		Overlay.setAttribute("id","AddNoticeOverLayer");
		Overlay.style.position = "absolute";
		Overlay.style.top = "0";
		Overlay.style.left = "0";
		Overlay.style.zIndex = "100";
		Overlay.style.width = "100%";
		Overlay.style.height = "500px";
		Overlay.style.backgroundColor = "#ffffff";
		if(Browser.isIE)
		{
			Overlay.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
		}
		else
		{
			Overlay.style.opacity = "0";
		}
		var p_s = getPageSize();
		Overlay.style.display = "none";
		Overlay.style.width = p_s[2] + "px";
		Overlay.style.height = p_s[1] + "px";
		Body.appendChild(Overlay);
		var main = document.createElement("div");
		main.setAttribute("id","Notice");
		main.className = "floatwindow";
	    var pa = getPageSize();
		var psl = getPageScroll();
		main.style.top = (psl[1]+pa[3]/2 - 100) + "px";
		main.style.left =  (pa[0]/2 - 150) + "px";
		main.style.width = "500px";
		main.style.bottom = "200px";
		main.style.zIndex = "101";
		Body.appendChild(main);
		Overlay.style.display = "";
        main.innerHTML = "<div class=\"shadow\" onmouseover=\"this.style.cursor='move';\" onmousedown=\"DargMessageDiv.init(event,this.parentNode);\">" + 
                            "<div class=\"inner_floatwindow\">" +
                                "<h4>" +
                                    "添加圈子公告"+
                                     "<img class=\"windowcontrol\" src=\"/images/button_del.gif\" border=\"0\" style=\"cursor:pointer;\"  onclick=\"javascript:AddNotice.closeDiv();\" />"+
                                "</h4>"+
                                "<div class=\"floatcontent\" onmousemove=\"javascript:event.cancelBubble = true;\" style=\"cursor:default;\">" +
                                    "<p>" +
                                        "<b>公告标题</b>" +
                                        "<span class=\"font_gray\">(公告标题，不超过22个中文字符)</span>"+
                                        "<br/>" +
                                        "<label>"+
                                            "<input id = \"Title\" class=\"biginput\" style=\"width: 460px\" name=\"textfield\" onmousemove=\"javascript:event.cancelBubble = true;\" />" + 
                                        "</label>"+
                                        "<br/><br/>" +
                                        "<b>公告内容</b>" + 
                                        "<span class=\"font_gray\">(添加公告的具体内容)</span>"+
                                        "<br>"+
                                        "<label>" + 
                                            "<textarea id = \"Info\" class=\"biginput\" style=\"width: 460px; height: 100px\" name=\"textarea\" onmousemove=\"javascript:event.cancelBubble = true;\"></textarea>" + 
                                        "</label>"+
                                    "</p>"+
                                    "<br/>" +
                                    "<p style=\"margin: 8px 0px 0px\">"+
                                        "<button onclick = \"javascript:AddNotice.addNotice();\">确定添加</button>"+
                                        "<button onclick = \"javascript:AddNotice.closeDiv();\">取消</button>"+
                                    "</p>"+
                                "</div>"+
                            "</div>"+
                         "</div>";
	},
	closeDiv:function()
	{
		try{$("Notice").parentNode.removeChild($("Notice"));}catch(e){}
		try{$("AddNoticeOverLayer").parentNode.removeChild($("AddNoticeOverLayer"));}catch(e){}
	},
	addNotice:function()
	{
	    var msginfo = "";
	    if( $( "Title" ).value.replace(/^\s*/,'').replace(/\s*$/,'').length == 0 )
	    {
	        msginfo += "公告标题不能为空！<br/>";
	    }
	    else
	    {
	        if( $( "Title" ).value.replace(/^\s*/,'').replace(/\s*$/,'').length >= 44 )
	            msginfo += "公告标题不超过22个中文字符<br/>";
	    }
	   
	    if( $( "Info" ).value.replace(/^\s*/,'').replace(/\s*$/,'').length == 0 )
	    {
	        msginfo += "公告的具体内容不能为空!</br>";    
	    }


	    if( msginfo != "" )
	    {
	        var msg = new Msgbox({title:"提示",msg:msginfo});
	        return;
	    }
	    
	    var url = "/group/ajax/group.aspx";
	    var param = "m=3&group_id=" + this.group_id + 
	                   "&title=" + escape($( "Title" ).value.replace(/^\s*/,'').replace(/\s*$/,'')) +
	                   "&info=" + escape($( "Info" ).value.replace(/^\s*/,'').replace(/\s*$/,''));
	    var ajax = new Ajax.Request(
										url,
										{
	                                    	method:"post",
	                                    	parameters:param,
	                                    	onComplete:finish
	                               		}
								   );
	}
}

