/**
 * QR.KG Mobile Sharing plugin
 * Allows you to generate QR-codes for any urls (pages, images and other).
 * For more info please visit http://qr.kg
 * or follow us on twitter @qrkg
 *
 * Author Michael Ageev (http://michaelageev.com)
 */
var QRShare=function(){var a=this;this.getElementsByClassName=function(d,c,e){if(document.getElementsByClassName){getElementsByClassName=function(l,o,k){k=k||document;var f=k.getElementsByClassName(l),n=(o)?new RegExp("\\b"+o+"\\b","i"):null,g=[],j;for(var h=0,m=f.length;h<m;h+=1){j=f[h];if(!n||n.test(j.nodeName)){g.push(j)}}return g}}else{if(document.evaluate){getElementsByClassName=function(p,s,o){s=s||"*";o=o||document;var h=p.split(" "),q="",m="http://www.w3.org/1999/xhtml",r=(document.documentElement.namespaceURI===m)?m:null,i=[],f,g;for(var k=0,l=h.length;k<l;k+=1){q+="[contains(concat(' ', @class, ' '), ' "+h[k]+" ')]"}try{f=document.evaluate(".//"+s+q,o,r,0,null)}catch(n){f=document.evaluate(".//"+s+q,o,null,0,null)}while((g=f.iterateNext())){i.push(g)}return i}}else{getElementsByClassName=function(t,w,s){w=w||"*";s=s||document;var j=t.split(" "),v=[],f=(w==="*"&&s.all)?s.all:s.getElementsByTagName(w),r,o=[],q;for(var n=0,g=j.length;n<g;n+=1){v.push(new RegExp("(^|\\s)"+j[n]+"(\\s|$)"))}for(var i=0,u=f.length;i<u;i+=1){r=f[i];q=false;for(var h=0,p=v.length;h<p;h+=1){q=v[h].test(r.className);if(!q){break}}if(q){o.push(r)}}return o}}}return getElementsByClassName(d,c,e)};var b=function(e){var d=0;var c=0;while(e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop)){d+=e.offsetLeft-e.scrollLeft;c+=e.offsetTop;e=e.offsetParent}return{top:c+18,left:d-4}};this.setButtonHTML=function(c){return"icon"==c?'<img src="http://qr.kg/images/share-icon.png" style="height:16px; width:16px;cursor:pointer;" />':'<img src="http://qr.kg/images/share-bar.png" style="height:20px; width:55px;cursor:pointer;" />'};this.bindButtonClick=function(){for(var c=0;c<this.buttons.length;c++){this.buttons[c].innerHTML=this.setButtonHTML(this.buttons[c].getAttribute("layout")||null);this.buttons[c].onclick=this.buttonClickHandler}};this.buttonClickHandler=function(j){j=j||window.event;var f=j.target||j.srcElement;var g=f.parentNode;var k="http://qr.kg/share?url="+g.getAttribute("url");var c=a.popup;var i=b(g);if(c.style.display=="block"&&a.activeBarcodeUrl==k){c.style.display="none";this.activeBarcodeUrl=null;return false}var h=function(){c.getElementsByTagName("img")[0].src=k;c.style.left=i.left+"px";c.style.top=i.top+"px";c.style.display="block"};var d=new Image();d.src=k;d.onload=h;a.activeBarcodeUrl=k;return false};this.appendPopupBlock=function(){this.popup=document.createElement("div");this.popup.setAttribute("id","qr-code-popup");this.popup.setAttribute("style","display:none;min-width:64px;min-height:64px;padding:6px;border:1px solid #000;position: absolute; background:#fff;-moz-border-radius:2px; border-radius:2px; z-index:10000;");this.popup.innerHTML='<a href="http://qr.kg/mobile-sharing"><img style="border:0;" src="" alt="Ссылка для мобильника" title="Подробнее о технологии на www.qr.kg" /></a>';document.body.appendChild(this.popup)};this.init=function(){this.activeBarcodeUrl=null;this.buttons=[];this.appendPopupBlock();this.buttons=this.getElementsByClassName("mobile-sharing");this.bindButtonClick()};this.init();};
(function(i) {
  var u=navigator.userAgent;var e=/*@cc_on!@*/false; var st = setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);} else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){document.addEventListener("DOMContentLoaded",i,false); } else if(e){(function(){var t=document.createElement('doc:rdy');try{t.doScroll('left'); i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}
})(function(){new QRShare()});

