document.write('<script type="text/javascript" src="/js/jquery.cycle.min.js"></script>');
document.write('<script type="text/javascript" src="/js/jquery.prettyphoto.js"></script>');

function pop(obj, width, height, scrolling)
{ 
	var x=(screen.width-width)/2; 
	var y=(screen.height-height)/2;
	if (scrolling) {
		scrollbars = "yes";
	} else {
		scrollbars = "no";
	}
	popUpWindow = window.open(obj.href, "", "width="+width+",height="+height+",resizable=no,scrollbars="+scrollbars+",screenX="+x+",screenY="+y+",left="+x+",top="+y);
	popUpWindow.focus();
	return false;
};

$(document).ready(function() {

	$('input.text, textarea.text').each(function() {
		$(this).focus(function() {
			$(this).addClass('focused');
			$(this).removeClass('error');
			$(this).prevAll('label').addClass('focused');
			$(this).prevAll('label.error').removeClass('error');
			if ($(this).val().substr(0,1) == '<') {
				$(this).data('valueOld', $(this).val());
				$(this).val('');
			}			
		});
		$(this).blur(function() {
			$(this).removeClass('focused');
			$(this).prevAll('label').removeClass('focused');
			if ($(this).val() == '') {
				$(this).val($(this).data('valueOld'));
			}
		});
	});
	
	$('div.expandable h2, div.expandable a.mark').live('click', function() {
		if ($(this).parent().hasClass('hidden')) {
			$(this).parent().removeClass('hidden');
			$(this).parent().addClass('shown');
		}

		$(this).nextAll('div.expanded').slideToggle('fast', function() {
			if ($(this).css('display') != 'block') {
			$(this).parent().removeClass('shown');
			$(this).parent().addClass('hidden');
			}
		});
		
		return false;
	});	
	
	$('div.textbox:last').css('margin-right', '0');
	$('div.textbox').css('width', '156px');
	$('div.expandable h2').css('cursor', 'pointer');
	$('div.expandable').each(function() {
		$(this).children('p').first().after('<a href="#" class="mark">mehr</a>');
	});
	$('div.expandable div.expanded').hide();
	$('div.expandable').addClass('hidden');

	
	$('#slideshow').show();
    $('#slide-images').cycle({
		fx: 'fade',
		random: 1,
		pause: 1,
		timeout: 4000,
		next: '#slide-next', 
		prev: '#slide-prev'
	});	
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	flowplayer("a.flowplayer", "/flowplayer/flowplayer-3.2.7.swf", {
		clip: {
			autoPlay: false, 
			autoBuffering: false 
		}
	});
	$('table.dates tbody th.title').click(function() {
		$('table.dates tbody div#date-desc-'+($(this).attr('id'))).slideToggle('fast');
	});
	$('table.dates tbody div.date-desc').hide();
	
});
