// HOMEPAGE: Set the active tab and active tab content
function activeTab(element) {
        var tabs = document.getElementById('tabs').childNodes;
        for( var i=0; i<tabs.length; i++)
        {
            tabs[i].className = null;
        }
        
        var content = document.getElementById('content_body').childNodes;
        for( var j=0; j<content.length; j++)
        {
           content[j].className = "content";
        }
        
        element.parentNode.className = "active";
        document.getElementById('content_' + element.id.toString()).className = "active";
}


function init( path ) {
	// Attempts to fix the IE6 flicker problem with rollovers
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
	window.onload = function() {
		// Explode the base dir, deep dir, and file name from current page path
		// e.g.  /resources/blah/page2.php
		path = path.split( "/" );
		var section = path[4];
		var dir = path[ path.length - 2 ];
		var page = path[ path.length - 1 ];		
		

		// Set the appropriate navigation tab to active
		// This assumes that the navigation tabs are id'd with similar naming conventions to the
		// directory structure -- e.g. the tab for '/services/' should be 'id="services"'
		if( document.getElementById('nav_' + dir) )
		{
		    document.getElementById('nav_' + dir).parentNode.className = "active";
		    //$('nav_' + section).up().addClassName('active');
		}
		 
		
		
		
		// Initialize the navigation tabs for index/internal pages
		var tabs = $('nav').childElements();
		for( var i = 0; i < tabs.length; i++ ) {
			tabs[i].onfocus = function() {
				this.blur();
			}
			tabs[i].onclick = function() {
				var lis = $$('#nav li.active');
				for( var j = 0; j < lis.length; j++ ) {
					lis[j].toggleClassName('active');		
				}
				this.addClassName('active');
			}
		}
		
		
		
		// Automate the Google map load/unload functions
		if( section == 'location' ) {
			load();
			window.onunload = function() {
				GUnload();
			}
		}
		
		if( section == 'services' && ( page == 'before_and_after.php' || page == 'botox_cosmetic.php' || page == 'spider_veins.php' ) ) {
			// Put all rollover images into an array
			var ros = $$('.ro_ba');
			for( var k = 0; k < ros.length; k++ ) {
				ros[k].writeAttribute( "rel", "lightbox" );
				ros[k].onmouseover = function() {
					this.morph( { backgroundPosition: '-100px 0' }, { transition: Effect.Transitions.sinoidal } );
				}
				ros[k].onmouseout = function() {
					this.morph( { backgroundPosition: '0px 0px' }, { transition: Effect.Transitions.sinoidal } );
				}
			}
		}
	}
	return;
}