/**
*用户管理模块的所有用到的js函数；
*认证用户与商家信息为多对一关系，一个商家下可以拥有多个用户ID；
*在js函数中，涉及到ajax内容的，解析返回的json类型后，  
*须包含将解析后的json内容，构造成html形式，反馈给前端页面,动态更新前端页面的内容；
*/
var descriptionDocument;
var noticeDocument;

function getCountWithoutHtml(str){
	var str =  str.replace(/<[^>].*?>|&nbsp;|\s|\n|\r\n/g,"")
					.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
	return str.length;
}
function getCountWithHtml(){
	 		var primarybusiness = trim($("#edit_primarybusiness").val()).replace(/\s|\n/g,"");
	 		$("#edit_primarybusinessTipDivId").html(primarybusiness.length+"/300");
	 	}
var idTabs = new Array("#edit_SJXX","#edit_GSJJ","#edit_ZXGG","#edit_GRXX","#edit_QIBS","#edit_GRTX","#edit_QYRZ","#edit_ZHMM");
var aLinks = new Array("#companyinfo_link","#description_link","#notice_link","#userinfo_link","#logo_link","#photo_link","#blncr_link","#password_link");
function hideOtherIdTabs(id){
	if(id == "#edit_QIBS"){
		$("#edit_GRTX").hide();
		$("#edit_GRTX").removeClass("selected");
	}else if(id == "#GRTX"){
		$("#edit_QIBS").hide();
		$("#edit_QIBS").removeClass("selected");
	}
	for(var i=0;i<idTabs.length;i++){
		if(id == idTabs[i]){
			$(id).show();
			$(aLinks[i]).addClass("selected"); 
		}else{
			$(idTabs[i]).hide();
			$(aLinks[i]).removeClass("selected");
		}
	}
}
	function isLogoOrPhotoDataLoading(linkType){ 
		if(linkType != "logo_link" && linkType != "photo_link"){
			$("#edit_QIBS_").html(logoSrcDivHtml);
			$("#edit_GRTX_").html(photoSrcDivHtml);
			return false;
		}
		if($("#edit_QIBS").attr("logoDataLoading") == "true" && pageType == 'logo_'){
			if(linkType == "photo_link"){
				$("#edit_QIBS_").html(logoSrcDivHtml);
				return false;
			}	
			return true;
		}else if($("#edit_GRTX").attr("photoDataLoading") == "true" && pageType == 'photo_'){
			if(linkType == "logo_link"){
				$("#edit_GRTX_").html(photoSrcDivHtml);
				return false;
			}	
			return true;
		}
	}

