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');
	
	// 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')
		}
	);
	
	/* 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();

	
	$('#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();

