jQuery.noConflict();
jQuery(document).ready(function() {
	var width = jQuery("#navmenu").width();
	var min = 10;
	var mainoffset = jQuery('#header').position().left;
		
	jQuery('.tablink').each(function() {
		var itemoffset;
		var item = jQuery("#tabcontent" + jQuery(this).attr('id').replace("tablink", ""));
		var linkmiddle = ((jQuery(this).position().left - mainoffset)+ (jQuery(this).width() /2));
		var linkoffset = 0 - ((width /2) - linkmiddle);
		var itemleft = (width /2) + linkoffset - (item.width() / 2);
		
		if (linkoffset - (item.width() / 2) < (0 - (width /2) + min)){
			itemoffset = (0 - (width /2) + min) + (item.width() / 2);
		}
		else if (linkoffset + (item.width() / 2) > (width/2) - min){
			itemoffset = ((width/2) - min) - (item.width() / 2);
		}
		else {
			itemoffset = linkoffset;
		}
		item.css('left', itemoffset + 'px');
	});
	
	jQuery('.tablink').mouseover(function() {
		var which = jQuery(this).attr('id').replace("tablink", "");
		jQuery('.tablink').addClass('tab');
		jQuery('.tablink').removeClass('tabactive');
		jQuery(this).addClass('tabactive');
		jQuery('.tabcontent').css('display', 'none');
		jQuery('#tabcontent'+which).css('display', 'inline');
	});
	
});