/**
 * 初始化编辑商家资料页面事件
 */ 
	function initTextInputListener(){
		//企业logo和个人photo链接事件
		$("#companyinfo_link").click(function(){if(isLogoOrPhotoDataLoading("companyinfo_link"))return;$("#tab_type").val("edit_SJXX");hideOtherIdTabs("#edit_SJXX");});
		$("#description_link").click(function(){
			if(isLogoOrPhotoDataLoading("description_link"))
				return;
	           	$("#tab_type").val("edit_GSJJ");
				hideOtherIdTabs("#edit_GSJJ");
		});
		$("#notice_link").click(function(){
			if(isLogoOrPhotoDataLoading("notice_link"))
				return;
	           	$("#tab_type").val("edit_ZXGG");
				hideOtherIdTabs("#edit_ZXGG");
		});
		$("#userinfo_link").click(function(){if(isLogoOrPhotoDataLoading("userinfo_link"))return;$("#tab_type").val("edit_GRXX");hideOtherIdTabs("#edit_GRXX");});
		$("#logo_link").click(function(){
			if(isLogoOrPhotoDataLoading("logo_link"))return;
				hideOtherIdTabs("#edit_QIBS");
				$("#tab_type").val("edit_QIBS");
				if($("#edit_QIBS").attr("isDataLoaded") == 'false'){
					onloadShow('logo_');
					$("#edit_QIBS").attr("isDataLoaded","true");
				}else
					pageType = 'logo_';
		});
		$("#photo_link").click(function(){
				if(isLogoOrPhotoDataLoading("photo_link"))return;
				hideOtherIdTabs("#edit_GRTX");
				$("#tab_type").val("edit_GRTX");
				if($("#edit_GRTX").attr("isDataLoaded") == 'false'){
					onloadShow('photo_');
					$("#edit_GRTX").attr("isDataLoaded","true");
				}else
					pageType = 'photo_';
		});
		$("#blncr_link").click(function(){if(isLogoOrPhotoDataLoading("blncr_link"))return;$("#tab_type").val("edit_QYRZ");hideOtherIdTabs("#edit_QYRZ");});
		$("#password_link").click(function(){if(isLogoOrPhotoDataLoading("password_link"))return;$("#tab_type").val("edit_ZHMM");hideOtherIdTabs("#edit_ZHMM");});
		
		//保存信息后提示事件
		$("#edit_companyname").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_shortcompanyname").keydown(function(){$("#edit_company_update_status").hide()});
		//$("#edit_area").keydown(function(){$("#edit_company_update_status").hide()});
		$("#provinceCity").mouseup(function(){$("#edit_company_update_status").hide()});
		$("#edit_primarybusiness").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_telcontact").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_address").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_postcode").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_shopaddress").keydown(function(){$("#edit_company_update_status").hide()});
		$("#edit_fax").keydown(function(){$("#edit_company_update_status").hide()});
	 	
 		$("#edit_name").keydown(function(){$("#edit_userinfo_update_status").hide()});
		$("#edit_telephone").keydown(function(){$("#edit_userinfo_update_status").hide()});
		$("#edit_mobile").keydown(function(){$("#edit_userinfo_update_status").hide()});
		$("#edit_qq").keydown(function(){$("#edit_userinfo_update_status").hide()});
		$("#edit_msn").keydown(function(){$("#edit_userinfo_update_status").hide()});
		$("#edit_bln").keydown(function(){$("#edit_blncr_update_status").hide()});
		$("#edit_cr").keydown(function(){$("#edit_blncr_update_status").hide()});
		$("#edit_oldPassId").keydown(function(){$("#edit_password_update_status").hide()});
		$("#edit_newPass").keydown(function(){$("#edit_password_update_status").hide()});
		$("#edit_rePass").keydown(function(){$("#edit_password_update_status").hide()});
		
		//统计字数：主营业务、公司描述、公司简介
	 	$("#edit_primarybusiness").keyup(getCountWithHtml);

		//页面text字段失去焦点时的验证事件
		$("#edit_companyname").blur(function(){checkCompanyname(trim($("#edit_companyname").val()),"")});
		$("#edit_shortcompanyname").blur(function(){checkShortcompanyname(trim($("#edit_shortcompanyname").val()),"")});
		//$("#edit_area").blur(function(){checkArea(trim($("#edit_area").val()),"")});
		$("#edit_primarybusiness").blur(function(){checkPrimarybusiness(trim($("#edit_primarybusiness").val()),"")});
		$("#edit_telcontact").blur(function(){checkTelcontact(trim($("#edit_telcontact").val()),"")});
		$("#edit_address").blur(function(){checkAddress(trim($("#edit_address").val()),"")});
		$("#edit_postcode").blur(function(){checkPostcode(trim($("#edit_postcode").val()),"")});
		$("#edit_shopaddress").blur(function(){checkShopaddress(trim($("#edit_shopaddress").val()),"")});
		$("#edit_fax").blur(function(){checkFax(trim($("#edit_fax").val()),"")});
		
		$("#edit_description").blur(function(){checkDescription(trim($("#edit_description").val()),"")});
		$("#edit_notice").blur(function(){checkNotice(trim($("#edit_notice").val()),"")});
		
		$("#edit_name").blur(function(){checkName(trim($("#edit_name").val()),"")});
		$("#edit_telephone").blur(function(){checkTelephone(trim($("#edit_telephone").val()),"")});
		$("#edit_mobile").blur(function(){checkMobile1(trim($("#edit_mobile").val()),"")});
		$("#edit_qq").blur(function(){checkQq(trim($("#edit_qq").val()),"")});
		$("#edit_msn").blur(function(){checkMsn(trim($("#edit_msn").val()),"")});
		
		$("#edit_bln").blur(function(){checkBln(trim($("#edit_bln").val()),"")});
		$("#edit_cr").blur(function(){checkCr(trim($("#edit_cr").val()),"")});
		
		$("#edit_oldPassId").blur(function(){checkOldPass(trim($("#edit_oldPassId").val()),"")});
		$("#edit_newPass").blur(function(){checkNewPass(trim($("#edit_newPass").val()),"")});
		$("#edit_rePass").blur(function(){checkRePass(trim($("#edit_rePass").val()),"")});
		
		//保存按钮事件
		$("#edit_updateCompany_button").click(updateCompanyInfo);
		$("#edit_updateDescription_button").click(updateDescription);
		$("#edit_updateNotice_button").click(updateNotice);
		$("#edit_updateUserInfo_button").click(updateUserInfo);
		$("#logo_updateLogo_button").click(cropMyImage);
		$("#photo_updatePhoto_button").click(cropMyImage);
		$("#edit_updateBlnCr_button").click(computerDataFullPercentForUpdateBlnCr);
		$("#edit_updatePass_button").click(updatePass);
		
		logoSrcDivHtml = $("#edit_QIBS_").html();
		photoSrcDivHtml = $("#edit_GRTX_").html();
	}
	
	function initDescriptionEditor(){
		var tempSrc = "/scripts/xheditor-1.0.0-rc2/initXhe.js";		
		if($("#edit_GSJJ").attr("isDataLoaded") == "false"){//是否已经初始化了编辑器
			if($("#edit_GSJJ").attr("isEditorScriptLoad") == "false"){
			 	var newscript=document.createElement('script');
			 	newscript.setAttribute('type','text/javascript');
			 	newscript.setAttribute('id', 'xheditorJsId_');
			 	newscript.setAttribute('src',tempSrc);
				document.body.appendChild(newscript);
				$("#edit_GSJJ").attr("isEditorScriptLoad", "true");
				$("#edit_ZXGG").attr("isEditorScriptLoad", "true");
				if(document.all)
				newscript.onreadystatechange = function () { 
		            if (newscript.readyState == 'loaded' || newscript.readyState == 'complete') { 
		            	$("#edit_ZXGG").attr("isEditorInit", "true");
						$("#edit_GSJJ").attr("isEditorInit", "true");
		            	$("#tab_type").val("edit_GSJJ");
						hideOtherIdTabs("#edit_GSJJ");
		           	} 
      			} 
      			else{
      				$("#edit_ZXGG").attr("isEditorInit", "true");
					$("#edit_GSJJ").attr("isEditorInit", "true");
      				$("#tab_type").val("edit_GSJJ");
					hideOtherIdTabs("#edit_GSJJ");
      			}
			}
		}
	}
	
	function initNoticeEditor(){
		var tempSrc = "/scripts/xheditor-1.0.0-rc2/initXhe.js";
		if($("#edit_ZXGG").attr("isDataLoaded") == "false"){//是否已经初始化了编辑器
			if($("#edit_ZXGG").attr("isEditorScriptLoad") == "false"){
			 	var newscript=document.createElement('script');
			 	newscript.setAttribute('type','text/javascript');
			 	newscript.setAttribute('id', 'xheditorJsId_');
			 	newscript.setAttribute('src',tempSrc);
				document.body.appendChild(newscript);
				$("#edit_ZXGG").attr("isEditorScriptLoad", "true");
				$("#edit_GSJJ").attr("isEditorScriptLoad", "true");
				if(document.all)
				newscript.onreadystatechange = function () { 
		            if (newscript.readyState == 'loaded' || newscript.readyState == 'complete') { 
			            $("#edit_ZXGG").attr("isEditorInit", "true");
						$("#edit_GSJJ").attr("isEditorInit", "true");
		            	$("#tab_type").val("edit_ZXGG");
						hideOtherIdTabs("#edit_ZXGG");
		           	} 
      			} 
      			else{
      				$("#edit_ZXGG").attr("isEditorInit", "true");
					$("#edit_GSJJ").attr("isEditorInit", "true");
      				$("#tab_type").val("edit_ZXGG");
					hideOtherIdTabs("#edit_ZXGG");
      			}
			}

		}
	}

	function reSetOpenFloderButton(){
				var pArr = document.getElementById("noticeUlId").getElementsByTagName("p");
				var firstText;
				var lineHeight_;
				if(pArr != null && pArr.length > 0){
					firstText = document.all ? pArr[0].innerText : pArr[0].textContent;
					lineHeight_ = pArr[0].style.lineHeight;
				}
				var zihuCount = {"20px":49,"23px":49, "27px":39, "30px":32, "35px":24, "40px":18, "47px":12}; 
				$("#noticeUlId").height("40px"); 
				$("#openfloder").text("展开"); 
				$("#openfloder").removeClass("close");
				$("#openfloder").addClass("open");	
				$("#noticeUlId").attr("isOpenStatus", 0);
				
				var tableArr =  document.getElementById("noticeUlId").getElementsByTagName("table");
				if((pArr != null && pArr.length > 1) || (tableArr != null && tableArr.length > 0) || (pArr.length != 0 && firstText.replace(/\s/g,"").length > zihuCount[lineHeight_])){//如果只有一行就不显示下拉按钮	
					$("#openfloderDivId").html('<a href="javascript:void(0)" class="open"  onclick="openOrFlorde();return false;" id="openfloder">展开</a>');
					
				}else
					$("#openfloderDivId").html('');	
	}

	
