try{
document.observe('dom:loaded', function() {

	var currentTab = 0;
	var allNavItems = $$('#tertiary-nav li');
	
	//ie6 in some instances is returning null is null or not an object. This is a quick fix
	
	var totalWidth = ($('tertiary-nav') != null) ? $('tertiary-nav').getWidth() : 0;
	var navWidth = 0;
	var navJumpPoints = new Array(allNavItems[0]);
	
	var cumulativeWidth = 0;
	allNavItems.each(function(elm) {
		cumulativeWidth += elm.getWidth();
		if(cumulativeWidth > totalWidth) {
			navJumpPoints.push(elm);
			//elm.insert({before: '<li style="width:'+(cumulativeWidth+elm.getWidth()-totalWidth)+'px;"></li>'});
			cumulativeWidth = elm.getWidth();
		}
		navWidth += elm.getWidth();
	});
	
	if (totalWidth < navWidth) {
		$('tertiary-nav-left-button').addClassName('buttonActive');
		$('tertiary-nav-right-button').addClassName('buttonActive');
	}

 try{
	$('tertiary-nav-left-button').observe('click', function(e) {
	   
		var nextItem = navJumpPoints[currentTab-1];
		if(nextItem) {
			$j('#tertiary-nav').scrollTo(nextItem, 800, {axis:'x'});
			currentTab--;
		}
	
	});
	$('tertiary-nav-right-button').observe('click', function(e) {
		var nextItem = navJumpPoints[currentTab+1];
		if(nextItem) {
			$j('#tertiary-nav').scrollTo(nextItem, 800, {axis:'x'});
			currentTab++;
		}
    });	
}catch(err){}

});}catch(err2){}
