var t;

function sm_over(otop, oleft) {
	document.getElementById('ifrm').style.display='block';
	document.getElementById('ifrm').style.top=(otop+25)+'px';
	document.getElementById('ifrm').style.left=oleft+'px';
	clearTimeout(t);
}

function sm_iover() {
	document.getElementById('ifrm').style.display='block';
	clearTimeout(t);
}

function sm_out() {
	t=setTimeout(function(){document.getElementById('ifrm').style.display='none';}, 600);
}

if(typeof(executed)!="boolean") {
	var as=document.getElementsByTagName("a");
	for(var i=0; i<as.length; i++) {
		if(as[i].getAttribute("class")=="spodelime" || as[i].getAttribute("id")=="spodelime") {
			if(as[i].getAttribute("href")!="http://spodelime.com/" || as[i].getAttribute("rel")) alert("spodelime.com: Invalid code!");

			alt=as[i].textContent;
			as[i].removeChild(as[i].firstChild);

			if(typeof(s_image)!="undefined") as[i].setAttribute("data-image", s_image); // old API support
			var image=(as[i].getAttribute("data-image") ? as[i].getAttribute("data-image") : "http://spodelime.com/button.png");

			as[i].setAttribute("onclick", "sm_over(this.offsetTop,this.offsetLeft);return(false)");
			as[i].setAttribute("onmouseover", "sm_over(this.offsetTop,this.offsetLeft)");
			as[i].setAttribute("onmouseout", "sm_out()");

			var img=document.createElement("img");
			img.setAttribute("src", image);
			img.setAttribute("alt", alt);
			img.setAttribute("style", "border-width:0");

			as[i].appendChild(img);

			if(document.getElementById('ifrm')==null) {
				var iframe=document.createElement("iframe");
				iframe.setAttribute("id", "ifrm");
				iframe.setAttribute("src", "http://spodelime.com/buttons.php?url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title));
				iframe.setAttribute("width", "281");
				iframe.setAttribute("height", "205");
				iframe.setAttribute("style", "display:none;position:absolute;border: 1px solid #bbb;z-index:99999;border-radius:5px;box-shadow: 0px 0px 7px #777;");
				iframe.setAttribute("onmouseover", "sm_iover()");
				iframe.setAttribute("onmouseout", "sm_out()");

				as[i].parentNode.insertBefore(iframe, as[i].nextSibling);
			}
		}
	}
	executed=true;
}

