
function InitializeTabs(Tabs,Panes) {
	Tabs = $$(Tabs);
	Panes = $$(Panes);
	
	if (Tabs[0]) {
		$(Tabs[0].parentNode).removeClass('Inactive');
	}
	
	Tabs.each( function(tabObj, tabindex, array) {
		//Panes[index].set('fullheight', Panes[index].getSize().y );
		var paneObj = Panes[tabindex];
		if (paneObj) {
			if (tabObj.hasClass('Active')) {
				//Panes[index].setStyle('display', 'none');
				paneObj.addClass('Active');
			}
			else {
				paneObj.addClass('Inactive');
			}
		}
		//item.index = index;
		tabObj.addEvent('click', function() {
			ActivateTabAndPane(tabindex);
		});
		
	});
	
	function ActivateTabAndPane(activateindex) {
		var tabObj = Tabs[activateindex];
		var paneObj = Panes[activateindex];
		Tabs.each( function(tabObj, tabindex) {
			var localPaneObj = Panes[tabindex];
			/// If the current tab in our loop is NOT the same one that was requested, do this
			if (tabindex != activateindex) {
				/// Only do something to the tab in question if it is already active.
				if (tabObj.hasClass('Active')) {
					tabObj.removeClass('Active');
					/// Make the pane not active
					if (localPaneObj) {
						localPaneObj.removeClass('Active');
						/// Make the pane Inactive
						localPaneObj.addClass('Inactive');
					}
				}
			}
		});
		tabObj.addClass('Active');
		if (paneObj) {
			paneObj.removeClass('Inactive');
			paneObj.addClass('Active');
		}
	}
}

function InitializeSearchTabs() {
	new TabSwapper({
		selectedClass: 'Active',
		deselectedClass: 'Inactive',
		//rearrangeDOM: false,
		tabs: $$('.SearchTabs li'),
		//clickers: $$('.SearchTabs li'),
		sections: $$('.SearchPanes .Pane')
		//initPanel: 0
		/*remember what the last tab the user clicked was*/
		//cookieName: 'ucflibLastSearchTab',
		/*use transitions to fade across*/
		//smooth: true
		//smoothSize: true
	});
	var TabsParents = $$('.SearchTabs');
	TabsParents.each( function(tabparent) {
		tabparent.removeClass('Inactive');
	});
}


/// Just do it right now, don't wait for the page to load.
//window.addEvent('domready', function() {
	//InitializeTabs( $$('.SearchTabs li'), $$('.SearchPanes>div'));
	InitializeSearchTabs();
	//window.alert('Something should be happening here');
//});
