// Fixes flicker in ie6 when hovering over tabs and page nav.
// It should also help general performance as it forces ie6 to cache css background images.
// http://www.mister-pixel.com/#Content__state=is_that_simple
if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5)) == 6)
{
	try{ document.execCommand('BackgroundImageCache', false, true); }
	catch(err){}
}

// domloaded event
Event.observe(document, 'dom:loaded', function(){
	$$('#tab-content .tabs a').each(function(item){
		// attach click event
		item.observe('click', function(e){
			// stop default click behavior on anchor
			e.stop();
			
			// collect some elements
			var target = $(e.target);
			var contentContainer = $$('#tab-content .content')[0];
			
			// remove focus border when clicking
			target.blur();
			
			// build url for ajax request
			var url = 'i_' + target.href.split('tab=')[1] + '.jsp';
			
			// update the container with the appropriate content
			new Ajax.Updater(contentContainer, url,{
				onSuccess: function(){
					// remove highlighting from selected tabs
					$$('#tab-content .tabs li.selected').each(function(item){
						item.removeClassName('selected');
					});
					
					// strip current tab text from page title
					var title = document.title.substring(0, document.title.lastIndexOf(' - ') + 3);
					// append new tab text the copy is pulled from the tab
					title += item.innerHTML.unescapeHTML();
					// update page title
					document.title = title;
					
					// select the tab that has been clicked on
					target.up(0).addClassName('selected');
				}
			});
		});
	});
});