$(function () {
    // type 1 关注按钮 0 取消关注
	if(PI.userid==0){
		  $('.iwbFollowControl').bind("click",function(){
			  var Sys = {};
		        var ua = navigator.userAgent.toLowerCase();
		        if (window.ActiveXObject)
		            {Sys.ie = ua.match(/msie ([\d.]+)/)[1];}
		        
		        //ie下
		        if(Sys.ie) {var r = confirm("你还没有登录,马上登录？");if(r){
		        	setTimeout(function(){
					var url=U('/user/login');
					 document.write("<a id='goa' href='"+url+"' style='display:none;'>a</a>");
					 try{ document.getElementById("goa").click();}catch(e){}
					 window.location.href = url;
		        	},1);
					}return;}

		        //非ie
				  var self=$(this).offset();
				    IWB_DIALOG.confirmbox({
						text:'你还没有登录',
						textok:'马上登录',
						top:self.top+20,
						left:self.left,
						ok:function(){
						  window.location.href=U('/user/login');
						}
					}) ; 
		  });
		  return;	
		}else{
	  var posConfig = {
        0: {
             0:["-52px", "-27px"]
            ,1:["-52px", "0px"]
           }
       ,1: {
             0:["0px", "-20px"]
            ,1:["0px", "0px"]
           }
    };
	// IWB_DIALOG.modaltipbox("warning","关注失败");
		// IWB_DIALOG.modaltipbox("warning","关注失败");
	    $(".iwbFollowControl").live({
	        click: function () {
				if(PI.userid==0){return false;}

	            var self = $(this);
	            var styleid = self.attr("data-styleid");
	            var type = self.attr("data-type");
	            var name = self.attr("data-name");

	            switch (type) {
	                case "0": // 取消关注
	                IWB_API.unfollow("unfollow", name, function (identity ,response) {

					//dump(response)
	                    if (response.ret === 0) { // 取消关注成功
	                        self.attr("data-type",1); // 标记按钮为关注按钮
	                        self.attr("title","关注");
							self.first().html("<span>关注</span>");
							self.addClass('btn-import');
	                    } else {
	                        IWB_DIALOG.modaltipbox("warning",response.msg)
	                    }
	                });
	                break;
	                case "1": // 关注
	                IWB_API.follow("unfollow", name, function (identity ,response) {
	                    if (response.ret === 0) { // 关注成功

	                        self.attr("data-type",0); // 标记按钮为取消关注按钮
	                        self.attr("title","取消关注");
							self.first().html("<span>取消关注</span>");
							self.removeClass('btn-import');
	                    } else {
	                        IWB_DIALOG.modaltipbox("warning",response.msg);
	                    }
	                });
	                break;
	            }
	        }
	});
 
	}
});2950
