// JavaScript Document

var fadingTimer;
var moving = false;
var replaceTimer;



function move_div(side) {
	if(!moving) {
		moving = true; 
		if (side == 'left') {
			movingTimer = move_left();
		} else if (side == 'right') {
			document.getElementById('programmSliderMiddle').style.width = '564px';
			movingTimer = move_right();
		}
	}
}

function move_left() {
	var targetDiv = document.getElementById('programmSliderLeft');
	var middleDiv = document.getElementById('programmSliderMiddle');
	if (parseInt(targetDiv.style.marginLeft) < 0) {
		targetDiv.style.marginLeft = parseInt(targetDiv.style.marginLeft) + 6 + 'px';
		movingTimer = window.setTimeout("move_left()", 1);
		return;
	}
	window.clearTimeout(movingTimer);
	targetDiv.style.marginLeft = '0px';
	targetDiv.style.width = '700px';
	middleDiv.style.width = '564px';
	document.getElementById('slider').removeChild(document.getElementById('programmSliderRight'));
	middleDiv.id = 'programmSliderRight';
	targetDiv.id = 'programmSliderMiddle';
	moving = false;
}

function move_right() {
	var targetDiv = document.getElementById('programmSliderRight');
	var middleDiv = document.getElementById('programmSliderMiddle');
	if (parseInt(middleDiv.style.marginLeft) > -564) {
		middleDiv.style.marginLeft = parseInt(middleDiv.style.marginLeft) - 6 + 'px';
		//targetDiv.style.marginRight = parseInt(targetDiv.style.marginRight) - 8 + 'px';
		movingTimer = window.setTimeout("move_right()", 1);	
		return;
	}
	window.clearTimeout(movingTimer);
	middleDiv.style.marginLeft = '-564px';
	targetDiv.style.width = '700px';
	document.getElementById('slider').removeChild(document.getElementById('programmSliderLeft'));
	middleDiv.id = 'programmSliderLeft';
	targetDiv.id = 'programmSliderMiddle';
	
	moving = false;
	return;
}


function display_login() {
	var login = document.getElementById('login');
	if (login.style.display == 'block') {
		login.style.display = 'none';
	} else {
		login.style.display = 'block';
	}
}

function display_guestform() {
	var guestform = document.getElementById('guestform');
	if (guestform.style.display == 'block') {
		guestform.style.display = 'none';
	} else {
		guestform.style.display = 'block';
	}
}

var RecaptchaOptions = {
    theme : 'white',
	lang : 'de'
};

var activeSpotlightId = 0;
var spotlightData = new Array();

function change_spotlight() {
	id = activeSpotlightId+1;
	var button = document.getElementById('spotlight_button_'+id);
	if (button != null) {
		load_spotlight(id, true);
	} else {
		load_spotlight(0, true);
	}
}

function load_spotlight(id, automatic) {
	if (id != activeSpotlightId) {
		var button = dojo.query('#spotlight_button_'+activeSpotlightId)[0];
		var spotlight = dojo.query('#spotlight_'+activeSpotlightId)[0];
		var text = dojo.query('#spotlight_text_'+activeSpotlightId)[0];
		
		button.src = 'images/empty_circle.jpg';
		dojo.style(text, 'display', 'none');
		dojo.style(spotlight, "display", 'none');
				
		button = dojo.query('#spotlight_button_'+id)[0];
		spotlight = dojo.query('#spotlight_'+id)[0];
		text = dojo.query('#spotlight_text_'+id)[0];
		
		button.src = 'images/filled_circle.jpg';
		dojo.style(text, "display", 'inline');
		dojo.style(spotlight, "display", 'block');
				
		activeSpotlightId = id;
		
	}
	if (automatic != true) {
		window.clearInterval(spotlightTimer);	
	}
	return;
}

function display_months(target) {
	var monthSelect = document.getElementById('programmMonth');
	if (target.value == 'fullList') {
		monthSelect.style.display = 'none';
	} else {
		monthSelect.style.display = 'inline';		
	}
}

window.onclick = function (ev) {
	if (ev.target.className == 'styleBox') {
		ev.target.previousSibling.checked = !ev.target.previousSibling.checked;
	}
}


