//
// jstools.js
//
// javascript animation tools for div
//
// © nui - loic berthelot - 2009
// contact@libnui.net
//


function jt_swap (id, newsrc)
{
  img = getImage (id);
  if (img)  img.src = newsrc;	
}



function jt_update (id, imgid)
{
  div = getObject (id);
  img = getObject (imgid);	
  
  if (!img.width) { setTimeout ("jt_update('"+id+"', '"+imgid+"')", 200); return; }
  
  div.style.width = img.width;
  div.style.height = img.height;

}


function jsShow(div)
{
  div.style.visibility = "visible";
}


function jsHide(div)
{
  div.style.visibility = "hidden";
}


// opacity = [0.0 1.0]
function jsSetOpacity(obj, opacity) 
{
  // IE/Win
  if (ISIE)
    obj.style.filter = "alpha(opacity:"+(opacity*100)+")";
  else
  {
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity;
    
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity;
  }
}





function jt_position(div, x, y)
{
  	div.style.left = x;
  	div.style.top = y;	
}


function jt_resize(div, w, h)
{
  div.style.width = w;
  div.style.height = h;	
}

function jt_setTop(div, y)
{
  div.style.top = y + 'px';
}

function jt_setHeight(div, h)
{
  div.style.height = h + 'px';   
}

function jt_getHeight(div)
{
  return div.offsetHeight;
}  
  

function jt_positionBy(div, x, y)
{
	src = div.style.left;
	srcx = parseInt (src.substr(0, src.length-2));
	src = div.style.top;
	srcy = parseInt (src.substr(0, src.length-2));
	
  	div.style.left = srcx + x;
  	div.style.top = srcy + y;	
}






