// body onload
$(function(){
	// load the history script for tracking the loaded tab
	$.getScript('/scripts/jquery.history.js', function(){
		$.historyInit(function(hash){
			$('#tabs-area').tabs('select',hash + '-tab');
			fitToScreen();
		});
		// add tab, content, or side link clicks to the history
		$("#tabs-area a,#side a").click(function(e){
			// if this is a reference to a link on the same page, just switch the tab
			var hash_regexp = new RegExp(decodeURI(this.hash).replace('?','\\?')+'.*');
			if (this.hash && decodeURI(document.URL).indexOf(decodeURI(this.href).replace(hash_regexp,'')) > -1){
				$.historyLoad(this.hash.replace('#','').replace('-tab',''));
			}
		});
	});
	// initialize the tabs area and focus any form elements
	$('#tabs-area').tabs({
		selected: -1,
		show: function(e,ui){
			$(ui.tab.hash+" :text:visible:first").focus();
			// send Omniture tracking data
			s.pageName = ui.tab.hash;
			s.t();
			// send Eloqua tracking data
			setTimeout("elqFCS(location.href.replace('#',''))",500);
		}
	}).tabs('select',window.location.hash+'-tab');
});