$(function(){
	   
// 00. FONCTIONS
// *******************************
getFramerate = function(number){
	return 1000/number;	
}

getSize = function(elm){
	return { w : elm.width() ,	h : elm.height() };
}

getPosition = function(elm){
	pos = elm.css("backgroundPosition");
	//alert(pos);
	props = pos.split(" ");
	scene = getSize(elm);
	//alert(props +"/"+ scene.w +"/"+ scene.h);
	p = {x : 0 , y : 0};
	if(props.length > 1){
		switch(props[1]){
			case "top" :
				p.y = 0;
				break;
			case "center" :
				p.y = scene.h / 2;
				break;
			case "bottom" :
				p.y = scene.h;
				break;
		}
		switch(props[0]){
			case "left" :
				p.x = 0;
				break;
			case "center" :
				p.x = scene.w / 2;
				break;
			case "right" :
				p.x = scene.w;
				break;
		}
	}else{
		alert("just one props");
	}
	return p;
}

// 01. ANIMER UN BACKGROUND
// *******************************
var e 		= $("#body");
	e.css({height : 500});
var iSec 	= getFramerate(6);
var bckg	= { image 		: e.css("backgroundImage") ,
				position 	: getPosition(e), 
				repeat 		: e.css("backgroundRepeat") }

toLeft = function(){
	//alert(bckg.position.x);
	x = bckg.position.x--;
	//alert(x);
	e.css({ backgroundPosition : (x+"px "+y+"px") });
}

toRight = function(){
	//alert(bckg.position.x);
	x = bckg.position.x++;
	//alert(x);
	e.css({ backgroundPosition : (x+"px "+y+"px") });
}

animation = function(animation,speed,bckg){
	x = bckg.position.x;
	y = bckg.position.y;
	switch(animation){
		case "right" :
			setInterval(toRight,speed);
			break;
		default :
			setInterval(toLeft,speed);
			break;
	}
}

// 02. LANCER L'ANIMATION
// *******************************
if($.browser.msie && $.browser.version <= "6.0"){
	
}else{
	animation("right",iSec,bckg);
}

});