/*
topnavi.js 





        Copyright(C)2009 blogoo.ne.jp All Rights Reserved.





*/

function topNavibar() {
//alert("topNavibarを開始します");

//alert("topbarを開始します");
	var div1=document.createElement('div');
	div1.style.background="rgb(241, 241, 241) url(/contents/bar/bar_bg.gif) repeat-x scroll 0pt 100%";
	div1.style.display="block";
	div1.style.position="absolute";
	div1.style.top="0pt";
	div1.style.left="0pt";
	div1.style.height="30px";
	div1.style.width="100%";
	div1.style.minWidth="740px";
	div1.style.MozBackgroundClip="-moz-initial";
	div1.style.MozBackgroundOrigin="-moz-initial";
	div1.style.MozBackgroundInlinePolicy="-moz-initial";
	div1.setAttribute('id','topbar');

//alert("barleftを開始します");
	var div2=document.createElement('div');
	div2.style.cssFloat="left";
	div2.style.width="170px";
	div2.setAttribute('id','barleft');
	div1.appendChild(div2);
	var p1=document.createElement('p');
	div2.appendChild(p1);
	var a1=document.createElement('a');
	a1.setAttribute('href','http://blogoo.ne.jp/','target','_blank');
	a1.setAttribute('target','_blank');
	p1.appendChild(a1);
	var img1=document.createElement('img');
	img1.setAttribute('border','0');
	img1.style.margin="3px 0pt 0pt 3px";
	img1.setAttribute('alt','blogoo');
	img1.setAttribute('src','http://blogoo.ne.jp/contents/bar/bar_logo.gif');
	a1.appendChild(img1);

//alert("barrightを開始します");
	var div3=document.createElement('div');
	div3.style.cssFloat="right";
	div3.style.height="30px";
	div3.style.width="180px";
	div3.style.fontSize="12px";
	div3.style.lineHeight="30px";
	div3.setAttribute('id','barright');
	div1.appendChild(div3);

//alert("barcenterを開始します");
	var div4=document.createElement('div');
	div4.style.margin="0pt";
	div4.style.fontSize="12px";
	div4.style.lineHeight="30px";
	div4.style.height="30px";
	div4.style.textAlign="left";
	div4.setAttribute('id','barcenter');
	div1.appendChild(div4);

//alert("clearを開始します");
	var div5=document.createElement('div');
	div5.style.clear="both";
	div1.appendChild(div5);
	var hr1=document.createElement('hr');
	hr1.style.display="none";
	div5.appendChild(hr1);

//alert("BODYの取得を開始します");
	var oBODY=elementbody;

//alert("BODYにtopnavibarをはめ込みます");
	oBODY.appendChild(div1);

//alert("topNaviBar完了。ランダムテキストへ移行します");
	bar_text();
}


function bar_text(){
//alert("ランダムテキストを開始します");
	var msgs = new Array;
// 【センターテキスト（ランダム）】ここから設定	
	msgs[0] = '<span class="black">[PR] <a href="http://blogoo.ne.jp/contents/flier/goo_3.html" target="_blank">登録者１３０万人中１位の実績。</a></span>';
	msgs[1] = '<span class="brown">[PR] <a href="http://blogoo.ne.jp/contents/flier/goo_4.html" target="_blank">アナウンサーが明かす「トーク＆セミナの達人」</a></span>';
	msgs[2] = '<span class="red">[PR] <a href="http://blogoo.ne.jp/contents/flier/goo_5.html" target="_blank">メタボなお腹、さようなら。</a></span>';
	msgs[3] = '<span class="black">[PR] <a href="http://blogoo.ne.jp/contents/flier/goo_6.html" target="_blank">日本ランカー＆スクール校長のテニス上達プログラム</a></span>';
	msgs[4] = '<span class="red">[PR] <a href=" http://blogoo.ne.jp/contents/flier/goo_7.html" target="_blank">7日間で売上3倍増達成プログラム</a></span>';
// 【センターテキスト（ランダム）】ここまで設定	
	var shuffle = Math.floor( Math.random() * msgs.length );
	document.getElementById("barcenter").innerHTML = (msgs[shuffle]);

	var msgs2 = new Array;
// 【右上テキスト（ランダム）】ここから設定	
	msgs2[0] = '<p><a style="line-height:30px;" href="http://blogoo.ne.jp/admin/member_regist.php">新規登録</a>｜<a style="line-height:30px;" href="http://blogoo.ne.jp/admin/login.php">ログイン</a>｜<a style="line-height:30px;" href="http://help.clog.jp/" target="_blank">ヘルプ</a></p>';
// 【右上テキスト（ランダム）】ここまで設定	
	document.getElementById("barright").innerHTML = msgs2;

//alert("次の処理（topbarCSS）へ移行します");
topbarCSS();
}


