







//	::::::::::::::: 簡易・ブラウザチェック :::::::::::::::



var usrAgent    = navigator.userAgent.toUpperCase( ) ;



var WIN	= ( usrAgent.indexOf("WIN") != -1 ) ? true : false ;

var MAC	= ( usrAgent.indexOf("MAC") != -1 ) ? true : false ;



var NN4	= ( document.layers ? true : false ) ;

var NN6	= ( document.getElementById && !document.all ? true : false ) ;

var IE4	= ( document.all && !document.getElementById ? true : false ) ;

var IE5	= ( document.all && document.getElementById ? true : false ) ;











//	:::::::::::::::::::: リンクの指定 ::::::::::::::::::::



//	JS

function setJsLink( which, URL )

{

	eval( which ).location = URL ;

}



//	HTML

function setHyperLink( linkName, which, URL )

{

	document.links[ linkName ].target = which ;

	document.links[ linkName ].href = URL ;

}











//	::::::::: レイヤー内のイメージを参照する関数 :::::::::



function getDivImage( layerObj,imgName )

{

	if ( NN4 )

	{

		return layerObj.document.images[ imgName ] ;

	}

	else

	{

		return document.images[ imgName ] ;

	}

}











//	::::::::::::::: レイヤーを参照する関数 :::::::::::::::

function refLayer( layerName, d )

{

	var i,x;

	

	if( !d )

	{

		d = document ;

	}



	if ( IE5 || NN6 )

	{

		x = d.getElementById( layerName ) ;

	}

	else if ( IE4 )

	{

		x = d.all[ layerName ] ;

	}

	else if ( NN4 )

	{

		x = d[ layerName ] ;



		for( i=0; !x && i<d.layers.length; i++ )

		{

			x = refLayer( layerName, d.layers[i].document ) ;

		}

	}



	return x;

}







//	::::::::::::::: レイヤーを初期化する関数 :::::::::::::

function initLayer( layerObj )

{

	if ( NN6 )

	{

		layerObj.style.width = layerObj.offsetWidth ;

		layerObj.style.height = layerObj.offsetHeight ;

	}

	else if( IE4 || IE5 )

	{

		layerObj.style.pixelLeft   = layerObj.offsetLeft ;

		layerObj.style.pixelTop    = layerObj.offsetTop ;

		layerObj.style.pixelWidth  = layerObj.offsetWidth ;

		layerObj.style.pixelHeight = layerObj.offsetHeight ;

	}

}











//	::::::::::::::: レイヤーの階層を変える :::::::::::::::



function setZindex( layerObj, zOrder )

{

	if ( NN4 )

	{

		layerObj.zIndex = zOrder ;

	}

	else

	{

		layerObj.style.zIndex = zOrder ;

	}

}



//	:::::::::::::::: レイヤーの階層を取得 ::::::::::::::::



function getZindex( layerObj )

{

	if ( NN4 )

	{

		return layerObj.zIndex;

	}

	else

	{

		return layerObj.style.zIndex ;

	}

}











//	::::::::::::::: レイヤーの表示・非表示 :::::::::::::::



function getLayerVisibility( layerObj )

{

	if ( NN4 )

	{

		return ( layerObj.visibility == "show" ) ;

	}

	else

	{

		return ( layerObj.style.visibility == "visible" ) ;

	}

}



function hideLayer( layerObj )

{

	if ( NN4 )

	{

		layerObj.visibility = "hide" ;

	}

	else

	{

		layerObj.style.visibility = "hidden" ;

	}

}



function showLayer( layerObj )

{

	if ( NN4 )

	{

		layerObj.visibility = "show" ;

	}

	else

	{

		layerObj.style.visibility = "visible" ;

	}

}











//	:::::::::::::::::: レイヤーを動かす ::::::::::::::::::



function shiftLayerTo( layerObj, x, y )

{

	if ( NN4 )

	{

		layerObj.moveTo( x, y ) ;

	}

	else if ( NN6 )

	{

		layerObj.style.left = x ;

		layerObj.style.top  = y ;

	}

	else

	{

		layerObj.style.pixelLeft = x ;

		layerObj.style.pixelTop  = y ;

	}

}



