// JavaScript Document
//jQuery.noConflict();

jQuery(document).ready( function ($) {
	$(".fancybox").fancybox({
		'padding'		    : 10,
		'autoScale'     	: true,
		'autoDimensions'	: true,
		'centerOnScroll'	: true,
		'overlayOpacity'	: 0.7,
		//'width'				: 480,
		//'height'			: 360,
		'titleShow'			: true,
		'titlePosition'		: 'over',
		//'type'				: 'swf',
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'speedIn'			: 'fast',
		'speedOut'			: 'fast',
		//'swf'				: { wmode: 'transparent' },
		//'swf'				: { menu: 'false' },
		'overlayColor'		: '#000'
	});
});

function format(valeur,decimal,separateur) {
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	
	/*
	// left padding
	if (valeur < 10) val_format = "0.000.00"+val_format;
	else if (valeur < 100) val_format = "0.000.0"+val_format;
	else if (valeur < 1000) val_format = "0.000."+val_format;
	else if (valeur < 10000) val_format = "0.00"+val_format;
	else if (valeur < 100000) val_format = "0.0"+val_format;
	else if (valeur < 1000000) val_format = "0."+val_format;
	*/
	
	return val_format;
}


var t_compteur;
var compteur_start;
var compteur_end;
var compteur_pas_milliseconde;
var compteur_pas_valeur;
function refreshHomeCompteur(){
	if (compteur_start > compteur_end){
		compteur_start = compteur_end;
		clearInterval(t_compteur);
		jQuery("#compteur").addClass('anim-end');
	}
	compteur_start_text = format(compteur_start,0,'.');
	jQuery("#compteur p").html(compteur_start_text);
	compteur_start += compteur_pas_valeur;
	return;
}

function carousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

jQuery.fn.center = function () {
	var left = ((jQuery(window).width() - this.outerWidth()) / 2) + "px"; //+ jQuery(window).scrollLeft()
	//this.css("position","absolute");
	this.css("left", left);
    return this;
}

/*
jQuery(document).ready(function($){
    $('#carousel').jcarousel({
		auto: 3,
		animation: "slow",
		easing: "easeInOutQuint",
		
        scroll: 1,
		visible: 1,
		initCallback: carousel_initCallback,
        //buttonNextHTML: null,
        //buttonPrevHTML: null,
		wrap: 'both'
    });
	
    $('#slide').center();
    $(window).bind('resize', function() {
        $('#slide').center();
    });
});
*/
