var isFans = false;

/* Footer contact developer*/
function contactDeveloper(appId){
    //alert('test');
	XN.DOM.disable();
    var d = XN.DO.confirm({
    	title:'联系开发者',
    	yes:'发送',
    	params:{addIframe:true},
		callBack : sendUserMsg
    }).setWidth(440);
	
	sendLoading('载入中 ...');
    new XN.net.xmlhttp({ 
        url:'http://apps.'+XN.env.domain+'/contactDeveloper.do',
        method:'get',
        data:'appId=' + appId,
        onComplete: showSendWindow,
        onError: function(transport){
                  alert("发生错误，请联系管理员。");
               }
    });
    
    function sendLoading(msg){
    	if(!msg) {
    		msg = 'Loading ...';
    	}
    	d.header.hide();
		d.footer.hide(); 
		d.body.setContent( msg );
		d.refresh();
    }
    
    function showSendWindow(transport){
    	
    	d.header.show();
    	d.footer.show();
    	//d.setTitle('发信给开发者');
    	d.body.setContent(transport.responseText);
    	//d.getButton('确定').setText('发送');
    	d.refresh();
    }
    
    function sendUserMsg(flag){
    	if(flag){ 
	 		if($('con_type').value==0){
	 			
	 			$('con_err').style.display='block';
	 			$('con_err').innerHTML="请选择一个问题类型";
	 			this.preventHide();
	 			$('con_type').focus();
	 			return false;
	 		}
	 		
	 		if(($('user_mail').value!="")&&(!test_email($('user_mail').value))){
	 		
	 			$('con_err').style.display='block';
	 			$('con_err').innerHTML="请输入正确的邮件地址";
	 			this.preventHide();
	 			$('user_mail').focus();
	 			return false;
	 		}

	 		if($('con_content').value==""){
	 			$('con_err').style.display='block';
	 			$('con_err').innerHTML="请输入反馈信息";
	 			this.preventHide();
	 			$('con_content').focus();
	 			return false;		
	 		}
	 		

		    //alert(XN.FORM.serialize($('contactForm')));      
		    new XN.net.xmlhttp({ 
		        url:'http://apps.'+XN.env.domain+'/contactDeveloper.do',
		        data:XN.FORM.serialize($('contactForm')),
		        method:'post',
		        onSuccess: showSuccDialog,
		        onError: function(transport){
		                  alert("发生错误，请联系管理员。");
		               }
		    });
		    d.preventHide();
		    sendLoading('发送中 ...');
		 } else {
			 d.hide();
			 XN.DOM.enable();
		 }
    }
    
    function showSuccDialog(transport){
		d.header.show();
    	d.footer.show();
    	d.setTitle('发送成功');
    	d.body.setContent('您的消息已经发送给此应用的开发人员。');
    	d.getButton('发送').hide();
    	d.getButton('取消').hide();//.setText("确定");
		d.addButton({text:'确定', onclick:function(){
			d.hide();
			XN.DOM.enable();
		}});
		d.refresh();
		setTimeout(function(){d.hide();XN.DOM.enable();},1500);
	}
	
	
}

function test_email(strEmail) { 
  var myReg = /^([a-zA-Z0-9(\.)_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; 
  if(myReg.test(strEmail)) return true; 
  return false; 
}

function getFriends(appId,page){	
	var postUrl = 'http://page.' +XN.env.domain+'/application/'+ appId + '/friends/'+ page;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			$('friends-holder').innerHTML=r.responseText;
		},
		onFailure: FailureRet
		}
	);
}

function getFans(appId,page){	
	var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/fans/'+ page;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			$('fans-holder').innerHTML=r.responseText;
		},
		onFailure: FailureRet
		}
	);
}

function FailureRet(r){
	XN.DO.alert("error");
}
//获得评论
function getRating(appId,page){	
	var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/reviews/'+ page;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			$('ulComments').innerHTML=r.responseText;
		},
		onFailure: FailureRet
		}
	);
}
//获得留言
function getComment(appId,page,type){
	var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/wall/'+ page;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		parameters: 'type=' + type,
		onComplete: function (r){
			if (type == 0)	$('ulComments').innerHTML=r.responseText;
			else if (type == 1)  $('ulReplys').innerHTML=r.responseText;
		},
		onFailure: FailureRet
		}
	);
}

