/*
	gforcesTabs Version 1.0
	Updated August 2009
	written by Chris Munn / Matthew Lindley for GForces Web Management
	www.gforces.co.uk
*/

		function gforcesTabs() {

			//  Loop <div>s
			$$('div.domTabs').each( function ( div ) {

				//  Set an id if one isn't present
				div.identify();

				//  Activate first tab
//				div.down().firstDescendant().addClassName( 'active' );
                $$( '#' + div.id + ' ul.domHeadings' ).each(function (div) {
                    div.firstDescendant().addClassName( 'active' );
                });
                
				//  Hide all content
				$$( '#' + div.id + ' div.domContent' ).invoke( 'hide' );

				//  Show first content
				$$( '#' + div.id + ' div.domContent' )[0].show();

				//  Loop <li>s
                $$( '#' + div.id + ' ul.domHeadings li' ).each(function (li, index) {
                
                    //  Monitor onclicks
                    li.down().observe( 'click', function ( ev ) {

                        ev.stop();
                        
                        //  Remove all class names
                        ev.element().up().up().childElements().invoke( 'removeClassName', 'active' );

                        //  Set active tab
                        ev.element().up().addClassName( 'active' );

                        //  Hide all content
                        $$( '#' + div.id + ' div.domContent' ).invoke( 'hide' );

                        //  Show content selected
                        $$( '#' + div.id + ' div.domContent' )[index].show();
    
                    });
                    
                });

			});

		}

var showGTabs = function (gTabId, tabToShowId) {
    //Hides all G Tabs
    $$('#' + gTabId + ' ul.domHeadings li').each( function ( li, index ) {
        li.removeClassName('active');
    });
    
    $$('#autoSearch' + ' div.domContent').invoke( 'hide' );

    //Show tabs with given id
    $(tabToShowId).up().addClassName('active');

    var tabId = $(tabToShowId).readAttribute('class');
    $$('#autoSearch' + ' div.' + tabId).invoke('show');
    

}


