/* This site has been commented to death because it was written by a Graphic Designer who's learning JavaScript. So be nice. */

/* Before putting variables to use, they need ot be declared. */
var active='';
var headlineWidth;
var detailsWidth;
var menuHeight;

function gotoSlide(whosasking){


	/* 	If the div that triggers a rollover event is the same div that most recently triggered a rollover event, then do nothing. */
	if(whosasking==active){
		return;
	}

	/* 	If the div that triggers a rollover event is different than the div that most recently triggered a rollover event, then do nothing. */
	else {

		/*Change the CSS classes assigned to the formerly selected tab so that they're no longer tagged as selected, but rather as neutral. */
		$('homeTopMenu'+active).removeClassName('selectedTabVertical');
		$('homeTopMenu'+active).addClassName('neutralTabVertical');

		/* We're going to move lots of things around on the stage so we need ot take some measurements. */
		
		/* Each tile on the page is the same width, but we don't know what that width is yet (since the layout is constantly being tweaked) so here we get that measurement by getting the width of the headline tile numbered to correspond with the number of the menu item paired with it. */
		headlineWidth=$('homeTopHeadlines'+whosasking).getWidth();

		/* Like above, here we get the details tiles widths by getting the width of the details tile numbered to correspond with the number of the menu item paired with it. */
		detailsWidth=$('homeTopDetails'+whosasking).getWidth();

		/* Finally, to move the prompt overtop the menu, we need the size of a menu tab (heightin this case becauseit's vertical movement). And so to get the height of a tab we het the height of the tab selected. */
		menuHeight=$('homeTopMenu'+whosasking).getHeight();

		/* For future versions of this function I plan to get these measurements once, ahead of time since they're always constant. */
		/* For even future-er versions of the code I may find a way to add up the cumulative wwidth or height of all the elements before or after the element we're scrolling to. Baby steps. */

		/* These 'offset' values are the amount we need to change the margins of the blocks of headline or details tabs by. For example item 6 with a headline width of 100 would mean 0-((6*100)-100) or -500. It would mean the new left margin of the strip should be -500, bringing pixels 500-600 on the strip into view. (Where strip 1 os 0-100, strip 2 is 100-200 etc...) */
		/* I should also mention that these offset values are used in combination with a MOrph effect below, to abjust the positioning of a strip of DIVs set _within_ a surrounding DIV that crops off the content outside of its boundaries. Like a sliding tab in an old pop-out book. */
		headlineOffset = (0-((whosasking*headlineWidth)-headlineWidth));
		detailsOffset = (0-((whosasking*detailsWidth)-detailsWidth));

		/* The Menu offset value is moving an object that is always in view on the screen, so there will always only be a positive value here. */
		menuOffset = (10+((whosasking*menuHeight)-menuHeight));
		

		/* Perform a quick visual flash over the selected menu item as a cue that the selection of this menu item has caused the following changes (see below). */
/* 		new Effect.Pulsate('homeTopMenu'+whosasking, { pulses: 1, duration: 0.25 }); */

		/*Adjust the horizontal offset of the strip of 'headline' tiles to reveal the tile corresponding to the selected menu item. */
		$('homeTopHeadlinesList').morph('margin-left:' + headlineOffset  + 'px;');

		/*Adjust the horizontal offset of the strip of 'detail' tiles to reveal the tile corresponding to the selected menu item. */
		$('homeTopDetailsList').morph('margin-left:' + detailsOffset + 'px;');

		/*Adjust the vertical offset of the marker superimposed over the menu, to line it up with the selected menu item.. */
		$('homeTopMenuHilight').morph('margin-top:' + menuOffset  + 'px;');

		/*Change the CSS classes assigned to the selected tab so that they're no longer tagged as neutral, but rather as selected. */
		$('homeTopMenu'+whosasking).removeClassName('neutralTabVertical');
		$('homeTopMenu'+whosasking).addClassName('selectedTabVertical');

		/* Now label this element as the active tab so that the script detects entry into tabs other than this one. */		
		active = whosasking;

		return;
	}
	return false;
}
