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;
			}
		}
	);
}
var slideShow = new Array();
slideShow[0] = "images/header/mvsz_1.jpg";
slideShow[1] = "images/header/mvsz_2.jpg";
slideShow[2] = "images/header/mvsz_3.jpg";
slideShow[3] = "images/header/mvsz_4.jpg";
slideShow[4] = "images/header/mvsz_5.jpg";

function fadeinSlideshow(elem, imageList, slideDuration, fadeSpeed, current) {
 var listSize = imageList.length;
 if (!current || current >= listSize) current = 0;
 if (!slideDuration) slideDuration = 5000;
 if (!fadeSpeed) fadeSpeed = 1000;
 $(elem + " img").attr("src", imageList[current]);
 if (current == (listSize - 1)) 
 {
	$(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
 } 
 else 
 {
	$(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
 }
 $(elem + " img").animate({ opacity: "1" }, slideDuration).animate({ opacity: "0.01" }, fadeSpeed, function() { $(this).css("opacity", "1"); fadeinSlideshow(elem, imageList, slideDuration, fadeSpeed, current + 1) });
}

function runSlideshow(){
 fadeinSlideshow("#sponsors_slideshow", slideShowSponsors, 3000, 0);
 fadeinSlideshow("#slideshow", slideShow, 5001, 1001);
}

//$(document).ready(runSlideshow);

$(document).ready(function() {initMenus(); runSlideshow();});