function getFeeds(appId){
	
	var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/wall/feedslist';
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			$('ulfeeds').innerHTML=r.responseText;
		},
		onFailure: FailureRet
		}
	);
	
}
//提交评论
function summitReviews(appId){
	
	var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/reviews/save';
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			var data = XN.JSON.parse(r.responseText);
			if (data.result == true){
				$('newRating').value = '';
				getRating(appId,0);
				pager.setCurrentPage(1);
			} else if (data.result == false){
				XN.DO.alert(data.msg);
			} else {
				XN.DO.alert('error');
			}
		},
		onFailure: FailureRet
		}
	);
	
}

function summitComment(appId){
	if(!isFans){
		XN.DO.alert('成为关注者后才能发留言');
		return;
	}
	var content = $('newComment').value;
	if(content == '' || content == null){
		XN.DO.alert('请填写留言:-)');
	}
	else if(content.length > 140){
		XN.DO.alert('您输入内容最多140字。');
	}
	else{
		var postUrl = 'http://page.'+XN.env.domain+'/application/'+ appId + '/wall/save';
		
		var myAjax = new Ajax.Request(postUrl, {
			method: 'post',
			parameters: 'sid='+$('sid').value+'&uid='+$('uid').value+"&uname="+$('uname').value+'&'+
						'sign='+$('sign').value+'&check='+$('check').value+"&newComment="+content,
			onComplete: function (r){
				var data = XN.JSON.parse(r.responseText);				
				if (data.result == 0){
					//document.getElementById("newcmt").reset();
					switchWallPanel(appId,'commentsPanel')
					$('newComment').value = '';
					$('uid').value='';
				}else if (data.result == 2) {
					appearFrame(appId);
				}else if (data.result == 1) {
					XN.DO.alert(data.msg);
				}else {
					XN.DO.alert('error');
				}
			},
			onFailure: FailureRet
			}
		);
	}
}

function summitFeeds(appId){
	if(!isDeveloper){
		XN.DO.alert('只有开发者才能发状态！');
		return;
	}
	var content = $('feedtext').value;
	if(content == '' || content == null){
		XN.DO.alert('您还没有输入状态内容:-)');
	}
	else if(content.length > 140){
		XN.DO.alert('您输入内容最多140字。');
	}
	else{
		var postUrl = "/application/"+ appId + "/wall/status";
		
		var myAjax = new Ajax.Request(postUrl, {
			method: 'post',
			parameters: 'newFeeds='+content,
			
			onComplete: function (r){
				var data = XN.JSON.parse(r.responseText);				
				if (data.result == 0){
					switchWallPanel(appId,'feedsPanel')
					$('feedtext').value = '';
					alert("发状态成功");
				}else if (data.result == 1) {
					XN.DO.alert(data.msg);
				}else {
					XN.DO.alert('error');
				}
			},
			onFailure: FailureRet
			}
		);
	}
}


function delComment(appId,userId,id){
	XN.DO.confirm('您确定要删除这条评论吗?','删除评论',
			function(r){
				if(r){
					var postUrl = "/application/"+ appId + "/wall/" + userId + "/" + id + "/delete";
					var myAjax = new Ajax.Request(postUrl, {
						method: 'post',
						onComplete: function (r){
							var data = XN.JSON.parse(r.responseText);
							if (data.result == true){
								XN.DO.alert('删除成功!');
								var div = 'comment_'+id;
								$(div).style.display = 'none';
							} else if (data.result == false){
								XN.DO.alert(data.msg);
							} else {
								XN.DO.alert('error');
							}
						},
						onFailure: FailureRet
						}
					);
				}
			});
}

function heighter(textId){
	$(textId).style.height='36px';
}

function shorter(textId){
	//setTimeout("$(textId).style.height='20px'",1);
	$(textId).style.height='20px';
}

function postValidation(appId,validation){
	var postUrl = "/application/"+ appId + "/wall/validation";
	var pars = 'validation=' + validation;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		parameters: pars,
		onComplete: function (r){
			var data = XN.JSON.parse(r.responseText);
			if (data.result == false){//验证码输入错误
				XN.DO.confirm({
					title:'提示',
					message : data.msg,
					callBack:function(r){
						if(r){
							appearFrame(appId);
						}
					}
				});
			}else if (data.result == true){
				summitComment(appId);
			}else {
				XN.DO.alert('error');
			}
		},
		onFailure: FailureRet
		}
	);
}