/**
 * 填充预览商家资料页面和商家店铺的左侧的信息卡
 * 填充商家信息，商家公告、个人信息、企业图片、公司简介
 */
	function showViewPageDate(friendid){
		if(friendid == null || friendid == -10 || friendid == "")
			indexLoginPage();
		var userid = $("#userid").val();
		var pageType = $("#tab_type").val();  
		var editType = $("#editType").val();
		if(editType == "edit_SJXX"){
			if(userid != friendid)
				friendid = userid;
		}
		$.ajax({//获取名片卡信息，包括公司基本信息和个人信息
			cache:false,
			url:"/userManage/userManageEntityAction!UserByUserID.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:showViewPageDate_success,
			error:ajax_error
		});
		fillBrandCategory(friendid);//获取已经发布报价单
		$.ajax({//获取公司简介
			cache:false,
			url:"/userManage/userManageParamAction!Notice.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:function(json){
				var notice = trim(isNullString(json.notice));  
				notice = fixDownloadNotDesCss(notice);
				$("#noticeConDivId").html(notice);//homepage   
				setLineHeight("noticeConDivId");
				reSetOpenFloderButton();
				$("#noticeUlId1").html(notice);//viewpage
				//让预览div的公告重新设置line-height
				setLineHeight("noticeUlId1");
			},
			error:function(){}
		});		 
		$.ajax({//获取公司描述
			cache:false,
			url:"/userManage/userManageParamAction!Description.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:function(json){
				var description = json.description;
				description = fixDownloadNotDesCss(description);
				$("#descriptionUlId").html(description);
				setLineHeight("descriptionUlId");
			},
			error:ajax_error
		});
		getPicture("logo_","logoImgId", friendid);//获取企业图片
		getInitTreeData();//获取用户的产品目录
		if(pageType == "viewInfoPage"){//预览公司信息页面
			getViewPageDifferent();
		}else if(pageType == "homePage"){ 
			getHomePageDifferent();
		}else if(pageType == "editPage"){
			gotoCompanyEditPage();
			if(trim(editType).length == 0)
				editType = "edit_SJXX";
			editType = "#"+editType;
			hideOtherIdTabs(editType);
			if(editType == "#edit_QIBS")
				onloadShow('logo_');
			else if(editType == "#edit_GRTX")
				onloadShow('photo_');
			else if(editType == "#edit_GSJJ")
				initDescriptionEditor();
			else if(editType == "#edit_ZXGG")
			  	initNoticeEditor();
		}
	}
	
/**
 * 获取预览公司信息页面的数据：公司基本信息，个人信息，公司公告，公司简介
 * 此方法给tab标签使用提供的，目的是只获取商家主页和商家资料不同的部分的数据
 */
var viewIdTabs = new Array("#SJXX","#GSJJ","#ZXGG","#GRXX");
var viewALinks = new Array("#SJXX_link","#GSJJ_link","#ZXGG_link","#GRXX_link");
 
   function getViewPageDifferent(){
   		$("#cAdPicDivId").css("display","block");
   		$("#viewPageDivId").css("display","block");
		$("#ProductCatalogTree").css("display","none");
		$("#homePageDivId").css("display","none");
		$("#editPageDivId").css("display","none");
		$("#viewLiId").addClass("selected");
		$("#viewLiId").html("商家资料");
		$("#homeLiId").removeClass("selected");
		$("#homeLiId").html('<a href="javascript:void(0)" onclick="getHomePageDifferent(); return false;">商家主页</a>');
		var friendid = $("#friendid").val();
		if($("#userid").val() == friendid)
			$("#inforEdit_button").html('<a href="javascript:void(0)" onclick="gotoCompanyEditPage(); return false;">修改我的资料</a>');
		else
			$("#inforEdit_button").html('<a href="javascript:void(0)" onclick="addFriendFloating('+friendid+'); return false;">加为好友</a>');
		if($("#userid").val() != friendid)
			$("#inforEdit_message").html('<a href="javascript:void(0)" onclick="newMessageInterface('+friendid+'); return false;">发站内信</a>');
		else
			$("#inforEdit_message").fadeOut("2");
		var type = "#"+$("#tab_type").val().split("_")[1];
		if(type != "#SJXX" && type != "#GSJJ" && type != "#ZXGG" && type != "#GRXX")
			type = "#SJXX";
		for(var i=0;i<viewIdTabs.length;i++){
			if(type != viewIdTabs[i]){
				$(viewALinks[i]).removeClass("selected");
				$(viewIdTabs[i]).hide();
			}else{
				$(viewALinks[i]).addClass("selected");
				$(viewIdTabs[i]).show();
			}
		}
   }
   
/** 
 * 此方法给tab标签使用提供的 
 */
   function getHomePageDifferent(){
   		$("#viewPageDivId").css("display","none");
   		$("#editPageDivId").css("display","none");
		$("#cAdPicDivId").css("display","block");
		$("#homePageDivId").css("display","block");
		$("#ProductCatalogTree").css("display","block");
		$("#homeLiId").addClass("selected");
		$("#homeLiId").html("商家主页");
		$("#viewLiId").removeClass("selected");
		$("#viewLiId").html('<a href="javascript:void(0)" onclick="getViewPageDifferent(); return false;">商家资料</a>');		
		var friendid = $("#friendid").val();
		if($("#userid").val() == friendid)
			$("#inforEdit_button").html('<a href="javascript:void(0)" onclick="gotoCompanyEditPage(); return false;">修改我的资料</a>');
		else
			$("#inforEdit_button").html('<a href="javascript:void(0)" onclick="addFriendFloating('+friendid+'); return false;">加为好友</a>');
		if($("#userid").val() != friendid)
			$("#inforEdit_message").html('<a href="javascript:void(0)" onclick="newMessageInterface('+friendid+'); return false;">发站内信</a>');
		else
			$("#inforEdit_message").fadeOut("2");
   }
   
