
function loadForm( sSubject ) {
	window.location.href = "/kontakt.html"
		+ "?subject=" + escape(sSubject)
		+ "&body=" + escape("Bitte senden Sie mir weitere Informationen zum oben genannten Kurs.") 
		+ "&" + SESSION_PARAM + "=" + SESSION_ID;
}

var nFlashCounter = 3;
var oNewsflashTimer = null;
var nCurrentNewsflash = 0;

function switchNewsflash( oEvent ) {
	if( oNewsflashTimer != null ) {
		oNewsflashTimer.stop();
		oNewsflashTimer = null;
	}
	
	var oSource = Event.element(oEvent);
	var nDestination = -1;
	if( oSource.identify() == "nb0" ) {
		nDestination = 0;
	}
	if( oSource.identify() == "nb1" ) {
		nDestination = 1;
	}
	if( oSource.identify() == "nb2" ) {
		nDestination = 2;
	}
	var x = nDestination * -698;
	new Effect.Move("nfcontainer", { "x": x, "y": 0, "mode": "absolute"});
	
	$("nb" + nCurrentNewsflash).removeClassName("activenb").addClassName("inactivenb");
	$("nb" + nDestination).removeClassName("inactivenb").addClassName("activenb");
	nCurrentNewsflash = nDestination;
}

function autoswitchNewsflash( oTimer ) {
	var nDestination = nCurrentNewsflash + 1;
	if( nDestination == nFlashCounter ) {
		nDestination = 0;
	}
	
	var x = nDestination * -698;
	new Effect.Move("nfcontainer", { "x": x, "y": 0, "mode": "absolute"});
	
	$("nb" + nCurrentNewsflash).removeClassName("activenb").addClassName("inactivenb");
	$("nb" + nDestination).removeClassName("inactivenb").addClassName("activenb");
	nCurrentNewsflash = nDestination;
}

function activateNewsflash() {
	if( $("nb0") == null ) return;
	$("nb0").observe("click", switchNewsflash);
	$("nb1").observe("click", switchNewsflash);
	$("nb2").observe("click", switchNewsflash);
	
	oNewsflashTimer = new PeriodicalExecuter(autoswitchNewsflash, 7);
}

function enableSC() {
	new Ajax.Request("/ajax_helper.php"
		+ "?" + SESSION_PARAM + "=" + SESSION_ID
		+ "&ts=" + (new Date()).getTime()
		, {
			"parameters": {
				"action":	"SET_VALUE"
				, "key":	"fbenabled"
				, "value":	1
			}
			, "onSuccess": function() {
				if( window.location.search.indexOf(SESSION_ID) != -1 ) {
					window.location.reload();
				}
				else {
					window.location.href = "/?" + SESSION_PARAM + "=" + SESSION_ID;
				}
			}
		});
}

