
function write_form_age()
{
	sexe_index = document.getElementById('select_sexe').selectedIndex;
	sexe_value = document.getElementById('select_sexe').options[sexe_index].value;
	
	if (sexe_index != 0)
	{
		// r&eacute;initialisation des autres choix
		document.getElementById('form_age').innerHTML = '';
		document.getElementById('form_relation').innerHTML = '';
		document.getElementById('form_occasion').innerHTML = '';
		document.getElementById('form_budget').style.display = 'none';
		
		// couleurs
		$("#number_sexe").removeClass("fred"); $("#number_sexe").addClass("fgrey");
		$("#number_age").removeClass("fgrey"); $("#number_age").addClass("fred");
		$("#number_relation").removeClass("fred"); $("#number_relation").addClass("fgrey");
		$("#number_occasion").removeClass("fred"); $("#number_occasion").addClass("fgrey");
		
		html = '';
		html = html + '<select id=\'select_age\' name=\'attribute_1\' class=\'searchform\' onChange=\"write_form_relation();\">';
		
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_title\' value=\'N/A\'>son &acirc;ge...</option>';
		if (sexe_value == 'couple')
			html = html + '<option class=\'searchform_select_title\' value=\'N/A\'>leur &acirc;ge...</option>';			
		
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'0\'>b&eacute;b&eacute;</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'1-5\'>1 &agrave; 5 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'6-10\'>6 &agrave; 10 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'11-14\'>11 &agrave; 14 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'15-18\'>15 &agrave; 18 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme') || (sexe_value == 'couple'))
			html = html + '<option class=\'searchform_select_option\' value=\'19-24\'>19 &agrave; 24 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme') || (sexe_value == 'couple'))
			html = html + '<option class=\'searchform_select_option\' value=\'25-35\'>25 &agrave; 35 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme') || (sexe_value == 'couple'))
			html = html + '<option class=\'searchform_select_option\' value=\'36-50\'>36 &agrave; 50 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme') || (sexe_value == 'couple'))
			html = html + '<option class=\'searchform_select_option\' value=\'50-70\'>50 &agrave; 70 ans</option>';
		if ((sexe_value == 'homme') || (sexe_value == 'femme') || (sexe_value == 'couple'))
			html = html + '<option class=\'searchform_select_option\' value=\'>70\'>plus de 70 ans</option>';			

		html = html + '</select>';
		
		document.getElementById('form_age').innerHTML = html;
	}
}

