/******************************************************************************
Copyright (C) Matteo Lucarelli - matteo@matteolucarelli.net
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
// these are some cross-browser fade effect
// should work with all browsers exept konqueror and opera
// NOTE: to work with ie the id dimension must be specified
// set opacity of id from 0 (hide) to 100 (show)
function setOpacity(id, value)
{
var elem = document.getElementById(id).style;
elem.opacity = (value / 100);
elem.MozOpacity = (value / 100);
elem.KhtmlOpacity = (value / 100);
//elem.setProperty("KhtmlOpacity","'"+value/100+"'");
elem.filter = "alpha(opacity=" + value + ")";
}
// opacity loop from opacStart to opacEnd
// time base is 1/10 sec
function fadeLoop(id, opacStart, opacEnd, time)
{
var timer = 0;
// switch between fade in and fade out
if(opacStart > opacEnd) {
for (i = opacStart; i >= opacEnd; i--) {
setTimeout("setOpacity('" + id + "'," + i + ")",(timer * time));
timer++;
}
} else if (opacStart < opacEnd) {
for (i = opacStart; i <= opacEnd; i++) {
setTimeout("setOpacity('" + id + "'," + i + ")",(timer * time));
timer++;
}
}
}
// opacity loop from current val to opacEnd
// time base is 1/10 sec
// should be cross-broser after 1 setOpacity call
function fadeTo(id, opacEnd, time)
{
// default val is 100
var opacCurr = 100;
// retrive current opacity
if(document.getElementById(id).style.opacity < 100)
opacCurr = document.getElementById(id).style.opacity * 100;
fadeLoop(id, opacCurr, opacEnd, time);
}