// init page
Event.observe(window, 'load', function() {
	init_slider();
});

// init form submit button
/*
function init_formSubmit()
{
	$$('form').each(function(form){
		if(form.down('.gui-submit'))form.down('.gui-submit').insert({
  			before: "<div class=\"button\"><div class=\"button-left\"></div>",
  			after: "<div class=\"button-right\"></div><div class=\"clearfix\"></div></div>"
		}).setStyle({
  			visibility: 'visible'
  		});
	})
}
*/

// SecNav Mouse Over
function showPrimeNav(element){
    element.className += "hover";
}
function hidePrimeNav(element){
   element.className = element.className = "";
}
var i = 0;
//	Home HV slider
function init_slider()
{
	var hvZone = $$('.headervisual')[0];
	if(!hvZone)
	{
		return;
	}
	else
	{
		//hvZone.down(0).down('img').setStyle({display: 'block'});
		hvZone.down(0).down('img').toggleClassName('active-slider');
		
		var childDIVs = hvZone.childElements();
		var nr = childDIVs.length;
		
		setInterval(function(){sliderClassToggle(childDIVs, nr);}.bind(i), 5000);

	}
}
function sliderClassToggle(childDIVs, nr)
{
	i++;
	var j = i - 1;
	if(i == nr)
	{
		i = 0;
		j = nr - 1;
	}
	
	childDIVs[j].down('img').toggleClassName('active-slider');
	childDIVs[i].down('img').toggleClassName('active-slider');
	//childDIVs[j].down('div').slideDown({ duration: 3.0});
	//childDIVs[i].down('div').slideUp({ duration: 3.0});
}

//countdown
function runCountdown() {
	if(!document.getElementById('countdown-block')) return;
	
	var eventdate = new Date(2011, 4-1, 29, 23, 59, 59);	//Jahr, Monat, Tag, Stunden, Minuten, Sekunden
	var now =new Date();
	count=Math.floor((eventdate.getTime()-now.getTime())/1000);
	count=Math.floor(count/(60*60*24));	// days
	var day = count > 1 ? " Tage" : " Tag";
	document.getElementById('countdown-block').innerHTML = count;
	document.getElementById('countdown-days').innerHTML = day;
	if(count < 1)
		document.getElementById('countdown-end').innerHTML = "Heute, um 19 Uhr";
	

    window.setTimeout("runCountdown()", 1000);
}

//window.onload=function(){runCountdown();}//call when everything has loaded
