
/* (C) dfacts Network  //  pix-r.us

Description: dynamic gui based on script.aculo.us
Version: 1.0
Author: Gerhard Koch

*/

init = function(script){
	focus = 1;
	new Effect.SlideUp('main', {queue: 'end', scaleContent: false, afterFinish: function(){
	new Ajax.Updater('logo', 'components/taube.html');
	new Ajax.Updater('main', 'components/main-'+lang+'.html', {onComplete:function(){
	new Effect.SlideDown('main');
	eval(script);
	}, asynchronous:true});
	}});
	
}


load = function(script){
	focus = 1;
	new Ajax.Updater('logo', 'components/taube.html');
	new Ajax.Updater('main', 'components/main-'+lang+'.html', {onComplete:function(){
	eval(script);
	}, asynchronous:true});
	
}


intro = function(setlang){

	if(window.location.search){	
		 window.location.href = window.location.href.replace(/\?/g, "#");
	} else {
	if(setlang != lang) {
		if(setlang) lang = setlang;
		hash = window.location.hash.substring(1, window.location.hash.length);
		focus = 1;
	switch (hash) {
 		case "solotrapez":	load('solotrapez();');
							break;
 		case "solotrapez,gallery":	
 							load('solotrapez_gallery();');
							break;
 		case "solotrapez,buehne":	
 							load('solotrapez_buehne();');
							break;
 		case "solotrapez,video":	
 							load('solotrapez_video();');
							break;
 		case "duotrapez":	load('duotrapez();');
							break;
 		case "duotrapez,gallery":	
 							load('duotrapez_gallery();');
							break;
 		case "duotrapez,buehne":	
 							load('duotrapez_buehne();');
							break;
 		case "duotrapez,video":	
 							load('duotrapez_video();');
							break;
 		case "vita":		load('vita();');
							break;
 		case "vita,0":		article = 0;
 							load('vita();');
							break;
 		case "vita,1":		article = 1;
							load('vita();');
							break;
 		case "vita,2":		article = 2;
							load('vita();');
							break;
 		case "vita,3":		article = 3;
							load('vita();');
							break;
 		case "vita,4":		article = 4;
							load('vita();');
							break;
 		case "vita,5":		article = 5;
							load('vita();');
							break;
 		case "kontakt":		load('kontakt();');
							break;
 		case "kontakt,anschrift":		
 							load('kontakt("anschrift");');
							break;
 		case "kontakt,impressum":		
 							load('kontakt("impressum");');
							break;
 		case "trapezbau":	load('trapezbau();');
							break;
 		case "trapezbau,bestellung":	
 							load('trapezbau("bestellung");');
							break;
 		case "kurse":		load('kurse();');
							break;
 		case "links":		load('linkpage();');
							break;

		case "deutsch":		lang = "de";
							langhilight("lang01");
							break;
		case "english":		lang = "en";
							langhilight("lang02");
							break;
		
		case "francais":	lang = "fr";
							langhilight("lang03");
							break;

  		default:			new Ajax.Updater('main', 'components/intro-'+lang+'.html', {onComplete:function(){
  		
  		
				  			switch (lang) {
						 		case "en":	langhilight("lang02");
	 										break;
 								case "fr":	langhilight("lang03");
				 							break;
						 		default:	langhilight("lang01");
 											break;
							}

  		
  		
							}, asynchronous:true});
							break;
	}	
	} else {
		init('solotrapez();');
	}

	}
	
}

showintroteaser  = function(div, src){
	if(div == "teaser01"){
		Element.setStyle('introwrapper', {backgroundPosition:"-250px -100px"} ); 
	} else {
		Element.setStyle('introwrapper', {backgroundPosition:"50px 0px"} ); 
	}
	$(div+"png").src = src;
	Element.setStyle(div, {visibility : 'visible'});
}

hideintroteaser  = function(div, src){
	$(div+"png").src = src;
	Element.setStyle(div, {visibility : 'hidden'}); 

}

solotrapez = function(){

	if(focus == 1){
	
		new Effect.Fade('content', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content', 'content/solotrapez/index/index-'+lang+'.html', {onComplete:function(){
		new Effect.Appear("content");
		urchinTracker("/solotrapez-"+lang);
		}, asynchronous:true});
		} });
	} else {
		new Effect.SlideDown('header', {queue: 'end', afterFinish: function(){
		new Effect.Fade('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content', 'content/solotrapez/index/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("contentrap"); 
		urchinTracker("/solotrapez-"+lang);
		}, asynchronous:true});
		}});
		}});
	}
	menuhilight('mainmenu01');
	switchbg('#520030 url(images/css-bg-star-purple-patina.jpg) top center no-repeat','wrapper');

	focus = 1;
	window.location.hash = "solotrapez";
}


solotrapez_gallery = function(){
	new Effect.Fade('content', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('content', 'content/solotrapez/gallery/index-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("content"); dockInit();
	urchinTracker("/solotrapez/gallery-"+lang);
	}, asynchronous:true});
	}});
	menuhilight('mainmenu01');
	focus = 1;
	window.location.hash = "solotrapez,gallery";

}

