$(function()
		{
			//***************************** LISTENNERS *****************************//

			$("#btModif").click(function()
						{
							affModif(0);
							return false;
						});

			//**************************************** END JQUERY *****************************************//
		}
);

//***************************** FONCTIONS EXTERNE *****************************//

function setSejour()
{
	$.post("/async/setsejour",
		{
			"dtDebut" : $("#calendar").val(),
			"duree" : $("#duree").val()
		},
		function(response)
		{
			var test = new Array();
			var notice = $(response);
			test = response.split('|');
			
			if(test[1]){
				var testSection = $("#modInfosResa").size();
				if(testSection == 1){
					$("#modInfosResa span:eq(0)").html(test[0]);
					$("#modInfosResa span:eq(1)").html(test[1]);
					$("#modInfosResa span:eq(2)").html(test[2]+' jours');
					affModif(1);
					var who = $("#itemName").text();
					if( who != ''){
						modShop(who);
					}
				}else{
					document.location.href='/shop';
				}
			}else{
				$("#aff").prepend(notice.fadeIn(600));
				
				setTimeout(function()
							{
								notice.slideUp(1500,function()
									{
										$(this).remove();
									})
							}, 4500);
			}
		});
	return false;
}

function affModif(cancel)
{
	if(cancel == 1){
		$('#frmModif').slideUp(400, function()
			{
				$('#modiDt').empty();
				$("#btModif").fadeIn(400);
			});
	}else{
		$.post("/async/modifsejour",
			{
			},
			function(response)
				{
					var notice = $(response);
					
					$("#btModif").slideUp(200, function()
						{
							setTimeout(function()
								{
									$("#modiDt").html(notice.hide().fadeIn(600));
								},300);
							
						});
				});
	}
}

function modShop(x){
	
	$.post("/async/shopitems",
			{
				"quoi" : x
			},
		   function(response)
			{
				var aff = $(response);
				$("#shopAll").html(aff);
				$("#block_tete span").hide();
				var nb = document.getElementById('nb_art').value;
				for(var i = 0;i <= nb;i++){
					$(".aff_pub"+i+" span:first").show();
					$(".aff_web"+i+" span:first").show();
				}
			});
}
