(function(){var a=function(k){var m={},n=window,s=document,f={SAVE:"Clip to Memonic",ALERT:"Unfortunately we cannot save your selection from this page with the current version of Memonic."},j="http://archiv.blogwerk.com/bookmarklet/savebutton.js",q="memonic_button",t="http://s.memonic.ch/assets/save_button/v2/img/clip_button_m_text.png",b={container:s.body,position:q,placement:"appendTo",autosave:true,preselect:true,title:"memonic_title",body:"memonic_body",button_html:'<img src="'+t+'" alt="'+f.SAVE+'" style="padding:0;margin:0;border:0;"/>',fetch_source:null,fetch_title:null,fetch_body:null,affiliate_id:null},p=function(d){d=d||{};d=e(d);for(var v=0;v<d.container.length;v++){c({index:v,container:d.container[v],position:d.position[v],placement:d.placement[v],preselect:d.preselect[v],autosave:d.autosave[v],title:d.title[v],body:d.body[v],button_html:d.button_html[v],fetch_source:d.fetch_source[v],fetch_title:d.fetch_title[v],fetch_body:d.fetch_body[v],affiliate_id:d.affiliate_id[v]})}},l=function(d){if(typeof Array.isArray==="undefined"){return Object.prototype.toString.call(d)==="[object Array]"}else{return Array.isArray(d)}},i=function(x,w){var v,d=(l(x))?x:[x];if(w&&typeof length==="number"){if(w<d.length){d=d.slice(0,w)}else{if(w>d.length){for(v=d.length;v<w;v++){d.push(d[d.length-1])}}}}return d},e=function(w){var A={},d,x,y=["container"],v=["position","placement","title","body","fetch_source","fetch_title","fetch_body","button_html","affiliate_id"],z=["preselect","autosave"];for(x=0;x<y.length;x++){d=y[x];if(d in w&&(w[d].nodeType===1||(typeof w[d]==="object"&&w[d].length)||(typeof w[d]==="function"&&typeof w[d].call==="undefined"))){A[d]=w[d]}else{A[d]=b[d]}A[d]=((typeof A[d]==="object"&&A[d].length)||(typeof w[d]==="function"&&typeof w[d].call==="undefined"))?A[d]:[A[d]]}for(x=0;x<v.length;x++){d=v[x];if(d in w&&w[d]&&(typeof w[d]==="string"||(l(w[d])&&w[d].length===A.container.length))){A[d]=w[d]}else{A[d]=b[d]}A[d]=i(A[d],A.container.length)}for(x=0;x<z.length;x++){d=z[x];if(d in w&&(typeof w[d]==="boolean"||(l(w[d])&&w[d].length===A.container.length))){A[d]=w[d]}else{A[d]=b[d]}A[d]=i(A[d],A.container.length)}return A},h=function(w,d){var v,x=document.createElement("div");x.innerHTML=w;v=x.firstChild;v.id=(typeof d!=="undefined")?q+"_"+d:q;return v},g=function(w,d,v){if(v==="insertBefore"){d.parentNode.insertBefore(w,d)}if(v==="insertAfter"){d.parentNode.insertBefore(w,d.nextSibling)}if(v==="appendTo"){d.appendChild(w)}},c=function(w){var x,B,z=s.getElementById(q),v=u(w.position,w.container,true),A=u(w.title,w.container,true),y=u(w.body,w.container),d=u(w.fetch_source,w.container,false);if(z){if(z.tagName.toLowerCase()==="img"||z.hasChildNodes()){}else{x=h(w.button_html,w.index);g(x,z,w.placement);z=x}}else{if(v){x=h(w.button_html,w.index);g(x,v,w.placement);z=x}else{if(w.container===b.container){x=h(w.button_html,w.index);B=x.outerHTML||new XMLSerializer().serializeToString(x);s.write(B);z=document.getElementById(q+"_"+w.index)}else{return false}}}z.memonic_bookmarklet=true;z.style.cursor="pointer";z.onclick=function(E){n.memonic_button_container=w.container;n.memonic_button_autosave=w.autosave;n.memonic_button_preselect=w.preselect;n.memonic_button_preselect_title=A;n.memonic_button_preselect_content=y;n.memonic_button_fetch_source=o(d);n.memonic_button_fetch_title=w.fetch_title;n.memonic_button_fetch_body=w.fetch_body;n.memonic_button_affiliate_id=w.affiliate_id;try{var D=j,C=s.createElement("script");if(location.protocol==="https:"){D=D.replace("http://","https://")}C.type="text/javascript";C.src=D;void (s.body.appendChild(C))}catch(F){alert(f.ALERT)}}},u=function(w,d,x){if(!w){return null}d=d||s;x=x||false;var v=[],y=document.getElementById(w);if(y){v.push(y)}else{v=(d.className.toLowerCase()===w.toLowerCase())?[d]:r(w,d);if(!v||v.length===0){v=(d.tagName.toLowerCase()===w.toLowerCase())?[d]:d.getElementsByTagName(w)}}if(x){if(v.length>0){return v[0]}else{return null}}else{return v}},r=function(z,d){var A=[];if(typeof d==="string"){d=document.getElementById(d)}else{if(typeof d!=="object"||typeof d.tagName!=="string"){d=s.body}}if(document.getElementsByClassName){A=d.getElementsByClassName(z)}else{var x=d.getElementsByTagName("*"),y=new RegExp("\\b"+z+"\\b"),w,v=0;while((w=x[v++])){if(w.className&&y.test(w.className)){A.push(w)}}}return A},o=function(v){if(v&&typeof v==="string"){return v}if(v&&typeof v==="object"&&typeof v.tagName!=="undefined"&&v.tagName.toLowerCase()==="a"&&v.href!==""){return v.href}if(v&&typeof v==="object"&&v.length>0){for(var d=0;d<v.length;d++){var w=v[d];if(typeof w==="object"&&typeof w.tagName!=="undefined"&&w.tagName.toLowerCase()==="a"&&w.href!==""){return w.href}}}return null};m.initButton=p;m.getElementsByClassName=r;return m};Memonic=a()})();
