/*
loading.js

要ptorotype.js
たぶんどのバージョンでも動くけど1.6で確認

  <script type="text/javascript" src="../lib/prototype.js"></script>
　<script type="text/javascript" src="../js/loading.js"></script>

その他にクルクル画像　loading.gif　がいります。


　loadingOn('読み込み中だよ！');	//これで切替
　loadingOff();						//これで解除


もしイベントを設置するなら、はじめに読み込もう！設置しないなら無視してよい
window.onload = function() {
	loadingDivInsert();
}

 writing by 榎内 2008.5.1 

*/



//読込ON
function loadingOn(loadingMsg){
	if($('loading-mask')){
	}else{
		loadingDivInsert();
	}
	$('loading').innerHTML='<img src="../img/loading.gif" style="width:16px;height:16px;" align="absmiddle" /> '+loadingMsg;

	$('loading-mask').style.display='block';
	$('loading').style.display='block';


	var screen = screenInfomation();

	$('loading-mask').style.top=screen.y+'px';
	$('loading-mask').style.left=screen.x+'px';

	var obj    = Element.getDimensions( $('loading') );
	$('loading').style.left = (screen.width/2) - obj.width/2 + 'px';
	$('loading').style.top  = (screen.nowHeight/2 + screen.y) - obj.height/2 + 'px';

	$('loading-mask').style.width=screen.width + 'px';
	$('loading-mask').style.height=screen.nowHeight + 'px';
}

//読込OFF
function loadingOff(){
	document.getElementById('loading-mask').style.display='none';
	document.getElementById('loading').style.display='none';
}

//DIVの差込
function loadingDivInsert(){
	var tmpInsertClass1="";
	tmpInsertClass1 +="display:none;";
	tmpInsertClass1 +="width:100%;";
	tmpInsertClass1 +="height:100%;";
	tmpInsertClass1 +="background:#BBBBBB;";
	tmpInsertClass1 +="position:absolute;";
	tmpInsertClass1 +="z-index:20000;";
	tmpInsertClass1 +="left:0;";
	tmpInsertClass1 +="top:0;";
	tmpInsertClass1 +="opacity: 0.35;";
	tmpInsertClass1 +="filter:progid:DXImageTransform.Microsoft.Alpha(Enabled=1,Style=0,Opacity=35);";

	var tmpInsertClass2="";
	tmpInsertClass2 +="display:none;";
	tmpInsertClass2 +="position:absolute;";
	tmpInsertClass2 +="left:41%;";
	tmpInsertClass2 +="top:40%;";
	tmpInsertClass2 +="border:1px solid #666666;";
	tmpInsertClass2 +="padding:9px;";
	tmpInsertClass2 +="margin:0px;";
	tmpInsertClass2 +="width:180px;";
	tmpInsertClass2 +="text-align:center;";
	tmpInsertClass2 +="vertical-align:middle;";
	tmpInsertClass2 +="z-index:20001;";
	tmpInsertClass2 +="background:white;";
	tmpInsertClass2 +="font:bold 13px tahoma,arial,helvetica;";
	tmpInsertClass2 +="color:#565656;";

	var tmpInsertDiv="";
	tmpInsertDiv +='<div id="loading-mask" style="'+tmpInsertClass1+'"> </div>';
	tmpInsertDiv +='<div id="loading" style="'+tmpInsertClass2+'">';
	tmpInsertDiv +='</div>';
	tmpInsertDiv +='</div>';

	document.body.innerHTML=document.body.innerHTML+tmpInsertDiv;

}


function screenInfomation(){
	var screen = new Object();

	screen.width     = document.body.clientWidth  || document.documentElement.clientWidth;    // 横幅
	screen.nowHeight = document.documentElement.clientHeight;    // 現在表示している画面の高さ
	screen.height    = document.body.clientHeight || document.body.scrollHeight;    // 画面の高さ
	screen.x = document.body.scrollLeft || document.documentElement.scrollLeft;    // 横の移動量
	screen.y = document.body.scrollTop || document.documentElement.scrollTop;      // 縦の移動量

	return screen;
}

