HD.ShareWidget=function(A){var C=HD.ShareWidget.SERVICES;
this.config=A||{};
this.config.embedMode=this.config.embedMode||false;
this.config.standaloneMode=this.config.standaloneMode||false;
this.config.previewLength=this.config.previewLength||0;
this.config.services=this.config.services||[C.DIGG,C.FACEBOOK,C.TWITTER];
this.config.getPermalink=this.config.getPermalink||function(F,D,E){return F.facade.generatePermalink()
};
this.config.useShareAPI=this.config.useShareAPI==null?true:this.config.useShareAPI;
this.config.callback=this.config.callback||function(D,F,H,E,I,G){};
for(var B=this.config.services.length-1;
B>=0;
B--){if(typeof this.config.services[B]=="string"){this.config.services[B]=this.getService(this.config.services[B]);
if(!this.config.services[B]){this.config.services[B].splice(B,1)
}}}this.observers=[];
this.loadTemplates(arguments.callee)
};
HD.ShareWidget.SERVICES={BLOGGER:{name:"Blogger",url:null,callback:null},DELICIOUS:{name:"Delicious",url:null,callback:null},DIGG:{name:"Digg",url:null,callback:null},FACEBOOK:{name:"Facebook",url:null,callback:null},FRIENDFEED:{name:"Friendfeed",url:null,callback:null},GOOGLE:{name:"Google",url:null,callback:null},LINKEDIN:{name:"Linked In",url:null,callback:null},MAGNOLIA:{name:"Magnolia",url:null,callback:null},MIXX:{name:"Mixx",url:null,callback:null},MYSPACE:{name:"MySpace",url:null,callback:null},NEWSVINE:{name:"NewsVine",url:null,callback:null},REDDIT:{name:"Reddit",url:null,callback:null},SLASHDOT:{name:"Slashdot",url:null,callback:null},STUMBLEUPON:{name:"Stumble Upon",url:null,callback:null},TECHNORATI:{name:"Technorati",url:null,callback:null},TWITTER:{name:"Twitter",url:null,callback:null},WORDPRESS:{name:"Wordpress",url:null,callback:null}};
HD.ShareWidget.templates={shareLabel:"Share: ",getShareLabel:function(){return this.shareLabel
},getHtml:function(){return this.html
},html:'		<div class="${classes.SHARE} ${classes.WIDGET}">			<span>${templates.getShareLabel()}</span>			<ul>			{for service in config.services}				<li class="${service|getClass} ${hooks.ITEMSHARE}">					<a class="${hooks.ITEMLINK}" 						{if _MODIFIERS.getUrl(service,media)}							href="${service|getUrl:media}" target="_blank"						{else}							href="javascript:void(0)"						{/if}					></a>					<div><span>${service.name}</span></div></li>			{/for}			</ul>		</div>		<div class="${classes.SHARE}Clear"></div>'};
(function(){var A=HD.CSS_CLASSES;
HD.ShareWidget.hooks={ITEMSHARE:A.SHARE+"-item",ITEMLINK:A.SHARE+"-link"}
})();
HD.ShareWidget.prototype={setListeners:function(D){if(!D){return 
}var A=this;
var B=HD.getByClass(this.config.hooks.ITEMLINK,"*",this.getParent());
var E=HD.getByClass(this.config.hooks.ITEMSHARE,"*",this.getParent());
for(var C=0;
C<this.config.services.length;
C++){if(E[C]){E[C].onmouseover=function(){HD.addClass(this,HD.CSS_CLASSES.SHARE+"Hover")
};
E[C].onmouseout=function(){HD.removeClass(this,HD.CSS_CLASSES.SHARE+"Hover")
}
}(function(){var F=A.config.services[C];
if(B[C]){B[C].onclick=function(){A.notifyObservers("share",{service:F,media:D});
HD.util.Analytics.track(A.analyticsShareString(F,D));
if(F.callback){F.callback(D)
}if(A.config.callback){var G=HD.util.Common.stripHtmlTags(D.description);
if(A.config.useShareAPI&&window.HDSocial){HDSocial.hdSocialShare(A.getServiceHash(F),A.config.getPermalink(D,F,A.config),D.title,HD.util.Common.ellipseText(G,A.config.previewLength||G.length),D.thumbUrl,null,null,D)
}A.config.callback(F,A.config.getPermalink(D,F,A.config),D.title,HD.util.Common.ellipseText(G,A.config.previewLength||G.length),D.thumbUrl,D)
}}
}})()
}},update:function(A,B){if(this.config.standaloneMode){if(A=="loadShare_Start"){this.render(B)
}}else{if(!this.config.embedMode){if(A=="getMedium_Start"){this.loading(true)
}else{if(A=="getMedium_Finish"){this.loading(false);
this.render(B)
}else{if(A=="activeItem_Change"){this.render(B)
}}}}}},getHtml:function(B){if(!B){return 
}var A=this;
return this.processTemplate(this.config.templates.getHtml(),{media:B,_MODIFIERS:{getClass:function(C){return A.getClass(C)
},getUrl:function(C,D){return A.getUrl(C,D)
}}})
},getServiceHash:function(A){return A.name.replace(/\s+/g,"").toLowerCase()||null
},getService:function(A){return HD.ShareWidget.SERVICES[A.replace(/\s+/g,"").toUpperCase()]||null
},getClass:function(A){return HD.CSS_CLASSES.SHARE+A.name.replace(/\s+/g,"")
},getUrl:function(A,C){if(A.url){var B=A.url;
B=B.replace(/\{permalink\}/,encodeURIComponent(this.config.getPermalink(C)));
B=B.replace(/\{title\}/,encodeURIComponent(C.title));
B=B.replace(/\{thumbnail\}/,encodeURIComponent(C.thumbUrl));
B=B.replace(/\{description\}/,encodeURIComponent(HD.util.Common.ellipseText(C.description,this.config.previewLength||C.description.length)));
return B
}else{return null
}},analyticsShareString:function(A,B){return"default_analyticsShareString"
}};
HD.extend(HD.ShareWidget,[HD.Widget]);
HD.register("hd_share_widget","HD.ShareWidget",{version:"1.0",build:"1"});