/* 
Optional extra classnames:

noaccordion : no accordion functionality
collapsible : menu works like an accordion but can be fully collapsed
expandfirst : first menu item expanded at page load
*/

function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}

$(document).ready(function() {

	initMenus();

	$('div#show_scroller a').click(function(e){

		e.stopPropagation();
		idTxt = this.id;
		eventPosition = idTxt.substr(7,1);
		ep = parseInt(eventPosition);
		if(ep == 0) $('div#feature_trailer').scrollTo('div.show_summary:eq(0)', 800);
		if(ep == 1) $('div#feature_trailer').scrollTo('div.show_summary:eq(1)', 800);
		if(ep == 2) $('div#feature_trailer').scrollTo('div.show_summary:eq(2)', 800);
		if(ep == 3) $('div#feature_trailer').scrollTo('div.show_summary:eq(3)', 800);

//		console.log($('#feature_trailer').children().get(eventPosition));

		return false;

	});

});