function shiftLayerBy( layerObj, x, y )

{

	if ( NN4 )

	{

		layerObj.moveBy( x, y ) ;

	}

	else if ( NN6 )

	{

		layerObj.style.left = getLayerPosition( layerObj, 'left' ) + x ;

		layerObj.style.top  = getLayerPosition( layerObj, 'top' ) + y ;

	}

	else if ( IE4 || (MAC && IE5) )

	{

		layerObj.style.pixelLeft += x ;

		layerObj.style.pixelTop  += y ;

	}

	else

	{

		layerObj.style.pixelLeft = layerObj.offsetLeft + x ;

		layerObj.style.pixelTop  = layerObj.offsetTop  + y ;

	}

}











//	::::::::::::::: レイヤーの大きさを変更 :::::::::::::::



function resizeLayerTo( layerObj, width, height )

{

	if ( NN4 )

	{

		layerObj.resizeTo( width, height ) ;

	}

	else if ( NN6 )

	{

		layerObj.style.width = width ;

		layerObj.style.height = height ;

	}

	else

	{

		layerObj.style.pixelWidth  = width ;

		layerObj.style.pixelHeight = height ;

	}

}











//	::::::::::::::::: レイヤーの値を取得 :::::::::::::::::



function getLayerSize( layerObj, value )

{

	if( value == "width" )

	{

		if ( NN4 )

		{

			return layerObj.document.width ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.width ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelWidth ;

		}

		else

		{

			return layerObj.offsetWidth ;

		}

	}

	if( value == "height" )

	{

		if ( NN4 )

		{

			return layerObj.document.height ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.height ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelHeight ;

		}

		else

		{

			return layerObj.offsetHeight ;

		}

	}

}











//	::::::::::::::: クリッピングの値を取得 :::::::::::::::



function getClipValue( layerObj, value )

{

	if( IE4 || IE5 || NN6 )

	{

		var cp = layerObj.style.clip.split(" ") ;

		cp[0] = cp[0].slice(5) ;



		switch ( value )

		{

			case "top" :

				return parseInt( cp[0] ) ;

			case "right" :

				return parseInt( cp[1] ) ;

			case "bottom" :

				return parseInt( cp[2] ) ;

			case "left" :

				return parseInt( cp[3] ) ;

		}

	}

	else

	{

		switch ( value )

		{

			case "top" :

				return ( layerObj.clip.top ) ;

			case "right" :

				return ( layerObj.clip.right ) ;

			case "bottom" :

				return ( layerObj.clip.bottom ) ;

			case "left" :

				return ( layerObj.clip.left ) ;

		}

	}

}











//	:::::::::::::::::::: クリッピング ::::::::::::::::::::



function clipLayerTo( layerObj, t, r, b, l )

{

	if ( NN4 )

	{

		layerObj.clip.top    = t ;

		layerObj.clip.right  = r ;

		layerObj.clip.bottom = b ;

		layerObj.clip.left   = l ;

	}

	else

	{

		layerObj.style.clip = "rect("+t+" "+r+" "+b+" "+l+")" ;

	}

}



function clipLayerBy( layerObj, t, r, b, l )

{

	var nextClipValue_top    = getClipValue( layerObj,'top'   ) + t ;

	var nextClipValue_right  = getClipValue( layerObj,'right' ) + r ;

	var nextClipValue_bottom = getClipValue( layerObj,'bottom') + b ;

	var nextClipValue_left   = getClipValue( layerObj,'left'  ) + l ;



	if ( NN4 )

	{

		layerObj.clip.top    = nextClipValue_top ;

		layerObj.clip.right  = nextClipValue_right ;

		layerObj.clip.bottom = nextClipValue_bottom ;

		layerObj.clip.left   = nextClipValue_left ;

	}

	else

	{

		layerObj.style.clip = "rect("+ nextClipValue_top    + "px "

										+ nextClipValue_right  + "px "

										+ nextClipValue_bottom + "px "

										+ nextClipValue_left   + "px)" ;

	}

}











