/*** ITL Technologie 2010 (C) ***/

var ANIMATION_FPS = 30;

// Set the bottom margin
function setAbsBottom($Element, $Value) {
	setStyle($Element, 'bottom', $Value+'px');
};


// Open the menu
function openMenu($id, $xoffset, $scroll_cat) {
	if($id != 'menu_forfait_spa') closeMenu('menu_forfait_spa', true);
	if($id != 'menu_forfait_versa') closeMenu('menu_forfait_versa', true);
	if($id != 'menu_forfait_happy') closeMenu('menu_forfait_happy', true);
	var $element = document.getElementById($id);
	var $start = -parseInt(getStyle($element)['height']);
	
	setStyle($element, 'left', $xoffset+'px');
	startAnim($element, setAbsBottom, $start, 0, 250, ANIMATION_FPS, stepf_linear);
	
	init_changeImage($scroll_cat);
};

// Close the menu
function closeMenu($id, $othermenu) {
	var $element = document.getElementById($id);
	var $start = parseInt(getStyle($element)['bottom']);
	var $end = -parseInt(getStyle($element)['height'])-40;
	
	startAnim($element, setAbsBottom, $start, $end, 250, ANIMATION_FPS, stepf_linear);
	
	if($othermenu != true) {
		init_changeImage('default');
	}
};

// Timer for automatic fading
var fade_timer = null;
var IMAGE_LIST = {
	"default": ["accueil01.jpg", "accueil02.jpg", "accueil03.jpg", "accueil04.jpg", "accueil05.jpg"],
	"spa": ["vivaldi01.jpg", "vivaldi02.jpg", "vivaldi03.jpg"],
	"versa": ["versa01.jpg", /*"versa02.jpg",*/ "versa03.jpg"],
	"happy": ["happyhour01.jpg", "happyhour02.jpg", "happyhour03.jpg"]
	};
	
var image_pointers = {"default": 0, "spa": 0, "versa": 0, "happy": 0 };

function init_changeImage($category) {
	if(fade_timer != null) {
		clearInterval(fade_timer);
	}
	
	fade_timer = setInterval(function(){ changeImage($category); }, 5000);
	changeImage($category);
};

function changeImage($category) {
	// Get the elements (Swapped, they will get their place back later)
	$out = document.getElementById("dynamic_fade_in");
	$_in = document.getElementById("dynamic_fade_out");
	
	// Swap them, IN is now going to OUT
	$out.id = "dynamic_fade_out";
	$_in.id = "dynamic_fade_in";
	
	$_in.src = "photo_scroll/" + IMAGE_LIST[$category][image_pointers[$category]];
	image_pointers[$category] = (image_pointers[$category]+1) % IMAGE_LIST[$category].length;
	
	// Set fading effects
	startAnim($out, setOpacity, 1, 0, 500, ANIMATION_FPS, stepf_linear);
	startAnim($_in, setOpacity, 0, 1, 500, ANIMATION_FPS, stepf_linear);
};
	
	
	
	
	
	

