// returns the element for multiple browser types
function getElem( divId ){
	var elem;
	if( document.getElementById ) // current standard
		elem = document.getElementById( divId );
	else if( document.all ) // old msie
		elem = document.all[divId];
	else if( document.layers ) // nn4 works
		elem = document.layers[divId];

	return elem;
}

// utility function for future use - toggles visibility to opposite state
function toggleLayer( divId )
{
	var vis = getElem(divId).style;
  
	// if the style.display value is blank we determine visibility here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';

	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function toggleLayerOff( divId )
{
	var vis = getElem(divId).style;  
	vis.display = 'none';
}

function toggleLayerOn( divId )
{
	var vis = getElem(divId).style;
	vis.display = '';
}

// set an element of a select box
function selectOption(selId, num)
{
	var selObj = getElem(selId);
	selObj.selectedIndex = num;
}

// Click handler for recipe search selection
function clickRecipe(){
	getElem('psel').value='rcp';
	toggleLayerOn('recipe_group');
	toggleLayerOff('product_group');
	//set value of non-applicable form elements to empty so that they are not factored into the search
	selectOption('qAndExact1',0);
	selectOption('qAndExact2',0);
	selectOption('qAndExact3',0);
	selectOption('qAndExact4',0);
}

// Click handler for product search selection
function clickProduct(){
	getElem('psel').value='prd';
	toggleLayerOff('recipe_group');
	toggleLayerOn('product_group');
	//set value of non-applicable form elements to empty so that they are not factored into the search
	selectOption('qAndExact1',0);
	selectOption('qAndExact2',0);
	selectOption('qAndExact3',0);
	selectOption('qAndExact4',0);
}

// Click handler for all results search selection
function clickAllResults(){
	getElem('psel').value='mor';
	toggleLayerOff('recipe_group');
	toggleLayerOff('product_group');
	selectOption('qAndExact1',0);
	selectOption('qAndExact2',0);
	selectOption('qAndExact3',0);
	selectOption('qAndExact4',0);
}

