// JavaScript Document
$(document).ready(function(){
	//監聽單個加好友Id
    if($("#addFriend")  != null) {
		var friendId = $("#friendId").val();
        $("#addFriend").bind("click", {linkId:'addFriend',friend_id:friendId}, friend.showAddFriendDiv);
    }
    //監聽單個打招呼Id
	if($("#addCall")  != null) {
		var friendId = $("#friendId").val();
        $("#addCall").bind("click", {friend_id:friendId}, friend.addCallForm);
    }
	//循環監聽加好友或打招呼按鈕
	
	if($(".Action")  != null) {
		var friendArrCount = $(".Action").length;
		friend.endTo = $("#endTo").val();
		for ( var i = 0; i < friendArrCount; i++ ) {
			var friendId = $("#friendId"+i).val();
			if ( friendId ) {
				if($("#addCall"+i)  != null) {
					if ( $_("noticeId"+i) ) { //在通知頁面里的用其他動作回應對方的(傳個noticeId是爲了更改通知的互動狀態)
						var noticeId = $("#noticeId"+i).val();
						var contentId = 0;
						if ( $_("contentId"+i) ) {
							contentId = $("#contentId"+i).val();
						}
						$("#addCall"+i).bind("click", {friend_id:friendId,noticeId:noticeId,contentId:contentId}, friend.addCallForm);
					} else {
						$("#addCall"+i).bind("click", {friend_id:friendId,noticeId:'',contentId:0}, friend.addCallForm);
					}
				}
				if($("#addFriend"+i)  != null) {
					$("#addFriend"+i).bind("click", {linkId:'addFriend'+i,friend_id:friendId,key:i}, friend.showAddFriendDiv);
				}
			}
		}
	}
});

