// JavaScript Document
var flash_array = new Array();

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  } else {
    return document[movieName]
  }
}

function stopAllVideos() {
	if(flash_array.length == 0){
		aTmp = $('contents').getElements('div[id^=folge]');
		aTmp.each(function(item){
		  aText = item.id.split("_");
			flash_array.push("flash_"+aText[1]);			
		});
	}
	else {
		for (var i = 0; i < flash_array.length; ++i) {
			thisMovie(flash_array[i]).GotoFrame(1);
		}
	}
}

window.addEvent('domready', function(){
	var accordion = new Accordion('h3.atStart', 'div.atStart', {
				opacity: true,
				display: 0,
				onActive: function(toggler, element){
					toggler.removeClass('videonavi_deaktive');
					toggler.addClass('videonavi_aktive');
					stopAllVideos();
				},
				
				onBackground: function(toggler, element){
					toggler.removeClass('videonavi_aktive');
					toggler.addClass('videonavi_deaktive');

				}
			}, $('accordion'));

      var divs = $$(['docs', 'js', 'html', 'css']);
      divs.each(function(div){
        var link = $(div.id + 'code');
        div.setStyle('display', 'none');
        link.addEvent('click', function(e){
          e = new Event(e);
          divs.each(function(other){
            if (other != div) other.setStyle('display', 'none');
          });
          div.setStyle('display', (div.getStyle('display') == 'block') ? 'none' : 'block');
          e.stop();
        });
      });

});
