// ------------[+]-- DynamicHTML demiIframe 
// ------------[+]-- Copyright (C) 2002- HP-DESIGN.NET. 
// ------------[+]-- Takeru [ http://hp-design.net/ ] 
// No reproduction , no republication without written permission of HP-DESIGN.NET 
// Must not delete this copyright in order to use this script 


function initDemiIframeBox(id,num,alphaflag,alphastep) {
	this.div = new Array() ;
	this.box = getObjectById(id) ;
	this.clipHeight = ( _bw.net4 ) ? 
			this.box.clip.height : getObjectHeight(this.box) ;
	this.alphaflag = ( ( !_bw.mac && _bw.ie4up ) || _bw.net6 ) ?
			( alphaflag >= 0 ) ? alphaflag : 1 : 0 ;
	this.alphastep = ( alphastep ) ? alphastep : 5 ;
	this.num = ( num ) ? num : 0 ; 
	this.speed = 50 ;
	this.timerID = 1 ; this.flag = 0 ;

	return this ;
}

function initDemiIframeData(chi,par,loop,type,movespd,stopspd) {

	this.box = getObjectById(par) ;
	this.inline = getObjectById(chi,par) ;
	this.loop = ( loop ) ? loop : 0 ; 
	this.movespd = ( movespd ) ? ( loop && type == 'down' ) ? Math.abs(movespd) : 
			( movespd < 0 ) ? movespd : -movespd : -5 ;
	this.stopspd = ( stopspd ) ? stopspd : 0 ;
	this.type = this.temptype = ( type ) ? type : ( this.loop ) ? 
			( this.movespd < 0 ) ? 'up' : 'down' : 0 ; 

	this.clipHeight = ( _bw.net4 ) ? 
			this.box.clip.height : getObjectHeight(this.box) ;
	this.availHeight = ( this.clipHeight > getObjectHeight(this.inline) ) ? 
			this.clipHeight : getObjectHeight(this.inline) ; 

	this.Ytop = ( this.type && this.loop ) ? 
			-this.availHeight : this.clipHeight -this.availHeight ;
	this.Ybottom = ( this.type && this.loop ) ? this.clipHeight : 0 ;
	this.startY = ( this.type == 'down' ) ? this.Ytop : this.Ybottom ;
	this.endY = ( this.type == 'down' ) ? this.Ybottom :  this.Ytop ;

	this.alphaopac = ( ( !_bw.mac && _bw.ie4up ) || _bw.net6 ) ? 100 : 0 ;
	this.per = ( _bw.net6 ) ? '%' : '' ; this.alphatimer = 1 ;
	this.setalpha  = setAlphaOfDemiIframe ; 

	this.x = 0 ; this.y = this.startY ; this.flag = 0 ;
	return this ; 
}

var oDemiIframeFlag = 0 ; var oDemiIframe ; 
function DemiIframe() {
	if( _bw.net4up || _bw.ie4up || _bw.opera6 ) {
		initDemiIframe() ; oDemiIframeFlag = 1 ; 
		for( var i = 0 ; i < oDemiIframe.length ; i++ ) 
			{ visibleDemiIframe( i ) }
	}
}

// oDemiIframeFlag 	= true 	| ページの読みこみ完了
// pal.flag 		= true 	| scrollDemiIframe 使用可能
// el.flag 			= true 	| moveDemiIframe 使用可能
// el.alphaflag 	= true  | AlphaFading 使用可能

function setDemiIframe( num1 , num2 ) { // boxnum , inlinenum
	if( oDemiIframeFlag ){ var pal = oDemiIframe[num1] ; 
		if( pal.num != num2 ) {
			if( pal.alphaflag ) {
				pal.div[pal.num].setalpha() ; 
				changeAlphaOfDemiIframe( num1 , num2 ) ;
			} else { 
				setObjectVisibility( pal.div[pal.num].inline , 0 ) ;
				pal.num = ( num2 >= 0 ) ? num2 : pal.num ; 
				visibleDemiIframe( num1 ) ;
			}
		}
	}
}

function changeDemiIframe( num1 ,num2 ){
	var pal = oDemiIframe[num1] ; 
	if( pal.div[pal.num].alphaflag ) { changeAlphaOfDemiIframe( num1 , num2 ) } 
	else { visibleDemiIframe( num1 ,num2 ) }
}

