// JavaScript Document
    
        /*
	 *
	 *
	 * Multimed Popup
	 */	
	 $('.ms_popup').click(function(){
		 
		 classlist = $('.ms_popup').attr('class');
		 classlist = classlist.split(' ');
		 idpopup = classlist[1];	
		 displayPopup(idpopup);	 
         });
	 
	 function displayPopup(idcontent)
	 {
		  content = $('#'+idcontent).html() + '<div id="close_ms_popup"></div>';
		  
		  if (!$('#bg_ms_popup').length)
		     $('body').prepend('<div id="bg_ms_popup"></div><div id="ms_popup"></div>');
			 
		  $('#bg_ms_popup').css({
			 'width'      : $(window).width(),
			 'height'     : $(window).width(),
			 'background' : '#000',
			 'opacity'    : '0.8'
		  });
		  
		  $('#ms_popup').css({
			 'background' : '#fff'		  
		  });
		  
		  $('#ms_popup').html(content);
		  
		  $('#bg_ms_popup').show();
		  $('#ms_popup').show();
	 }
	 //Fermeture
	 $('#bg_ms_popup').live('click', function(){closepopup()});
	 $('#close_ms_popup').live('click', function(){closepopup()});
	 
	 function closepopup()
         {
	    $('#bg_ms_popup').hide();
	    $('#ms_popup').hide();
         }  
         
         
         
         
         
         

// 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
			}
		});
	}
);
}

/*
 * 
 * 
 * Adwords pour la page de devis
 */
function adwords()
{
    if($('#convertionAdw').length)
    {
       $.get('/include/code/conversionAdwordDevis.html', function(data) {
             $('#convertionAdw').html(data);
       });
               
    }
}
