// JavaScript Document


// Fait clignoter un element
function Clignote ( eid , speed )
{
	if ( speed == undefined ) speed = 'slow';
	
	var fadeIn = function FadeIn ( eid )
	{
		jQuery('#' + eid).fadeIn ( speed , function() { fadeOut ( eid ); } );
	}
	
	var fadeOut = function FadeOut ( eid )
	{
		jQuery('#' + eid).fadeOut ( speed , function() { fadeIn ( eid ); } );
	}
	
	fadeOut ( eid );
}

function changeOpac(opacity, id) 
{
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function Opacity (id, opacStart, opacEnd, millisec) 
{
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	
	if(opacStart > opacEnd) 
	{
		for(i = opacStart; i >= opacEnd; i--) 
		{
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
    	}
	} 
	else if(opacStart < opacEnd) 
	{
		for(i = opacStart; i <= opacEnd; i++) 
		{
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
	}
}



/*
// Fait défiler un texte
function Defile ( eid , speed )
{
	if ( speed == undefined ) speed = 20;

	jQuery('#' + eid).marquee('pointer').mouseover
	(
		function ()
		{
			$(this).trigger('stop');
		}
	).mouseout
	(
		function ()
		{
			$(this).trigger('start');
		}
	)
	
}
*/


// Gère un slideshow
function Slideshow ( eid , ctrls , speed )
{
	if ( ctrls  == undefined ) ctrls = true;
	if ( speed  == undefined ) speed = 3000;
	
	
	// Determine la taille de la plus grande image
	var width = 0;
	var height = 0;
	var element = document.getElementById( eid );
	for ( i = 0; i < element.childNodes.length; i++ )
	{
		var child = element.childNodes[i];
		if ( child.width > width )
			width = child.width;
		if ( child.height > height )
			height = child.height;
	}

	
	
	jQuery(document).ready(
	function()
	{
		jQuery('#' + eid).slideshow(
		{
			title:false,
			width:width,
			height:height,
			playframe:false,
			time:speed,
			play:true,
			imgresize:false,
			imgzoom:false,
			panel:ctrls,
			imgcenter:true,
			
			controls:
			{
				'hide':false,
				'help':false
			}
		});
	}
);
}

