var offset = ""; 
var user_agent,browser, IE6;

$(document).ready(function() {
	
	
	setTimeout("init_line()",1500);
	
	
	if($(".zoom_image").length)
	{
		$(".zoom_image").fancybox({
			'overlayOpacity'	:	0.5,
			'overlayColor'		:	'#000000',
			'zoomSpeedIn'		:	500,
			'zoomSpeedOut'		:	480,
			'transitionIn'		:	'elastic',
			'transitionOut'		:	'elastic',
			'easingIn'			: 	'easeOutBack',
			'easingOut'			: 	'easeInBack',		
			'centerOnScroll'	: 	true,
			'titleShow'			: 	true,
			'titlePosition'		:	'over'
		});
	}

	if($(".zoom_offre").length)
	{
		
		$(".zoom_offre").fancybox({
			'overlayOpacity'	:	0.5,
			'overlayColor'		:	'#000000',
			'zoomSpeedIn'		:	500,
			'zoomSpeedOut'		:	480,
			'autoDimensions'	:	false,
			'width'				:	1000,
			'height'			:	300,
			'transitionIn'		:	'elastic',
			'transitionOut'		:	'elastic',
			'easingIn'			: 	'easeOutBack',
			'easingOut'			: 	'easeInBack',		
			'centerOnScroll'	: 	true,
			'titleShow'			: 	true,
			'titlePosition'		:	'over',
			'scrolling'			:	'yes',
			'onComplete': function() {
					$("#fancybox-wrap").css({'width':'630px'})
					$("#fancybox-inner").html("<img src='"+$(this).attr('href')+"' border='0'>").css({'width':'620px'});
				
			} 		
		});
	}
		
	user_agent = navigator.userAgent;
	
	var Reg = new RegExp("Opera")
	if(Reg.test(user_agent))
		browser = "opera";

	//Menu
	
	$("#nav li a.niv1").mouseenter(function(){
				if(!$(this).hasClass("no_click"))
					$(this).css({"background":"#d56c10"})
			})
			.mouseleave(function(){
				if(!$(this).hasClass("no_click"))
					$(this).css({"background":"#272846"})
			});
	
	//Mini news
	
	if(IE6)
	{
		$(".div_mininews").children()
				.mouseenter(function(){
					$(this).parent().css({"background":"#e6d9ce","cursor":"pointer"});
				})
				.mouseleave(function(){
					$(this).parent().css({"background":"none","cursor":"auto"});
				});
	}
	
	$('a.iframe').click(function() {
		var c, w, h, href, partial;
		
		w = $(this).attr('width') != undefined ? $(this).attr('width') : 700;
		h = $(this).attr('height') != undefined ? $(this).attr('height') : 400;
		href = $(this).attr('href');
		partial = $(this).hasClass('partial');
		if(partial)
		{
			$.post('includes/ajax_partial_page.php', {page: href}, function(page) {
				c = '<div style="background-color: #272846">'+page.content+'</div>';
				$.fancybox({
					autoDimensions: false,
					content: c,
					width: w,
					height: h,
					title: page.titre
				});
				return false;
			}, 'json');
		}
		else
		{
			$.fancybox({
				width: w,
				height: h,
				type: 'iframe',
				'href': href
			});
		}
		return false;
	});
	
});


function init_line()
{
	if($("#baseline").length){
		var py=$("#baseline").offset().top;
		$("#upline").css("top",(py+15)+"px");
	}
}

function format_nombre(valeur,decimal,separateur) {
// formate un chiffre avec 'decimal' chiffres après la virgule et un 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;}
	return val_format;
}