/** 
 * 此方法给修改商家链接使用,并使修改商家资料链接变成预览商家资料链接
 */
   function gotoCompanyEditPage(){
   		$("#cAdPicDivId").css("display","none");
   		$("#ProductCatalogTree").css("display","none");
   		$("#viewPageDivId").css("display","none");
   		$("#homePageDivId").css("display","none");
   		$("#editPageDivId").css("display","block");
		$("#viewLiId").addClass("selected");
		$("#viewLiId").html("商家资料");
		$("#homeLiId").removeClass("selected");
		$("#homeLiId").html('<a href="javascript:void(0)" onclick="getHomePageDifferent(); return false;">商家主页</a>');
   		$("#inforEdit_button").html('<a href="javascript:void(0)" onclick="getViewPageDifferent(); return false;">预览我的资料</a>');
   		if($("#editPageDivId").attr("isloadListener") == "false"){
   			initTextInputListener();
   			$("#editPageDivId").attr("isloadListener", "true");
   		}
   		var friendid = $("#friendid").val();
   		if($("#userid").val() != friendid)
			$("#inforEdit_message").html('<a href="javascript:void(0)" onclick="newMessageInterface('+friendid+'); return false;">发站内信</a>');
		else
			$("#inforEdit_message").fadeOut("2");
   }
   