function appearFrame (appId) {
	var url = "/application/"+ appId + "/wall/validation";
	var myAjax = new Ajax.Request(url, {
		method: 'get',
		onComplete: function(transport){
			XN.DO.confirm({
				title:'您留言的次数过于频繁，请输入验证码',
				message : transport.responseText,
				callBack:function(r){
					if(r){
						postValidation(appId,$('validation').value);
					}
				}
			});
		}
	});
}

//Profile页中信息框用到的js
function validation(appId) {
	var p = $("introp");
	var ta = $("introta");
	var a = $("introa");
	var tae = $("introtaEcho")
	p.style.display = "none";
	tae.style.display = ta.style.display = a.style.display = "block";
	if( p.innerText )
		ta.value = p.innerText;
	else if( p.textContent )
		ta.value = p.textContent;
	else
		ta.value = p.innerHTML;

	ta.value = XN.STRING.trim(ta.value);
	if(ta.value=="请输入描述信息......")
		ta.value = "";
	ta.focus()
	ta.onblur = function() {
		tae.style.display = ta.style.display = a.style.display = "none";
		p.style.display = "block";
		var v = XN.STRING.trim(ta.value);
		new XN.net.xmlhttp({//是一个ajax请求
			url : "/application/"+appId+"/info/message",
			data : "newMessage=" + encodeURIComponent(v),
			onSuccess : function(r) {
				var data = XN.JSON.parse(r.responseText);
				if(data.result) {
					if(v=="") v = "请输入描述信息......";
					if( p.innerText ) {
						p.innerText = v;
					} 
					else if(p.textContent) {
						p.textContent = v;
					} 
					else {
						p.innerHTML = v;
					}
				} else
					XN.DO.alert(data.msg);
			}
		});
	};
}

//刷新验证码
function refreshCode() {
	var sr = $('verifyPic').src.split("&")[0]+"&rnd=";
	$('verifyPic').src = sr + Math.random();
}

function appearApply(userName,userId,id,check,sign){
	$('sid').value=id;
	$('uid').value=userId;
	$('uname').value=userName;	
	$('sign').value=sign;   
	$('check').value=check;            			
   
	$('newComment').value="回复"+userName+":";
	$('newComment').style.height="36px";
	setTimeout("$('newComment').focus()",1);
}

//添加评论
function saveRating(appId){	
	var postUrl = "/application/"+ appId + "/reviews/save";
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: saveRatingSuccRet,
		onFailure: FailureRet
		}
	);
}

function saveRatingSuccRet(r){
	$('ulComments').innerHTML=r.responseText;
	
}

function beFans(appId,action){	
	var postUrl = "/application/"+ appId + "/fans/" + action;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			XN.DO.alert(r.responseText);
			$('beafans').style.display = "none";
			$('abortafans').style.display = "";
			$('isafans').style.display = "";
			isFans = true;
		},
		onFailure: FailureRet
		}
	);
}

function abortFans(appId,action){	
	XN.DO.confirm({
		message:'您确定退出关注者吗?',
		title:'退出关注者',
		yes:'确认',
		no:'取消',
		callBack:function(r){
			 if(r){
				var postUrl = "/application/"+ appId + "/fans/" + action;
				var myAjax = new Ajax.Request(postUrl, {
					method: 'post',
					onComplete: function (r){
						XN.DO.alert(r.responseText);
						$('beafans').style.display = "";
						$('abortafans').style.display = "none";
						$('isafans').style.display = "none";
						isFans = false;
					},
					onFailure: FailureRet
					}
				);
			 }
		}});
}

