﻿// JScript 文件
var AddLink = 
{
    group_id:0,
    createDiv:function( groupid )
	 {
	    this.group_id = groupid;
		Body = document.getElementsByTagName("body").item(0);
		var Overlay = document.createElement("div");
		Overlay.setAttribute("id","AddLinkOverLayer");
		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","AddLink");
		main.className = "floatwindow";
		var pa = getPageSize();
		var psl = getPageScroll();
		main.style.top = (psl[1]+pa[3]/2 - 138) + "px";
		main.style.left =  (pa[0]/2 - 150) + "px";
		main.style.width = "300px";
		main.style.bottom = "100px";
		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:AddLink.closeDiv();\" />"+
                                "</h4>"+
                                "<div class=\"floatcontent\" onmousemove=\"javascript:event.cancelBubble = true;\" style=\"cursor:default;\">" +
                                    "<p>" +
                                        "<b>链接标题</b>" +
                                        "<span class=\"font_gray\">(显示链接文字标题，如：YOHO.cn)</span>" +
                                        "<br/>" +
                                            "<label>" +
                                                "<input title = \"请添加链接标题\" id = \"linkName\"class=\"biginput\" style=\"width: 270px\" name=\"textfield\" onmousemove=\"javascript:event.cancelBubble = true;\" />" + 
                                            "</label>" +
                                        "<br/>"+
                                        "<br/>" +
                                        "<b>链接地址</b>" +
                                         "<span class=\"font_gray\">(添加链接的URL地址)</span>"+
                                         "<br>"+
                                         "<label>" +
                                            "<input title = \"请添加链接的URL地址\" id=\"linkUrl\" class=\"biginput\" style=\"width: 270px\" value = \"http://\" name=\"textfield\" onmousemove=\"javascript:event.cancelBubble = true;\" />"+
                                         "</label>"+
                                    "</p>"+
                                    "<br/>"+
                                    "<p style=\"margin: 8px 0px 0px\">"+
                                        "<button onclick = \"javascript:AddLink.addLink();\">确定添加</button>"+
                                        "<button onclick = \"javascript:AddLink.closeDiv();\">取消</button>"+
                                    "</p>" +
                                "</div>"+
                            "</div>"+
                        "</div>";
	},
	closeDiv:function()
	{
		try{$("AddLink").parentNode.removeChild($("AddLink"));}catch(e){}
		try{$("AddLinkOverLayer").parentNode.removeChild($("AddLinkOverLayer"));}catch(e){}
	},
	addLink:function()
	{
	    var msginfo = "";
	    if( $( "linkName" ).value.replace(/^\s*/,'').replace(/\s*$/,'').length == 0 )
	    {
	        msginfo += "链接标题不能为空！";
	    }
	
	    if( $( "linkUrl" ).value.replace(/^\s*/,'').replace(/\s*$/,'').length == 0 )
	    {
	        msginfo += "链接地址不能为空!";    
	    }
		
	    if( msginfo != "" )
	    {
	        var msg = new Msgbox({title:"提示",msg:msginfo});
	        return;
	    }
	    
	    var url = "/group/ajax/group.aspx";
		
	    var param = "m=4&group_id=" + this.group_id +
	                   "&linkname=" + escape($( "linkName" ).value.replace(/^\s*/,'').replace(/\s*$/,'')) +
	                   "&linkinfo=" + escape($( "linkUrl" ).value.replace(/^\s*/,'').replace(/\s*$/,''));

	    var ajax = new Ajax.Request(
										url,
										{
	                                    	method:"post",
	                                    	parameters:param,
	                                    	onComplete:finish
	                               		}
								   );
	    
	}
}
