/* ----- ----- ----- Free software Foundation - Affero Licence ----- ----- -----

diapo.js - Slideshow with fading
    Copyright (C) 2008  Thibault Garcia (thibault.garcia@revaweb.com)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

----- ----- ----- Free software Foundation - Affero Licence ----- ----- ----- */

function dispInit(id,img) {
	var el=document.getElementById(id);

	el.dispTimeOut=null;
	el.dispImg=document.getElementById(img);
	el.dispDelay=25;
	el.dispStep=0.1;

	el.onmouseover=function() { dispOver(el) };
	el.onmouseout=function() { dispOut(el); };

}

function dispOver(el) {
	if(el.dispTimeOut) clearTimeOut(el.dispTimeOut);

	el.dispImg.style.opacity=1;
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		el.dispImg.style.filter='alpha(opacity=100)';
		el.dispImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.dispImg.src+"', sizingMethod='scale')"
	}
	el.dispVal=1;
}

function dispOut(el) {
	if(el.dispTimeOut) clearTimeOut(el.dispTimeOut);

	if(el.dispVal-el.dispStep<0) {
		el.dispImg.style.opacity=0;

		if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
			el.dispImg.style.filter='alpha(opacity=0)';
		}
	} else {
		el.dispVal-=el.dispStep;
		el.dispImg.style.opacity=Math.round(100*el.dispVal)/100;

		if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
			el.dispImg.style.filter='alpha(opacity='+(100*el.dispVal)+')';
//			el.dispImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.dispImg.src+"', sizingMethod='scale')"
		}

		el.disptimeOut=setTimeout(function() { dispOut(el); },el.dispDelay);
	}
}