//-----------------------------------------------
//
//开发者编辑AppProfile时用到的弹层，类似用户设置App
//add by lifusong
//-----------------------------------------------
function create_app_diag(){
	var confirm;
	if ($('comfirm_diag')) {
		confirm = $('comfirm_diag');
	}
	else {
		confirm = document.createElement("div");
		confirm.id="comfirm_diag";
		confirm.className = "generic_dialog pop_dialog";
		document.body.appendChild(confirm);
	}
    confirm.innerHTML = '<div class="generic_dialog_popup" style="top:125px;"><table class="pop_dialog_table" id="pop_dialog_table" style="width:400px;"><tr><td class="pop_topleft"></td><td class="pop_border"></td><td class="pop_topright"></td></tr><tr><td class="pop_border"></td><td id="pop_content" class="pop_content">载入中...</td><td class="pop_border"></td></tr><tr><td class="pop_bottomleft"></td><td class="pop_border"></td><td class="pop_bottomright"></td></tr></table></div>';
}
function diagEditAppProfile(appId,appProfileId) {
	create_app_diag();
	//http://app.renren.com/developers/app/50/profile/edit#
	//var url = 'http://app.' + XN.env.domain + '/app/editAppsPrivacy/profile';
	var url = 'http://app.' + XN.env.domain + '/developers/app/'+appProfileId+'/profile/appsetting';
	var pars = 'appId=' + appProfileId+'&app_id=' + appId+'&app_profile_id='+appProfileId;
	var myAjax = new Ajax.Request(url, {
		method: 'get',
		parameters: pars,
		onComplete: function(transport){
			ge('pop_content').innerHTML = transport.responseText;
			changeAppTab();
		}
	});
}
function changeAppTab(){
	var tv = new XN.ui.tabView({
			activeClass : 'current'
		});
	var i = 1;
	while( i < 2 ){
		if ($('t'+i) && $('c'+i)){				
			tv.addTab({
				label : 't' + i,
				content : 'c' + i,
				active : ( i == 1 )
			});
		}
		i ++;
	}
}
//关闭弹窗
function closeApp(){
    var oP = document.getElementById('comfirm_diag');
    oP.parentNode.removeChild(oP);
}
//${applicationScope.urlApp}/developers/app/50/profile/addtab"
/**
 * 在弹层中操作 添加 或 移除 tab
 * @param profileId 当前的appProfile的id
 * @param appId 被添加到app profile上的app的Id
 * @param op 请传入 "del" 或 "add"
 * @param item 请传入 "tab" 或 "box"
 */
function makeProfileChange(profileId,appId,op,item) {
	var url = '';
	var opme = '';
	if(item=="tab"){
		if(op == "add"){
			opme = 'addtab';
		}else if(op == "del"){
			opme = 'removetab';
		}
	}else if(item=="box"){
	}
	url = 'http://app.' + XN.env.domain + '/developers/app/'+profileId+'/profile/'+opme;
	var pars = 'appId=' + profileId+'&app_id=' + appId+'&profile_id='+profileId;
	var myAjax = new Ajax.Request(url, {
		method: 'post',
		parameters: pars,
		onComplete: function(transport){
			ge('dialog_content_tab_block').innerHTML = transport.responseText;
		}
	});
}
/**
 * 解除App Profile 和App的关系
 * @param profileId
 * @param appId
 * @return
 */
function removeAppFromProfileChange(profileId,appId) {
	var url = 'http://app.' + XN.env.domain + '/developers/app/'+profileId+'/profile/removeapp';
	var pars = 'appId=' + profileId+'&app_id=' + appId+'&profile_id='+profileId;
	var myAjax = new Ajax.Request(url, {
		method: 'post',
		parameters: pars,
		onComplete: function(transport){
			location.reload(); 
			//ge('dialog_content_tab_block').innerHTML = transport.responseText;
		}
	});
}

//var str = $('menu').innerHTML 


/**
 * 为App Profile增加一个新的Tab
 * @param profileId
 * @param addedAppId
 * @return http://page.renren.com/application/50/apps?origin=5200&appProfileId=50
 */
function addANewTabToAppProfile(profileId,addedAppId) {
	var url = 'http://page.' + XN.env.domain + '/application/'+profileId+'/apps/addtab';
	var pars = 'app_id=' + addedAppId ;
	var myAjax = new Ajax.Request(url, {
		method: 'post',
		parameters: pars,
		onComplete: function(transport){
			//ge('dialog_content_tab_block').innerHTML = transport.responseText;
		//location.reload(); 
		window.location.href='http://page.' + XN.env.domain + '/application/'+profileId+'/apps/tab?app_id='+addedAppId;
		}
	});
}
//${applicationScope.urlPage}/application/${requestScope.appId}/apps/add?appProfileId=${item.pageId}
/**
 * 
 */
function addAppToAppProfile(profileId,addedAppId) {
	var url = 'http://page.' + XN.env.domain + '/application/'+profileId+'/apps/add';
	var pars = 'app_id=' + addedAppId ;
	var myAjax = new Ajax.Request(url, {
		method: 'post',
		parameters: pars,
		onComplete: function(transport){
			$('profile_id_' + addedAppId).hide();
		}
	});
}
/*
function beFans(appId,action){	
	var postUrl = "/application/"+ appId + "/fans/" + action;
	var myAjax = new Ajax.Request(postUrl, {
		method: 'post',
		onComplete: function (r){
			XN.DO.alert(r.responseText);
			$('beafans').style.display = "none";
			$('abortafans').style.display = "";
			$('isafans').style.display = "";
			isFans = true;
		},
		onFailure: FailureRet
		}
	);
}
*/