/**
 * 店铺首页的展开或收起公告信息js
 *	
 */
	function openOrFlorde(){ 
		if($("#noticeUlId").attr("isOpenStatus") == 0){//展开
			var lineHeights = {1:"20px",2:"23px",3:"27px",4:"30px",5:"35px",6:"40px",7:"47px"};
			$("#openfloder").text("收起");
			$("#openfloder").removeClass("open");
			$("#openfloder").addClass("close");
			$("#noticeUlId").attr("isOpenStatus", 1); 
			var notice = fixDownloadNotDesCss($("#noticeConDivId").html());
			$("#noticeUlId").html("<div id='noticeConDivId' style='overflow:visible;'>"+notice+"</div>");
 			$("#noticeUlId").height($("#noticeConDivId").height());
		}else{
			$("#noticeUlId").html("<div id='noticeConDivId' style='height:40px;overflow:hidden;'>"+$("#noticeConDivId").html()+"</div>"); 
			$("#noticeUlId").height("40px");
			$("#openfloder").text("展开");
			$("#openfloder").removeClass("close");
			$("#openfloder").addClass("open");			
			$("#noticeUlId").attr("isOpenStatus", 0); 
		} 
	}
	/**
	 * 填充公司简介
	 */
	function fillIntroduction(friendid){
	
		$.ajax({
			cache:false,
			url:"/userManage/userManageParamAction!Description.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:fillIntroduction_success,
			error:ajax_error
		});
	}
	/**
	 * 填充商家公告
	 */
	function fillBulletin(friendid){
		$.ajax({
			cache:false,
			url:"/userManage/userManageParamAction!Notice.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:fillBulletin_success,
			error:ajax_error
		});
	}

	/**
	 * 填充品牌类别信息
	 */
	function fillBrandCategory(friendid){
		$.ajax({
			cache:false,
			url:"/offer/offerListAction!AllUserBrandByUserid.action",
			type:"post",
			dataType:"json",
			data:{friendid:friendid},
			success:fillBrandCategory_success,
			error:ajax_error
		});
	}

	var updatecheck = "updatecheck";
 	function checkCompanyname(companyname, checkflag){
		if(companyname == ""){
			if(checkflag == updatecheck){
				$("#edit_companynameTipDivId").html("<font color='red'>请输入公司全称</font>");
				$("#edit_companynameTipDivId").show();
			}else
				$("#edit_companynameTipDivId").hide();
			return false;
		}else if(companyname.length > 30){
			$("#edit_companynameTipDivId").html("<font color='red'>公司全称长度必须在30个以内</font>");
			$("#edit_companynameTipDivId").show();
			return false;
		}else
			$("#edit_companynameTipDivId").hide();
		return true;
 	}
 	function checkShortcompanyname(shortcompanyname, checkflag){
 		if(shortcompanyname.length == 0){
 			if(checkflag == updatecheck){
				$("#edit_shortcompanynameTipDivId").html("<font color='red'>请填写公司简称</font>");
				$("#edit_shortcompanynameTipDivId").show();
			}else
				$("#edit_shortcompanynameTipDivId").hide();
			return false;
 		}else if(shortcompanyname.length < 2 || shortcompanyname.length > 6){
			$("#edit_shortcompanynameTipDivId").html("<font color='red'>公司简称长度必须在2-6个以内</font>");
			$("#edit_shortcompanynameTipDivId").show();
			return false;
		}else
			$("#edit_shortcompanynameTipDivId").hide();
		return true;
 	}
 	function checkArea(area, checkflag){
  		if(area == "省/市"){
  			if(checkflag == updatecheck){
	  			$("#edit_areaTipDivId").html("<font color='red'>请选择 省份/城市</font>");
				$("#edit_areaTipDivId").show();
			}else
				$("#edit_areaTipDivId").hide();
			return false;
  		}else
			$("#edit_areaTipDivId").hide();
		return true;
 	}	
  	function checkPrimarybusiness(primarybusiness, checkflag){
		if(primarybusiness == ""){
			if(checkflag == updatecheck){
				$("#edit_primarybusinessTipDivId").html("<font color='red'>请填写你的主营业务</font>");
				$("#edit_primarybusinessTipDivId").show();
			}else
				$("#edit_primarybusinessTipDivId").html("0/300");
			return false;
		}else if(primarybusiness.length > 300){
			$("#edit_primarybusinessTipDivId").html("<font color='red'>主营业务字数必须在300个以内</font>");
			$("#edit_primarybusinessTipDivId").show();
			return false;
		}
		return true;
 	}	
  	function checkTelcontact(telcontact, checkflag){
		if(telcontact.length == 0){
			if(checkflag == updatecheck){
				$("#edit_telcontactTipDivId").html("<font color='red'>请填写你的联系电话</font>");
				$("#edit_telcontactTipDivId").show();
			}else
				$("#edit_telcontactTipDivId").html("电话之间可以用逗号分开");
			return false;
		}else if(telcontact.length > 100){
			$("#edit_telcontactTipDivId").html("<font color='red'>电话的个数太多</font>");
			$("#edit_telcontactTipDivId").show();
			return false;
		}else
			$("#edit_telcontactTipDivId").html("电话之间可以用逗号分开");
		var tels = telcontact.split(",");
		var istelcontactLegal = true;            
		for(var i=0;i<tels.length;i++){
			if(!checkPhone(tels[i]))
				istelcontactLegal = false;
		}
		if(!istelcontactLegal){
			$("#edit_telcontactTipDivId").html("<font color='red'>电话填写不正确</font>");
			$("#edit_telcontactTipDivId").show();
			return false;
		}else
			$("#edit_telcontactTipDivId").hide();	
		return true;
 	}	
  	function checkAddress(address, checkflag){
		if(address.length == 0){
			if(checkflag == updatecheck){
				$("#edit_addressTipDivId").html("<font color='red'>请填写公司地址</font>");
				$("#edit_addressTipDivId").show();
			}else
				$("#edit_addressTipDivId").hide();
			return false;
		}else if(address.length > 50){
			$("#edit_addressTipDivId").html("<font color='red'>字数必须在50个以内</font>");
			$("#edit_addressTipDivId").show();
			return false;
		}else
			$("#edit_addressTipDivId").hide();
		return true;
 	}	
  	function checkPostcode(postcode, checkflag){
		if(postcode.length == 0){
			if(checkflag == updatecheck){
				$("#edit_postcodeTipDivId").html("<font color='red'>请填写邮编</font>");
				$("#edit_postcodeTipDivId").show();
			}else
				$("#edit_postcodeTipDivId").hide();
			return false;
		}else if(postcode.length > 10){
			$("#edit_postcodeTipDivId").html("<font color='red'>字数必须在10个以内</font>");
			$("#edit_postcodeTipDivId").show();
			return false;
		}else
			$("#edit_postcodeTipDivId").hide();
		return true;
 	}	
  	function checkShopaddress(shopaddress, checkflag){
		if(shopaddress.length == 0){
			if(checkflag == updatecheck){
				$("#edit_shopaddressTipDivId").html("<font color='red'>请填写门市地址</font>");
				$("#edit_shopaddressTipDivId").show();
			}else
				$("#edit_shopaddressTipDivId").hide();
			return false;
		}else if(shopaddress.length > 50){
			$("#edit_shopaddressTipDivId").html("<font color='red'>字数必须在50个以内</font>");
			$("#edit_shopaddressTipDivId").show();
			return false;
		}else{
			$("#edit_shopaddressTipDivId").hide();
		}
		return true;
 	}	
  	function checkFax(fax, checkflag){
		if(fax.length == 0){
			if(checkflag == updatecheck){
				return true;
				//$("#edit_faxTipDivId").html("<font color='red'>请填写传真</font>");
				//$("#edit_faxTipDivId").show();
			}else
				$("#edit_faxTipDivId").hide();
			return false;
		}else if(fax.length > 20){
			$("#edit_faxTipDivId").html("<font color='red'>字数必须在20个以内</font>");
			$("#edit_faxTipDivId").show();
			return false;
		}else
			$("#edit_faxTipDivId").hide();
		return true;
 	}	
	/**
	 * 验证商家输入信息       
	 */
	 function checkCompanyInfo(companyname,shortcompanyname,area,primarybusiness,telcontact,address,postcode,shopaddress,fax){
		if(!checkCompanyname(companyname,updatecheck))return false;
		if(!checkShortcompanyname(shortcompanyname,updatecheck))return false;
		if(!checkArea(area,updatecheck))return false;
		if(!checkPrimarybusiness(primarybusiness,updatecheck))return false;
		if(!checkTelcontact(telcontact,updatecheck))return false;
		if(!checkAddress(address,updatecheck))return false;
		if(!checkPostcode(postcode,updatecheck))return false;	
		if(!checkShopaddress(shopaddress,updatecheck))return false;	
		if(!checkFax(fax,updatecheck))return false;	
		return true;
	 }
	/**
	 * 保存商家信息
	 */
	function updateCompanyInfo(){
		var companyname = conversion(trim($("#edit_companyname").val()));
		var shortcompanyname = conversion(trim($("#edit_shortcompanyname").val()));
		var area = $("#provinceCity").text();
		var primarybusiness = conversion(trim($("#edit_primarybusiness").val()));
		var telcontact = conversion(trim($("#edit_telcontact").val()));
		var address = conversion(trim($("#edit_address").val()));
		var postcode = conversion(trim($("#edit_postcode").val()));
		var shopaddress = conversion(trim($("#edit_shopaddress").val()));
		var fax = conversion(trim($("#edit_fax").val()));
		
		if(!checkCompanyInfo(companyname,shortcompanyname,area,primarybusiness,telcontact,address,postcode,shopaddress,fax)){
			return ;
		}
		var province = area.split("/")[0];
		var city = area.split("/")[1];
		
		
		$("#edit_updateCompany_button").attr("disabled",true);
		$.ajax({
			cache:false,
			url:"/userManage/userManageVoidAction!updateUserInfo.action",
			type:"post",
			dataType:"json",
			data:{companyname:companyname,shortcompanyname:shortcompanyname,
			province:province,city:city,primarybusiness:primarybusiness,telcontact:telcontact,
			address:address,postcode:postcode,shopaddress:shopaddress,fax:fax},
			success:updateCompanyInfo_success,
			error:ajax_error
		});
	}

	/**
	 * 验证商家简介
	 */
	function checkDescription(description, checkflag){
		if(description.length == 0){
			if(checkflag == updatecheck){
				$("#edit_descriptionTipDivId").html("<font color='red'>请填写公司简介</font>");
				$("#edit_descriptionTipDivId").show();
			}else
				$("#edit_descriptionTipDivId").html("0/2000");
			return false;
		}else if(getCountWithoutHtml(description) > 2000){
			$("#edit_descriptionTipDivId").html("<font color='red'>字数必须在2000个以内</font>");
			$("#edit_descriptionTipDivId").show();
			return false;
		}else
			$("#edit_descriptionTipDivId").html(getCountWithoutHtml(description)+"/2000");
		return true;
	}
	/**
	 * 更新商家简介
	 */
	function updateDescription(){
		
		
		var description = trim(descriptionDocument.body.innerHTML);
		description = removeNullHtml(description);
		description = description == "你可以在此输入最新简介。" ? "" : description;
		description = wrapWithPTag(description);
		if(!checkDescription(description,"updatecheck")){
			return;
		}
		$("#dLoadingDiv").css("display", "block");
		$("#edit_updateDescription_button").attr("disabled",true);
		$.ajax({
			cache:false,
			url:"/userManage/userManageVoidAction!updateUserInfo.action",
			type:"post",
			dataType:"json",
			data:{description:description},
			success:updateDescription_success,
			error:function(){
				$("#dLoadingDiv").css("display", "none");
				$("#edit_updateDescription_button").attr("disabled",false);
			}
		});
	}
	
	/**
	 * 验证商家公告
	 */
	function checkNotice(notice, checkflag){
		if(notice.length == 0){
			if(checkflag == updatecheck){
				$("#edit_noticeTipDivId").html("<font color='red'>请填写公司公告</font>");
				$("#edit_noticeTipDivId").show();
			}else
				$("#edit_noticeTipDivId").html("0/2000");
			return false;
		}else if(getCountWithoutHtml(notice) > 2000){
			$("#edit_noticeTipDivId").html("<font color='red'>字数必须在2000个以内</font>");
			$("#edit_noticeTipDivId").show();
			return false;
		}else
			$("#edit_noticeTipDivId").html(getCountWithoutHtml(notice)+"/2000");
		return true;
	}
	
	
	function removeNullHtml(str){
			str = str.replace(/<P[^<^>]*>\s*<\/P>/g,"");  
			str = str.replace(/<p[^<^>]*>\s*<\/p>/g,"");  
			str = str.replace(/<FONT[^<^>]*>\s*<\/FONT>/g,""); 
			str = str.replace(/<font[^<^>]*>\s*<\/font>/g,"");
			return str;
	}
