﻿function getAllArgument(){
	//Type of cuisines
	//le tableau retourné est le suivant
	/*
	tableau argument
				mood 
					|||||||||||||||||        recherche de valeur[0][nom]         ||||||||||||
					client
					naughty
					energic
					romantic
					broke
					cele brities
					dinig alone
					sophiticated
				
				type_cuisine
					|||||||||||||||||||         recherche de valeur[1][nom]          |||||||||||
					salads
					seafoods
					meat
					wine_bars
					fast_food
					superbistros
					bistros_brasseries
					pasta_mediterranean
					exoticism_world
					hotel_station
					bio_vegetarian
					fondue
					
				filters
					reputation
						||||||||||||||||||||||||           [2][n0][n1]               |||||||||||||||||
						valeur min
						valeur max
	*/
	
	var argument=new Array();
		var mood=new Array();
			var and = false;
			if( jQuery( "#clients" ).is(':checked') )
			{
				mood[ 'clients' ] = jQuery( "#clients" ).val();
				and = true;
			}
			else
				mood[ 'clients' ] = "";
			if( jQuery( "#naughty" ).is(':checked') )
			{
				if( and )
					mood[ 'naughty' ] = "," + jQuery( "#naughty" ).val();
				else
				{
					mood[ 'naughty' ] = jQuery( "#naughty" ).val();
					and = true;
				}
			}
			else
				mood[ 'naughty' ] = "";
			if( jQuery( "#energetic" ).is(':checked') )
			{
				if( and )
					mood[ 'energetic' ] = "," + jQuery( "#energetic" ).val();
				else
				{
					mood[ 'energetic' ] = jQuery( "#energetic" ).val();
					and = true;
				}
			}
			else
				mood[ 'energetic' ] = "";
			if( jQuery( "#romantic" ).is(':checked') )
			{
				if( and )
					mood[ 'romantic' ] = "," + jQuery( "#romantic" ).val();
				else
				{
					mood[ 'romantic' ] = jQuery( "#romantic" ).val();
					and = true;
				}
			}
			else
				mood[ 'romantic' ] = "";
			if( jQuery( "#broke" ).is(':checked') )
			{
				if( and )
					mood[ 'broke' ] = "," + jQuery( "#broke" ).val();
				else
				{
					mood[ 'broke' ] = jQuery( "#broke" ).val();
					and = true;
				}
			}
			else
				mood[ 'broke' ] = "";
			if( jQuery( "#celebrities" ).is(':checked') )
			{
				if( and )
					mood[ 'celebrities' ] = "," + jQuery( "#celebrities" ).val();
				else
				{
					mood[ 'celebrities' ] = jQuery( "#celebrities" ).val();
					and = true;
				}
			}
			else
				mood[ 'celebrities' ] = "";
			if( jQuery( "#dining_alone" ).is(':checked') )
			{
				if( and )
					mood[ 'dining_alone' ] = "," + jQuery( "#dining_alone" ).val();
				else
				{
					mood[ 'dining_alone' ] = jQuery( "#dining_alone" ).val();
					and = true;
				}
			}
			else
				mood[ 'dining_alone' ] = "";
			if( jQuery( "#sophisticated" ).is(':checked') )
			{
				if( and )
					mood[ 'sophisticated' ] = "," + jQuery( "#sophisticated" ).val();
				else
				{
					mood[ 'sophisticated' ] = jQuery( "#sophisticated" ).val();
					and = true;
				}
			}
			else
				mood[ 'sophisticated' ] = "";
		
		var type_cuisine=new Array();
			var and = false;
			if( jQuery( "#salads" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'salads' ] = "," + jQuery( "#salads" ).val();
				else
				{
					type_cuisine[ 'salads' ] = jQuery( "#salads" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'salads' ] = "";
			if( jQuery( "#seafoods" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'seafoods' ] = "," + jQuery( "#seafoods" ).val();
				else
				{
					type_cuisine[ 'seafoods' ] = jQuery( "#seafoods" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'seafoods' ] = "";
			if( jQuery( "#meat" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'meat' ] = "," + jQuery( "#meat" ).val();
				else
				{
					type_cuisine[ 'meat' ] = jQuery( "#meat" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'meat' ] = "";
			
			if( jQuery( "#wine_bars" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'wine_bars' ] = "," + jQuery( "#wine_bars" ).val();
				else
				{
					type_cuisine[ 'wine_bars' ] = jQuery( "#wine_bars" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'wine_bars' ] = "";
			if( jQuery( "#fast_food" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'fast_food' ] = "," + jQuery( "#fast_food" ).val();
				else
				{
					type_cuisine[ 'fast_food' ] = jQuery( "#fast_food" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'fast_food' ] = "";
			if( jQuery( "#superbistros" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'superbistros' ] = "," + jQuery( "#superbistros" ).val();
				else
				{
					type_cuisine[ 'superbistros' ] = jQuery( "#superbistros" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'superbistros' ] = "";
			if( jQuery( "#bistros_brasseries" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'bistros_brasseries' ] = "," + jQuery( "#bistros_brasseries" ).val();
				else
				{
					type_cuisine[ 'bistros_brasseries' ] = jQuery( "#bistros_brasseries" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'bistros_brasseries' ] = "";
			if( jQuery( "#pasta_mediterranean" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'pasta_mediterranean' ] = "," + jQuery( "#pasta_mediterranean" ).val();
				else
				{
					type_cuisine[ 'pasta_mediterranean' ] = jQuery( "#pasta_mediterranean" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'pasta_mediterranean' ] = "";
			if( jQuery( "#exoticism_world" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'exoticism_world' ] = "," + jQuery( "#exoticism_world" ).val();
				else
				{
					type_cuisine[ 'exoticism_world' ] = jQuery( "#exoticism_world" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'exoticism_world' ] = "";
			if( jQuery( "#hotel_station" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'hotel_station' ] = "," + jQuery( "#hotel_station" ).val();
				else
				{
					type_cuisine[ 'hotel_station' ] = jQuery( "#hotel_station" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'hotel_station' ] = "";
			if( jQuery( "#bio_vegetarian" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'bio_vegetarian' ] = "," + jQuery( "#bio_vegetarian" ).val();
				else
				{
					type_cuisine[ 'bio_vegetarian' ] = jQuery( "#bio_vegetarian" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'bio_vegetarian' ] = "";
			if( jQuery( "#fondue" ).is(':checked') )
			{
				if( and )
					type_cuisine[ 'fondue' ] = "," + jQuery( "#fondue" ).val();
				else
				{
					type_cuisine[ 'fondue' ] = jQuery( "#fondue" ).val();
					and = true;
				}
			}
			else
				type_cuisine[ 'fondue' ] = "";
			
		var filtre=new Array();
			var reputation=new Array(jQuery("#sliderReputation").slider('value',0),jQuery("#sliderReputation").slider('value',1));
			var price=new Array(jQuery("#sliderPrice").slider('value',0),jQuery("#sliderPrice").slider('value',1));
			var satisfaction=new Array(jQuery("#sliderSatisfaction").slider('value',0),jQuery("#sliderSatisfaction").slider('value',1));
			var cuisine=new Array(jQuery("#sliderCuisine").slider('value',0),jQuery("#sliderCuisine").slider('value',1));
			var gastronomique=new Array(jQuery("#sliderGastronomique").slider('value',0),jQuery("#sliderGastronomique").slider('value',1));
			var vin_qp=new Array(jQuery("#sliderVinQP").slider('value',0),jQuery("#sliderVinQP").slider('value',1));
			var vin_qd=new Array(jQuery("#sliderVinQD").slider('value',0),jQuery("#sliderVinQD").slider('value',1));
			var service=new Array(jQuery("#sliderService").slider('value',0),jQuery("#sliderService").slider('value',1));
			var rapidite=new Array(jQuery("#sliderRapidite").slider('value',0),jQuery("#sliderRapidite").slider('value',1));
			var amabilite=new Array(jQuery("#sliderAmabilite").slider('value',0),jQuery("#sliderAmabilite").slider('value',1));
			var competence=new Array(jQuery("#sliderCompetence").slider('value',0),jQuery("#sliderCompetence").slider('value',1));
			var environnement=new Array(jQuery("#sliderEnvironnement").slider('value',0),jQuery("#sliderEnvironnement").slider('value',1));
			var tranquilite=new Array(jQuery("#sliderTranquilite").slider('value',0),jQuery("#sliderTranquilite").slider('value',1));
			var rapport_qp=new Array(jQuery("#sliderRapportQP").slider('value',0),jQuery("#sliderRapportQP").slider('value',1));
			
			filtre=Array(reputation,price,satisfaction,cuisine,gastronomique,vin_qp,vin_qd,service,rapidite,amabilite,competence,environnement,tranquilite,rapport_qp);
	
	var km=jQuery('km').val();
	var location=jQuery('location').val();
	
	var checkboxs = new Array();
	and = false;
	if( jQuery( "#membersLiving" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'membersLiving' ] = ", " + jQuery( "#membersLiving" ).val();
		else
		{
			checkboxs[ 'membersLiving' ] = jQuery( "#membersLiving" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'membersLiving' ] = "";
	if( jQuery( "#men" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'men' ] = ", " + jQuery( "#men" ).val();
		else
		{
			checkboxs[ 'men' ] = jQuery( "#men" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'men' ] = "";
	if( jQuery( "#women" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'women' ] = ", " + jQuery( "#women" ).val();
		else
		{
			checkboxs[ 'women' ] = jQuery( "#women" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'women' ] = "";
	if( jQuery( "#c_vue" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_vue' ] = ", " + jQuery( "#c_vue" ).val();
		else
		{
			checkboxs[ 'c_vue' ] = jQuery( "#c_vue" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_vue' ] = "";
	if( jQuery( "#c_terrasse" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_terrasse' ] = ", " + jQuery( "#c_terrasse" ).val();
		else
		{
			checkboxs[ 'c_terrasse' ] = jQuery( "#c_terrasse" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_terrasse' ] = "";
	if( jQuery( "#c_jardin" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_jardin' ] = ", " + jQuery( "#c_jardin" ).val();
		else
		{
			checkboxs[ 'c_jardin' ] = jQuery( "#c_jardin" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_jardin' ] = "";
	if( jQuery( "#c_handicape" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_handicape' ] = ", " + jQuery( "#c_handicape" ).val();
		else
		{
			checkboxs[ 'c_handicape' ] = jQuery( "#c_handicape" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_handicape' ] = "";
	if( jQuery( "#c_enfants" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_enfants' ] = ", " + jQuery( "#c_enfants" ).val();
		else
		{
			checkboxs[ 'c_enfants' ] = jQuery( "#c_enfants" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_enfants' ] = "";
	if( jQuery( "#c_animaux" ).is(':checked') )
	{
		if( and )
			checkboxs[ 'c_animaux' ] = ", " + jQuery( "#c_animaux" ).val();
		else
		{
			checkboxs[ 'c_animaux' ] = jQuery( "#c_animaux" ).val();
			and = true;
		}
	}
	else
		checkboxs[ 'c_animaux' ] = "";
	
	
	var argument=Array(mood,type_cuisine,filtre,location,km, checkboxs);
	
	return argument;
}

function createArgument4Query(){
	var arg=getAllArgument();
	var argument='';
	
	// arguments pour les mood
	argument += 'mood=' + arg[0]['moood'];
	argument += 'clients=' + arg[0]['clients'];
	argument += '&naughty=' + arg[0]['naughty'];
	argument += '&energetic=' + arg[0]['energetic'];
	argument += '&romantic=' + arg[0]['romantic'];
	argument += '&broke=' + arg[0]['broke'];
	argument += '&celebrities=' + arg[0]['celebrities'];
	argument += '&dining_alone=' + arg[0]['dining_alone'];
	argument += '&sophisticated=' + arg[0]['sophisticated'];
	//arguments pour le  type de cuisine
	argument += '&salads=' + arg[1]['salads'];
	argument += '&seafoods=' + arg[1]['seafoods'];
	argument += '&meat=' + arg[1]['meat'];
	argument += '&wine_bars=' + arg[1]['wine_bars'];
	argument += '&fast_food=' + arg[1]['fast_food'];
	argument += '&superbistros=' + arg[1]['superbistros'];
	argument += '&bistros_brasseries=' + arg[1]['bistros_brasseries'];
	argument += '&pasta_mediterranean=' + arg[1]['pasta_mediterranean'];
	argument += '&exoticism_world=' + arg[1]['exoticism_world'];
	argument += '&hotel_station=' + arg[1]['hotel_station'];
	argument += '&bio_vegetarian=' + arg[1]['bio_vegetarian'];
	argument += '&fondue=' + arg[1]['fondue'];
	//arguments pour les filtres
	argument += '&reputation_min=' + arg[2][0][0];
	argument += '&reputation_max=' + arg[2][0][1];
	argument += '&price_min=' + arg[2][1][0];
	argument += '&price_max=' + arg[2][1][1];
	argument += '&satisfaction_min=' + arg[2][2][0];
	argument += '&satisfaction_max=' + arg[2][2][1];
	argument += '&cuisine_min=' + arg[2][3][0];
	argument += '&cuisine_max=' + arg[2][3][1];
	argument += '&gastronomique_min=' + arg[2][4][0];
	argument += '&gastronomique_max=' + arg[2][4][1];
	argument += '&vin_qp_min=' + arg[2][5][0];
	argument += '&vin_qp_max=' + arg[2][5][1];
	argument += '&vin_qd_min=' + arg[2][6][0];
	argument += '&vin_qd_max=' + arg[2][6][1];
	argument += '&service_min=' + arg[2][7][0];
	argument += '&service_max=' + arg[2][7][1];
	argument += '&rapidite_min=' + arg[2][8][0];
	argument += '&rapidite_max=' + arg[2][8][1];
	argument += '&amabilite_min=' + arg[2][9][0];
	argument += '&amabilite_max=' + arg[2][9][1];
	argument += '&competence_min=' + arg[2][10][0];
	argument += '&competence_max=' + arg[2][10][1];
	argument += '&environnement_min=' + arg[2][11][0];
	argument += '&environnement_max=' + arg[2][11][1];
	argument += '&tranquilite_min=' + arg[2][12][0];
	argument += '&tranquilite_max=' + arg[2][12][1];
	argument += '&rapport_qp_min=' + arg[2][13][0];
	argument += '&rapport_qp_max=' + arg[2][13][1];
	argument += '&location=' + arg[3];
	argument += '&km=' + arg[4];
	argument += '&membersLiving=' + arg[5]['membersLiving'];
	argument += '&men=' + arg[5]['men'];
	argument += '&women=' + arg[5]['women'];
	argument += '&c_vue=' + arg[5]['c_vue'];
	argument += '&c_terrasse=' + arg[5]['c_terrasse'];
	argument += '&c_jardin=' + arg[5]['c_jardin'];
	argument += '&c_handicape=' + arg[5]['c_handicape'];
	argument += '&c_enfants=' + arg[5]['c_enfants'];
	argument += '&c_animaux=' + arg[5]['c_animaux'];
	
	//alert(argument);
	return argument;
}