//----------------------------------------------------
//
//App Profile的Tab，下拉菜单，
//add by 李福松
//----------------------------------------------------
XN.dom.ready(function()
{
  if ($( 'appProfileAddTabAction' ) ){
	  new XN.ui.menu({
	      bar:'appProfileAddTabAction',
	      menu:'addtagdropdownMenu',
			fireOn:'click',
			alignType: '1-1',
			offsetX: 1
		});
  }
  
  if ($( 'appProfileAddedExtendAction' ) ){
	  new XN.ui.menu({
	      bar:'appProfileAddedExtendAction',
	      menu:'applistdropdownMenu',
			fireOn:'click',
			alignType: '1-1',
			offsetX: 1
		});
  }
});

//开发者维护的App Profile, lifusong add
var myPagesDialog;
//显示开发者维护的App Profile列表
function showMyPages(appId,appName){
	var requestUrl = '/application/' + appId + '/apps?origin=5200';
	XN.DOM.disable();
	myPagesDialog = XN.DO.confirm({
    	title:'添加 ' + appName + ' 到你的应用主页',
    	params:{addIframe:true},
    	submit:'关闭',cancel:'cancel',
		callBack : submitForm
    }).setWidth(500);
    myPagesDialog.setY(100);
	
    myPagesDialog.footer.hide();
	sendLoading('载入中 ...');
    new XN.net.xmlhttp({ 
        url: requestUrl,
        method:'get',
        data:'appProfileId=' + appId,
        onComplete: showSendWindow,
        onError: function(transport){
                  alert("发生错误，请联系管理员。");
               }
    });
    
    function sendLoading(msg){
    	if(!msg) {
    		msg = 'Loading ...';
    	}
    	myPagesDialog.header.hide();
    	myPagesDialog.footer.hide(); 
    	myPagesDialog.body.setContent( msg );
    	myPagesDialog.refresh();
    }
    
    function submitForm(){
    	closeMyPagesDialog();
    	//$('myPages_form').submit();
    }
    
    function showSendWindow(transport){
    	
    	myPagesDialog.header.show();
    	myPagesDialog.footer.show();
    	//d.setTitle('发信给开发者');
    	myPagesDialog.body.setContent(transport.responseText);
    	//d.getButton('确定').setText('发送');
    	myPagesDialog.getButton('cancel').hide();
    	myPagesDialog.refresh();
    	eval($('myPagesRunJs').innerHTML);
    	//alert($('runJs').innerHTML);
    }
}

function closeMyPagesDialog(){
	
	myPagesDialog.hide();
	XN.DOM.enable();
}


//-------------------------------------

var inviteDialog;
function inviteFriends(appId){
	
	var requestUrl = '/application/' + appId + '/invite?origin=5200';
	XN.DOM.disable();
    inviteDialog = XN.DO.confirm({
    	title:'邀请好友',
    	params:{addIframe:true},
		callBack : submitForm
    }).setWidth(500);
	inviteDialog.setY(100);
	
    inviteDialog.footer.hide();
	sendLoading('载入中 ...');
    new XN.net.xmlhttp({ 
        url: requestUrl,
        method:'get',
        data:'appId=' + appId,
        onComplete: showSendWindow,
        onError: function(transport){
                  alert("发生错误，请联系管理员。");
               }
    });
    
    function sendLoading(msg){
    	if(!msg) {
    		msg = 'Loading ...';
    	}
    	inviteDialog.header.hide();
		inviteDialog.footer.hide(); 
		inviteDialog.body.setContent( msg );
		inviteDialog.refresh();
    }
    
    function submitForm(){
    	
    	$('req_form').submit();
    }
    
    function showSendWindow(transport){
    	
    	inviteDialog.header.show();
    	//inviteDialog.footer.show();
    	//d.setTitle('发信给开发者');
    	inviteDialog.body.setContent(transport.responseText);
    	//d.getButton('确定').setText('发送');
    	inviteDialog.refresh();
    	eval($('runJs').innerHTML);
    	//alert($('runJs').innerHTML);
    }
}