/**
 * 标准格式化文本内容每个段落 wrap with p tag
 */
	function wrapWithPTag(str){
		if(str.length == 0)
			return str;
		var temp = str.substring(0,2) == "<P" ? true : false;
		if(str.substring(0,2) == "<P" || str.substring(0,2) == "<p"){

			return str;
		}
		if(temp == true){
			str = str.replace(/<P[\s^<P.*>]*>|<\/P><P[\s^<P.*>]>/,"</P><P>");
			str = "<P>" + str;	 
		}else{
			str = str.replace(/<p[\s^<p.*>]*>|<\/p><p[\s^<p.*>]>/,"</p><p>");
			str = "<p>" + str;
		}
		return str;
	}	
	
	/**
	 * 更新商家公告
	 */
	function updateNotice(){
		var notice = trim(noticeDocument.body.innerHTML); 
		notice = removeNullHtml(notice);
		notice = notice == "你可以在此输入最新公告。" ? "" : notice;
		notice = wrapWithPTag(notice);
		if(!checkNotice(notice,"updatecheck")){
			return;
		}
		$("#nLoadingDiv").css("display", "block");
		$("#edit_updateNotice_button").attr("disabled",true);
		$.ajax({
			cache:false,
			url:"/userManage/userManageVoidAction!updateUserInfo.action",
			type:"post",
			dataType:"json",
			data:{notice:notice},
			success:updateNotice_success,
			error:function(){
				$("#nLoadingDiv").css("display", "none");	
				$("#edit_updateNotice_button").attr("disabled",false);
			}
		});
	}
	
	function checkName(name, checkflag){
		if(name.length == 0){
			if(checkflag == updatecheck){
				$("#edit_nameTipDivId").html("<font color='red'>请填写名字</font>");
				$("#edit_nameTipDivId").show();
			}else
				$("#edit_nameTipDivId").html("只能用中文姓名");
			return false;
		}else if(!isChina(name)){
			$("#edit_nameTipDivId").html("<font color='red'>只能用中文姓名</font>");
			$("#edit_nameTipDivId").show();
			return false;
		}else if(name.length > 6 || name.length < 2){
			$("#edit_nameTipDivId").html("<font color='red'>字数必须在2-6以内</font>");
			$("#edit_nameTipDivId").show();
			return false;
		}else
			$("#edit_nameTipDivId").html("只能用中文姓名");
		return true;
	}
	function checkTelephone(telephone, checkflag){
		if(telephone.length == 0){
			if(checkflag == updatecheck){
				$("#edit_telephoneTipDivId").html("<font color='red'>请填写电话</font>");
				$("#edit_telephoneTipDivId").show();
			}else
				$("#edit_telephoneTipDivId").hide();
			return false;
		}else if(telephone.length > 30){
			$("#edit_telephoneTipDivId").html("<font color='red'>数字太长</font>");
			$("#edit_telephoneTipDivId").show();
			return false;
		}else if(!checkPhone(telephone)){
			$("#edit_telephoneTipDivId").html("<font color='red'>电话填写不正确</font>");
			$("#edit_telephoneTipDivId").show();
			return false;
		}else
			$("#edit_telephoneTipDivId").hide();
		return true;
	}
	function checkMobile1(mobile, checkflag){
		if(mobile.length == 0){
			if(checkflag == updatecheck){
				$("#edit_mobileTipDivId").html("<font color='red'>请填写手机</font>");
				$("#edit_mobileTipDivId").show();
			}else
				$("#edit_mobileTipDivId").hide();
			return false;
		}else if(mobile.length > 20){
			$("#edit_mobileTipDivId").html("<font color='red'>数字太长</font>");
			$("#edit_mobileTipDivId").show();
			return false;
		}else if(!checkPhone(mobile)){
			$("#edit_mobileTipDivId").html("<font color='red'>手机填写不正确</font>");
			$("#edit_mobileTipDivId").show();
			return false;
		}else
			$("#edit_mobileTipDivId").hide();
		return true;
	}
	function checkQq(qq, checkflag){
		var qqReg = new RegExp("^[0-9]{5,15}$");
	 	if(qq.length == 0){
	 		if(checkflag == updatecheck){
				$("#edit_qqTipDivId").html("<font color='red'>请填写QQ号码</font>");
				$("#edit_qqTipDivId").show();
			}else
				$("#edit_qqTipDivId").hide();
			return false;
		}else{
			var qqs = qq.split(",");
			if(qqs.length > 5){
				$("#edit_qqTipDivId").html("<font color='red'>最多可以填写５个</font>");
				$("#edit_qqTipDivId").show();
				return false;	
			}
			for(var i=0;i<qqs.length;i++){
				var q = trim(qqs[i]);
				if(!qqReg.test(q)){
					$("#edit_qqTipDivId").html("<font color='red'>QQ号码不合法</font>");
					$("#edit_qqTipDivId").show();
					return false;		
				}
			}
		}
		return true;
	}
	function checkMsn(msn, checkflag){
	 	if(msn.length == 0){
	 		if(checkflag == updatecheck){
	 			return true;
				//$("#edit_msnTipDivId").html("<font color='red'>请填写MSN</font>");
				//$("#edit_msnTipDivId").show();
			}else
				$("#edit_msnTipDivId").hide();
			return false;
		}else if(!isEmail(msn)){
			$("#edit_msnTipDivId").html("<font color='red'>MSN格式不正确</font>");
			$("#edit_msnTipDivId").show();
			return false;		
		}else
			$("#edit_msnTipDivId").hide();
		return true;
	}
	/**
	 * 验证个人信息
	 */
	function checkUserInfo(name,telephone,mobile,qq,msn){
		if(!checkName(name,updatecheck))return false;
		if(!checkTelephone(telephone,updatecheck))return false; 
		if(!checkMobile1(mobile,updatecheck))return false;
		if(!checkQq(qq,updatecheck))return false;
		//if(!checkMsn(msn,updatecheck))return false;	
		return true;
	}
	/**
	 * 更新个人信息
	 */	
	function updateUserInfo(){ 
		var name = conversion(trim($("#edit_name").val()));
		var telephone = conversion(trim($("#edit_telephone").val()));
		var mobile = conversion(trim($("#edit_mobile").val()));
		var qq = conversion(trim($("#edit_qq").val()));
		var msn = conversion(trim($("#edit_msn").val()));
		
		if(!checkUserInfo(name,telephone,mobile,qq,msn)){
			return;
		}
		$("#edit_updateUserInfo_button").attr("disabled",true);
		$.ajax({
			cache:false,
			url:"/userManage/userManageVoidAction!updateUserInfo.action",
			type:"post",
			dataType:"json",
			data:{name:name,telephone:telephone,mobile:mobile,qq:qq,msn:msn},
			success:updateUserInfo_success,
			error:ajax_error
		});
	}
	function checkBln(bln, checkflag){
		if(bln.length == 0){
			if(checkflag == updatecheck){
				$("#edit_blnTipDivId").html("<font color='red'>请填写营业注册号码</font>");
				$("#edit_blnTipDivId").show();
			}else
			{
				$("#edit_blnTipDivId").hide(); 
			}
			return false;
		}else if(bln.length > 20 || bln.length < 10){
			$("#edit_blnTipDivId").html("<font color='red'>字符必须在10-20个以内</font>");
			$("#edit_blnTipDivId").show();
			return false;
		}else
		{
			$("#edit_blnTipDivId").hide();
		}
		return true;
	}
	function checkCr(cr, checkflag){
		if(cr.length == 0){
			if(checkflag == updatecheck){
				$("#edit_crTipDivId").html("<font color='red'>请填写法人姓名</font>");
				$("#edit_crTipDivId").show();
			}else
			{
				$("#edit_crTipDivId").hide();
			}
			return false;
		}else if(cr.length > 6 || cr.length < 2){
			$("#edit_crTipDivId").html("<font color='red'>字符必须在2-6个以内</font>");
			$("#edit_crTipDivId").show();
			return false;
		}else
		{
			$("#edit_crTipDivId").hide();
		}
			
		return true;
	}
	/**
	 * 验证营业信息
	 */
	function checkBlnCr(bln,cr){
		if(!checkBln(bln,updatecheck))return false;
		if(!checkCr(cr,updatecheck))return false;
		return true;
	}
	
