// Allows a handset tariffs table row to click through to the 'More Info' URL.
function handsetClickthrough(tr)
{
	var links = tr.getElementsByTagName('a');
	if (links != null && links.length > 0)
	{
		pageTracker._trackPageview('/URMob/');
		window.open(links[0].href, '_blank');
	}
	return false;
}

function navigatePopup(a)
{
	window.open(a.href, a.href);
	return false;
}

// Filter handset models based on a search string.
function filter(value)
{
	value = value.toLowerCase().replace(/ +/g, '');
	var visibleModels = 0;
	var handsets = $('handsets_by').getElementsByTagName('div');
	for (var i = 0; i < handsets.length; i++)
	{
		if (handsets[i].className == 'handset')
		{
			var model = handsets[i].getElementsByTagName('a')[1].innerHTML.toLowerCase().replace(/ +/g, '');
			handsets[i].style.display = (model.indexOf(value) > -1) ? 'block' : 'none';
			if (handsets[i].style.display == 'block')
			{
				visibleModels++;
			}
		}
	}
	$('filter_count').innerHTML = (visibleModels == 0) ? 'We do not have any models matching the text you entered.' : 'Matched ' + visibleModels + ' of ' + (handsets.length / 2) + ' models.';
}
