var stg={};
//stg.allowedLabels=["follow-me","follow-us","follow","my-twitter"];
var wHeight = getBrowserHeight();
stg.defaultTop = (wHeight/2);
//stg.defaultTop=300;
stg.defaultColor="#35ccff";
//stg.isInArray=function(str,ar){
//	if(ar.length<1)return;
//	for(var i=0;i<ar.length;i++){
//		if(ar[i]==str){
//			return true;
//			break;
//		}
//	}
//	return false;
//}
stg.showtengaibadge=function(top, showtengai_shop_id){
	//var wHeight = getBrowserHeight();
	if(!window.XMLHttpRequest){
		return;
	}

	if(document.getElementById('showtengaiBadge')){
		document.body.removeChild(document.getElementById('showtengaiBadge'));
	}

	stg.top = (parseInt(stg.defaultTop) + parseInt(top));
	var twitterTab = document.getElementById('tfbTab');
	if (twitterTab != null){
		twitterTab.style.top = (parseInt(twitterTab.style.top) + parseInt(65)) + 'px';
	}
//	if(stg.top<0||stg.top>1000||isNaN(stg.top)){
//		stg.top=stg.defaultTop;
//	}
//	if(!stg.isInArray(stg.label,stg.allowedLabels)){
//		stg.label=stg.allowedLabels[0];
//	}
	var validColorPattern=/^#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$/;
	if(!validColorPattern.test(stg.color)||(stg.color.length!=4&&stg.color.length!=7)){
		stg.color=stg.defaultColor;
	};

	if(stg.side!='l'){
		stg.side='r';
	}
//
	stg.tabStyleCode='position:fixed;'+'top:'+stg.top+'px;'+'width:30px;'+'height:120px;'+'z-index:8765;'+'cursor:pointer;'+'background:'+stg.color+' url(/img/sozai/showtengai.png);'+'background-repeat:no-repeat;';
	stg.tabStyleCode+='right:0; background-position:left top;';
	stgMainDiv=document.createElement('div');
	stgMainDiv.setAttribute('id','showtengaiBadge');
	document.body.appendChild(stgMainDiv);
	stgMainDiv.innerHTML='<div id="stgTab" style="'+stg.tabStyleCode+'"></div><div id="stgAbout" style="'+stg.aboutStyleCode+'"></div>'+'<style>#stgAbout{visibility:hidden;} #showtengaiBadge:hover #stgAbout{visibility:visible;}</style>';
	document.getElementById('stgTab').onclick=function(){window.open('http://showtengai.jp/d/' + showtengai_shop_id);}
}

function getBrowserHeight() {
    if ( window.innerHeight ) {
            return window.innerHeight;
    }
    else if ( document.documentElement && document.documentElement.clientHeight != 0 ) {
            return document.documentElement.clientHeight;
    }
    else if ( document.body ) {
            return document.body.clientHeight;
    }
    return 0;
}

