MemberInterest={likeCallbacks:new Array(),unlikeCallbacks:new Array(),viewAllLinkFunctions:new Array(),errorDisplays:new Array(),click:new Array(),init:function(){MemberInterest.addUnlikeCallbackByType('member',function(result){MemberInterest.updateActionIcons(result,false)})},addLikeCallbackByType:function(type,callback){if(typeof(callback)=='function'){if(typeof MemberInterest.likeCallbacks[type]==='undefined'){MemberInterest.likeCallbacks[type]=new Array()}MemberInterest.likeCallbacks[type].push(callback)}else{throw('MemberInterest.js: callback must be a function')}},setViewAllLinkFunctionByType:function(type,viewAllLinkFunction){if(typeof(viewAllLinkFunction)=='function'){MemberInterest.viewAllLinkFunctions[type]=viewAllLinkFunction}else{throw('MemberInterest.js: viewAllLinkFunction must be a function')}},addUnlikeCallbackByType:function(type,callback){if(typeof(callback)=='function'){if(typeof MemberInterest.unlikeCallbacks[type]==='undefined'){MemberInterest.unlikeCallbacks[type]=new Array()}MemberInterest.unlikeCallbacks[type].push(callback)}else{throw('MemberInterest.js: callback must be a function')}},setErrorDisplayByType:function(type,errorDisplayFunction){if(typeof(errorDisplayFunction)=='function'){MemberInterest.errorDisplays[type]=errorDisplayFunction}else{throw('MemberInterest.js: errorDisplayFunction must be a function')}},setClickFunction:function(type,clickFunction){if(typeof(clickFunction)=='function'){MemberInterest.click[type]=clickFunction}else{throw('MemberInterest.js: clickFunction must be a function')}},like:function(type,item,poster,errorContainer){$.ajax({url:SITE_URL+'apps/memberinterests/like',data:{type:type,item:item,poster:poster},dataType:'jsonp',success:function(result){if(result.result===true){for(var functionIndex in MemberInterest.likeCallbacks[result.type]){MemberInterest.likeCallbacks[result.type][functionIndex](result)}}else{MemberInterest.errorDisplay(type,result.result,errorContainer)}},error:function(result){MemberInterest.errorDisplay(type,'Sorry, but your request could not be completed at this time.',errorContainer)}})},updateActionIcons:function(result,becameFan){if(result.result){if(becameFan===false){if(typeof ActionIcons.members['_'+result.item]!=='undefined'){ActionIcons.members['_'+result.item].isViewerInterested=false;$('div.actionIcons[data-memberId='+result.item+']').each(function(){ActionIcons.initDiv($(this))})}}}},unlike:function(type,item,errorContainer,callback){$.ajax({url:SITE_URL+'apps/memberinterests/unlike',data:{type:type,item:item},dataType:'jsonp',success:function(result){if(result.result===true){for(var functionIndex in MemberInterest.unlikeCallbacks[result.type]){MemberInterest.unlikeCallbacks[result.type][functionIndex](result)}if(typeof callback==='function'){callback(result)}}else{MemberInterest.errorDisplay(type,result.result,errorContainer)}},error:function(result){MemberInterest.errorDisplay(type,'Sorry, but your request could not be completed at this time.',errorContainer)}})},unlikeAndGetObjects:function(type,item,limit,offset,errorHandler){$.ajax({url:SITE_URL+'apps/memberinterests/unlike',data:{type:type,item:item,limit:limit,offset:offset,displayType:'objects'},dataType:'jsonp',success:function(result){if(result.result===true){for(var functionIndex in MemberInterest.unlikeCallbacks[result.type]){MemberInterest.unlikeCallbacks[result.type][functionIndex](result)}}else{if(typeof errorHandler==='function'){errorHandler(result)}}}})},displayInterestedMembers:function(displayType,interestType,offset,limit,clickedItem,itemId,errorContainer,resultAppendArea,callback){var interestedMembersContainer=$('div.interestedMembers',resultAppendArea);$.ajax({url:SITE_URL+'apps/memberinterests/interestedmembers',dataType:'jsonp',data:{displayType:displayType,interestType:interestType,itemId:itemId,limit:limit,offset:offset},success:function(result){if(result.result===true){interestedMembersContainer.remove();interestedMembersContainer=$(result.markup).appendTo(resultAppendArea);if(displayType=='large'){$('span.interestedMembersNext',interestedMembersContainer).one('click',function(){MemberInterest.displayInterestedMembers(displayType,interestType,offset+10,limit,$(this),itemId,errorContainer,resultAppendArea)});$('span.interestedMembersPrev',interestedMembersContainer).one('click',function(){MemberInterest.displayInterestedMembers(displayType,interestType,offset-10,limit,$(this),itemId,errorContainer,resultAppendArea)})}else if(displayType=='small'&&typeof(MemberInterest.viewAllLinkFunctions[interestType]=='function')){$('span.viewAllInterestedMembers',interestedMembersContainer).bind('click',MemberInterest.viewAllLinkFunctions[interestType])}if(clickedItem.hasClass('showInterestedMembers')){clickedItem.one('click',function(){$('div.interestedMembers',resultAppendArea).remove();clickedItem.one('click',function(){MemberInterest.displayInterestedMembers(displayType,interestType,0,limit,clickedItem,itemId,errorContainer,resultAppendArea)})})}}else{interestedMembersContainer.remove();MemberInterest.errorDisplay(interestType,'Sorry, but your request could not be completed at this time.',errorContainer);if(clickedItem.hasClass('showInterestedMembers')){clickedItem.one('click',function(){MemberInterest.displayInterestedMembers(displayType,interestType,0,limit,clickedItem,itemId,errorContainer,resultAppendArea)})}}if(typeof(callback)=='function'){callback(result)}},error:function(result){interestedMembersContainer.remove();MemberInterest.errorDisplay(interestType,'Sorry, but your request could not be completed at this time.',errorContainer);if(clickedItem.hasClass('showInterestedMembers')){clickedItem.one('click',function(){MemberInterest.displayInterestedMembers(displayType,interestType,0,limit,clickedItem,itemId,errorContainer,resultAppendArea)})}}})},setClick:function(type,item){if(typeof(MemberInterest.click[type])=='function'){item.bind('click',MemberInterest.click[type])}},errorDisplay:function(type,message,container){if(typeof(MemberInterest.errorDisplays[type])=='function'){MemberInterest.errorDisplays[type](message,container)}}};MemberInterest.init();