﻿// JavaScript Document
var currentBox = 0;
var newBox = 0;
var flash;

$(function() {	
	flash = document.getElementById('intro');

	$('.box_description:not(#box_description_'+currentBox+')').hide();
	
	$(document).keydown(function(e) {
		if (typeof flash.switchToId == 'function') {
			if (e.keyCode == 39)
				flash.switchNextBox();
			else if (e.keyCode == 37)
				flash.switchBackBox();
		}
	});
});

function switchToId(id) {
	clickedOnId(id);
	if (typeof flash.switchToId == 'function')
		flash.switchToId(id);
}

// Auf Box geklickt
function clickedOnId(id) {
	if (id == newBox)
		return false;
	
	newBox = id;
	var minHeight = $('#box_description_' + currentBox).height();
	$('div.container.right_large').css('min-height', minHeight+'px');
	$('#box_description_' + currentBox).fadeOut('slow', function() {
		$('#box_description_' + newBox).fadeIn('slow');
		var minHeight = $('#box_description_' + newBox).height();
		$('div.container.right_large').css('min-height', minHeight+'px');
		currentBox = newBox;
	});
	
	return true;
}
