/* Mailmask */
function noSpam(){if(document.getElementById){var at="@";var links=document.getElementsByTagName('a');for(var i=0;i<links.length;i++){var linkElem=links[i];if(linkElem.className=='escape'){var mail=linkElem.firstChild;var domain=linkElem.lastChild;mail.nextSibling.firstChild.innerHTML=at;linkElem.href="mailto:"+mail.data+at+domain.data;}}}}

(function ($, window, document, undefined) {
	
	$(document).ready(function(){
		noSpam();
		
		if($("a[rel=fancybox]").length > 0){
			$("a[rel=fancybox]").fancybox({titlePosition:'over'});
		}
		
		// prevent nav bug in IE: if hover over title, subnavi loses focus. so removing the title for IE is the solution
		if ($.browser.msie){
			$("#navigation a").removeAttr("title");
		}
		
		//$('#navigation li ul').css({ opacity: 0 });
		$('#navigation li ul').css({ display: "none" });
		
		var topval = $('#navigation li ul').css("top");
		var duration = 500;
		
		$('#navigation li').hover(
			function(e){
				if ( $.browser.msie && $.browser.version == "8.0" ){
					$('ul', this).css({ display: "block" });
				}else{
					$('ul', this).css({ opacity: 0 , display: "block", top: "0px" }).stop().animate({ opacity: 1, top: topval }, duration);
				}
				//$('ul', this).stop().fadeIn(duration);
			},
			function(e){
				if ( $.browser.msie && $.browser.version == "8.0" ){
					$('ul', this).css({ display: "none" });
				}else{
					$('ul', this).css({ opacity: 1 }).stop().animate({ opacity: 0, top: parseInt(topval, 10) * 2 + "px" }, duration, 'swing', function(){$(this).css({ display: "none" });});
				}
				//$('ul', this).stop().fadeOut(duration);
			}
		);
		
		if($('#contactform').length > 0){
			if($("body").hasClass('de')){
				$.ketchup.messages({
					required	:	'Dieses Feld ist erforderlich',
					email		:	'Eine gültige E-Mail Adresse eintragen' //Muss eine gültige E-Mail-Adresse sein.
				});
			}else{
				$.ketchup.messages({
					required	:	'This field is mandatory',
					email		:	'Enter valid e-mail address'
				});
			}
			$('#contactform').ketchup({}, {
			  '.required'	: ['required', 'keyup'],
			  '.mail'		: ['email', 'keyup focus']
			});
		}
	});

})(jQuery, window, document);
