var $ = jQuery.noConflict();

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	}
});


$(function() {
	
	adapte_foot();
	
	if( jQuery.browser.msie && jQuery.browser.version<8 ) {
		
		jQuery('div#axome_home_contenu ul li:not(:first)').css('display', 'none');
		jQuery('div#sousnav ul li *').css('float', 'left');
		
		jQuery(this).find("h1 a").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
	} else {

		var mrg = 0;
		var wli = 338;
		var nb = $('#slide_ben ul li').length;
		var poz = 1;
		
		if( nb )
			setInterval(function() {
				var ml = "-"+(wli*poz)+"px";
				$("#slide_ben ul").stop().animate({marginLeft: ml}, {queue:false, duration: 990, easing: 'easeOutBounce'});
				poz++;
				if( poz>nb-1) poz = 0;
			}, 2900);
	}
});

$.event.add(window, "resize", adapte_foot);



function adapte_foot() {
	var t = 160;
	var h = $(window).height();
	var d = t+$('div#pied_axome').position().top;
	if( d<h ) {
		$('div#pied_axome').css('height', 130+(h-d)+'px');
	}
}


	var scrollSpeed = 100;
	var step = 1;
	var current = 0;
	var imageWidth = 1400;
	var headerWidth = 713;		

	var restartPosition = -(imageWidth - headerWidth);

	function scrollBg(){
		current -= step;
		if (current == restartPosition){
			current = 0;
		}

		$('body').css("background-position",current+"px 0");
	}

	var init = setInterval("scrollBg()", scrollSpeed);
