﻿function init( path ) {
	// Attempts to fix the IE6 flicker problem with rollovers
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
	window.onload = function() {
		$('nav_edu').up().addClassName('active');
		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');
			}
		}

		// Set up the front page tabs
		if( section == 'home' ) {
			var tabs = $('tabs').childElements();
			$('content_specialty').setStyle( { display: 'block' } );
			$('specialty').up().addClassName('active');
			
			for( var i = 0; i < tabs.length; i++ ) {
				tabs[i].onfocus = function() {
					this.blur();
				}
				tabs[i].onclick = function() {		
					var lis = $$('#tabs li.active');		
					for( var j = 0; j < lis.length; j++ ) {
						lis[j].toggleClassName('active');
						$( 'content_' + lis[j].down().identify() ).setStyle( { display: 'none' } );
					}
					$( 'content_' + this.down().identify() ).setStyle( { display: 'inline' } );
					this.addClassName('active');
					return false;
				}
			}				
		}
		
		// 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 i = 0; i < ros.length; i++ ) {
				ros[i].writeAttribute( "rel", "lightbox" );
				ros[i].onmouseover = function() {
					this.morph( { backgroundPosition: '-100px 0' }, { transition: Effect.Transitions.sinoidal } );
				}
				ros[i].onmouseout = function() {
					this.morph( { backgroundPosition: '0px 0px' }, { transition: Effect.Transitions.sinoidal } );
				}
			}
		}
	}
	return;
}