(function($,window,undefined){function Pinterest(){var self=this;if($.isFunction(self.init)){self.init.apply(self,arguments);}}
Pinterest.prototype={init:function(opts,element){var self=this,options={};self.defaults=$.fn.pinterest.defaults;$.extend(true,options,self.defaults,opts);self.options=options;self.$element=$(element);self.pinterestLink=undefined;self._setPinterestLink();self.enable();},_getDescription:function(){var self=this,$element=self.$element,alt=$element.attr('alt'),title=$element.attr('title');if(title){return encodeURI(title);}
if(alt){return encodeURI(alt);}
return'';},_getMediaUrl:function(){var self=this,$element=self.$element;return encodeURI($element.attr('src'));},_getLocationUrl:function(){return encodeURI(window.location.href);},_getPinterestUrl:function(){var self=this,urlTemplate='http://pinterest.com/pin/create/bookmarklet/?media={MEDIA_URL}&url={URL}&description={DESC}';return urlTemplate.replace('{MEDIA_URL}',self._getMediaUrl()).replace('{URL}',self._getLocationUrl()).replace('{DESC}',self._getDescription());},_togglePinterestLink:function(value){var self=this,options=self.options,$overlay=self.$element.closest('.cc-imagewrapper').find('.'+options.overlayClass);$overlay.toggle(value);},_bindEvents:function(){var self=this,options=self.options,$wrapper=self.$element.closest('.cc-imagewrapper'),$pinterestLink=$wrapper.find('.'+options.linkClass);$wrapper.bind('mouseover.pinterest mouseleave.pinterest',function(e){self._togglePinterestLink(e.type==='mouseover');});$pinterestLink.bind('click.pinterest',function(e){e&&e.preventDefault();self._openLinkAsPopup();});},_setStyle:function(){var self=this,options=self.options,$element=self.$element,$overlay=$element.closest('.cc-imagewrapper').find('.'+options.overlayClass);$overlay.css({'margin-left':$element.css('padding-left'),'margin-right':$element.css('padding-right'),'margin-top':$element.css('padding-top')});$overlay.width($element.width());},_unbindEvents:function(){var self=this,options=self.options,$wrapper=self.$element.closest('.cc-imagewrapper'),$pinterestLink=$wrapper.find('.'+options.linkClass);$wrapper.unbind('mouseover.pinterest').unbind('mouseleave.pinterest');$pinterestLink.unbind('click.pinterest');},_setPinterestLink:function(){var self=this;self.pinterestLink=self._getPinterestUrl();},_openLinkAsPopup:function(){var self=this;window.open(self.pinterestLink,'Pinterest','width=900,height=500,resizable=yes').focus();},enable:function(){var self=this;self._unbindEvents();self._setPinterestLink();self._bindEvents();self._setStyle();},disable:function(){var self=this;self._unbindEvents();self._togglePinterestLink(false);}};$.fn.extend({pinterest:function(options){var args=Array.prototype.slice.call(arguments),method=args.shift();return this.each(function(index,element){var instance=$.data(element,'pinterest')||$.data(element,'pinterest',new Pinterest(options,element));if(method&&typeof method==='string'&&method.charAt(0)!=='_'&&$.isFunction(instance[method])){instance[method].apply(instance,args);}});}});$.fn.pinterest.defaults={linkClass:'cc-pinterest-link',overlayClass:'cc-pinterest-overlay'};}(jimdoGen002,window));