$(document).ready(function() {

			//set up mailto links.. light defense vs. spambots
			$('.mailto').each(function() {
				var $this 		= $(this);
				var str			= $this.html();
				var newStr 		= str.replace(' (at) ', '@');
				newStr 			= newStr.replace(' (dot) ', '.');
				var link 		= document.createElement('a');
				link.setAttribute('href','mailto:'+newStr+'?subject=e-mail from nwsurgeons.com visitor');
				$(link).text('e-mail us');
				$this.empty().append(link);
			});

			// hide sections to be shown in tabs
            $('.tabsec').hide().css( { position: "absolute", top: "0", width: "100px", left: "-100px" } );
            
            // check for a hashtag in the url
            var url = document.location.href;
            url = url.split('#');
            
            // yeah?  select the hashed section and its menu item
            if (url[1]) {
                var firstLink = '#' + url[1];
                $('#tabselect li a').each(function(){
                    if ($(this).attr('href') == firstLink) {
                        $(this).parents('li').addClass('current');
                    }
                });                            
            }
            // no? select first item and its navlink
            else {
                var firstLink = $('#tabselect li:first-child a').attr('href');
                $('#tabselect li:first-child').addClass('current');

            }
            var firstView = $(firstLink).html();
            $('#viewer').html(firstView);
            
            // handle clicks on the tabselect UL
            $('#tabselect li a').click(function() {
                var tabSource = $(this).attr('href');
                var tabContent = $(tabSource).html();
              	
              	$('#tabselect li.current').removeClass('current');
                $(this).parents('li').addClass('current');
                
                //if (window.location.hash) {
                window.location.hash = tabSource;
                //}
                
                $('#viewer').fadeOut(200, function() {                    
                    $('#viewer').html(tabContent).fadeIn(200);
                });
                //console.log('completed');
                return false;
            });

}); // end main doc.ready statement

function loadGmap(url) {
	iframe = '<iframe id="map" width="525" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + url + '"></iframe>';
	$('#mapviewer').html(iframe);
}