
// steppy
var steppy = new Object();
steppy.showSw = true;

/*lib*/
//ID
steppy.$ = function(i){
	if(document.getElementById(i) != null){
		return document.getElementById(i);
	}else{
		return null;
	}
}
steppy.ads = steppy.$('steppy_ads_dTDtkwBNcCNOHwIh');
steppy.btn = steppy.$('steppy_btn_dTDtkwBNcCNOHwIh');

steppy.getTopOffset = function() {
    if(document.all) {
	if(document.compatMode == "CSS1Compat")
	    return document.body.parentNode.scrollTop;
	else if(document.body.scrollTop)
	    return document.body.scrollTop;
	else
	    return 0;
    }
    else {
		return window.pageYOffset;
    }
}

steppy.getWindowHeight = function() {
    if(window.innerHeight)
		return window.innerHeight;
    if(document.compatMode == "CSS1Compat")
		return document.body.parentNode.clientHeight;
    if(document.body.clientHeight)
		return document.body.clientHeight;	
}
steppy.getWindowWidth = function() {
    if(window.innerWidth)
		return window.innerWidth;
    if(document.compatMode == "CSS1Compat")
		return document.body.parentNode.clientWidth;
    if(document.body.clientWidth)
		return document.body.clientWidth;
}

steppy.adon = function(){
	steppy.ads.style.display = "block";
	clearTimeout(steppy.tid);
}
steppy.adoff = function(){
	steppy.tid=setTimeout(function(){steppy.ads.style.display = "none";},100);
}
/*license check*/
if(steppy.btn.style.display == "none") steppy.showSw = false;
if(steppy.btn.rel == 'nofollow') steppy.showSw = false;

steppy.sticky = function(){
	if(steppy.btn != null){
		var btn = steppy.btn;
		var ad = steppy.ads;
		btn.style.position = "fixed";
		ad.style.position = "fixed";
		var under = parseInt(steppy.getWindowHeight() + steppy.getTopOffset());
		var left = steppy.getWindowWidth();
		if(document.all) {
			btn.style.pixelLeft = left -51;
			btn.style.pixelTop = under -16;
			ad.style.pixelLeft = left -202;
			ad.style.pixelTop = under -218;
		}else {
			btn.style.left = left -51 + "px";
			btn.style.top = under -16 + "px";
			ad.style.left = left -202 + "px";
			ad.style.top = under -218 + "px";
		}
	}
}


steppy.sticky();
window.onscroll = steppy.sticky;
window.onresize = steppy.sticky;

steppy.showFlash = function(){
	//alert(arguments[0]);
	if(steppy.showSw && arguments[0]){
		var swf = steppy.$('steppy_dTDtkwBNcCNOHwIh');
		var obj = "<embed src='http://www.steppy.jp/swf/steppy.swf?u_key=dTDtkwBNcCNOHwIh' quality='high' luginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' FlashVars='u_key=dTDtkwBNcCNOHwIh' width='333' height='500'></embed>";
		swf.innerHTML += obj;
	}
}


steppy.url = "http://www.steppy.jp/show.php?";
steppy.url += "u_key=dTDtkwBNcCNOHwIh";
steppy.url += "&tag="+steppy.ads.innerHTML;
steppy.show = document.createElement('script');
steppy.show.setAttribute("type","text/javascript");
steppy.show.setAttribute("src", encodeURI(steppy.url));
steppy.$('steppy_dTDtkwBNcCNOHwIh').appendChild(steppy.show);

steppy.btn.innerHTML = "<img src=\"http://www.steppy.jp/img/steppy_btn.png\" alt=\"Steppy\" border=\"0\" />";
steppy.ads.innerHTML = "<strong style=\"padding:10px 0 0 20px;\">Steppy ads</strong><br />" + steppy.ads.innerHTML;
steppy.ads.style.width = "200px";
steppy.ads.style.height = "200px";
steppy.ads.style.backgroundColor = "#DDDDDD";
steppy.ads.style.border = "1px #999999 solid";
steppy.ads.style.fontSize = "12px";
steppy.ads_a = steppy.ads.getElementsByTagName('a');
for(var i=0;i<steppy.ads_a.length;i++){
	steppy.ads_a.item(i).style.display = "block";
	steppy.ads_a.item(i).style.paddingTop = "20px";
	steppy.ads_a.item(i).style.paddingLeft = "20px";
	steppy.ads_a.item(i).style.color = "#333333";
	steppy.ads_a.item(i).onmouseover = steppy.adon;
}

steppy.ads.style.display = "none";
steppy.btn.onmouseover = steppy.adon;
steppy.ads.onmouseover = steppy.adon;
steppy.ads.onmouseout = steppy.adoff;