// get the info from the form and build a get/post string out of it
// if empty is true, display an alert if no form fields are filled in
function processForm(form,empty){
    // preset the post and got a value variables
	var post='';
	var gotval=false;
	
	// cycle all form elements
	for(var i=0;i<form.elements.length;i++){
		field=form.elements[i];
		if(field.name=='') // can't process form elements that have no name
			continue;
			
		if(field.name=='result-view') // skip results_view radio buttons
			continue;
			
		// handle radio button and check box fields
		if(field.type=='radio' || field.type=='checkbox'){
			var val='';
			// cycle all radio buttons or checkboxes w/same name and type
			while(form.elements[i].type == field.type && form.elements[i].name==field.name){
				if(form.elements[i].checked){
					val=form.elements[i].value;
				}
				i++;
			} // end cycle all radio buttons or checkboxes
			
			// check if there is a value
			if(val!=''){
                // update gotval if the field has a non-empty value
                gotval++;
			
                // add the field and value to the  post
                post=post+'&'+field.name+'='+escape(val);
            }
			
			// we went past the last one so we need to back up
			i--;
			
			// go on to next field
			continue;
		}
		
		
        // check if there is a value
		if(field.value!=''){
            // update gotval if the field has a non-empty value
            gotval++
		
            // build the post argument from the name and value
            post=post+'&'+field.name+'='+escape(field.value);
        }
	} // end cycle all form elements
	
	// if we didn't get any values and empty is set
	if(!gotval && empty){
		// display alert and make sure post is empty
		alert('Please make one or more selections on the search form');
		post='';
	}
	//alert(post); // for debugging
	return(post);
}

