function show(x) {
	if (!($('#'+x).hasClass('selected'))) { //if this div isn't selected
		$('#main div.selected').fadeToggle("400", "linear", function(){ // fade out the div that is selected
			$('#'+x).fadeToggle("400", "linear").addClass('selected'); // fade in the div we want and call it selected
		}).removeClass('selected'); // stop calling the hidden div selected
		$('#toolbar li').removeClass('selected'); // unselect all toolbar buttons
		$('#btn-'+x).addClass('selected'); // select the toolbar button that we want

	}
}	

function init() {
	var L = document.location.toString(); /* bookmark: http://blog.rebeccamurphey.com/2007/12/04/anchor-based-url-navigation-with-jquery */ 
	if (L.match('#')) { // if the URL contains an anchor
		var A = L.split('#')[1]; // get the name sans #
	}
	else {
		// this will always be undefined now. leaving the code in case it proves useful, but the work around is to drop .secondary from the div, and replace it with .selected. (#about remains as .secondary)
		// no relevant CSS styles rely on .secondary. If they ever do, then firstTab will need to be defined again, before loading this file.
		if (typeof firstTab == 'undefined') { 
			var A='about'; 
		} else {
			var A=firstTab;
		}; 
	};
	
	// highlight main toolbar button
	if (typeof maintoolbarhighlight != "undefined") $(document.getElementById(maintoolbarhighlight)).addClass('selected');

	// hide all but the first selected item and add the selected class
	$('#'+A).removeClass('secondary');  
	$('#main div.secondary').hide(); 
	$('#'+A).addClass('secondary');
	$('#'+A).addClass('selected');
	$('#btn-'+A).addClass('selected');
	
	// show text to help those that miss the toolbar. Not needed for those w/o javascript, as they will just keep scrolling down.
	//$('#main.location #about').append('<p class="helper"><span>Find out who is going to be there: <a href="#guests">Guests&nbsp;&raquo;</a></span></p>');
	//$('#main.location #guests').append('<p class="helper"><span>Find out the schedule: <a href="#schedule">Schedule&nbsp;&raquo;</a></span></p>');
	//$('#main.location #schedule').append('<p class="helper"><span>Here are our prices: <a href="#prices">Prices&nbsp;&raquo;</a></span></p>');
	//$('#main.location #prices').append('<p class="helper"><span>Here are the hotels available: <a href="#hotels">Hotels&nbsp;&raquo;</a></span></p>');
	//$('#main.location #hotels').append('<p class="helper"><span>Here are some common questions and their answers: <a href="#faq">FAQ&nbsp;&raquo;</a></span></p>');
	//$('#main.location #faq').append('<p class="helper"><span>Ready to register? <a href="#register">Register&nbsp;&raquo;</a></span></p>');
	
	// helper nav text, link override
	//$('#main div p.helper a[href^="#"]').click(function(e){ 
	//	e.preventDefault();
	//	x = $(this).attr('href').split('#')[1];
	//	show(x);
	//});

	// ie8 can't handle hovers on anything but links.
	$('#toolbar li').hover(
		function(){ $(this).addClass('iehover') },
		function(){ $(this).removeClass('iehover') }
	);

	$('#small li').hover(
		function(){ $(this).addClass('iehover') },
		function(){ $(this).removeClass('iehover') }
	);


	// watch for click on toolbar LI, override the internal link, and show desired element
	$('#toolbar li a[href^="#"]').parent().click(function(e){ 
		e.preventDefault();
		x = $(this).find('a').first().attr('href').split('#')[1];
		show(x);
	});

	$('#small li a[href^="#"]').parent().click(function(e){ 
		e.preventDefault();
		x = $(this).find('a').first().attr('href').split('#')[1];
		show(x);
	});


	$('#header a[href^="#"]').parent().click(function(e){   // same for header button
		e.preventDefault();
		x = $(this).find('a').first().attr('href').split('#')[1];
		show(x);
	});

	// for toolbar clicks that miss the links, that aren't internal
	// I'm still not sure why this has to be done in this manner, rather than simply triggering the click of the link.
	$('#toolbar li a').not("[href^=#]").parent().bind('click', function(event) {
		event.preventDefault();
		window.location = $(this).find('a').first().attr('href');
	});
	
	$('#small li a').not("[href^=#]").parent().bind('click', function(event) {
		event.preventDefault();
		window.location = $(this).find('a').first().attr('href');
	});


	$('#main div.secondary > h3:first-child').css('display','none'); /* hide this when using the toolbar to navigate, as it's pretty self-evident. leave it for those w/o javascript who are scrolling. */
	
	$('#guests > ul > li:first-child').css('border-top-width','0'); /* similarly, hide the separation border for the guests (the h2 location title has its own border) */ 
	
	$('#guests > ul > li img:even').css('float','right'); /* alternate guests pictures */
	
//	$('#schedule td.event').prepend('<span>&laquo;&nbsp;</span>'); /* extra highlights that only make sense for hovers */
//	$('#schedule td.event').append('<span>&nbsp;&raquo;</span>');  /* extra highlights that only make sense for hovers */

	$('#schedule td.event').hover(
		function(){
			$(this).addClass('bold');
			$(this).prev().addClass('whiteBG');
			$(this).parent().parent().find('th').first().addClass('whiteBG');
		},
		function(){
			$(this).removeClass('bold');
			$(this).prev().removeClass('whiteBG');
			$(this).parent().parent().find('th').first().removeClass('whiteBG');
		}
	);
	$('#schedule td.time').hover(
		function(){
			$(this).addClass('whiteBG')
			$(this).next().addClass('bold')
			$(this).parent().parent().find('th').first().addClass('whiteBG')
		},
		function(){
			$(this).removeClass('whiteBG')
			$(this).next().removeClass('bold');
			$(this).parent().parent().find('th').first().removeClass('whiteBG')
		}
	);
	/*  This seemed to not be helpful.
		$('#schedule tbody').hover(
			function(){
				$(this).find('th').first().addClass('whiteBG')
			},
			function(){
				$(this).find('th').first().removeClass('whiteBG')
			}
		);
	*/
	
	/* pricing table */
	$('#prices td, #prices th').css('color','#333');  /* dim the colors slightly if they have javascript, as we'll set them to solid black on hover */
	$('#prices th.section').css('color','#fff'); /* to fix the section header back to white after the previous */


	$('#prices td.confprice').hover(
		function(){
			$(this).parent().find('td').addClass('selected');
			$(this).parent().parent().find('td.info').removeClass('selected'); /* we don't want to style the info */
			$(this).parent().parent().find('td.info').css('color','#000'); /* color: we do want to change just the color though */
		},
		function(){
			$(this).parent().find('td').removeClass('selected');
			$(this).parent().parent().find('td.info').css('color','#333');
		}
	);
	$('#prices td.persons, #prices td.regprice').hover(
		function(){
			$(this).parent().find('td').addClass('highlight');
			$(this).parent().parent().find('td.info').removeClass('highlight'); /* we don't want to style the info */
			$(this).parent().parent().find('td.info').css('color','#000'); /* color: we do want to change just the color though */
		},
		function(){
			$(this).parent().find('td').removeClass('highlight');
			$(this).parent().parent().find('td.info').css('color','#333');
		}
	);
	$('#prices td.ebdprice').hover(
		function(){
			$(this).parent().find('td.persons').addClass('selected');
			$(this).parent().parent().find('th.ebdprice').addClass('selected');
			$(this).parent().parent().find('td.ebdprice').addClass('highlight');
			$(this).next('td.regprice').addClass('highlight');
			$(this).parent().parent().find('td.info').removeClass('highlight'); /* we don't want to style the info */
			$(this).parent().parent().find('td.info').css('color','#000'); /* color: we do want to change just the color though */
			$(this).addClass('selected');
		},
		function(){
			$(this).parent().find('td.persons').removeClass('selected');
			$(this).parent().parent().find('th.ebdprice').removeClass('selected');
			$(this).parent().parent().find('td.ebdprice').removeClass('highlight');
			$(this).next('td.regprice').removeClass('highlight');
			$(this).parent().parent().find('td.info').css('color','#333');
			$(this).removeClass('selected');
		}
	);

	// setup faq.
	$('#faq div.faq h4').css('text-align','left').css('cursor','pointer').prepend('<span class="hidden"></span>').click(function() {
		$(this).find('span').toggleClass('hidden shown');
		$(this).next().slideToggle('slow');
		return false;
	}).next().hide();
	
	// hotels
	$('#hotels div h5').css('text-align','left').css('cursor','pointer').prepend('<span class="shown"></span>').click(function() {
		$(this).find('span').toggleClass('shown hidden');
		$(this).next().slideToggle('medium');
		return false;
	})

	$('#hotels div h5.full').find('span').toggleClass('shown hidden').end().next().hide();

	
	// test for rounded corner support....  turns out, it looks ok with out support. commenting out.
	//
	//	if (!$.browser.msie) { // assume if it's not IE, then we're ok. it falls back nicely enough. $.browser is depreciated.
	//		$('#hotels div.pricingblock li').addClass('fancy');
	//	} else {
	//		if ($.browser.msie && $.browser.version.substr(0,1)>8) {
	//			$('#hotels div.pricingblock li').addClass('fancy');
	//		};
	//	 };
	//

	$('#hotels div.pricingblock li').addClass('fancy').hover(
		function(){ $(this).addClass('iehover') },
		function(){ $(this).removeClass('iehover') }
	);

	
	// $('#header').css('cursor','pointer').click(function() {window.location = '/';});
	
// END INIT FUNCTION

}
init();

