/* ---- [ Parametre ] ---- */
/*
	var lectureAuto = true;
	var le_ul = ".gite_photos";
	var btn_prev = "";
	var btn_next = "";
	var btn_play = "";
	var btn_pause = "";
	var tps_photo_immobile = 3;
	
	var slider_width = "651px";
	var slider_height = "430px";
*/
/* ---- [ FIN Parametre ] ---- */

function slideByStan(lectureAuto, le_ul, btn_prev, btn_next, btn_play, btn_pause, tps_photo_immobile, slider_width, slider_height, horizontalVertical)
{

	var speed = tps_photo_immobile * 1000;
	le_ul_obj = (typeof(le_ul) == "string") ? $(le_ul) : le_ul;
	la_div_obj = le_ul_obj.parent();
	btn_prev = (typeof(btn_prev) == "string") ? (btn_prev != "auto") ? $(btn_prev) : la_div_obj.find("prev") : btn_prev;
	btn_next = (typeof(btn_next) == "string") ? (btn_next != "auto") ? $(btn_next) : la_div_obj.find("next") : btn_next;
	btn_play = (typeof(btn_play) == "string") ? (btn_play != "auto") ? $(btn_play) : la_div_obj.find("play") : btn_play;
	btn_pause = (typeof(btn_pause) == "string") ? (btn_pause != "auto") ? $(btn_pause) : la_div_obj.find("start") : btn_pause;

	la_div_obj.css
	(
		{
			"overflow" : "hidden",
			"display" : "block",
			"width" : slider_width,
			"height" : slider_height
		}
	);
	
	var width_max = (horizontalVertical == "horizontal" || horizontalVertical == "h") ? (le_ul_obj.find("li").size() + 2) * la_div_obj.width() : la_div_obj.width();
	le_ul_obj.css
	(
		{
			"margin" : "0",
			"padding" : "0",
			"list-style" : "none",
			"z-index" : "0",
			"width" : width_max+"px",
			"overflow" : "hidden"
		}
	);
	
	le_ul_obj.find("li").css
	(
		{
			"float" : "left",
			"width" : slider_width,
			"background" : "none",
			"margin" : "0",
			"padding" : "0",
			"min-height" : slider_height,
			"overflow" : "hidden",
			"cursor" : "pointer"
		}
	);
	le_ul_obj.find("li").hover
	(
		function()
		{
			$(this).css("background","#eee");
		},
		function()
		{
			$(this).css("background","none");
		}
	);
	
	le_ul_obj.find("li > img").css
	(
		{
			"width" : slider_width
		}
	);


	
	if(lectureAuto == true)
	{
		run = setInterval('newsscoller(0, "'+le_ul+'")', speed);	
	}
	//Next Slide by calling the function
	btn_next.click(function () {
		newsscoller(0, le_ul);	
		return false;
	});	

	//Previous slide by passing prev=1
	btn_prev.click(function () {
		newsscoller(1, le_ul);	
		return false;
	});	

	//slide auto
	btn_play.click(function () {
		run = setInterval('newsscoller(0, "'+le_ul+'")', speed);	
		return false;
	});	

	//slide pause
	btn_pause.click(function () {
		clearInterval(run);
		return false;
	});	
	le_ul_obj.find("li").hover
	(
		function()
		{
			clearInterval(run);
		},
		function()
		{
			run = setInterval('newsscoller(0, "'+le_ul+'")', speed);
		}
	);
}

	function newsscoller(ou, le_ul_class) {
	
	le_ul = $(le_ul_class);
	la_div = le_ul.parent();
		//On selectionne la premiere image si ce n'est pas deja fait
		var current_image = le_ul.find('li.selected').length ? le_ul.find('li.selected') : le_ul.find('li:first');
		
		if (ou == 1)
		{
			//Photo precedente
			var next_image = (current_image.prev().length) ? current_image.prev() : le_ul.find('li:last');
		}
		else if(ou != 1 && ou != 0)
		{
			//On prend la photo choisis
			var next_image = le_ul.find('li.'+ou);
		}
		else {
			//Photo suivante
			var next_image = (current_image.next().length) ? current_image.next() : le_ul.find('li:first');
		}
		//clear the selected class
		le_ul.find('li').removeClass('selected');
		
		//reassign the selected class to current items
		next_image.addClass('selected');

		//Scroll the items
		la_div.css("height",next_image.height()+"px");
		la_div.scrollTo(next_image, 800);
		
	}
