(function(){function makeSharer(href){return function(event){window.open(href,"share",["width=632","height=456,","location=yes","resizable=yes","toolbar=no","menubar=no","scrollbars=no","status=no"].join(","));stopEvent(event||window.event);};}
function buildQueryParams(params){var queries=[];for(var i=0,n=0;i<params.length;){var key=params[i++];var value=params[i++];if(!value)continue;queries[n++]=key+"="+encodeURIComponent(value);}
return queries.join("&");}
function observeEvent(element,name,observer){if(element.addEventListener){element.addEventListener(name,observer,false);}else if(element.attachEvent){element.attachEvent("on"+name,observer);}else{element["on"+name]=observer;}}
function stopEvent(event){if(event.preventDefault){event.preventDefault();event.stopPropagation();}else{event.returnValue=false;event.cancelBubble=true;}}
var elements=document.getElementsByTagName("a");for(var i=0,l=elements.length;i<l;i++){var a=elements[i];if(!a.getAttribute("check_key"))continue;for(var j=a.childNodes.length-1;j>=0;j--)a.removeChild(a.childNodes[j]);var type=a.getAttribute("check_button")||"button-1";var prefix=("https:"==document.location.protocol)?"https://img.mixi.net/":"http://img.mixi.net/";var button=type.split("-");if(!button||button.length<2)button=["button","1"];var src=(button[0]=="button")?[prefix,"img/basic/mixicheck_entry/bt_check_",button[1],".png"]:(button[0]=="icon")?[prefix,"img/basic/mixicheck_entry/icon_mixi_",button[1],".png"]:[prefix,"img/basic/mixicheck_entry/bt_check_1.png"];src=src.join("");var img=document.createElement("img");img.setAttribute("src",src);a.appendChild(img);var query_params=buildQueryParams(["u",a.getAttribute("check_url")||document.location.href,"k",a.getAttribute("check_key"),"c",a.getAttribute("check_config"),"nocache",a.getAttribute("check_nocache")]);var href="http://mixi.jp/share.pl?"+query_params;a.setAttribute("target","_blank");a.setAttribute("href",href);observeEvent(a,"click",makeSharer(href));}})();

