// ------------[+]-- DynamicHTML POPUP ELEVATER
// ------------[+]-- 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 initPopUpElev(id,top,mtop,mbottom) {

	this.id = getObjectById(id) ;
	this.divh = getObjectHeight(this.id) ;

	this.leftX = getObjectX(this.id) ;
	this.topY = this.currentY = top ? top : 0 ;

	this.mTop = mtop ? mtop : 0 ;
	this.mBottom = mbottom ? mbottom : 0 ;
	this.opened = 0 ; this.xflag = 0 ; this.timerID = 1 ;
	this.flag = false ;

	return this ;
}

var oPopUpElev ;
function startPopUpElev(id,top,mtop,mbottom) { // DIVid, position-top, margin-top, margin-bottom
	if( _bw.ie4up || _bw.net4up || _bw.opera6 ) {
		oPopUpElev = new initPopUpElev(id ,top,mtop,mbottom) ;
		moveyPopUpElev() ;
	} 
}

function moveyPopUpElev() { 
	var pal = oPopUpElev ; 
	var winh = getWindowHeight() ; var yt = getScrollY() ;

	if( winh >= pal.divh ) {
		if( winh >= pal.mTop + pal.divh + pal.mBottom ) {
			yt = Math.max( yt + pal.mTop , pal.topY ) ;
		} else {
			var yt1 = Math.max( yt + pal.mTop, pal.topY ) ;
			var f1 = ( yt1 > pal.currentY ) ? 1 : 0 ;
			var yt2 = yt - ( pal.divh + pal.mBottom - winh ) ;
			yt2 = Math.max( yt2, pal.topY ) ;
			var f2 = ( yt2 < pal.currentY ) ? 1 : 0 ;
			if ( f1 && f2 ) { yt = pal.currentY }
			else { yt = f2 ? Math.max( yt1 , yt2 ) : Math.min( yt1 , yt2 ) }
		}
		if( yt != pal.currentY ) {
			var vy = ( yt - pal.currentY ) * 0.25 ;
			if ( Math.abs(vy) < 1 ) { vy = (vy > 0) ? 1 : (vy < 0) ? -1 : 0 }
			pal.currentY += Math.round( vy );
			setObjectTo( pal.id , pal.leftX , pal.currentY ) ;
		}
	} setTimeout('moveyPopUpElev()', 20);
}

function initPopUpMenu(id) {
	this.id = getObjectById( id ) ;
	return this ;
} 

var oPopUpMenu ;
initPopUpMenu.prototype.visctrl = ctrlPopUpMenu ;

function PopUpMenu(id) {
	oPopUpMenu = new initPopUpMenu( id ) ;
	oPopUpMenu.visctrl() ;
}

function ctrlPopUpMenu() {
	this.flag = getObjectVisibility( this.id ) ;
	switch( this.flag ) {
		case 0 : this.flag = 1 ; break ;
		case 1 : this.flag = 0 ; break ;
	} setObjectVisibility( this.id , this.flag ) ;
}


