function clear_field(field, lang) {
	var fields = new Array(
	"choixdate",
	"jour_start",
	"mois_start",
	"annee_start",
	"jour_end",
	"mois_end",
	"annee_end",
	"num_arr_start",
	"num_arr_stop",
	"num_rol",
	"part",
	"dictum",
	"qu");
	if (field == "all") {
			document.forms['frmSearchTwo'].choixdate.value = "D";
			document.forms['frmSearchTwo'].jour_start.value = "";
			document.forms['frmSearchTwo'].mois_start.value = "";
			document.forms['frmSearchTwo'].annee_start.value = "";
			document.forms['frmSearchTwo'].jour_end.value = "";
			document.forms['frmSearchTwo'].mois_end.value = "";
			document.forms['frmSearchTwo'].annee_end.value = "";
			document.forms['frmSearchTwo'].num_arr_start.value = "";
			document.forms['frmSearchTwo'].num_arr_stop.value = "";
			document.forms['frmSearchTwo'].num_rol.value = "";
			document.forms['frmSearchTwo'].part.value = "";
			document.forms['frmSearchTwo'].dictum.value = "";
			document.forms['frmSearchTwo'].qu.value = "";
			
			
			document.forms['frmSearchTwo'].method.value = "and";
			document.forms['frmSearchTwo'].choixdate.value = "L";
			
			document.getElementById('etle').style.display="none";
			switch (lang) {
				case 'nl' : 
					document.forms['frmSearchTwo'].index.value= "nl";
					break;
				case 'fr' :
					document.forms['frmSearchTwo'].index.value= "fr";
					break;
			}

	}
}

search_query_bool = trim(request("booleanConditions"))



	function add_condition(message)
	{

		if(document.forms['frmSearchTwo'].booleanConditions.value == '')
		{
		document.forms['frmSearchTwo'].booleanConditions.value= '('+ message + ')';
		}
	
		else
		
		{
			document.forms['frmSearchTwo'].booleanConditions.value +=' AND (' + message + ')';
		}	
	
	}
	
	
	
	function ifFilled_date(id)
	{
		//
		if(id==1)
		{
		return ((!(document.forms['frmSearchTwo'].annee_start.value==''))&&(!(document.forms['frmSearchTwo'].mois_start.value==''))&&(!(document.forms['frmSearchTwo'].jour_start.value=='')));
		}
		
		if(id==2)
		{
		return ((!(document.forms['frmSearchTwo'].annee_start.value==''))&&(!(document.forms['frmSearchTwo'].mois_start.value==''))&&(!(document.forms['frmSearchTwo'].jour_start.value==''))&&(!(document.forms['frmSearchTwo'].annee_stop.value==''))&&(!(document.forms['frmSearchTwo'].mois_stop.value==''))&&(!(document.forms['frmSearchTwo'].jour_stop.value=='')));
		}
		
	}
	
	function check_date(id)
	{
		return true;
	}
	
	function get_date(id)
	{
	}
	

	function fillFields(obj)
	{
		//1. Date
		switch (obj.choixdate.value)
		{
		  case 'L':
		  	//exact date
		  	
		  	if(ifFilled_date(1))
		  	{
			  	if (check_date(1))
			  	{
			  	add_condition('dat_arr contains (' + obj.annee_start.value + obj.mois_start.value + obj.jour_start.value + ' )');
			  	}
			  	else
			  	{
			  	alert('date not ok');
			  	return false;
			  	}
		  	}
		  break;
		  
		  case 'D':
		  	// From
		  	if(ifFilled_date(1))
		  	{
			 	if (check_date(1))
			  	{
			  	add_condition('dat_arr contains (' + obj.annee_start.value + obj.mois_start.value + obj.jour_start.value + '~~)');
			  	}
			  	else
			  	{
			  	alert('date not ok');
			  	return false;
				}
		  	}
		  	
		  break;
		  
		  case 'E':
		  //between
		  	if(ifFilled_date(1))
		  	{
			  	if (check_date(2))
			  	{
			  	add_condition('dat_arr contains (' + obj.annee_start.value + obj.mois_start.value + obj.jour_start.value + '~~'+ obj.annee_end.value + obj.mois_end.value + obj.jour_end.value +')');
			  	}
			  	else
			  	{
			  	alert('date not ok');
			  	return false;
			  	}
			}		  
		  break;
		  
		  case 'J':
		  // till
		  	if(ifFilled_date(1))
		  	{
			 	if (check_date(1))
			  	{
			  	add_condition('dat_arr contains (~~' + obj.annee_start.value + obj.mois_start.value + obj.jour_start.value + ')');
			  	}
			  	else
			  	{
			  	alert('date not ok');
			  	return false;
				}
		  	}
		  break;
		}
		
		//2. Num arrest
		//2.1 test if we need a range

		var reg=new RegExp("\\.", "g");
		if(!(obj.num_arr_stop.value=='')&&(obj.num_arr_start.value==''))
		{
			add_condition('num_arr contains(' + obj.num_arr_stop.value.replace(reg,'')+')');	
		}

		else
		if(!(obj.num_arr_stop.value=='')&&(!(obj.num_arr_start.value=='')))
		// missing check : stop.value > start.value
		{
			add_condition('num_arr contains(' + obj.num_arr_start.value.replace(reg,'') + '~~'+ obj.num_arr_stop.value.replace(reg,'')+')');	
		}

		else
		if (!(obj.num_arr_start.value==''))
		{
		add_condition('num_arr contains(' + obj.num_arr_start.value.replace(reg,'')+')');	
		}
		


		//Numero de role 
		if (!(obj.num_rol.value==''))
		{
		add_condition('num_rol contains(' + obj.num_rol.value + ')');	
		}
		
		//Parties 
		if (!(obj.part.value==''))
		{
		add_condition('part contains(' + obj.part.value  + ')');	
		}
		

		//Decision
		if (!(obj.dictum.value==''))
		{
		add_condition('dictum contains(' + obj.dictum.value + ')');	
		}
	return true	;	
	}
	
	
	
	
	
	// Datum range Display 
	
	function display_div(obj,value,condition) 
	{

       if (value ==  condition) {

               document.getElementById(obj).style.display = "block";
			   document.getElementById(obj + "2").style.display = "block";

       } else {

               document.getElementById(obj).style.display = "none";
			   document.getElementById(obj + "2").style.display = "none";

       }

	}
	
	

	

