window.addEvent('domready', function ()
{
	/*--------------working with menu-----------------*/
	$$('div.menuitem a').each(function(item,index)
	{
		item.onmouseover = function (e)
		{
			this.parentNode.style.backgroundImage ="url('/assets/templates/gasthof/images/menu.gif')";
			l=$(this.parentNode).getChildren('.left')[0];
			r=$(this.parentNode).getChildren('.right')[0];

			l.style.display = 'block';
			r.style.display = 'block';
		}
		item.onmouseout = function (e)
		{
			this.parentNode.style.backgroundImage ="none";
			l=$(this.parentNode).getChildren('.left')[0];
			r=$(this.parentNode).getChildren('.right')[0];

			l.style.display = 'none';
			r.style.display = 'none';
		}

	});
	
	$$('div.menuitem').each(function(item,index)
	{
		width = item.getChildren('a')[0].offsetWidth+28;
		item.style.width = width+"px";
	});
	/*--------------/working with menu-----------------*/
	/*---------------------collage----------------------*/
	var szNormal = 245, szSmall  = 167, szFull   = 480;
 
		var kwicks = $$("#kwicks .kwick");
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 600, transition: Fx.Transitions.Expo.easeOut});
		kwicks.each(function(kwick, i) {
			kwick.addEvent("mouseenter", function(event) {
				var o = {};
				o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != szSmall) o[j] = {width: [w, szSmall]};
					}
				});
				fx.start(o);
			});
		});
		 
		$("kwicks").addEvent("mouseleave", function(event) {
			var o = {};
			kwicks.each(function(kwick, i) {
				o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
			});
			fx.start(o);
		})
	/*---------------------collage----------------------*/
	
	/*---------------------list: onmouseover----------------------*/
		
		$$(".cleft .list").each(function(item,index)
		{
 
			item.addEvent("mouseenter", function(e){
				
				e.stop();
			 var myEffects = new Fx.Morph(item, {duration: 200, transition: Fx.Transitions.Sine.easeOut});
				myEffects.start( ".hoveredlist", {duration: 200, transition: Fx.Transitions.Sine.easeOut});
				
			 var myTween = new Fx.Tween(item.getChildren(".bullet")[0],{duration: 200, transition: Fx.Transitions.Sine.easeOut});
			 	myTween.start("left","5px");
			 		
			});
			 
			item.addEvent("mouseleave", function(e){
				
				e.stop();
			 var myEffects = new Fx.Morph(item, {duration: 200, transition: Fx.Transitions.Sine.easeOut});
				myEffects.start( ".list", {duration: 200, transition: Fx.Transitions.Sine.easeOut});
			 var myTween = new Fx.Tween(item.getChildren(".bullet")[0],{duration: 200, transition: Fx.Transitions.Sine.easeOut});
				myTween.start("left","15px");	
			});
		});
		
	/*---------------------/list: onmouseiver---------------------*/
	
	//********************************MainPageShowGallery******************************************
	$('collage').addEvent("mouseenter", function(e){
	
		e.stop();
	
		/*$('zurgal').style.visibility = 'visible';
		$('zurgal').fade(1);*/
		var myFx = new Fx.Tween($('zurgal'), {duration: 300});
		myFx.start("opacity" , 1);

	});
	
	$('collage').addEvent("mouseleave", function(e){
	
		e.stop();
	
		/*$('zurgal').style.visibility = 'visible';
		$('zurgal').fade(1);*/
		var myFx = new Fx.Tween($('zurgal'), {duration: 300});
		myFx.start("opacity" , 0);

	});
	/*----------------------------------Start settings----------------------------------*/
	var myFx = new Fx.Tween($('zurgal'), {duration: 1, onComplete: function(){$('zurgal').style.visibility = 'visible';}});
		myFx.start("opacity" , 0);
	/*---------------------------------/Start settings----------------------------------*/	

	/*----------------------------------LANG CLICKS----------------------------------*/
	$('ade').onclick = function(e)
	{
		$('inputlang').value = 'de';
		$('formlang').submit();
	}
	$('aen').onclick = function (e)
	{
		$('inputlang').value = 'en';
		$('formlang').submit();
	}
	$('acz').onclick = function (e)
	{
		$('inputlang').value = 'cz';
		$('formlang').submit();
	}
	$('aru').onclick = function (e)
	{
		$('inputlang').value = 'ru';
		$('formlang').submit();
	}
	/*---------------------------------/LANG CLICKS----------------------------------*/
	
	/*----------------------------------FORM----------------------------------*/
	if($("sbmt")!=null)
	{
		$("sbmt").onclick = function (e)
		{
			if(document.forms['meldung'].elements['nachname'].value==''){alert(document.forms['meldung'].elements['nachnamemsg'].value); return;}
			if(document.forms['meldung'].elements['email'].value==''){alert(document.forms['meldung'].elements['emailmsg'].value); return;}
			document.forms['meldung'].submit();
		}
	}	
	/*---------------------------------/FORM----------------------------------*/
});