/**
 * 个人资料完整性计算
 * 用于认证前检测
 */
function computerDataFullPercentForUpdateBlnCr(){
	var url = "/publicAction/getServerDataAction!computerDataFullPercent.action",
			 	type = "post",
			 	dataType = "json",
			 	cache = false;	
		$.ajax({
			cache:cache,
			url:url,
			type:type,
			dataType:dataType,
			data:{},
			success:function(json){
				if (json.responseValue!=null&&json.responseValue<100)
				{
					if (json.responseValue1<5)//其他资料未填
						deleteAndDisable3(3,json.responseValue1,null,"请先完善你的资料后,再提交企业认证资料");
					else
						updateBlnCr();
				}
				else updateBlnCr();//都填完了
			},
			error:ajax_error
		});
}
	
	
	/**
	 * 更新营业信息
	 */	
	function updateBlnCr(){
		var bln = conversion(trim($("#edit_bln").val()));
		var cr = conversion(trim($("#edit_cr").val()));
		if(!checkBlnCr(bln,cr)){
			return;
		}
		$("#edit_updateBlnCr_button").attr("disabled",false);
				$.ajax({
				cache:false,
				url:"/userManage/userManageVoidAction!updateUserInfo.action",
				type:"post",
				dataType:"json",
				data:{bln:bln,cr:cr},
				success:updateBlnCr_success,
				error:ajax_error
			});

	}
	
	function checkOldPass(oldPass, checkflag){ 
		if(oldPass.length == 0){
			if(checkflag == updatecheck){
				$("#edit_oldPassIdTipDivId").html("<font color='red'>请填写旧密码</font>");
				$("#edit_oldPassIdTipDivId").show();
			}else
				$("#edit_oldPassIdTipDivId").hide();
			return false;
		}else if(oldPass.length > 16 || oldPass.length < 6){
			$("#edit_oldPassIdTipDivId").html("<font color='red'>字符必须在6-16个以内</font>");
			$("#edit_oldPassIdTipDivId").show();
			return false;
		}else
			$("#edit_oldPassIdTipDivId").hide();
		return true;
	}
	function checkNewPass(newPass, checkflag){
		if(newPass.length == 0){
			if(checkflag == updatecheck){
				$("#edit_newPassIdTipDivId").html("<font color='red'>请填写新密码</font>");
				$("#edit_newPassIdTipDivId").show();
			}else
				$("#edit_newPassTipDivId").hide();
			return false;
		}else if(newPass.length > 16 || newPass.length < 6){
			$("#edit_newPassIdTipDivId").html("<font color='red'>字符必须在6-16个以内</font>");
			$("#edit_newPassIdTipDivId").show();
			return false;
		}else
			$("#edit_newPassIdTipDivId").hide();
		return true;
	}
	function checkRePass(rePass, checkflag){
		if(rePass.length == 0){
			if(checkflag == updatecheck){
				$("#edit_rePassIdTipDivId").html("<font color='red'>请填写确认密码</font>");
				$("#edit_rePassIdTipDivId").show();
			}else
				$("#edit_rePassTipDivId").hide();
			return false;
		}else if(rePass.length > 16 || rePass.length < 6){
			$("#edit_rePassIdTipDivId").html("<font color='red'>字符必须在6-16个以内</font>");
			$("#edit_rePassIdTipDivId").show();
			return false;
		}else
			$("#edit_rePassIdTipDivId").hide();	
		return true;
	}
	/**
	 * 验证密码
	 */
	function checkPass(oldPass,newPass,rePass){ 
		if(!checkOldPass(oldPass, updatecheck))return false;
		if(!checkNewPass(newPass, updatecheck))return false;
		if(!checkRePass(rePass, updatecheck))return false;
		if(newPass != rePass){
			$("#edit_rePassIdTipDivId").html("<font color='red'>确认密码和新密码不匹配</font>");
			$("#edit_rePassIdTipDivId").show();
			return false;
		}else
			$("#edit_rePassIdTipDivId").hide();
		return true;
	}
	/**
	 * 更新密码
	 */	
	function updatePass(){ 
		var oldPass = conversion(trim($("#edit_oldPassId").val()));

		var newPass = conversion(trim($("#edit_newPass").val()));
		var rePass = conversion(trim($("#edit_rePass").val()));
			
		if(!checkPass(oldPass,newPass,rePass)){
			return;
		}				 
		if(trim($("#systemOutPass").val()).length == 32){
			oldPass = trim($("#systemOutPass").val());
		}
		$("#edit_updatePass_button").attr("disabled",true);
		$.ajax({
			cache:false,
			url:"/userManage/userManageVoidAction!updateUserInfo.action",
			type:"post",
			dataType:"json",
			data:{oldPass:oldPass,newPass:newPass},
			success:updatePass_success,
			error:ajax_error
		});
	}
	/**
	 * 上广告图片action
	 */	
	function uploadComAdvitisementPic(){
		if($("#uploadComAdPic").val() == ""){
			return false;
		}
		$("#forLoadingDivId").html("<center><img src='/img/loading.gif'/></center>");
		$.ajaxFileUpload({
			url:'/userPicManager/uploadComAdPicAction!uploadComAdPicture.action',
			secureuri:false,
			type:'post',
			fileElementId:"uploadComAdPic",
			dataType: 'json',
			success:function(json){
				if(json.isDimensionLegal == "true"){
					$("#companyAdvertisementPic").attr("src", "/"+json.companyAdPicturePath+"/"+json.fileRealName);
					closeFloating();
				}else{
					alertFloating(json.isDimensionLegal);
					$("#forLoadingDivId").html("");
				}
			},
			error:function(json){
				alertFloating("你上传的图片太大了,上传的图片应小于500KB");
			}
		});
		return false;
	}
	
