
questia.Package( "coreweb.ui" );

coreweb.ui.tips = new Object();
coreweb.ui.tips.func = new Object();

coreweb.ui.QTip = function(elementId, tipId, enabled ) {
   this.m_enabled = enabled;
	this.m_tipId = tipId;
	this.m_tip = document.getElementById(tipId);
	this.m_tippedId = elementId;
	coreweb.ui.tips[tipId] = this;
	
	this.getTippedId = function() {
		return this.m_tippedId;
	}	
	
	this.mouseOver = function() {
	   if ( !this.m_enabled ) {
	      return;
	   }
		var tipped = document.getElementById(this.m_tippedId);
		var pos = coreweb.common.ComponentUtils.getPosition( tipped );
		pos.x = pos.left + 20;
		pos.y = pos.top + tipped.offsetHeight + 5;
		this.m_tip.style.left = pos.x + 'px';
		this.m_tip.style.top = pos.y + 'px';
		this.m_tip.style.opacity = '.1';
		coreweb.ui.tips.func.showTip( 10, this.m_tipId );
		this.m_tip.style.display='block';
	}

	this.mouseOut = function( evt) {
		this.mouseDown();
	}
	
	this.mouseDown = function( evt ) {
	   if ( !this.m_enabled ) {
	      return;
	   }
		this.m_tip.style.display='none';
	}
}

coreweb.ui.tips.func.showTip = function( opac, tipId ) {
		opac = opac + 5;
		var qtip = coreweb.ui.tips[tipId];
		if ( opac < 95 ) {
			qtip.m_tip.style.opacity = '.'+opac;
			qtip.m_tip.style.filter = "alpha(opacity:"+opac+")";
			opacityID = window.setTimeout( "coreweb.ui.tips.func.showTip(" + opac + ", '" + tipId + "' )", 15);
		}
		else { 
			qtip.m_tip.style.opacity = '.95';
			qtip.m_tip.style.filter = "alpha(opacity:95)";
		}
}