var friend = ({
	endTo:'',
	//取好友頭像,名字
	getFriendAvatarName:function(friendId) {
		$.getJSON("http://friends."+ getUrl() +"/ajax.php?module=index&action=getFriendAvatarName&friendId=" + friendId +"&callBack=?",
				  function(data){
                    if (data != null) {
						if ( $_("friendAvatar") ) {
								$("#friendAvatar").attr("style",'');
								$("#friendAvatar").attr("src",data.min_avatar);
							}
							 if ( $_("friendMidAvatar") ) {
								$("#friendMidAvatar").attr("src",data.mid_avatar);
							}
							if ( $_("friendName") ) {
								$_("friendName").innerHTML = data.name;
							}
							if ( $_("friendSex") ) {
								$_("friendSex").innerHTML = data.ta;
							}
					}
				  })
	},
	delBlack:function(linkId,friendId){
		if (isNaN(friendId)) return false;
		msgBox.loadingShow();
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		$.getJSON("ajax.php?module=index&action=delFriendBlack&friendId=" + friendId,
				function(data){
					if( data[0]==1){
						friend.getFriendAvatarName(friendId);					
						Html = '<div style="padding:10px; width:350px;"><p style="font-size:15px;text-align:left;border-bottom: solid 1px #dddddd;margin:15px;padding:3px;"><strong>發送好友邀請</strong></p>';
						Html += '<div style="overflow:hidden;"><div style="width:80px;float:left;text-align:center;"><img id="friendAvatar" src="' + loadImage + '" style="margin-top:30px" /></div>';
						Html += '<div style="margin-left:80px;text-align:left;line-height:25px;width:250px;;">';
						Html += '<p style="margin:0px;">向<span id=\'friendName\' style=\'color:red;\'></span>發送好友邀請，她登入後會收到提示，經對方確認後，你們就可以成為好友了。<br />附加消息：(選填)</p>';
						Html += '<p style="margin:5px 0;"><textarea id="additional_info"  cols="40" rows="4" style="border:1px solid #cccccc;"></textarea></p>';
						Html += '<p style=\'line-height:20px;margin:5px 0;\'><input type="button" id="sendAddRequest" class="CptButtom" style="width:50px;height:25px;margin-right:10px;padding:0px;" value="確定" onclick="friend.addFriendForm(\''+linkId + '\',' + friendId+');">';
						Html += '<input class="CptButtomGray" type="button" style="width:50px;height:25px;padding:0px;" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();"></p></div></div></div>';
						msgBox.showHtml(Html);
						return false;
					}else{
						msgBox.showText("黑名單成功失敗！");
						return false;						
					}
				})
	},
	// 顯示添加好友對話框
	showAddFriendDiv:function(event) {var date = new Date();
		var friend_id = event.data.friend_id;
		var linkId = event.data.linkId;		
		var key = event.data.key;
		msgBox.loadingShow();
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		$.getJSON("http://i."+ getUrl() +"/ajax.php?module=index&action=getFriendIsBlack&friendId=" + friend_id +"&callBack=?",
				function(data){
					friend.getFriendAvatarName(friend_id);
					if(data[0]==9999){
						Html = '<div style="padding:10px;"><p style="font-size:15px;text-align:left;border-bottom: solid 1px #dddddd;margin:15px;padding:3px;"><strong>解除黑名單</strong></p>';
						Html += '<div style="overflow:hidden;"><div style="width:80px;float:left;text-align:center;"><img id="friendAvatar" src="' + loadImage + '" style="margin-top:30px" /></div>';
						Html += '<div style="margin-left:80px;text-align:left;line-height:25px;">';
						Html += '你已把<span id=\'friendName\' style=\'color:red;\'></span>加入了黑名單，要加其為好友，請先解除黑名單。';						
						Html += '<p style=\'line-height:20px;margin:5px 0;\'><input type="button" id="sendAddRequest" class="CptButtom" style="width:100px;height:25px;margin-right:10px;padding:0px;" value="解除黑名單" onclick="friend.delBlack(\''+linkId + '\',' + friend_id+');" />';
						Html += '<input class="CptButtomGray" type="button" style="width:50px;height:25px;padding:0px;" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();" /></p></div></div></div>';
						msgBox.showHtml(Html);
					}else{
						Html = '<div style="padding:10px; width:350px;"><p style="font-size:15px;text-align:left;border-bottom: solid 1px #dddddd;margin:15px;padding:3px;"><strong>發送好友邀請</strong></p>';
						Html += '<div style="overflow:hidden;"><div style="width:80px;float:left;text-align:center;"><img id="friendAvatar" src="' + loadImage + '" style="margin-top:30px" /></div>';
						Html += '<div style="margin-left:80px;text-align:left;line-height:25px;width:250px;;">';
						Html += '<p style="margin:0px;">向<span id=\'friendName\' style=\'color:red;\'></span>發送好友邀請，<span id="friendSex"></span>登入後會收到提示，經對方確認後，你們就可以成為好友了。<br />附加消息：(選填)</p>';
						Html += '<p style="margin:5px 0;"><textarea id="additional_info"  cols="40" rows="4" style="border:1px solid #cccccc;"></textarea></p>';
						Html += '<p style=\'line-height:20px;margin:5px 0;\'><input type="button" id="sendAddRequest" class="CptButtom" style="width:50px;height:25px;margin-right:10px;padding:0px;" value="確定" onclick="friend.addFriendForm(\''+linkId + '\',' + friend_id+','+ key +');">';
						Html += '<input class="CptButtomGray" type="button" style="width:50px;height:25px;padding:0px;" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();"></p></div></div></div>';
						msgBox.showHtml(Html);
					}					
				  })
	},
	//顯示解除好友關係的確認窗口
	showDelFriend:function(obj) {
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		var Html = '<div style="padding:10px;"><p style="font-size:18px;text-align:left;border-bottom: solid 1px #dddddd;"><strong>解除好友關係</strong></p>';
		Html += '<div style="overflow:hidden;"><div style="width:80px;float:left;text-align:center;"><img id="friendAvatar" src="' + loadImage + '" style="margin-top:30px" /></div>';
		Html += '<div style="margin-left:80px;text-align:left;line-height:25px;width:250px;">你確認要和<span id="friendName"></span>解除好友關係嗎？解除後你也將不再出現在對方的好友列表中，但系統不會發消息給對方';
		Html += '<p style=\'line-height:20px;margin:5px 0;padding-left:120px;\'><input type="button" id="sendAddRequest" class="CptButtom" style="width:50px;height:25px;padding:0px;" value="確定" onclick="' + obj + '">';
		Html += '&nbsp;&nbsp;<input class="CptButtomGray" type="button" style="width:50px;height:25px;padding:0px;" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();"></p></div></div></div>';
		msgBox.showHtml(Html);
	},
	//顯示忽略好友請求的確認窗口
	showIgnoreRequest:function() {
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		var Html = '<div style="padding:10px;"><p style="font-size:18px;text-align:left;border-bottom: solid 1px #dddddd;"><strong>解除好友關係</strong></p>';
		Html += '<div style="overflow:hidden;"><div style="width:80px;float:left;text-align:center;"><img id="friendAvatar" src="' + loadImage + '" style="margin-top:30px" /></div>';
		Html += '<div style="margin-left:80px;text-align:left;line-height:25px;width:250px;">你確認要忽略<span id="friendName"></span>的好友請求嗎？如果忽略了下次就不顯示了！';
		Html += '<p style=\'line-height:20px;margin:5px 0;padding-left:130px;\'><input type="button" id="sendAddRequest" class="CptButtom" style="width:50px;height:25px;padding:0px;" value="確定" onclick="' + obj + '">';
		Html += '&nbsp;&nbsp;<input class="CptButtomGray" type="button" style="width:50px;height:25px;padding:0px;" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();"></p></div></div></div>';
		msgBox.showHtml(Html);
	},
	// 顯示打招呼對話框
	showAddCallDiv99:function(event) {
		var friend_id = event.data.friend_id;
		friend.getFriendAvatarName(friend_id);
		var Html = '<div style="padding:10px;"><p style="font-size:18px;text-align:left;border-bottom: solid 1px #dddddd;"><strong>向好友打招呼</strong></p>';
		Html += '<div style="overflow:hidden;"><div style="width:90px;float:left;text-align:center;"><img src="http://statics.1796.com.tw/img/public/loading.gif" id="friendAvatar"  style="margin-top:30px"  /></div>';
		Html += '<div style="margin-left:100px;text-align:left;line-height:25px;">&nbsp<br /><br />';
		Html += '<p line-height:20px;><input type="button" id="sendAddRequest" class="CptButtom" value="確定" onclick="friend.addCallForm('+friend_id+');">&nbsp;&nbsp;';
		Html += '<input class="CptButtomGray" type="button" id="cancelRequest" value="取消" onclick="msgBox.removeMsgBox();"></p></div></div></div>';
		msgBox.showHtml(Html);
	},
	// 顯示打招呼對話框
	showAddCallDiv:function(friendId) {
		friend.getFriendAvatarName(friendId);
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		var Html = '<div style="padding:10px;"><p style="font-size:15px;text-align:left;border-bottom: solid 1px #dddddd;padding-bottom:5px;margin-bottom:15px;"><strong>打招呼</strong></p>';
		Html += '<div style="overflow:hidden;width:300px;"><div style="width:90px;float:left;text-align:center;"><img src="' + loadImage + '" id="friendMidAvatar"  /></div>';
		Html += '<div style="float:left;width:200px;margin-left:10px;text-align:left">向<span id="friendName" style="color:red"></span>打招呼成功，對方登入後會收到通知</div>'
		Html += '</div></div>';
		msgBox.showHtml(Html);
		window.setTimeout("msgBox.removeMsgBox();",3000);
	},
	// 顯示已經打過招呼對話框
	showAddedCallDiv:function(friendId) {
		friend.getFriendAvatarName(friendId);
		var loadImage = 'http://statics.' + getUrl() + '/img/public/loading.gif';
		var Html = '<div style="padding:10px;"><p style="font-size:15px;text-align:left;border-bottom: solid 1px #dddddd;padding-bottom:5px;margin-bottom:15px;"><strong>打招呼</strong></p>';
		Html += '<div style="overflow:hidden;width:300px;"><div style="width:90px;float:left;text-align:center;"><img src="' + loadImage + '" id="friendMidAvatar"  /></div>';
		Html += '<div style="float:left;width:200px;margin-left:10px;text-align:left">你已經向<span id="friendName" style="color:red"></span>打過招呼了，對方登入後會收到通知</div>'
		Html += '</div></div>';
		msgBox.showHtml(Html);
		window.setTimeout("msgBox.removeMsgBox();",3000);
	},
	//向好友發送加好友請求
	addFriendForm:function(linkId,friendId,key) {
		var additionalInfo = $("#additional_info").val();
		$.getJSON("http://friends."+ getUrl() +"/ajax.php?module=index&action=addFriend&friendId=" + friendId + "&additionalInfo=" + additionalInfo +"&callBack=?",
		 function(data){
			if ( !ChkLoginStatus.chkLoginIn(data) ) {
				return;
			}
				switch (parseInt(data)) {
						  case 1:
							msgBox.showText('發送好友請求成功,對方登入後會收到通知');
							if ( $("#LastKey").val() > 0 ) {
								var objIdVal = $("#showObjIdVal").val();
								showNextPush(objIdVal, key);
							}
							if (friend.endTo != '') {
								window.setTimeout(friend.endTo+"("+key+")",300);
							} else {
								if ($("#" + linkId).length > 0) {
									if ($("#" + linkId).parent().length > 0) {
										$("#" + linkId).parent().html("<span class='Gray'>已發送請求</span>");
									} else {
										$("#" + linkId).html("已發送邀請");
									}
								}
							}
							if ($(".pushRequestAdd").length > 0) {
								var date = new Date();
								var dTime = date.getFullYear() + '年';
								var month = date.getMonth() + 1;
								dTime += month < 10 ? '0' + month + '月' : month + '月';
								dTime += date.getDate() < 10 ? '0' + date.getDate() + '日 ' : date.getDate() + '日 ';
								dTime += date.getHours() + ':' + date.getMinutes();
								var accessTxt = '<span class="ML15 FLeft S13px">你的好友請求已經發送給' + $("#MemberNameTxt" + friendId).html() + '，請等待對方通過。</span>';
								accessTxt += '<span class="FRight MR15 Gray">' + dTime + '</span><div style="height:0px;" class="Clear"></div>';
								//$("#pushFIdVal" + friendId).css("_padding", "8px 0");
								$("#pushFIdVal" + friendId).html(accessTxt);
								var countFriend = parseInt($("#countFriendLeft").text()) - 1;
								$("#countFriendLeft").text(countFriend);
							}
							break;
						case 0:
							msgBox.showText('對方已是你好友或已經發送了好友請求');
							break;
						case 9998:
							msgBox.showText('你已經加他到黑名單了，要加好友請先解除黑名單');
							break;
						case 9999:
							msgBox.showText('由於對方的隱私設定，你不能加其為好友');
							break;
						case 1000:
							msgBox.showText('你的好友已經滿2000位，無法再增加好友了');
							break;
						case 1001:
							msgBox.showText('該會員的好友已滿2000位，無法再加好友');
							break;
				}
			}
		);
	},
	//向好友打招呼
	addCallForm:function(event) {
		msgBox.loadingShow();
		var noticeId = event.data.noticeId;
		var contentId = event.data.contentId;
		
		var friendId = event.data.friend_id;
		// 獲取系統招呼類型
		
		var url = "http://i." + getUrl() + "/ajax.php?module=index&action=getCallInfoSystem&callback=?";
		$.getJSON(url,
			function(data) {
				// 檢測是否登陸
				if ( !ChkLoginStatus.chkLoginIn(data) ) {
					return false;
				}msgBox.removeMsgBox();
				friend.showCallDiv(noticeId,contentId,friendId);
				if (data != null ) {
					 $.each(data, function(i,item){
							html = '<li style="float:left;width:100px;"><label for="radio' + item['id'] + '"><input name="radioCall" type="radio" id="radio' + item['id'] + '" value="' + item['id'] + '" onclick="friend.setCallType(\'system\');" /><img src="http://statics.' + getUrl() + '/img/compents/hello/' + item['call_icon'] + '" />' + item['call_title'] + '</label></li>';
							$("#callInfoSystem").append(html);
					})
				}
			});
		
		 // 獲取自定義招呼
		 var url = "http://i." + getUrl() + "/ajax.php?module=index&action=getCallInfoSelf&callback=?";
		 $.getJSON(url,
				  function(data){
                    if (data != null) {
						var j = 0;
						 $.each(data, function(i,item){
							html = '<div style="margin-bottom:5px;" id="callSelfLine' + item['id'] + '"><label for="radioSelf' + item['id'] + '"><input name="radioCall" type="radio" id="radioSelf' + item['id'] + '" value="' + item['id'] + '" onclick="friend.setCallType(\'self\');"/><img src="http://statics.' + getUrl() + '/img/compents/hello/' + item['call_info_icon'] + '" />' + item['call_info_content'] + ' </label>&nbsp; &nbsp; &nbsp; &nbsp;<a class="BlueLink" onclick="friend.delCallSelf(\'' + item['id'] + '\');" href="#s">移除</a></div>';
							$("#callInfoSelf").after(html);
							j++;
						 })
						 if ( parseInt(j) >= 5 ) {
							 $("#newCallSelf").css("display","none");
						 }
					}
				  })
		 
		 // 獲取好友頭像，好友給自己打招呼內容
		var url = "http://i." + getUrl() + "/ajax.php?module=index&action=getAvatarCall&friendId=" + friendId + "&callback=?";
		$.getJSON(url,
				  function(data){
                    if (data != null) {
						 $.each(data, function(i,item){
							$("#friendNameCall").text(item['friendName']);
							$("#minAvatarCall").attr('src',item['midAvatar']);
                            /*var content = item['content'] != null ? item['content'] : '';
							var callContent = '';
							var icon = item['icon'];
							
							if ( icon != null ) {
								callContent = content + "<img src='http://statics." + getUrl() + "/img/compents/hello/" + icon + "'>";
							} else {
								callContent = content;
							}
							$("#friendCallContent").html(callContent);*/
						 })
					}
				  });
	},
	/**
	*
	* 設置招呼類型
	**/
	setCallType:function(type)
	{
		$("#callType").val(type);
	},
	/**
	*
	* 提交打招呼
	* @param Int noticeId 通知的ID（只在通知頁面里的回應對方的招呼用到，是為了更改動作的互動狀態）
	* @param int contentId 通知內容ID（在這裡的作用是區別收到招呼通知的那個“用自定義動作回覆” A動作 和好友同意你加入1796的通知的那個“打招呼” B動作,為0就是B動作，否則就是A動作）
	**/
	addCall:function(noticeId,contentId)
	{
		var val = friend.getCallAction();
		var callTitle = '';
		var callContent = '';
		var callType = $("#callType").val();
		
		if ( val == '' ) {
			msgBox.showText("請先選擇打招呼的動作");
			return false;
		}
	
		if ( val == 'new' ) {
			if ( $("#callTitle").val() == '' &&  $("#callContent").val() == '' ) {
				msgBox.showText("請先輸入自己設定的動作內容或選擇其他的再提交");
				return false;
			}
			//callTitle = $("#callTitle").val();
			callContent = $("#callContent").val();
		}
		
		var friendId = $("#friendId").val();
		if ( friendId == '' ) {
			msgBox.showText("操作錯誤");
			return false;
		}
		
		msgBox.loadingShow();
		
		if ( noticeId != '' && contentId != '0' ) { //從通知頁面過來的且是A動作
		} else {
			noticeId = '';
		}
		
		var url = "http://compents." + getUrl() + "/ajax.php?module=index&action=addCall&callType=" + callType + "&friendsId=" + friendId + "&callInfoId=" + val + "&callTitle=" + encodeURIComponent(callTitle) + "&noticeId=" + noticeId + "&callContent=" + encodeURIComponent(callContent) + "&callback=?";
		
		$.getJSON(url,
			function(data) {
				if ( !ChkLoginStatus.chkLoginIn(data) ) {
					return false;
				}
				if (data != null ) {
					if(data[0]==9999){
						msgBox.showText('對方已設置了隱私權限，你無法對其打招呼');
						return false;
					}
					if (data[0] == '-1') {
						msgBox.showText('請不要頻繁操作');
						return false;
					} else {
						if ( noticeId != '' && contentId != '0' ) { //從通知頁面過來的且是A動作
							friend.removeCallBox();
							
							//移除互動操作
							$("#response" + noticeId).remove();
							
							//顯示已操作的小框框提示
							var html = '<div class="message">你已經用其它的動作回覆他</div>';
							$("#listOne" + noticeId).append(html);
							msgBox.removeMsgBox();
						} else {
							msgBox.showText('打招呼成功');
							friend.removeCallBox();
							msgBox.removeMsgBox();
						}
					}
				}
			});
	},
	/**
	*
	* 刪除自定義招呼
	* @param Int callSelfId
	**/
	delCallSelf:function(callSelfId)
	{
		msgBox.showTrueOrFalse2("刪除自定義動作","你確認要刪除自定義動作嗎","friend.submitDelCallSelf('" + callSelfId + "')");
	},
	submitDelCallSelf:function(callSelfId)
	{
		/*$.ajax({
				type: "POST",
				url: "./ajax.php",
				dataType: 'html',
				data: "module=index&action=delCallSelf&callSelfId=" + callSelfId,
				timeOut: 300,
				success: function(html){
					if (html.indexOf("-1") != -1) {
						msgBox.showText('操作錯誤');
						return false;
					} 
					msgBox.showText('刪除自定義動作成功');
				   $("#callSelfLine" + callSelfId).remove();
				   $("#newCallSelf").css("display","block");
				}
			  });*/
		
		$.getJSON("http://compents." + getUrl() + "/ajax.php?module=index&action=delCallSelf&callSelfId=" + callSelfId + "&callback=?",
			function(data) {
				if (data != null ) {
					if (data[0] == '-1') {
						msgBox.showText('操作錯誤');
						return false;
					} 
					msgBox.showText('刪除自定義動作成功');
				    $("#callSelfLine" + callSelfId).remove();
				    $("#newCallSelf").css("display","block");
				}
			});
		
	},
	/**
	* 
	* 獲取招呼動作
	**/
	getCallAction:function()
	{
		var len = document.getElementsByName("radioCall").length;
		for ( var i = 0; i < len; i++ ) {
			if ( document.getElementsByName("radioCall")[i].checked == true ) {
				return document.getElementsByName("radioCall")[i].value;
			}
		}
		return '';
	},
	/**
	*
	* 顯示打招呼的層
	* @param Int noticeId 通知的ID（只在通知頁面里的回應對方的招呼用到，是為了更改動作的互動狀態）
	* @param int contentId 通知內容ID（在這裡的作用是區別收到招呼通知的那個“用自定義動作回覆” A動作 和好友同意你加入1796的通知的那個“打招呼” B動作,為0就是B動作，否則就是A動作）
	**/
	showCallDiv:function(noticeId,contentId,friendId)
	{
		var html = '<div style="width:500px;padding:0 10px 10px 10px;border:1px solid #FF6600;background:#ffffff;position:absolute;text-align:left;" id="callBoxMain">';
		html += '<div style="padding:10px 0 10px 0;border-bottom:1px solid #cccccc;width:100%;" class="FLeft"><span class="FLeft" style="font-size:15px;"><strong>跟<span id="friendNameCall"></span>打招呼</strong></span><span class="FRight"><a href="javascript:void(0)" class="Close" onclick="friend.removeCallBox();"></a></span></div>';
		html += '<div style="padding-top:10px;float:left">';
		html += '<div style="float:left;margin-right:10px;width:90px;"><img id="minAvatarCall" src="http://statics.' + getUrl() + '/img/public/loading.gif"></div>';
		html += '<div style="float:left;width:400px;margin-bottom:20px;">';
		html += '<div style="margin-bottom:10px;" id="friendCallContent"></div>';
		html += '<div style="margin-bottom:10px;padding-bottom:5px;width:100%;border-bottom:1px solid #cccccc;"><strong>選動作</strong></div>';
		html += '<div style="margin-bottom:10px;float:left"><ul id="callInfoSystem"></ul></div>';
		html += '<div style="clear:both;margin-bottom:10px;font-size:13px;width:400px;padding-bottom:5px;border-bottom:1px solid #cccccc;" id="callInfoSelf"><strong>或選擇自己設定的動作</strong></div>';
		html += '<div id="newCallSelf" style="margin-bottom:5px;"><input name="radioCall" type="radio" value="new" /><img src="http://statics.' + getUrl() + '/img/compents/hello/hi.gif" /><input name="" class="CptTextGray" id="callContent" type="text" /></div>';
		html += '<div style="margin-top:10px;"><input type="button" class="CptButtom" onclick="friend.addCall(\'' + noticeId + '\',\'' + contentId + '\');" value="確定">&nbsp;&nbsp;<input type="button" class="CptButtomGray" onclick="friend.removeCallBox();" value="取消"><input id="callType" type="hidden" value=""><input id="friendId" type="hidden" value="' + friendId + '"></div>';
		html += '</div></div></div>';
		
		$("body").append(html);
		friend.setWidthAndHeight();
	},
	 //設定窗口位置
    setWidthAndHeight:function() {
        var mainWidth = $("#callBoxMain").width();
        var mainHeight = $("#callBoxMain").height();
        var bodyTop = msgBox.getBodyTop();
        var bodyClientWidth = document.body.clientWidth/2 - mainWidth/2;
        var bodyClientHeight = document.documentElement.clientHeight/2 + bodyTop - mainHeight/2 - 60;
        $("#callBoxMain").css("left", bodyClientWidth);
        $("#callBoxMain").css("top", bodyClientHeight);
    },
	//刪除信息窗口
    removeCallBox:function(){
        if($("#callBoxMain").length > 0) {
            $("#callBoxMain").fadeTo("slow",0.12,function(){
                $("#callBoxMain").remove();
            });
        }
    }

});