// ------------[+]-- 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,type,movespd,stopspd) {

	this.box = getObjectById(par) ;
	this.inline = getObjectById(chi,par) ;

	var temptype = ( type ) ? type : 'none' ;
	switch( temptype ) {
		case 'loopup'   : this.loop = 1 ; this.type = this.temptype = 'up'   ; break ;
		case 'loopdown' : this.loop = 1 ; this.type = this.temptype = 'down' ; break ;
		case 'showup'   : this.loop = 0 ; this.type = this.temptype = 'up'   ; break ;
		case 'showdown' : this.loop = 0 ; this.type = this.temptype = 'down' ; break ;
		case 'none'     : this.loop = 0 ; this.type = this.temptype = 0      ; break ;
	}

	this.movespd = ( movespd ) ? ( this.loop && this.type == 'down' ) ? 
			Math.abs(movespd) : ( movespd < 0 ) ? movespd : -movespd : -5 ;
	this.stopspd = ( stopspd ) ? stopspd : 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.x = 0 ; this.y = this.startY ; this.flag = 0 ;
	return this ; 
} 
	initDemiIframeData.prototype.setalpha = setAlphaOfDemiIframe ;
	initDemiIframeData.prototype.resetalpha = resetAlphaOfDemiIframe ;
	initDemiIframeData.prototype.reset = resetDemiIframe ;


var oDemiIframeFlag = 0 ; var oDemiIframe ; 
function DemiIframe() {
	if( _bw.net4up || _bw.ie4up || _bw.opera6up ) {
		initDemiIframe() ; oDemiIframeFlag = 1 ; 
		for( var i = 0 ; i < oDemiIframe.length ; i++ ) 
			{ visibleDemiIframe( i ) }
	}
}

// oDemiIframeFlag 	= true 	| when page loaded
// pal.flag 		= true 	| scrollDemiIframe work
// pal.alphaflag 	= true  | AlphaFading work
// el.flag 			= true 	| moveDemiIframe work

function setDemiIframe( num1 , num2 ) { // boxnum , inlinenum
	if( oDemiIframeFlag ){ var pal = oDemiIframe[num1] ; 
		if( pal.num != num2 ) {
			if( pal.alphaflag ) {
				pal.div[pal.num].resetalpha() ; 
				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 resetAlphaOfDemiIframe() {
	this.alphaopac = ( ( !_bw.mac && _bw.ie4up ) || _bw.net6 ) ? 100 : 0 ;
	this.per = ( _bw.net6 ) ? '%' : '' ; this.alphatimer = 1 ;
	return this ;
}

function setAlphaOfDemiIframe() { 
	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 ; el.setalpha() ;
		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].resetalpha() ; pal.div[pal.num].setalpha() }

	pal.num = ( num2 >= 0 ) ? num2 : pal.num ; 
	var el = pal.div[pal.num] ; el.reset() ;
	setObjectTo( el.inline , 0 , el.y ) ;
	setObjectVisibility( el.inline , 1 ) ;
	setObjectVisibility( pal.box , 1 ) ;
	moveDemiIframe( num1 ) ;
}

function resetDemiIframe() {
	this.type = this.temptype ; this.flag = ( this.type ) ? 1 : 0 ;
	this.y = ( this.type ) ? ( this.type == 'up' ) ? this.clipHeight : -this.availHeight : 0 ;
	return this ;
}

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 ) }
	}
}