solotrapez_buehne = function(){
	new Effect.Fade('content', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('content', 'content/solotrapez/index/buehne-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("content"); dockInit();
	urchinTracker("/solotrapez/buehne-"+lang);
	}, asynchronous:true});
	}});
	menuhilight('mainmenu01');
	focus = 1;
	window.location.hash = "solotrapez,buehne";

}

solotrapez_video = function(){
	new Effect.Fade('content', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('content', 'content/solotrapez/video/index-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("content"); 
	urchinTracker("/solotrapez/video-"+lang);
	}, asynchronous:true});
	}});
	menuhilight('mainmenu01');
	focus = 1;
	window.location.hash = "solotrapez,video";
}


duotrapez = function(){

	if(focus == 1){
		new Effect.Fade('content', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content', 'content/duotrapez/index/index-'+lang+'.html', {onComplete:function(){
		new Effect.Appear("content");
		urchinTracker("/duotrapez-"+lang);
 		}, asynchronous:true});
		}});
	} else {
		new Effect.SlideDown('header');
		new Effect.Fade('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content', 'content/duotrapez/index/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("contentrap"); 
		urchinTracker("/duotrapez-"+lang);
		}, asynchronous:true});
		}});
	}
	menuhilight('mainmenu02');
	switchbg('#5E003C url(images/css-bg-star-circle-patina.jpg) top center no-repeat','wrapper');
	focus = 1;
	window.location.hash = "duotrapez";
}


duotrapez_gallery = function(){
	new Effect.Fade('content', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('content', 'content/duotrapez/gallery/index-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("content"); dockInit();
	urchinTracker("/duotrapez/gallery-"+lang);
	}, asynchronous:true});
	}});
	menuhilight('mainmenu02');
	focus = 1;
	window.location.hash = "duotrapez,gallery";
}


duotrapez_video = function(){
	new Effect.Fade('content', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('content', 'content/duotrapez/video/index-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("content"); 
	urchinTracker("/duotrapez/video-"+lang);
	}, asynchronous:true});
	}});
	menuhilight('mainmenu02');
	focus = 1;
	window.location.hash = "duotrapez,video";
}

duotrapez_detail = function(){
	new Effect.Fade('text', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('text', 'content/duotrapez/index/lang-'+lang+'.html', {onComplete:function(){
	if($('text').runtimeStyle){
		$('text').runtimeStyle.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100, finishopacity=0, style=1, startx=0, starty=60, finishx=0,finishy=200)";
	}
	new Effect.Appear("text"); 
	urchinTracker("/duotrapez/detail-"+lang);
	}, asynchronous:true});
	}});
	window.location.hash = "duotrapez,detail";
}

duotrapez_buehne = function(){
	new Effect.Fade('text', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('text', 'content/duotrapez/index/buehne-'+lang+'.html', {onComplete:function(){
	if($('text').runtimeStyle){
		$('text').runtimeStyle.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100, finishopacity=0, style=1, startx=0, starty=60, finishx=0,finishy=200)";
	}
	new Effect.Appear("text");
	urchinTracker("/duotrapez/buehne-"+lang); 
	}, asynchronous:true});
	}});
	window.location.hash = "duotrapez,buehne";
}





vitanavi = function(index){
	article = index;
	for(var i=1; i<5; i++){
		if(i == index){
			Element.setStyle('navi0'+i, {visibility : 'visible'});
			$('tom0'+i).src='content/vita/tom_0'+i+'_color.png';
		} else {
			Element.setStyle('navi0'+i, {visibility : 'hidden'});
			$('tom0'+i).src='content/vita/tom_0'+i+'_sw.png';
		}
	}
	new Effect.Fade('vitacontent', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('vitacontent', 'content/vita/text0'+index+'-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("vitacontent"); 
	urchinTracker("/vita/"+ article + "-" + lang);
	}, asynchronous:true});
	}});
	window.location.hash = "vita,"+index;
}

vita = function(){
	if(focus == 1){
		new Effect.SlideUp('header', {queue: 'end', afterFinish: function(){
		new Effect.SlideUp('contentrap', {queue: 'end', afterFinish: function(){
		new Effect.Appear("content2", {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/vita/index-'+lang+'.html', {onComplete:function(){
		vitanavi(article);
		}});
		}, asynchronous:true});
		}});
		}});
	} else {
		new Effect.SlideUp('content2', {queue: 'end', afterFinish: function(){
		new Effect.SlideDown("content2", {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/vita/index-'+lang+'.html', {onComplete:function(){
		vitanavi(article);
		}});
		}, asynchronous:true});
		}});
	}
	menuhilight('metamenu01');
	focus = 2;
}


kontakt = function(sub){
	if(!sub){ sub = "formular"; }
	if(focus == 1){
		new Effect.SlideUp('header');
		new Effect.SlideUp('contentrap', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/kontakt/index-'+lang+'.html', {onComplete:function(){
		new Ajax.Updater('kontaktcontent', 'content/kontakt/'+sub+'-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/kontakt/"+sub+"-"+lang);
		}, asynchronous:true});
		}});
		}});
	} else {
		new Effect.SlideUp('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/kontakt/index-'+lang+'.html', {onComplete:function(){
		new Ajax.Updater('kontaktcontent', 'content/kontakt/'+sub+'-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/kontakt/"+sub+"-"+lang);
		}, asynchronous:true});
		}});
		}});
	}
	menuhilight('metamenu02');
	focus = 2;
	window.location.hash = "kontakt,"+sub;
}