function write_form_relation()
{
	sexe_index = document.getElementById('select_sexe').selectedIndex;
	sexe_value = document.getElementById('select_sexe').options[sexe_index].value;
	
	age_index = document.getElementById('select_age').selectedIndex;
	age_value = document.getElementById('select_age').options[age_index].value;	
	
	if ((sexe_index != 0) && (age_index != 0))
	{
		// r&eacute;initialisation des autres choix
		document.getElementById('form_relation').innerHTML = '';
		document.getElementById('form_occasion').innerHTML = '';
		document.getElementById('form_budget').style.display = 'none';
		
		// couleurs
		$("#number_age").removeClass("fred"); $("#number_age").addClass("fgrey");
		$("#number_relation").removeClass("fgrey"); $("#number_relation").addClass("fred");	
		$("#number_occasion").removeClass("fred"); $("#number_occasion").addClass("fgrey");		
		
		html = '';
		html = html + '<select id=\'select_relation\' name=\'attribute_4\' class=\'searchform\' onChange=\"write_form_occasion();\">';
		
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_title\' value=\'N/A\'>c\'est...</option>';
		if (sexe_value == 'couple')
			html = html + '<option class=\'searchform_select_title\' value=\'N/A\'>ce sont...</option>';			
		
		// homme
		if ((sexe_value == 'homme') &&
			((age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'parent\'>mon p&egrave;re</option>';
		if ((sexe_value == 'homme') &&
			((age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'grandparent\'>mon grand-p&egrave;re</option>';			
		if ((sexe_value == 'homme') &&
			((age_value == '15-18') || (age_value == '19-24') || (age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'ami\'>un ami</option>';
		if ((sexe_value == 'homme') &&
			((age_value == '15-18') || (age_value == '19-24'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'conjoint\'>mon petit ami</option>';		
		if ((sexe_value == 'homme') &&
			((age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'conjoint\'>mon homme</option>';	
		if ((sexe_value == 'homme')
			)
			html = html + '<option class=\'searchform_select_option\' value=\'enfant\'>mon fils</option>';
			
		// femme
		if ((sexe_value == 'femme') &&
			((age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'parent\'>ma m&egrave;re</option>';
		if ((sexe_value == 'femme') &&
			((age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'grandparent\'>ma grand-m&egrave;re</option>';		
		if ((sexe_value == 'femme') &&
			((age_value == '15-18') || (age_value == '19-24') || (age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'ami\'>une amie</option>';
		if ((sexe_value == 'femme') &&
			((age_value == '15-18') || (age_value == '19-24'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'conjoint\'>ma petite amie</option>';		
		if ((sexe_value == 'femme') &&
			((age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'conjoint\'>ma femme</option>';	
		if ((sexe_value == 'femme')
			)
			html = html + '<option class=\'searchform_select_option\' value=\'enfant\'>ma fille</option>';
			
		// couple
		if ((sexe_value == 'couple') &&
			((age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'parent\'>mes parents</option>';
		if ((sexe_value == 'couple') &&
			((age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'grandparent\'>mes grand-parents</option>';		
		if ((sexe_value == 'couple') &&
			((age_value == '15-18') || (age_value == '19-24') || (age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'ami\'>des amis</option>';
		
		// joker !
		html = html + '<option class=\'searchform_select_option\' value=\'autre\'>(autre...)</option>';
		
		html = html + '</select>';
		
		document.getElementById('form_relation').innerHTML = html;
	}
}


function write_form_occasion()
{
	sexe_index = document.getElementById('select_sexe').selectedIndex;
	sexe_value = document.getElementById('select_sexe').options[sexe_index].value;
	
	age_index = document.getElementById('select_age').selectedIndex;
	age_value = document.getElementById('select_age').options[age_index].value;	

	relation_index = document.getElementById('select_relation').selectedIndex;
	relation_value = document.getElementById('select_relation').options[relation_index].value;	
	
	if ((sexe_index != 0) && (age_index != 0) && (relation_index != 0))
	{
		// r&eacute;initialisation
		document.getElementById('form_occasion').innerHTML = '';
		document.getElementById('form_budget').style.display = 'none';

		// couleurs
		$("#number_relation").removeClass("fred"); $("#number_relation").addClass("fgrey");
		$("#number_occasion").removeClass("fgrey"); $("#number_occasion").addClass("fred");	
		
		html = '';
		html = html + '<select id=\'select_occasion\' name=\'attribute_3\' class=\'searchform\' onChange=\"write_form_budget();\">';
		
		html = html + '<option class=\'searchform_select_title\' value=\'N/A\'>pour...</option>';
		
		
		html = html + '<option class=\'searchform_select_option\' value=\'parceque\'>faire plaisir !</option>';
		
		if ((sexe_value == 'homme') || (sexe_value == 'femme'))
			html = html + '<option class=\'searchform_select_option\' value=\'anniversaire\'>son anniversaire</option>';
		if (sexe_value == 'couple')
			html = html + '<option class=\'searchform_select_option\' value=\'anniversaire\'>leur anniversaire</option>';
/*
		html = html + '<option class=\'searchform_select_option\' value=\'noel\'>Noël</option>';
*/		
		if (((sexe_value == 'homme') || (sexe_value == 'femme')) &&
			(relation_value == 'conjoint') &&
			((age_value == '15-18') || (age_value == '19-24') || (age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			)
			html = html + '<option class=\'searchform_select_option\' value=\'stvalentin\'>la St Valentin</option>';
/*
		if ((sexe_value == 'homme') &&
			(relation_value == 'pere')
			)
			html = html + '<option class=\'searchform_select_option\' value=\'fete\'>la f&ecirc;te des p&egrave;res</option>';

		if ((sexe_value == 'femme') &&
			(relation_value == 'pere')
			)
			html = html + '<option class=\'searchform_select_option\' value=\'fete\'>la f&ecirc;te des m&egrave;res</option>';

		if ((sexe_value == 'femme') &&
			(relation_value == 'grandpere')
			)
			html = html + '<option class=\'searchform_select_option\' value=\'fete\'>la f&ecirc;te des grand-m&egrave;res</option>';
*/
		if (sexe_value == 'couple')
			html = html + '<option class=\'searchform_select_option\' value=\'mariage\'>leur mariage</option>';

		if (age_value == '0')
			html = html + '<option class=\'searchform_select_option\' value=\'naisance\'>sa naissance</option>';

		if ((age_value == '19-24') || (age_value == '25-35') || (age_value == '36-50') || (age_value == '50-70') || (age_value == '>70'))
			html = html + '<option class=\'searchform_select_option\' value=\'invitation\'>une invitation</option>';

			
		html = html + '</select>';
		
		document.getElementById('form_occasion').innerHTML = html;
	}
}

function write_form_budget()
{
	sexe_index = document.getElementById('select_sexe').selectedIndex;
	age_index = document.getElementById('select_age').selectedIndex;
	relation_index = document.getElementById('select_relation').selectedIndex;
	occasion_index = document.getElementById('select_occasion').selectedIndex;
	
	if ((sexe_index != 0) &&
		(age_index != 0) &&
		(relation_index != 0) &&
		(occasion_index != 0)
		)
	{
		// couleurs
		$("#number_occasion").removeClass("fred"); $("#number_occasion").addClass("fgrey");
	
		document.getElementById('form_budget').style.display = 'block';
	}

}