function wipeLayerBy( layerObj, endPoint, direction, wipeType, step )

{

	var speed = 1 ;

	var t = r = b = l = 0 ;



	step += 1 ;



	if ( wipeType == "wipeIn" )

	{

		if ( direction == "fromLeft" )

		{

			if ( ( getClipValue(layerObj,'right') + step ) < endPoint )

			{

				r = step ;

			}

			else if ( getClipValue(layerObj,'right') < endPoint )

			{

				r = endPoint - getClipValue(layerObj,'right') ;

			}

		}

		if ( direction == "fromRight" )

		{

			if ( ( getClipValue(layerObj,'left') - step ) > endPoint )

			{

				l = -step ;

			}

			else if ( getClipValue(layerObj,'left') > endPoint )

			{

				l = endPoint - getClipValue(layerObj,'left') ;

			}

		}

		if ( direction == "fromTop" )

		{

			if ( ( getClipValue(layerObj,'bottom') + step ) < endPoint )

			{

				b = step ;

			}

			else if ( getClipValue(layerObj,'bottom') < endPoint )

			{

				b = endPoint - getClipValue(layerObj,'bottom') ;

			}

		}

		if ( direction == "fromBottom" )

		{

			if ( ( getClipValue(layerObj,'top') - step ) > endPoint )

			{

				t = -step ;

			}

			else if ( getClipValue(layerObj,'top') > endPoint )

			{

				t = endPoint - getClipValue(layerObj,'top') ;

			}

		}

		if ( direction == "fromCenterX" )

		{

			if ( ( getClipValue(layerObj,'left') - step ) > endPoint )

			{

				r = step ;

				l = -step ;

			}

			else if ( getClipValue(layerObj,'left') > endPoint )

			{

				r = ( endPoint - getClipValue(layerObj,'left') ) * -1 ;

				l = endPoint - getClipValue(layerObj,'left') ;

			}

		}

		if ( direction == "fromCenterY" )

		{

			if ( ( getClipValue(layerObj,'top') - step ) > endPoint )

			{

				t = -step ;

				b = step ;

			}

			else if ( getClipValue(layerObj,'top') > endPoint )

			{

				t = endPoint - getClipValue(layerObj,'top') ;

				b = ( endPoint - getClipValue(layerObj,'top') ) * -1 ;

			}

		}

	}



	if ( wipeType == "wipeOut" )

	{

		if ( direction == "fromLeft" )

		{

			if ( ( getClipValue(layerObj,'left') + step ) < endPoint )

			{

				l = step ;

			}

			else if ( getClipValue(layerObj,'left') < endPoint )

			{

				l = endPoint - getClipValue(layerObj,'left') ;

			}

		}

		if ( direction == "fromRight" )

		{

			if ( ( getClipValue(layerObj,'right') - step ) > endPoint )

			{

				r = -step ;

			}

			else if ( getClipValue(layerObj,'right') > endPoint )

			{

				r = endPoint - getClipValue(layerObj,'right') ;

			}

		}

		if ( direction == "fromTop" )

		{

			if ( ( getClipValue(layerObj,'top') + step ) < endPoint )

			{

				t = step ;

			}

			else if ( getClipValue(layerObj,'top') < endPoint )

			{

				t = endPoint - getClipValue(layerObj,'top') ;

			}

		}

		if ( direction == "fromBottom" )

		{

			if ( ( getClipValue(layerObj,'bottom') - step ) > endPoint )

			{

				b = -step ;

			}

			else if ( getClipValue(layerObj,'bottom') > endPoint )

			{

				b = endPoint - getClipValue(layerObj,'bottom') ;

			}

		}

		if ( direction == "fromCenterX" )

		{

			if ( ( getClipValue(layerObj,'right') - step ) > endPoint )

			{

				r = -step ;

				l = step ;

			}

			else if ( getClipValue(layerObj,'right') > endPoint )

			{

				r = endPoint - getClipValue(layerObj,'right') ;

				l = ( endPoint - getClipValue(layerObj,'right') ) * -1 ;

			}

		}

		if ( direction == "fromCenterY" )

		{

			if ( ( getClipValue(layerObj,'bottom') - step ) > endPoint )

			{

				t = step ;

				b = -step ;

			}

			else if ( getClipValue(layerObj,'bottom') > endPoint )

			{

				t = ( endPoint - getClipValue(layerObj,'bottom') ) * -1 ;

				b = endPoint - getClipValue(layerObj,'bottom') ;

			}

		}

	}



	clipLayerBy( layerObj, t, r, b, l ) ;



	if ( ( t || r || b || l ) == 0 )

	{

		clearTimeout( ClipAction ) ;

		return false ;

	}

	else

	{

		ClipAction = setTimeout( "wipeLayerBy('"+layerObj+"',"+endPoint+",'"+direction+"','"+wipeType+"',"+step+")", speed) ;

	}

}