kurse = function(sub){
	if(focus == 1){
		new Effect.SlideUp('header');
		new Effect.SlideUp('contentrap', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/kurse/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/kurse-"+lang);
		}, asynchronous:true});
		}});
	} else {
		new Effect.SlideUp('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/kurse/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/kurse-"+lang);
		}, asynchronous:true});
		}});
	}
	menuhilight('metamenu04');
	focus = 2;
	window.location.hash = "kurse";
}


linkpage = function(){
	if(focus == 1){
		new Effect.SlideUp('header');
		new Effect.SlideUp('contentrap', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/links/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/links-"+lang);
		}, asynchronous:true});
		}});
	} else {
		new Effect.SlideUp('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/links/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/links-"+lang);
		}, asynchronous:true});
		}});
	}
	menuhilight('metamenu05');
	focus = 2;
	window.location.hash = "links";
}

trapezbau = function(){

	if(focus == 1){
		new Effect.SlideUp('header');
		new Effect.SlideUp('contentrap', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/trapezbau/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/trapezbau-"+lang);
		}, asynchronous:true});
		}});
	} else {
		new Effect.SlideUp('content2', {queue: 'end', afterFinish: function(){
		new Ajax.Updater('content2', 'content/trapezbau/index-'+lang+'.html', {onComplete:function(){
		new Effect.SlideDown("content2"); 
		urchinTracker("/trapezbau-"+lang);
		}, asynchronous:true});
		}});
	}
	focus = 2;
	menuhilight('metamenu03');
	switchbg('#0D1F51 url(content/trapezbau/ringe-bg.jpg) top center no-repeat','wrapper2');
	window.location.hash = "trapezbau";
}


bestellung = function(){
	new Effect.Fade('trapezcontent', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('trapezcontent', 'content/trapezbau/bestellung-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("trapezcontent"); 
	urchinTracker("/bestellung-"+lang);
	}, asynchronous:true});
	}});
	window.location.hash = "trapezbau,bestellung";
}

anschrift = function(){
	new Effect.Fade('kontaktcontent', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('kontaktcontent', 'content/kontakt/anschrift-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("kontaktcontent"); 
	urchinTracker("/anschrift-"+lang);
	}, asynchronous:true});
	}});
	window.location.hash = "kontakt,anschrift";	
}

impressum = function(){
	new Effect.Fade('kontaktcontent', {queue: 'end', afterFinish: function(){
	new Ajax.Updater('kontaktcontent', 'content/kontakt/impressum-'+lang+'.html', {onComplete:function(){
	new Effect.Appear("kontaktcontent"); 
	urchinTracker("/impressum-"+lang);
	}, asynchronous:true});
	}});
	window.location.hash = "kontakt,impressum";	
}




menuhilight = function(which){
	menus = ['mainmenu01','mainmenu02','metamenu01','metamenu02','metamenu03','metamenu04','metamenu05'];
	for(var i=0; i<menus.length; i++){
		if(which == menus[i]){
			Element.addClassName(menus[i], 'active');
		} else {
			Element.removeClassName(menus[i], 'active');
		}
	}


}

langhilight = function(which){
	menus = ['lang01','lang02','lang03'];
	for(var i=0; i<menus.length; i++){
		if(which == menus[i]){
			Element.addClassName(menus[i], 'active');
		} else {
			Element.removeClassName(menus[i], 'active');
		}
	}


}

switchbg = function(bg, div) {
		Element.setStyle(div, {background: bg} ); 
}


sende_kontakt = function() {
  var url = 'kontakt-form.php';
  var myAjax = new Ajax.Request(
    url, {
      method: 'post',
      postBody: Form.serialize(document.forms['kontaktform']),
      onSuccess: function(){ new Ajax.Updater('kontaktcontent', 'content/kontakt/gesendet-'+lang+'.html')},
      onFailure:  function(){ new Ajax.Updater('kontaktcontent', 'content/kontakt/fehler-'+lang+'.html')}
    }
  );
}

sende_bestellung = function() {
  var url = 'bestell-form.php';
  var myAjax = new Ajax.Request(
    url, {
      method: 'post',
      postBody: Form.serialize(document.forms['bestellform']),
      onSuccess: function(){ 	new Ajax.Updater('trapezcontent', 'content/trapezbau/gesendet-'+lang+'.html');
							window.scrollTo(0, 0)
	 },
      onFailure:  function(){ new Ajax.Updater('trapezcontent', 'content/trapezbau/fehler-'+lang+'.html')}
    }
  );
}

var focus = 0;
var article = 0;
var lang = "de";

var languageinfo=navigator.language? navigator.language : navigator.userLanguage;
switch (languageinfo.substr(0,2)) {
 		case "de":	lang = "de";
					break;
 		case "fr":	lang = "fr";
					break;
		default:	lang = "en";
					break;

}