function closeInvite(){
	
	inviteDialog.hide();
	XN.DOM.enable();
}

XN.dom.ready(function()
{
	
	if (XN.browser.IE) { $('content').style.minHeight=document.getElementById('sidebar').offsetHeight+80+"px";}
	if (XN.browser.IE6) { $('content').style.height=document.getElementById('sidebar').offsetHeight+80+"px";}
	
});

function switchWallPanel(appId,showPanel){
	$('feedsPanel').style.display = $('commentsPanel').style.display = $('replysPanel').style.display = "none";
	$('newComment').style.display = $('feedtext').style.display = $('commentbutton').style.display = $('feedbutton').style.display = "none";
	$('liComments').className = $('liFeeds').className = $('liReplys').className = "";
	$(showPanel).style.display = "block";
	if((showPanel == 'feedsPanel')){
		//getFeeds(appId);
		$('liFeeds').className = "selected";
		$('feedtext').style.display = $('feedbutton').style.display = "inline";
		
	}else if (showPanel == 'replysPanel'){
		getComment(appId,0,1);
		pager2.setCurrentPage( 1 );
		$('liReplys').className = "selected";
		$('newComment').style.display = $('commentbutton').style.display = "inline";
	} else if (showPanel == 'commentsPanel'){
		getComment(appId,0,0);
        pager.setCurrentPage( 1 );
		$('liComments').className = "selected";
		$('newComment').style.display = $('commentbutton').style.display = "inline";
	}
}


function reportComment(appId,id){
	XN.DO.confirm({
		title: '举报不良留言',
		message: '确认举报这条留言吗？',
		submit: '举报',
		cancel: '取消',
		callBack: function(f){
			if (f){
				var postUrl = 'http://page.' +XN.env.domain+ '/application/'+appId+'/wall/'+id+'/report';
				var myAjax = new Ajax.Request(postUrl, {
					method: 'post',
					onComplete: function (r){
						var div = 'comment_'+id;
						$(div).style.display = 'none';
					},
					onFailure: FailureRet
				});
			}
		}
	});
}

//修改资料页
function showEditDiv(){
		$('info_p').style.display='none';
		$('info_edit_div').style.display='block';
		$('info_edit_text').value = $('info_p').innerHTML;
}
function infoEditSubmit(appId){
		$('info_submit').disabled = true;
		if ($('info_p').innerHTML == $('info_edit_text').value) {
				infoEditCancel();
				return;
		}
		var v = XN.STRING.trim($('info_edit_text').value);
	new XN.net.xmlhttp({
		url: 'http://page.'+XN.env.domain+'/application/'+appId+'/info/edit',
		method:'post',
		data: 'content='+encodeURIComponent(v),
		onComplete: function(r){
				var data = XN.JSON.parse(r.responseText);
						if (!data.result)
								XN.DOM.alert(data.msg);
						infoEditCancel();
		},
		onError: function(r){
				  alert("发生错误，请联系管理员。");
			   }
	});
}
function infoEditCancel(){
		$('info_submit').disabled = false;
		$('info_p').style.display='block';
		$('info_edit_div').style.display='none';
		$('info_p').innerHTML = $('info_edit_text').value;
}
//上传图片
function uploadProfilePic(appId){
	XN.DOM.disable();
	var div = '<form id="profile_pic_form" action="http://app.'+XN.env.domain+'/developers/app/'+appId+'/pic/profilemain" method="post" enctype="multipart/form-data">'
						+ '<div>'
						+ '<p style="margin-bottom:10px;">选择电脑里的一张图片（图片大小不超过300*200）：</p>'
						+ '<p style="margin-bottom:5px;padding-bottom:10px;border-bottom:1px solid #CCCCCC;"><input type="file" name="theFile" id="theFile" size="30" class="inputfile"/></p>'
						+ '<input type="hidden" id="appId" value="'+appId+'"/>'
						+ '<input type="checkbox" value="1" name="agree" id="agree" onfocus="this.blur();" /> '
						+ '<label id="label_agree" for="agree">我保证有权利使用和传播该照片，不与人人网相关条款抵触。</label></p>'
						+ '</div><form>'
	XN.DO.confirm({
		title: '上传应用主页头像',
		message: div,
		width:550,
		submit:'上传图片',
		cancel:'取消',
		callBack: function (f) {
				if (f) {
						$('profile_pic_form').submit();
				}
		}
	});
}