$(document).ready(function() {
	$('.expand').live('click',function() {
		$(this).parent().next('.expand_container').slideToggle('slow',function() {
			if(lng==1) {
				// de
				if($(this).css('display')=='block') {
					$(this).prev('p').children('.expand').children('a').html('schlie&szlig;en');
				}	else {
					$(this).prev('p').children('.expand').children('a').html('ausklappen');
				}
			} else {
				//en
				if($(this).css('display')=='block') {
					$(this).prev('p').children('.expand').children('a').html('close');
				}	else {
					$(this).prev('p').children('.expand').children('a').html('expand');
				}
			}
		});
		
	});
	
	$('.galexpand').live('click',function() {
		$(this).parent().prev('.expand_container').slideToggle('slow',function() {
			if(lng==1) {
				// de
				if($(this).css('display')=='block') {
					$(this).next('p').children('.galexpand').children('a').html('schlie&szlig;en');
				}	else {
					$(this).next('p').children('.galexpand').children('a').html('ausklappen');
				}
			} else {
				//en
				if($(this).css('display')=='block') {
					$(this).next('p').children('.galexpand').children('a').html('close');
				}	else {
					$(this).next('p').children('.galexpand').children('a').html('expand');
				}
			}
		});
		
	});
	
	 $('div.gal div.galimage a,div.gal a.galthumb').fancybox({
	 	'titlePosition':'over',
	 	'transitionIn':'elastic',
	 	'transitionOut':'elastic',
	 	'easingIn':'easeOutBack',
	 	'easingOut': 'easeInBack',
	 	'opacity':true
	 });
	 
	 $('a.iframe').fancybox({
	 	'titlePosition':'over',
	 	'transitionIn':'elastic',
	 	'transitionOut':'elastic',
	 	'easingIn':'easeOutBack',
	 	'easingOut': 'easeInBack',
	 	'opacity':true,
	 	'width':'600',
	 	'height':'300'
	 });
	 
	 $('div#slider').slideshow({'sleep':6000});
	 
	 var form = false;
	 $('form#contact_email').submit(function(ev) {	 		
	 		if(form==false) {

	 			$('div#messages').empty();
		 		form=true;
		 		$.post($(this).attr('action'), { "name": $('input[name=name]').val(), 'email': $('input[name=email]').val(), 'to':$('select[name=to]').val(),'subject':$('input[name=subject]').val(),'message':$('textarea[name=message]').val(),'copy':$('input:checkbox[name=copy]:checked').val() },
		 	function(data){
	
	 				switch(data.type) {
	 					case 'ERROR':	$('<div class="error"><p>'+data.msg+'</p></div>').appendTo('div#messages').hide().fadeIn('fast');
	 									break;
	 					case 'SUCCESS':	$('<div class="success"><p>'+data.msg+'</p></div>').appendTo('div#messages').hide().fadeIn('fast');
	 									break;
	 				}	

   					form=false;
	   				}, "json");
   			}   		
	 ev.preventDefault();
	 });
});

