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

mousefade.js - fading and mouse
    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 mousefadeInit(id,attribut,out2,over2,out1,over1,focus){
	var item=document.getElementById(id);

	item.mousefadeColorOver1=over1;
	item.mousefadeColorOver2=over2;
	item.mousefadeColorOut1=out1;
	item.mousefadeColorOut2=out2;
	item.mousefadeFocus=focus;
	item.mousefadeMouseOver=0;

	/* ----- Initialisation des classes des miniatures ----- */
	if(item.mousefadeFocus) {
		fade_init(id,attribut,item.mousefadeColorOut1,item.mousefadeColorOut1);
	} else {
		fade_init(id,attribut,item.mousefadeColorOut2,item.mousefadeColorOut2);
	}

	eventAddAfter(item,'onmouseout','mousefadeOut("'+id+'")');
	eventAddAfter(item,'onmouseover','mousefadeOver("'+id+'")');
}

/* ----- ----- mousefadeFocus ----- -----
Elément devient actif
id : identifiant
*/
function mousefadeFocus(id) {
	var item=document.getElementById(id);

	item.mousefadeFocus=1;
	if(item.mousefadeMouseOver) {
		fade_color(id,item.mousefadeColorOver1);
	} else {
		fade_color(id,item.mousefadeColorOut1);
	}
}

/* ----- ----- mousefadeUnfocus ----- -----
Elément deviens inactif
id : identifiant
*/
function mousefadeUnfocus(id) {
	var item=document.getElementById(id);

	item.mousefadeFocus=0;
	if(item.mousefadeMouseOver) {
		fade_color(id,item.mousefadeColorOver2);
	} else {
		fade_color(id,item.mousefadeColorOut2);
	}
}

/* ----- ----- mousefadeOver ----- -----
Evénement onmouseover sur miniatures
*/
function mousefadeOver(id){
	var item=document.getElementById(id);

	item.mousefadeMouseOver=1;
	if(item.mousefadeFocus) {
		fade_set(id,item.mousefadeColorOver1);
	} else {
		fade_set(id,item.mousefadeColorOver2);
	}
}

/* ----- ----- mousefadeOut ----- -----
Evénement onmouseout sur miniatures
*/
function mousefadeOut(id){
	var item=document.getElementById(id);

	item.mousefadeMouseOver=0;
	if(item.mousefadeFocus) {
		fade_color(id,item.mousefadeColorOut1);
	} else {
		fade_color(id,item.mousefadeColorOut2);
	}
}
