// JavaScript Document

jQuery.extend( jQuery.easing,
{
	easeStage: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	}
});

$(document).ready(function() {
	$("#menu").dropMenu();	
	$('#searchcriteria').focus(function() {
		if (this.value==this.defaultValue) this.value='';
	}).blur(function() {
		if (this.value=='') this.value=this.defaultValue;
	});
	$("a[rel=fancytableimage]").each(function(i){
		if ($(this).children().attr("alt")!=''){
			$(this).attr({'title': $(this).children().attr("alt")});
		}
	});
	$("a[rel=fancyimage]").fancybox({		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
			'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	
	$("a[rel=fancytableimage]").fancybox({		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
			'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	
   	$(".iframe").fancybox({
		'width' : '95%',
		'height' : '95%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'type' : 'iframe'
   	}); 
	
	$('.navbox>ul>li').each(function() {
		$(this).hover(function() {
			$(this).children('ul').eq(0).css({'width':0}).show().stop().animate({'width': 180},{duration: 200, easing:'easeStage'});
		}, function() {
			$(this).children('ul').eq(0).stop().animate({'width': 0},{duration: 100, easing:'easeStage', complete: function() {$(this).hide();}});
		});
	});

});


