window.addEvent('domready',function(){

	/*
	var browser=navigator.appName;
	if(browser=='Netscape') { document.body.addEvent('contextmenu',function(e) { e.stop(); }); }
	*/
	
	var coolNavi=false;
	if(Browser.Engine.gecko || Browser.Engine.webkit || Browser.Engine.presto){ var coolNavi=true; document.body.addEvent('contextmenu',function(e) { e.stop(); }); }
	if(Browser.Engine.trident) { if(Browser.Engine.version>=5){ coolNavi=true; } }
	
	var linkIt = function() { window.location.href = this.href }
	
	var fadeEl = $$('.fadeElements');
	fadeEl.each(function(item, index){
		item.setStyle('opacity','0');
		item.set('tween',{ duration: 1000, transition: Fx.Transitions.Sine.easeIn, link: 'chain'});
		item.tween('opacity',1);
	});
	
	var siteOpacityOut = new Fx.Tween($('sitecontent'), {
		property: 'opacity',
		duration: 1000,
		transition: Fx.Transitions.Sine.easeOut,
		link: 'cancel'
	});
	
	var menubaritem = $('site').getElementById('menu');
	if(menubaritem){
	$("menu").getElements("a").each(function(item,index) {
		item.setStyle('color','#666666');
		if(item.match('.act')){ item.setStyle('color','#ffffff'); }
		item.addEvents({
			"mouseenter": function() {
				if(!item.match('.act')){
					item.set('tween', {'duration': '160'});
					item.tween('color','#ffffff');
				}
			},
			"mouseleave": function() {
				if(!item.match('.act')){
					item.set('tween', {'duration': '500'});
					item.tween('color','#666666');
				}
			},
			"click": function(e) {
				siteOpacityOut.removeEvents();
				siteOpacityOut.addEvent('onComplete', linkIt.bind(this));
				siteOpacityOut.start(1,0);
				fadeEl.each(function(item, index){
					item.set('tween',{ duration: 1000, transition: Fx.Transitions.Sine.easeOut, link: 'cancel'});
					item.tween('opacity',0);
				});
				e.stop();
			}
		});
	});
	}

/*
	// UPDATE slideshow mim AJAX
	$("menu").getElements("a").each(function(item,index) {
		if(item.getProperty("href").contains("index.php?page=artwork_")) {
			if($("SuperBox")) {
				item.removeEvents("click");
				item.addEvents({
					"click": function(e) {
						var jsFile = "js/album_"+item.getProperty("href").substr(23)+".js";
						new Request({
							url: jsFile,
							evalResponse: true,
							onComplete: function(rText,rXml) {
								var dataAlbumConfig = JSON.decode(JSONdataAlbumConfig);
								dataAlbum.empty();
								dataAlbum = JSON.decode(JSONdataAlbum);
								var imageUrls = new Array();
								var thumbUrls = new Array();

								for(var i = 0; i<dataAlbum.length; i++){
									imageUrls.push(dataAlbum[i].FileName);
									thumbUrls.push(dataAlbum[i].ThumbFileName);
								}
								slideShow.update(imageUrls,thumbUrls,0);
							}
						}).send();
						$("menu").getElement("a.act").removeClass("act").setStyle("color","#666666");
						item.addClass("act").setStyle("color","#ffffff");
						if(this.getParent("li").getParent("li")) {
							this.getParent("li").getParent("li").fireEvent("mouseleave");
						}
						else {
							this.getParent("li").fireEvent("mouseleave");
						}
						$("bcrumb").getLast("a").get("tween").start("opacity",0).chain(function() {
							$("bcrumb").getLast("a").setProperty("href",item.getProperty("href")).set("text",item.get("text")).get("tween").start("opacity",0,1);
						});

						e.stop();
					}
				});
			}
		}
	});
*/
	
	if(coolNavi && menubaritem) {
		$("menu").getElement("ul").getChildren("li").each(function(item,index) {
			var ul = item.getFirst("ul");
			ul.setStyles({
				"opacity": 0
			});
			item.setStyles({
				'background-image':'url(img/bg.gif)',
				'background-position':'top center',
				'background-color':'#000000'
			});
			ul.set("tween",{ property: "opacity", link: "cancel" });
			item.set("tween", { property: "background-color", link: "cancel" });
			item.addEvents({
				"mouseenter": function() {
					ul.addClass("moo");
					item.get("tween").start("#191919").chain(function() {
						ul.get("tween").start(1);
					}.bind(null,ul));
				}.bind(null,ul),
				"mouseleave": function() {
					item.get("tween").start("#000000");
					ul.get("tween").start(0).chain(function() {
						ul.removeClass("moo");
					}.bind(null,ul)); // laft net weil es css vorher schun visibility: hidden mocht
				}.bind(null,ul)
			});
		});
	}
});