//	::::::::::::::::: レイヤーの座標を取得 :::::::::::::::::



function getLayerPosition( layerObj, value )

{

	if( value == "top" )

	{

		if ( NN4 )

		{

			return layerObj.top ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.top ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelTop ;

		}

		else

		{

			return layerObj.offsetTop ;

		}

	}

	if( value == "right" )

	{

		if ( NN4 )

		{

			return layerObj.left + getLayerSize( layerObj, "width" ) ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.left + getLayerSize( layerObj, "width" )  ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelLeft + getLayerSize( layerObj, "width" ) ;

		}

		else

		{

			return layerObj.offsetLeft + getLayerSize( layerObj, "width" ) ;

		}

	}

	if( value == "bottom" )

	{

		if ( NN4 )

		{

			return layerObj.top + getLayerSize( layerObj, "height" ) ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.top + getLayerSize( layerObj, "height" ) ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelTop + getLayerSize( layerObj, "height" ) ;

		}

		else

		{

			return layerObj.offsetTop + getLayerSize( layerObj, "height" ) ;

		}

	}

	if( value == "left" )

	{

		if ( NN4 )

		{

			return layerObj.left ;

		}

		else if ( NN6 )

		{

			return parseInt( layerObj.style.left ) ;

		}

		else if ( IE4 )

		{

			return layerObj.style.pixelLeft ;

		}

		else

		{

			return layerObj.offsetLeft ;

		}

	}

}











//	:::::::::::::: イベント発生座標を取得 ::::::::::::::



function getEventX( evt )

{

	if ( NN4 )

	{

		return evt.x ;

	}

	else if ( NN6 )

	{

		return ( window.scrollX + evt.clientX ) ;

	}

	else if ( IE4 || IE5 )

	{

		return ( document.body.scrollLeft + event.clientX ) ;

	}

}



function getEventY( evt )

{

	if ( NN4 )

	{

		return evt.y ;

	}

	else if ( NN6 )

	{

		return ( window.scrollY + evt.clientY ) ;

	}

	else if ( IE4 || IE5 )

	{

		return ( document.body.scrollTop + event.clientY ) ;

	}

}











//	::::::::::::: レイヤーの中央座標を取得 :::::::::::::



function getCenterSize( layerObj, which )

{

	return ( getWinSize( which ) - getLayerSize( layerObj, which ) ) / 2 ;

}











//	:::::::::::::: レイヤーの内容を書き換える関数 ::::::::::::::



function replaceContent( layerObj, txt )

{

	if ( NN4 )

	{

		layerObj.document.open( "text/html" ) ;

		layerObj.document.write( txt ) ;

		layerObj.document.close( ) ;

	}

	else

	{

		layerObj.innerHTML = txt ;

	}

}











//	:::::::::::::: ページのオフセットを取得 ::::::::::::::



function getPageOffset( which )

{

	if ( which == "left" )

	{

		if ( NN4 )

		{

			return self.pageXOffset ;

		}

		else if ( NN6 )

		{

			return window.scrollX ;

		}

		else

		{

			return document.body.scrollLeft ;

		}

	}

	if ( which == "top" )

	{

		if ( NN4 )

		{

			return self.pageYOffset ;

		}

		else if ( NN6 )

		{

			return window.scrollY ;

		}

		else

		{

			return document.body.scrollTop ;

		}

	}

}











