var currentBoard = "background";
var currentBackground = "background";
var buttonStatus = 1;

function clearBoard () {
 ['band','news','musik','termine','background'].each(function(b){
	new Effect.Fade(b,{ duration: 0.1 });
});

new Effect.Appear("background2",{ duration: 0.5 });
}

function fillBoard () {

new Effect.Fade("band",{ duration: 1.0 });
new Effect.Fade("background2",{ duration: 1.0 });
new Effect.Appear("background",{ duration: 1.0 });
}
/*var Engine = {
        detect: function() {
          var UA = navigator.userAgent;
          this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
          this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
          this.isOpera = /Opera/.test(UA);
          this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
          this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);
        }
      }
      Engine.detect();
  */    

function bubble(id,x,y){
        //$(id).setStyle({left:x+'px',top:y+'px'});
        new Effect.Scale(id,100, Object.extend({
          beforeStart:function(effect){
            $(effect.element).style.display = 'block';
            $(effect.element).setOpacity(0);
            //$$('#'+id+' img').each(function(p){p.hide()});
          },
          afterUpdate:function(effect){
            $(effect.element).setOpacity(effect.position);
          },
          scaleFrom:0,
          scaleFromCenter:true,
          afterFinish:function(effect){
              new Effect.Appear(effect.element,{duration:0.4});
          }
        }, arguments[3] || {}));        
      }

function myappear(id){
	new Effect.Appear(id, Object.extend(
	{
		duration: 3.0,
		beforeStart:function(effect){
			//$(effect.element).style.display = 'block';
			//alert("hallo");
			//$(effect.element).setOpacity(0);
			//$$('#'+id+' img').each(function(p){p.hide()});
		},
		afterFinish:function(effect){
			new Effect.Fade(effect.element,{to:0.8,duration:2.4});
		}
	}));        
}


function start() {
	new Effect.Appear("background",{ from: 0.0, to:0.9,duration: 0.3, queue: 'end'});
	showButtons();
}

function showButtons() {
	new Effect.Appear("newsbutton",{ from: 0.0, to:0.9, duration: 0.5, queue: 'end' });
	new Effect.Appear("bandbutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end' });
	new Effect.Appear("photosbutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	new Effect.Appear("terminebutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	new Effect.Appear("kontaktbutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	new Effect.Appear("musikbutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	new Effect.Appear("linksbutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	new Effect.Appear("gaestebutton",{ from: 0.0, to:0.9,duration: 0.5, queue: 'end'});
	buttonStatus = 1;
}


function fadeButtons() {
	new Effect.Fade("newsbutton",{  duration: 0.1, queue: 'end' });
	new Effect.Fade("bandbutton",{ duration: 0.1, queue: 'end' });
	new Effect.Fade("photosbutton",{ duration: 0.1, queue: 'end'});
	new Effect.Fade("terminebutton",{ duration: 0.1, queue: 'end'});
	new Effect.Fade("kontaktbutton",{ duration: 0.1, queue: 'end'});
	new Effect.Fade("musikbutton",{ duration: 0.1, queue: 'end'});
	new Effect.Fade("linksbutton",{ duration: 0.1, queue: 'end'});
	new Effect.Fade("gaestebutton",{ duration: 0.1, queue: 'end'});
	buttonStatus = 0;
}


//TODO Spagetti Code
function showboard(board,background) {
	// fading all the current stuff
	if (currentBoard!= board) 
		new Effect.Fade(currentBoard,{ duration: 0.5, queue:'end' });
	if (background == "backgroundbig" && buttonStatus == 1)
		fadeButtons(); 
	if (currentBackground!= background ) {
		if(
			( background == "background" && currentBackground == "background2"  ) ||
			( background == "background2" && currentBackground == "background"  )) {
			new Effect.Fade(currentBackground ,{ duration: 0.3  });
			new Effect.Appear(background,{ duration: 0.3  });
		} else {
			new Effect.Fade(currentBackground ,{ duration: 0.3, queue:'end' });
			new Effect.Appear(background,{ duration: 0.3 , queue:'end' });
		}
	}
	if ((background == "background" || background == "background2" )&& buttonStatus == 0)
		showButtons(); 
	if (currentBoard!= board) 
		new Effect.Appear(board,{ duration: 0.5, queue:'end'});

/*
	if (currentBoard == "band" ) 
		new Effect.Fade("mehr",{ duration: 0.1, queue:'end' });
	// home button gedrückt
	if (board == "background" )
	{ 
		if (currentBoard == "backgroundbig" ) 
			new Effect.Fade("backgroundbig",{ duration: 0.5, queue:'end'});
		new Effect.Fade("background2",{ duration: 0.5, queue:'end' });
		start();
	} else
		new Effect.Appear(board,{ duration: 1.0, queue:'end'});
	if (board == "band" || board == "news") 
		new Effect.Appear("mehr",{ duration: 1.0 });*/
	currentBoard = board;
	currentBackground = background;
}


function Bildwechsel (Bildnr, Bildobjekt) {
  window.document.images[Bildnr].src = Bildobjekt.src;
}


