function menuin(tt,ordner){
	if (document.getElementById(tt)){
		document.getElementById(tt).src="img/"+tt+"_over.gif";
	}
	document.getElementById("m"+tt+"").style.visibility="visible";
}

function menuout(tt,state,ordner){
	if (document.getElementById(tt)){
		if(state!="no"){
			document.getElementById(tt).src="img/"+tt+".gif";
		}
	}
	document.getElementById("m"+tt+"").style.visibility="hidden";
}

function menuEvents(tt,state,ordner){
	if($(tt)){
		$(tt).addEvents(
			{
			'mouseenter': function(){menuin(tt,ordner);},
			'mouseleave': function(){menuout(tt,state,ordner);}
				}
			);}
}
 function submenuEvents(tt,state,ordner){
 			if($('m'+tt)){
		$('m'+tt).addEvents(
			{
			'mouseenter': function(){menuin(tt,ordner);},
			'mouseleave': function(){menuout(tt,state,ordner);}
				}
			);}
 }
 
 
 function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
 
window.addEvent('domready', function(){
	doMenu();
	
	
	/*Facebook SDK*/
	if($('fb-root')){
		window.fbAsyncInit = function() {
			FB.init({appId: '153684724667531', status: true, cookie: true,	xfbml: true});
		};
		(function() {
			var e = document.createElement('script'); e.async = true;
			e.src = document.location.protocol +
			'//connect.facebook.net/de_DE/all.js';
			document.getElementById('fb-root').appendChild(e);
		}());
	}
	
	/*socialmedia-widget*/
	if($('socialMedia_WidgetLink')){
		$('socialMedia_WidgetLink').addEvent('click', function(ev){
			if($('socialMedia_Widget').get('class')!="widgetAktiv"){
				$('socialMedia_Widget').set('class', 'widgetAktiv');
			}else{
				$('socialMedia_Widget').set('class', 'widgetInAktiv');
			}
		});
	}
	
});

var myGallery;
var isPaused = 0;
function startGallery() {
	 myGallery = new gallery($('myGallery'), {
		timed: true,
		showArrows: true,
		showCarousel: false,
		embedLinks: false,
		showInfopane: false
	});
}
window.addEvent('domready', startGallery);

  function resumeGallery() {
    if (this.options.timed)
			//this.timer = this.nextItem.delay(this.options.delay, this);
   if (this.galleryInit == 1)
		{
			imgPreloader = new Image();
			imgPreloader.onload=function(){
				this.startSlideShow.delay(10, this);
			}.bind(this);
			imgPreloader.src = this.galleryData[0].image;
			if(this.options.preloader)
				this.galleryElements[0].load();
		} else {
			if (this.options.showInfopane)
			{
				if (this.options.showInfopane)
				{
					this.showInfoSlideShow.delay((500 + this.options.fadeDuration), this);
				} else
					if ((this.options.showCarousel)&&(this.options.activateCarouselScroller))
						this.centerCarouselOn(position);
			}
		}
  }

  function pauseGallery() {
    if (this.options.timed)
			$clear(this.timer);
			 myGallery.clearTimer();
 myGallery.options.timed=false;
  }

  function PausePlayGallery() {
    if (isPaused == 0)
    {
    myGallery.clearTimer();
 		myGallery.options.timed=false;
    isPaused = 1;
    document.getElementById('pausebutton').src = 'img/play.gif';
    }
  else
    {
   myGallery.options.timed=true;
	 myGallery.prepareTimer();;
	 myGallery.nextItem();
    isPaused = 0;
    document.getElementById('pausebutton').src = 'img/break.gif';
    }
  }