//	:::::::::::::::: windowの大きさを取得 ::::::::::::::::



function getWinSize( which )

{

	if ( which == "width" )

	{

		if ( NN4 || NN6 )

		{

			return window.innerWidth ;

		}

		else

		{

			return document.body.clientWidth ;

		}

	}

	if ( which == "height" )

	{

		if ( NN4 || NN6 )

		{

			return window.innerHeight ;

		}

		else

		{

			return document.body.clientHeight ;

		}

	}

}











//	:::::::::::::::::: 画面のスクロール ::::::::::::::::::



function doPageScroll( st_X,max_X,st_Y,max_Y )

{

	var diffX,diffY,stepX,stepY,moveX,moveY ;



	diffX = .1 * ( max_X - st_X ) ;

	if( diffX > 0 )

		stepX = Math.ceil( diffX ) ;

	else

		stepX = Math.floor( diffX ) ;



	diffY = .1 * ( max_Y - st_Y ) ;

	if( diffY > 0 )

		stepY = Math.ceil( diffY ) ;

	else

		stepY = Math.floor( diffY ) ;



	moveX = st_X + stepX ;

	moveY = st_Y + stepY ;

	

// window.status = "X is : " +moveX+ " Y is : " +moveY ;



	if ( stepX > 0 && moveX <= max_X || stepY > 0 && moveY <= max_Y ||

		 stepX < 0 && moveX >= max_X || stepY < 0 && moveY >= max_Y )

	{

		scroll( moveX,moveY )



		st_X += stepX ;

		st_Y += stepY ;



		setTimeout( "doPageScroll( " +st_X+ "," +max_X+ "," +st_Y+ "," +max_Y+ " )",1 ) ;

	}

	else return true ;

}



function pageScrollTo( max_X,max_Y )

{

	var st_X,st_Y ;



	st_X = getPageOffset( "left" ) ;

	st_Y = getPageOffset( "top" ) ;



	doPageScroll( st_X,max_X,st_Y,max_Y ) ;

}











//	::::::::::::::: 新しくwindowを開く関数 :::::::::::::::



function openWin( url, w, h, winName )

{

	var startWinX = ( screen.availWidth  - w ) / 2 ;

	var startWinY = ( screen.availHeight - h ) / 2 ;



	if ( arguments[4] == "no" )

		winOption = "directories=no,status=no,scrollbars=no,toolbar=no,location=no,menubar=no,resizable=yes,width=" + w + ",height=" + h + ",left=" + startWinX + ",top=" + startWinY ;



	if ( arguments[4] == "yes" )

		winOption = "directories=yes,status=yes,scrollbars=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes,width=" + w + ",height=" + h + ",left=" + startWinX + ",top=" + startWinY ;



	winName = window.open( url, winName, winOption ) ;

	winName.focus( ) ;

}











//	:::::::::::::::::: サブ・ウィンドウ ::::::::::::::::::



function delayWin( url, winOption )

{

	var submenu = window.open ( url, "subwin", winOption ) ;



	if ( closetime )

		setTimeout("submenu.close( );", closetime * 1000 ) ;

}



function openSubWin( url,w,h,st,sc,t,l,m,r,x,y,ct,delay )

{

	closetime	= ct ;



	var winOption = "status=" + st + ",toolbar=" + t + ",location=" + l + ",menubar=" + m + ",scrollbars=" + sc + ",resizable=" + r + ",left=" + x + ",top=" + y + ",width=" + w + ",height=" + h ;



	setTimeout("delayWin( '" +url+ "','" +winOption+ "' )", delay * 1000 );

}











function intToHex( Integer )

{

	var hexValue = Integer.toString( 16 ) ;



	if ( hexValue.length == 1 ) hexValue = "0"+hexValue ;



	return hexValue ;

}



function hexToInt( hex )

{

	return parseInt( hex, 16 ) ;

}











function viewSource( fileName )

{

	var file     = ( fileName ) ? fileName : location.href ;

	var filePath = 'view-source:' + file ;



	location.href = filePath ;

}











