
//
// OpenBenchmarking.org results comparison functions
//

var result_comparison_r = new Array();

function oborg_page_loaded()
{
	//document.getElementById('oborg_horizontal_top_nav_search').style.visibility = 'visible';
}
function oborg_user_search()
{
	if(document.getElementById('user_search').value.length < 3)
	{
		alert('Enter a longer search query.');
		return false;
	}

	oborg_search(document.getElementById('user_search').value);
}
function oborg_list_comparison(div_id, public_id)
{
	if(result_comparison_r.indexOf(public_id) != -1)
	{
		oborg_list_to_comparison('');
	}
	else
	{
		document.getElementById(div_id).style.border = '1px solid #E12128';
		document.getElementById(div_id + '_compare').innerHTML = 'Compare Results';
		result_comparison_r.push(public_id);
	}

	return false;
}
function oborg_rpage_compare(click_tag, public_id, compare_button)
{
	if(public_id == 'compare')
	{
		oborg_list_to_comparison('&compare');
	}
	else
	{
		if(result_comparison_r.indexOf(public_id) != -1)
		{
			click_tag.style.fontWeight = 'normal';
			result_comparison_r.splice(result_comparison_r.indexOf(public_id), 1);
		}
		else
		{
			click_tag.style.fontWeight = 'bold';
			result_comparison_r.push(public_id);
		}

		if(result_comparison_r.length > 1)
		{
			document.getElementById(compare_button).style.display = 'block';
		}
		else
		{
			document.getElementById(compare_button).style.display = 'none';
		}
	}

	return false;
}
function oborg_search(s)
{
	document.location = '/s/' + s;
}
function oborg_test_page(i)
{
	document.location = '/test/' + i;
}
function oborg_list_to_comparison(postfix)
{
	document.location = '/result/' + result_comparison_r.toString() + postfix;
}
function oborg_switch_display_tab(display_tab, switch_to)
{
	var aNodes = document.getElementById(display_tab + '_attachment').childNodes;
	var dNodes = document.getElementById(display_tab + '_blockquote').childNodes;

	for(var i = 0; i < aNodes.length; i++)
	{
		aNodes[i].getElementsByTagName('div')[0].style.background = '#E12128';
	}
	for(var i = 0; i < dNodes.length; i++)
	{
		if(dNodes[i].style.display == 'block')
		{
			dNodes[i].style.display = 'none';
		}
	}

	document.getElementById('display_tab_' + switch_to + '_header').style.background = '#1B75BB';
	document.getElementById('display_tab_' + switch_to).style.display = 'block';

	if(document.getElementById('display_tab_' + switch_to).getElementsByTagName('input').length > 0)
	{
		document.getElementById(display_tab + '_submit').style.display = 'block';
	}
	else
	{
		document.getElementById(display_tab + '_submit').style.display = 'none';
	}
}
function oborg_finder_set_type(category, finder_form)
{
	document.getElementById('oborg_finder_options').style.display = 'block';

	if(category == 'GPU')
	{
		document.getElementById('oborg_finder_options_graphics').style.display = 'block';
	}
	else
	{
		document.getElementById('oborg_finder_options_graphics').style.display = 'none';
	}
}

