// fdrlib.js - version 1.0
// FadeDropRaise Library for Javascript
// Nick O'Neill 2005

function fadeElementIn(id,time,begin){
   // <a href="javascript:fadeElementIn(myelementid,0.3)">fade in!</a>
   // ---- SET THESE IN YOUR SCRIPTS
   // id is the id of the element you're fading
   // time is the amount of time you'd like your element to spend fading in (try 0.3)
   // set final opacity after fade in on line 30 - change .93 to 1 to remove opacity after faded in
   
   // ---- DON'T SET THESE IN YOUR SCRIPTS
   // begin is the start time of your fade - it will be set automatically when the function is called
       
   var elem = getByID(id);
   
   var current = new Date().getTime();
   if (typeof(begin) == "number"){}
   else {begin = new Date().getTime()}
   
   var timeDiff = (current - begin) / 1000; // /
   
   if (timeDiff < time){
      
      var boxOpacity = (timeDiff/time)*(timeDiff/time);

      setOpacity(elem.id,boxOpacity);
   
      setTimeout("fadeElementIn(\'"+id+"\',"+time+","+begin+")",16);
   } else {setOpacity(elem.id,.93);return} // change .93 to 1 to remove opacity after faded in
}

function setOpacity(id,opacity){
   var toSet = getByID(id);
   
   if (toSet.style.MozOpacity != null){toSet.style.MozOpacity = opacity;}
   if (toSet.style.opacity != null){toSet.style.opacity = opacity;}
   if (toSet.style.filter != null){toSet.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+(opacity*100)+")";}
}
function setTop(id,top){
   getByID(id).style.position = 'relative';
   getByID(id).style.top = pixel(top);
}
function getByID(n){
	var d = window.document;
	if (d.getElementById)
		return d.getElementById(n);
	else if (d.all)
		return d.all[n];
}
function pixel(px){
   return px+"px";
}
function antipixel(px){
   return parseInt(px.replace(/px/,''));
}
