
function debug(title){}
var UserCard=function(_config){this.select=_config.select;this.attr=_config.attr;this.left=_config.left;this.top=_config.top;this.target='#user_card';this.data=new Array();this.temp='<div class="user_card_loading"><img src="http://site.hellochina.com/img/ajax_waiting4.gif" /></div>';this.win='<dl class="cls_dl_03 user_card_win"><dt><a onclick="$.unblockUI()" href="javascript:void(0)"></a>@title</dt><dd>@content</dd></dl>';this.init();}
UserCard.prototype.init=function(){_this=this;var html='<div id="user_card" class="user_card hidden">'+_this.temp+'</div>';$('body').append(html);var hideTimer=null;var showTimer=null;$(_this.select).each(function(){var _self=$(this);_self.hover(function(e){_member_id=_self.attr(_this.attr);_isonline=_self.attr('isonline');showTimer=setTimeout(function(){_this.getData(_member_id,_isonline);$(_this.target).bgiframe();$(_this.target).css({'position':'absolute','display':'block','top':_self.offset().top+_self.outerHeight()+_this.top,'left':_self.offset().left+_this.left}).show();},500);},function(e){if(showTimer)
clearTimeout(showTimer);if(hideTimer)
clearTimeout(hideTimer);hideTimer=setTimeout(function(){if($(e.relatedTarget).attr('id')!=_this.target&&$(e.relatedTarget).attr('class')!='bgiframe'){$(_this.target).hide().html(_this.temp);}},200);});$(_this.target).hover(function(){if(showTimer)
clearTimeout(showTimer);if(hideTimer)
clearTimeout(hideTimer);},function(){if(showTimer)
clearTimeout(showTimer);if(hideTimer)
clearTimeout(hideTimer);hideTimer=setTimeout(function(){$(_this.target).hide().html(_this.temp);},200);});});}
UserCard.prototype.getData=function(member_id,isonline){var _this=this;_data=_this.data[member_id];if(typeof(_data)=="undefined"){$.ajax({type:"GET",url:'/user/getMiniProfile',data:'member_id='+member_id,dataType:'json',success:function(res){if(res.status=='ok'){_this.data[member_id]=res.data;_this.render(res.data,isonline);}}});}else{_this.render(_data,isonline);}}
UserCard.prototype.render=function(data,isonline){var _this=this;var html='<a class="user_card_avatar" href="@url"><img src="@avatar" /></a><div class="user_card_info"><h5><a href="@url">@nickname</a><span class="user_card_@isonline">&nbsp;</span><span class="gray2">@gender</span></h5>@headline @location @language @usercaeraction</div>@description @membership';html=html.replace(/@nickname/g,data.fullname);html=html.replace(/@url/g,data.url);html=html.replace(/@avatar/g,data.avatar);if(data.headline!=null&&data.headline!=''){html=html.replace(/@headline/g,'<span class="user_card_headline">'+data.headline+'</span><br />');}else{html=html.replace(/@headline/g,'');}
if(data.description!=null&&data.description!=''){html=html.replace(/@description/g,'<p>'+data.description+'</p>');}else{html=html.replace(/@description/g,'');}
if((data.city==null||data.city=='')&&(data.country==null||data.country=='')){html=html.replace(/@location/g,'');}else{html=html.replace(/@location/g,data.i18n_location+' : '+data.city+', '+data.country+'<br />');}
if(data.language!=null&&data.language!=''){html=html.replace(/@language/g,data.i18n_language+' : '+data.language);}else{html=html.replace(/@language/g,'');}
if(data.status=='0'){html=html.replace(/@usercaeraction/g,'');}else if(data.status=='1'){html=html.replace(/@usercaeraction/g,'<div class="user_card_action"><a title="@i18n_add" class="user_card_addfriend" href="javascript:void(0)"></a></div>');}else if(data.status=='2'){html=html.replace(/@usercaeraction/g,'<div class="user_card_action"><a title="@i18n_send" class="user_card_sendmsg" href="javascript:void(0)"></a></div>');}
html=html.replace(/@gender/g,data.gender);html=html.replace(/@membership/g,data.membership);html=html.replace(/@mark/g,data.mark);html=html.replace(/@addfriend/g,data.addfriend);html=html.replace(/@i18n_send/g,data.i18n_send);html=html.replace(/@i18n_add/g,data.i18n_add);html=html.replace(/@isonline/g,isonline);$(_this.target).html(html);_this.bind(data);}
UserCard.prototype.bind=function(data){var _this=this;$(_this.target+' .user_card_avatar').hover(function(){$(this).parent().find('p').show();},function(){$(this).parent().find('p').hide();});if(data.status=='1'){var html=_this.win;html=html.replace(/@title/g,data.i18n_add);$(_this.target+' a.user_card_addfriend').click(function(){$.ajax({type:"GET",url:data.addfriend_url,dataType:'json',success:function(res){if(res.status=='ok'){html=html.replace(/@content/g,res.msg);$.blockUI({message:html,css:{width:'570px',left:($(window).width()-570)/2+'px',top:($(window).height()-310)/2+'px',cursor:'default'},centerX:true,centerY:true,overlayCSS:{backgroundColor:'#000',opacity:'0.4'}});}else{alert(res.msg);}}});});}else if(data.status=='2'){$(_this.target+' a.user_card_sendmsg').click(function(){window.location.href=data.sendmsg_url;});}}