/**
 * 获取店铺广告图片
 * targetType: 获取店铺广告图片："ad_"，用户个人图片："photo_"，公司logo："logo_"
 */
	function getPicture(targetType,targetDiv, friendid){
		var url = "/userPicManager/uploadPictureAction!LastUploadPictureFullPath.action";
		$.ajax({
			cache:false,
			url:url,
			type:"post",
			dataType:"json",
			data:{targetDiv:targetDiv,targetType:targetType,friendid:friendid},
			success:function(json){ 
				if (json.targetDiv == 'companyAdvertisementPic')//公司广告图片
				{
					var companyname = '';
						companyname = $("#card_companyname").text();
					if (json.userid!=json.friendid)//看别人的店铺
					{
						if (json.fileFullPath!=null)//没有图片
						{
							try
							{
								if (checkEndWith(json.fileFullPath,"default.jpg")==true)
								{
									$("#"+targetDiv).attr("src","/"+json.fileFullPath);
								}else $("#"+targetDiv).attr("src","/"+json.fileFullPath);
							}catch(Exception){
								$("#"+targetDiv).attr("src","/"+json.fileFullPath);
							}
						}else $("#"+targetDiv).attr("src","/"+json.fileFullPath); 
					}else//自已看自已
						$("#"+targetDiv).attr("src","/"+json.fileFullPath) ;
				}else
					$("#"+targetDiv).attr("src","/"+json.fileFullPath) ;
			},
			error:ajax_error
		});
	}


/**
 * 获取用户图片
 */
	function getUserPicture(userid,targetDiv){
		var url = "/userPicManager/uploadPictureAction!LastUploadPictureFullPath.action";
		$.ajax({
			cache:false,
			url:url,
			type:"post",
			dataType:"json",
			data:{targetDiv:targetDiv,targetType:targetType,
					userid:userid},
			success:function(json){$("#"+targetDiv).attr("src","/"+json.fileFullPath)},
			error:ajax_error

		});
	}
	
	
    function initQq(qq){//friendid
    	var friendid = $("#friendid").val();
    	var userid = $("#userid").val();
    	var result = '在线联系：';
    	if (qq!=null&&qq!='')
    		qq = trim(qq);
    	var qqs = null;
    	if(qq == null || qq == '')
    		if(friendid != userid)
    			result = '在线联系：<a href="javascript:void(0)">暂无QQ</a>';
    		else
    			result = '在线联系：<a href="javascript:void(0)" onclick="gotoCompanyEditPage();hideOtherIdTabs(\'#edit_GRXX\');return false;">暂无QQ</a>';
    	else if (qq.indexOf(",")!=-1)
    	{
    		qqs = qq.split(",");
	    	for(var i=0;i<qqs.length;i++){
	    		result += '<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin='+trim(qqs[i])+'&Site=qq&Menu=yes"><img border="0" align="absmiddle" src="http://wpa.qq.com/pa?p=2:'+trim(qqs[i])+':46" alt="点击这里给该商家发消息" onerror="this.src=\'/img/noQQ.jpg\'"/></a>';
	    	}
    	}else
     		result += '<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin='+qq+'&Site=qq&Menu=yes"><img border="0" align="absmiddle" src="http://wpa.qq.com/pa?p=2:'+qq+':46" alt="点击这里给该商家发消息" onerror="this.src=\'/img/noQQ.jpg\'"/></a>';
 		$("#qqDivId").html(result);
    }
 
	function getUserByUserID(userid,targetDiv,targetType) {
		if (targetType==null) {
			targetType = "default";
		}
		var url = "/userManage/userManageEntityAction!UserByUserID.action";
	 	type = "post",
	 	dataType = "json",
	 	cache = false;
		$.ajax({
			cache:cache,
			url:url,
			type:type,
			dataType:dataType,
			data:{targetDiv:targetDiv,targetType:targetType,
					userid:userid},
			success:getUserByUserID_success,
			error:ajax_error
		});
		
		if(document.getElementById("button_a")){
			document.getElementById("button_a").disabled = true;
		}
	}