function topbarCSS(){
//alert("topbarCSSを開始します");

 if(document.all)
  document.createStyleSheet('http://blogoo.ne.jp/contents/bar/styles.css');
   // stylesheet object createStyleSheet([sURL] [, iIndex])
   // iIndexは省略可。省略するとスタイルシート集合の最後に追加。 

 else if(document.styleSheets){
  var nLink=document.createElement('link');
   // Element createElement(in DOMString tagName)
   // raises(DOMException);
  
  nLink.rel="StyleSheet";
  nLink.type="text/css";
  nLink.href="http://blogoo.ne.jp/contents/bar/styles.css";
  var oHEAD=document.getElementsByTagName('head').item(0);
  oHEAD.appendChild(nLink);
   // Node appendChild(in Node newChild)
   // raises(DOMException);
 }
//alert("インフォメーションバー完了");
barenable();
}





function barenable () {
//alert("BODY背景処理を処理を開始します");

//alert("ブラウザ判定を開始します");
	if (elementbodystyle.backgroundPositionY) {
//alert("判定結果：IE");
		iebgposition();
	}else if (elementbodystyle.backgroundPosition) {
//alert("判定結果：FF");
		ffbgposition();
	}
}


function iebgposition() {
//alert("IEを実行します");
	if (elementbodystyle.backgroundPositionY=="0px") {
		elementbody.style.backgroundPositionY = "30px";
//alert("Y軸を 0px から"+elementbodystyle.backgroundPositionY+"に変更しました。");
	}
	else if (elementbodystyle.backgroundPositionY=="0%") {
		elementbody.style.backgroundPositionY = "30px";
//alert("Y軸を 0% から"+elementbodystyle.backgroundPositionY+"に変更しました。");
	}
	else if (elementbodystyle.backgroundPositionY=="0pt") {
		elementbody.style.backgroundPositionY = "30px";
//alert("Y軸を 0pt から"+elementbodystyle.backgroundPositionY+"に変更しました。");
	}
	else if (elementbodystyle.backgroundPositionY=="top") {
		elementbody.style.backgroundPositionY = "30px";
//alert("Y軸を top から"+elementbodystyle.backgroundPositionY+"に変更しました。");
	}
	else {
//alert("該当の条件が見つかりませんでした。BODYのbackgroundPositionYは "+elementbodystyle.backgroundPositionY+" です。");
	}
}


function ffbgposition() {	
//alert("FFを実行します");
	var _arr = elementbodystyle.backgroundPosition.split(" ");
//alert("取得値： "+elementbodystyle.backgroundPosition);
	var backgroundPositionX = _arr[0];
//alert("X軸 "+backgroundPositionX);
	var backgroundPositionY = _arr[1];
//alert("Y軸 "+backgroundPositionY);
	if (backgroundPositionY=="0px") {
		elementbody.style.backgroundPosition = backgroundPositionX+" 30px";
//alert(backgroundPositionX+" 0px から"+backgroundPositionX+" 30px"+" に変更しました。");
	}
	else if (backgroundPositionY=="0%") {
		elementbody.style.backgroundPosition = backgroundPositionX+" 30px";
//alert(backgroundPositionX+" 0% から"+backgroundPositionX+" 30px"+" に変更しました。");
	}
	else if (backgroundPositionY=="0pt") {
		elementbody.style.backgroundPosition = backgroundPositionX+" 30px";
//alert(backgroundPositionX+" 0pt から"+backgroundPositionX+" 30px"+" に変更しました。");
	}
	else if (backgroundPositionY=="top") {
		elementbody.style.backgroundPosition = backgroundPositionX+" 30px";
//alert(backgroundPositionX+" top から"+backgroundPositionX+" 30px"+" に変更しました。");
	}
}





//alert("インフォメーションバー読み込みを開始します");

var elementbody = document.getElementsByTagName("body")[0];
//alert("BODYを取得しました");

var elementbodystyle = elementbody.currentStyle || document.defaultView.getComputedStyle(elementbody, "") 
//alert("BODYをセットしました");

window.onload = topNavibar;
