function addOn(theForm)
{

	var boxes = new Array();
	boxes[0] = theForm.box1;
	boxes[1] = theForm.box2;
	boxes[2] = theForm.box3;
	boxes[3] = theForm.box4;
	boxes[4] = theForm.box5;
	boxes[5] = theForm.box6;
	boxes[6] = theForm.box7;
	boxes[7] = theForm.box8;
	boxes[8] = theForm.box9;
	boxes[9] = theForm.box10;
	boxes[10] = theForm.box11;
	boxes[11] = theForm.box12;
	boxes[12] = theForm.box13;
	boxes[13] = theForm.box14;

	var boxQuery = "";
	
	var metaCount = 0;
	
	for (var i=0;i<boxes.length;i++) {
	
		if (boxes[i].checked) {
			if (metaCount>0) {
				boxQuery += " OR meta:kategori:" + boxes[i].value;
			} else {
				boxQuery = "meta:kategori:" + boxes[i].value;
			}
			metaCount++;
		}
		
	}	
	 
	if (metaCount>0) {
		boxQuery = "(" + boxQuery + ")";
		if(theForm.query.value.length > 0) //Om queryn inte är tom, lägg till slutdatum till värdet som finns
		{
			theForm.query.value=theForm.query.value+" " + boxQuery;
		} else {
			theForm.query.value=boxQuery;
		}		
	}
	
	if(theForm.startDate.value.length > 0) //Om startdatum finns inskrivet
	{

		if(theForm.query.value.length > 0) //Om queryn inte är tom, lägg till startdatum till värdet som finns
		{
			theForm.query.value=theForm.query.value+" (meta:startdatum <= "+theForm.startDate.value;
		
			if(theForm.stopDate.value.length > 0) //Om slutdatum finns inskrivet, lägg till det värdet som finns
			{
				theForm.query.value=theForm.query.value+" meta:slutdatum >= "+theForm.startDate.value+") OR (meta:startdatum <= "+theForm.stopDate.value+" meta:slutdatum >= "+theForm.stopDate.value+")";
			}
			else {
			theForm.query.value=theForm.query.value+")";
			}
		}
		else { //Om queryn är tom, lägg till startdatum

			theForm.query.value="(meta:startdatum <= "+theForm.startDate.value;
			if(theForm.stopDate.value.length > 0) //Om slutdatum finns inskrivet
			{
				theForm.query.value=theForm.query.value+" meta:slutdatum >= "+theForm.startDate.value+") OR (meta:startdatum <= "+theForm.stopDate.value+" meta:slutdatum >= "+theForm.stopDate.value+")";
			}
			else {
			theForm.query.value=theForm.query.value+")";
			}
		}
	}
	
	else if(theForm.stopDate.value.length > 0) //Om startdatum inte finns men slutdatum finns inskrivet
	{

		if(theForm.query.value.length > 0) //Om queryn inte är tom, lägg till slutdatum till värdet som finns
		{
			theForm.query.value=theForm.query.value+" meta:slutdatum >= "+theForm.stopDate.value;
		}
		else { //Om queryn är tom, lägg till slutdatum
		theForm.query.value="meta:slutdatum >= "+theForm.stopDate.value;
		}
	}

  if(theForm.query.value.length > 0) //If it's not empty
  {
    //theForm.query.value=theForm.query.value+" "+theForm.pass.value;
    return true;
  }
  
  
  return false; //Nothing to submit!
}