function setAlphaOfDemiIframe() { this.alphaopac = 100 ;
	if( _bw.ie4up ) { this.inline.style.filter = 'alpha(opacity=' + this.alphaopac + ')' }
	if( _bw.net6 ) { this.inline.style.MozOpacity = this.alphaopac + this.per }
}

function changeAlphaOfDemiIframe( num1 , num2 ) {
	var pal = oDemiIframe[num1] ; var el = pal.div[pal.num] ;
	if( ( el.alphaopac >= 0 ) ) { el.alphaopac -= pal.alphastep ; 
		if( _bw.ie4up ) { el.inline.style.filter = 'alpha(opacity=' + el.alphaopac + ')' }
		if( _bw.net6 ) { el.inline.style.MozOpacity = el.alphaopac + el.per }
		el.alphatimer = setTimeout("changeAlphaOfDemiIframe("+num1+","+num2+")",20) ;
	} else { clearTimeout(el.alphatimer) ; visibleDemiIframe( num1 ,num2 ) }
}

function visibleDemiIframe( num1 ,num2 ) { 
	var pal = oDemiIframe[num1] ; 
	setObjectVisibility( pal.div[pal.num].inline , 0 ) ;

	if( pal.alphaflag ) { pal.div[pal.num].setalpha() }

	pal.num = ( num2 >= 0 ) ? num2 : pal.num ; var el = pal.div[pal.num] ; 
	el.type = el.temptype ; el.flag = ( el.type ) ? 1 : 0 ;
	el.y = ( el.type ) ? ( el.type == 'up' ) ? el.clipHeight : -el.availHeight : 0 ;
	setObjectTo( el.inline , 0 , el.y ) ;
	setObjectVisibility( el.inline , 1 ) ;
	setObjectVisibility( pal.box , 1 ) ;
	moveDemiIframe( num1 ) ;
}

function scrollDemiIframe( num1 , movespd ) {
	if( oDemiIframeFlag ) {
		var pal = oDemiIframe[num1] ; el = pal.div[pal.num] ;
		if( pal.flag ) { el.movespd = movespd ; el.flag = true ; moveDemiIframe( num1 ) }
	}
}

function moveDemiIframe( num1 ) { 
	var pal = oDemiIframe[num1] ; var el = pal.div[pal.num] ;
	clearTimeout( pal.timerID ) ; pal.flag = ( !el.type ) ? 1 : 0 ;
	if( el.flag ) { var speed = pal.speed ; 
		var endY = ( el.type ) ? ( el.loop ) ? el.endY : 0 : 0 ; 
		var movespd = ( !el.loop && el.type ) ? -( el.y * 0.1 ) : el.movespd ;
		if( Math.abs( movespd ) < 1 ) { movespd = ( movespd > 0 ) ? 1 : ( movespd < 0 ) ? -1 : 0 }

		var flag = ( movespd < 0 ) ? 
			( ( el.y > el.Ytop ) ? 1 : 0 ) : ( ( el.y < el.Ybottom ) ? 1 : 0 ) ;

		if( flag ) { el.y += Math.round( movespd ) ;
			el.y = ( !el.type ) ? ( el.y <= el.Ytop ) ? 
					el.Ytop : ( el.y >= el.Ybottom ) ? el.Ybottom : el.y : el.y ;
			if( ( ( el.y <= endY ) && ( el.type == 'up' ) ) || 
				( ( el.y >= endY ) && ( el.type == 'down' ) ) ) { 
				if( !el.loop ) { el.flag = 0 ; el.type = 0 }
				else { el.y = el.startY ; speed = el.stopspd }
			} setObjectTo( el.inline , 0 , el.y ) ;
		} pal.timerID = setTimeout( 'moveDemiIframe(' + num1 +')' , speed ) ;
	}
}

function stopDemiIframe( num1 ) {
	if( oDemiIframeFlag ) {
		var pal = oDemiIframe[num1] ; var el = pal.div[pal.num] ; 
		if( pal.flag ) { el.flag = 0 ; clearTimeout( pal.timerID ) }
	}
}


