/*_______________________________________

ブラウザ判別
________________________________________*/

var ns4=document.layers&&!document.getElementById?1:0
var ns6=document.getElementById&&!document.all?1:0
var ie4=document.all?1:0
var ie5=(navigator.appName.indexOf('Microsoft Internet Explorer')>=0&&document.getElementById&&!window.opera)?1:0;
var mac=navigator.userAgent.indexOf('Mac')>=0?1:0
var opera=window.opera?1:0

/*_______________________________________

グローバル変数の宣言
________________________________________*/
var lwObj='';	// レイヤーウィンドウオブジェクト
var pre_lwObj=null;	// すでに起動しているレイヤーウィンドウオブジェクト
var orgX=738;	// レイヤーの初期X座標
var orgY=111;	// レイヤーの初期Y座標
var startX=0;
var startY=0;
var grabObj=null;

/*_______________________________________

idから オブジェクトを取得する
________________________________________*/
function getLayName(nm) {
	if (ns6||opera) {
		return document.getElementById(nm);
	}
	if (ns4) {
		var s='';
		for (var i=1; i<arguments.length; i++)
		  s+='document.layers.'+arguments[i]+'.';
		return eval(s+'document.layers.'+nm);
	}
	if (ie4) {
		return ie5?document.getElementById(nm):document.all(nm);
	}
	return null;
}

/*_______________________________________

指定した座標にレイヤーを移動する
________________________________________*/
function moveLayTo(lay,left,top) {
  if (ns6||opera) { 
    lay.style.left=left+'px';
    lay.style.top =top +'px';
    return;
  }
  if (ns4) {
		lay.moveTo(left,top); return;
	}
  if (ie4) {
    lay.style.pixelLeft=left;
    lay.style.pixelTop =top;
    return;
  }
}

/*___________________________________________

指定した差分だけ、レイヤーを移動する
___________________________________________*/
function moveLayBy(lay,left,top) {
  if (ns6||opera) { 
    lay.style.left=parseInt(lay.style.left)+Math.round(left);
    lay.style.top =parseInt(lay.style.top )+Math.round(top);
    return;
  }
  if (ns4) {
		lay.moveBy(left,top); return;
	}
  if (ie4) {
    if (ie5) {
      lay.style.pixelLeft=lay.offsetLeft+Math.round(left);
      lay.style.pixelTop=lay.offsetTop+Math.round(top);
    } else {
      lay.style.pixelLeft+=Math.round(left);
      lay.style.pixelTop+=Math.round(top);
    }
    return;
  }
}

/*________________________________________

レイヤーの表示/非表示を制御する
________________________________________*/
function setLayView(lay,visible) {
	if (ns6||ie4) { 
		lay.style.visibility=(visible)?'inherit':'hidden';
		lay.style.left = orgX;
		lay.style.top = orgY;
		return;
	}
	if (ns4) { 
		lay.visibility=(visible)?'inherit':'hide'; return; 
		lay.style.left = orgX;
		lay.style.top = orgY;
		return;
	}
	if (opera) { 
		lay.style.visibility=(visible)?'visible':'hidden';
		lay.style.left = orgX;
		lay.style.top = orgY;
		return;
	}
}

/*___________________________________________

マウスイベント発生時のX座標を取得する
___________________________________________*/
function getEventPageX(e) {
	if (ns6) {
		return window.scrollX+e.clientX;
	}
	if (ns4) {
		return e.pageX;
	}
	if (ie4) {
		return document.body.scrollLeft+event.clientX;
	}
	if (opera) { 
		return (document.documentElement?pageXOffset:0)+e.clientX;
	}
	return 0;
}

/*____________________________________________

マウスイベント発生時のY座標を取得する
____________________________________________*/
function getEventPageY(e) {
	if (ns6) {
		return window.scrollY+e.clientY;
	}
	if (ns4) {
		return e.pageY;
	}
	if (ie4) {
		return document.body.scrollTop+event.clientY;
	}
	if (opera) {
		return (document.documentElement?pageYOffset:0)+e.clientY;
	}
	return 0;
}

/*_________________________________________________________

リンクをクリックしたときの処理：レイヤーの初回表示
__________________________________________________________*/
function showLayWin(subObj) {
	if (!subObj) {
		return;
	}  
	if (!pre_lwObj) {
	    moveLayTo(subObj,orgX,orgY);
	    setLayView(subObj,true);
	    subObj.isVisible=true;
	} else {
		setLayView(pre_lwObj,true);
		pre_lwObj.isVisible=true;
	} 
}

/*________________________________________________________________________

レイヤーの「×」ボタンをクリックしたときの処理：レイヤーを非表示に
________________________________________________________________________*/
function hideLayWin(subObj) {
	setLayView(subObj,false);
	subObj.isVisible=false;
	pre_lwObj=subObj;
}


/*______________

初期化
_____________*/
function init() {
	lwObj=getLayName('LayWin0');

}
