// document.write = "<link href=\"js/layer.css\" rel=\"stylesheet\" type=\"text/css\" title=\"default.\" media=\"screen\" />";

var winSize={};

	//IE6
if(document.documentElement.clientWidth + document.documentElement.clientHeight == 0){
	winSize.getViewAreaWidth=function(){return document.body.clientWidth;};
	winSize.getViewAreaHeight=function(){return document.body.clientHeight;};
	winSize.getHorizontalScroll=function(){return document.body.scrollLeft;};
	winSize.getVerticalScroll=function(){return document.body.scrollTop};
}

	//Firefox Safari
else if(window.innerWidth && document.documentElement.clientWidth){
		winSize.getViewAreaWidth=function(){return document.body.clientWidth;};
		winSize.getViewAreaHeight=function(){return window.innerHeight;};
		winSize.getHorizontalScroll=function(){return window.pageXOffset;};
		winSize.getVerticalScroll=function(){return window.pageYOffset;};
}

 else if(document.documentElement && document.documentElement.clientWidth){
	//IE7〜
	winSize.getViewAreaWidth=function(){return document.documentElement.clientWidth;};
	winSize.getViewAreaHeight=function(){return document.documentElement.clientHeight;};
	winSize.getHorizontalScroll=function(){return document.documentElement.scrollLeft;};
	winSize.getVerticalScroll=function(){return document.documentElement.scrollTop;};
}


// ボックスの表示切り替え
	var layerflag;

function addLayer(obj){
	 scrollX=winSize.getHorizontalScroll();
	 viewX=winSize.getViewAreaWidth();
	 scrollY=winSize.getVerticalScroll();
	 viewY=winSize.getViewAreaHeight();


	//背景のレイヤーが表示されていない時のレイヤーを追加
	if(!layerflag){

		//背景のレイヤーを設定する
		layer = document.createElement('div');
		layer.id="bgtrpnt"
		layer.style.position="absolute";
		layer.style.display="block";
		layer.style.zIndex="10";
		layer.style.top='0';
		layer.style.left='0';

			if( document.width != "undefined"){
				olWdt = document.body.scrollWidth;
				olHgt = document.body.scrollHeight;
			}else{
				olWdt = document.width;
				olHgt = document.height;
			}

		layer.style.width= olWdt + "px";
		layer.style.height= olHgt + "px";
		layer.style.overflow='auto';

		boxWdt = 600;
		boxHgt = 405;

		layer2 = document.createElement('div');
		layer2.style.id="olframe";
		layer2.style.position="absolute";
		layer2.style.display="block";
		layer2.style.zIndex="11";
		layer2.style.backgroundColor="#d7d7d7";
		//枠をブラウザ表示領域の真ん中に表示させる
		layer2.style.top=(viewY-boxHgt)/2 + scrollY + 'px';
		layer2.style.left=(viewX-boxWdt)/2 + scrollX + 'px';
		layer2.style.overflow='auto';

	//枠内のコンテンツ
		layer3 = document.getElementById(obj);
		layer3.style.position="absolute";
		layer3.style.display="block";
		layer3.style.zIndex="12";
			layer3.style.top=(viewY-boxHgt)/2 + scrollY + 'px';
			layer3.style.left=(viewX-boxWdt)/2 + scrollX + 'px';
			layer3.style.overflow='auto';
		if (typeof document.documentElement.style.maxHeight != "undefined") {
		//コンテンツのサイズ調整：モダンブラウザ
			layer3.style.width= boxWdt + 'px';
		}else {
		//コンテンツのサイズ調整：IE6用
			layer3.style.width= boxWdt + 'px';
		}
		//イメージ枠をレイヤー内に表示させる

		document.getElementsByTagName('body')[0].appendChild(layer);
		document.getElementsByTagName('div')[0].appendChild(layer2);
		document.getElementsByTagName('div')[0].appendChild(layer3);
		layerflag=true;
	}else{
	//レイヤーが表示されている時にレイヤーを削除
		removeLayer();
	}
			return false;
}

function removeLayer(){// レイヤーを消す function
	document.getElementsByTagName('body')[0].removeChild(layer);
	document.getElementsByTagName('div')[0].removeChild(layer2);
	layer3.style.display="none";
	layerflag=false;
}
























