// Created: march 13, 2007
// Author:  Zishan Zulfiqar

/*
	modified: 20070515
	author: ezra dalimunthe
	purpose: - to make the "floater" object created dinamically;
			 - to make use the library.js
	modify summary: removing id for each floater element;
	
*/

function Load()
{
}

/*
	write_floater (string text for floater head , 
				   string text to floater body,
				   int x position,
				   int y position);
*/

function write_floater(headerText,bodyText,xpos,ypos,intHeight)
{
	document.writeln('<div class="floater" style="left:'+xpos+'px;top:'+ypos+'px;" onmouseover="toggleBlock(this);" onmouseout="toggleBlock(this, true);">');
	document.writeln('<span class="header" >'+headerText+'</span>');
	if (intHeight){
		document.writeln('<div class="body"  mheight ='+intHeight+' style="position:absolute;z-index:0;overflow-y:auto;max-height:'+intHeight+'px;height:'+intHeight+'px"><span >'+bodyText+'</span></div>');	
		
	}
	else{
		document.writeln('<div class="body" style="position:absolute;z-index:0"><span >'+bodyText+'</span></div>');	
	}
		
	
	document.writeln('</div>');
	
}
var intRollSpeed = 10;
var intFadeSpeed = 1;

var int_tbOpacity = 0;
var int_tbHeight = 0;
var intTimeoutHide = null;
var intTimeoutId = null;
var intOH = null;

function toggleBlock (objFloater, boolHide) {
	
   if (typeof(boolHide)=='undefined') var boolVis = false;
   var objFloaterbody = _childNodes(objFloater)[1];
   var objFloaterbodyText = _childNodes(objFloaterbody)[0];
 
   
   if(boolHide){
      objFloaterbody.className = 'body bodyHid';
      intTimeoutHide = setTimeout('int_tbOpacity=0;int_tbHeight=0;', 10);
      clearTimeout(intTimeoutId);
      //objFloaterbody.style.height = 'auto';
      objFloater.style.zIndex =0;
      objFloaterbodyText.style.display = 'none';
   }else{
      objFloaterbody.className = 'body bodyVis';
      objFloaterbodyText.style.display = 'block';
      objFloater.style.zIndex =1000;
      	var maxh = objFloaterbody.style.maxHeight;
	   	if (!maxh)
	   	{
		   	maxh =objFloaterbody.getAttribute("mheight");
	   	} 
      //intOH = objFloaterbody.offsetHeight - 6;
      //elemById('topLeft').innerHTML=intOH;
      if (maxh)
      	intOH=maxh;
      else
      	intOH = objFloaterbody.offsetHeight - 6;
      tbFade(objFloater, intOH);
      clearTimeout(intTimeoutHide);
   }
}

function tbFade (objFloater, int_targetHeight) {
   if (typeof(int_targetHeight)=='undefined') var int_targetHeight = null;
   var objFloaterbody = _childNodes(objFloater)[1];
   var objFloaterbodyText = _childNodes(objFloaterbody)[0];
   
   	
   	
  if(int_tbOpacity<=7 || int_tbHeight < parseInt(int_targetHeight)){
    if(int_tbOpacity<=7) int_tbOpacity += intFadeSpeed;
    if(int_tbHeight < parseInt(int_targetHeight)) int_tbHeight += intRollSpeed;
    
    if(int_tbHeight >= parseInt(int_targetHeight)){
      if(!ie7) objFloaterbodyText.style.display = 'block';
      if(moz)objFloaterbody.style.height = 'auto';
    }else{
      if(!ie7) {objFloaterbodyText.style.display = 'none';
      objFloaterbody.style.height = int_tbHeight+'px';}
    }
      objFloaterbody.style.filter = 'alpha(opacity='+int_tbOpacity*10+')';
      objFloaterbody.style.KhtmlOpacity = '0.'+int_tbOpacity;
      objFloaterbody.style.MozOpacity = '0.'+int_tbOpacity;
      objFloaterbody.style.opacity = '.'+int_tbOpacity;
      intTimeoutId = setTimeout( function() {tbFade(objFloater,int_targetHeight)}, 40);
  }
  
}