	




/*
This function compiles the query based on what is/isn't checked and saves it to a hidden input.

*/
function compileNsubmit()	{
	var query = "";
	var options_keys = new Array();
	var sogs = new Array();
// loop through the form.  If the type is a checkbox AND it is checked, add the key to the options_array.
	for(i=0; i<document.myfinder.elements.length; i++){
		
		
if(document.myfinder.elements[i].type == 'checkbox' && document.myfinder.elements[i].checked == true)	{
// check to see if sogs(SOGID) array exists and create it or add to it.
	if(sogs[document.myfinder.elements[i].name.substr(0,2)] == undefined)	{
		sogs[document.myfinder.elements[i].name.substr(0,2)] = new Array();
		sogs[document.myfinder.elements[i].name.substr(0,2)].push(document.myfinder.elements[i].name);
		
		}
	else
		sogs[document.myfinder.elements[i].name.substr(0,2)].push(document.myfinder.elements[i].name);
// add the current sog id to the options_keys array ONLY if it isn't already present.			
	if(options_keys.indexOf(document.myfinder.elements[i].name.substr(0,2)) == -1)
		options_keys.push(document.myfinder.elements[i].name.substr(0,2));

	}
		
		}
//use the id's in the options_keys array to put the query together. 
//If multiple pogs are present, they must be contained within ().  
//Each value, solo or grouped, needs to be in quotes. 

	for(i = 0; i < options_keys.length; i++)	{
		if(sogs[options_keys[i]].length > 1)	{
			query += '+(';
			for(u = 0; u < sogs[options_keys[i]].length; u++)	{
				if(u != 0)
					query += ' ';
				query += '%22'+sogs[options_keys[i]][u]+'%22';
				}
			query += ')';
			}
		else
			query += '+%22'+sogs[options_keys[i]]+'%22 ';
		}
//set the value of a hidden input so that the query gets passed when the form is submitted.
	document.myfinder.query.value = query;
	document.myfinder.submit();
	}






//uncheck all the checkboxes for SOGID.
function uncheckSog(SOGID)	{

	for(i=0; i<document.myfinder.elements.length; i++){

		if(document.myfinder.elements[i].name.substr(0,2) == SOGID)	{
			if(document.myfinder.elements[i].checked == true)	{
				document.myfinder.elements[i].checked = false;
//				alert(document.myfinder.elements[i].name+" = "+document.myfinder.elements[i].checked);
				}
			}
		}
	compileNsubmit()
	}

