/*
####################################################################################################
# Art Studio Vincent
# HTML, JavaScript, CSS coding ; vincent.
# Web : http://vincent.site.ne.jp/
# Mail : admin@vincent.site.ne.jp
# Copyright (C) 2003 Art Studio Vincent All rights reserved.
####################################################################################################
*/
/* open popup window */
function popupWindow(url,winName,w,h,sb,rs) {
	var leftPos = (screen.width) ? (screen.width - w) / 2 : 0;
	var topPos  = (screen.height) ? ((screen.height - h) / 2) - 30 : 0;
	var property = 'width='+w+',height='+h+',left='+leftPos+',top='+topPos+',toolbar=0,location=0,directories=0,menubar=0,status=0,scrollbars='+sb+',resizable='+rs;
	winName = window.open(url,winName,property);
	self.onBlur = winName.focus();
}



// window resize bug evasion (for ns 4.x)
function reloadPage(e) { self.location.reload(); }
if (_ns4) {
	document.captureEvents(Event.RESIZE);
	window.onresize = reloadPage;
}
/*
####################################################################################################
# Keith69
# JavaScript coding ; keith
# Web : http://www.keith69.com/
# Mail : keith@jpacom.co.jp
# Copyright (C) 2003 Keith69 All rights reserved.
####################################################################################################
*/
/* popup centerWin */
function centerWin(_url,w,h,sb,rs) {
 var centerPos = (window.screenX + (window.innerWidth - w) / 2);
 var subWin;
 if (_ns4 || (_mac && _Opr6)) {
  statusBarHeight = (document.layers && window.statusbar.visible) ? 2 : 0;
  pos = "left=" + centerPos + ",top=" + (window.screenY + window.outerHeight - window.innerHeight - statusBarHeight - statusBarHeight - 40) + ",";
  subWin = window.open(_url,"",pos + 'width='+w+',height='+h+',toolbar=0,location=0,directories=0,status=0,menubar=yes,scrollbars='+sb+',resizable='+rs+',favorites=0,titlebar=0');
  subWin.focus();
 }
}
/*
####################################################################################################
*/

/* PopUp Manu */

var msX;
var msY;
var tmrID;					// タイマーID
var hdlPopUp = null;		// ポップアップハンドル

function openPopUp(strMsg){

	// メニュー表示処理
	
	getMousePos(event);

	moveLayer("popup",msX+0,msY-50);

	strMsg='<table border="0" cellspacing="1" cellpadding="3"><tr><td class="popup">'+strMsg+'</td></tr></table>';

	outputLAYER("popup",strMsg);

	showLayer("popup");

}

function closePopUp(){

	// ポップアップ削除処理

	if(hdlPopUp == null){
		return;
	}

	if ( document.getElementById )
		document.getElementById( hdlPopUp ).style.visibility = 'hidden' 
	else if ( document.all ) 
		document.all( hdlPopUp ).style.visibility = 'hidden' 
	else if ( document.layers )
		document.layers[ hdlPopUp ].visibility = 'hide' 

	hdlPopUp = null;

}


function outputLAYER(layName,html){

	if(document.getElementById){
		document.getElementById(layName).innerHTML=html
	} else if(document.all){
		document.all(layName).innerHTML=html
	} else if(document.layers) {
		document.layers[layName].document.open()
		document.layers[layName].document.write(html)
		document.layers[layName].document.close()
    }

}

function showLayer(objName){ 

	if ( document.getElementById )
		document.getElementById( objName ).style.visibility = 'visible' 
	else if ( document.all )
		document.all( objName ).style.visibility = 'visible' 
	else if ( document.layers )
		document.layers[ objName ].visibility = 'show' 

	hdlPopUp = objName;

}

function moveLayer(objName,x,y){
      
	if(document.getElementById){
		document.getElementById(objName).style.left=x;
		document.getElementById(objName).style.top=y;
	}else if(document.all){
		document.all(objName).style.pixelLeft=x;
		document.all(objName).style.pixelTop=y;
	}else if(document.layers){
		document.layers[objName].moveTo(x,y);
	}

}

function getMousePos(e) {

	if (window.opera) {
		msX=e.clientX;
		msY=e.clientY;
	}else if (document.all) {
		msX=document.body.scrollLeft+event.clientX;
		msY=document.body.scrollTop+event.clientY;
	}else if (document.layers || document.getElementById) {
		msX=e.pageX;
		msY=e.pageY;
	}
}

/* swapImg */

function swapImgRestore() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
