// JavaScript Document

            $(function() {
                $(window).scroll(function(){
					var scrollTop = $(window).scrollTop();
					if(scrollTop != 0)
						$('#main').stop().animate({'opacity':'0.2'},400);
					else
						$('#main').stop().animate({'opacity':'1'},400);
				});

				$('#main').hover(
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('#main').stop().animate({'opacity':'1'},400);
						}
					},
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('#main').stop().animate({'opacity':'0.2'},400);
						}
					}
				);
            });

            $(function() {
                $(window).scroll(function(){
					var scrollTop = $(window).scrollTop();
					if(scrollTop != 0)
						$('#footer').stop().animate({'opacity':'0.2'},400);
					else
						$('#footer').stop().animate({'opacity':'0.9'},400);
				});

				$('#footer').hover(
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('#footer').stop().animate({'opacity':'0.9'},400);
						}
					},
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('#footer').stop().animate({'opacity':'0.2'},400);
						}
					}
				);
            });

		//when the dom is ready...
		window.addEvent('domready',function() {
			//a few settings
			var labelColor = '#999', restingPosition = 5;
			//for every form field
			$$('form#info .slider label').each(function(label){
				//set the label enhancements into place
				label.setStyles({
					color: labelColor,
					position: 'absolute',
					top: 6,
					left: restingPosition,
					display: 'inline',
					'z-index': 99
				});
				//get input value
				var input = label.getNext('input');
				//grab label width, add resting position value
				var width = label.getSize().x;
				var move = width + restingPosition;
				//onload, check if a field is filled out, if so, move the label out of the way
				if(input.get('value') !== '') {
					label.tween('left',0 - move);
				}
				// if the input is empty on focus move the label to the left
				// if it's empty on blur, move it back
				input.addEvents({
					focus: function() {
						if(input.get('value') == '') {
							label.tween('left',0 - move);
						}
						else {
							label.setStyle('left',0 - move);
						}
					},
					blur: function() {
						if(input.get('value') == ''){
							label.tween('left',restingPosition);
						}
					}
				});
			});
		});
function countdown(time,id){

  //time brauchen wir später noch
  t = time;

  //Tage berechnen
  d = Math.floor(t/(60*60*24)) % 24;

  // Stunden berechnen
  h = Math.floor(t/(60*60)) % 24;


  // Minuten berechnen
  // Sekunden durch 60 ergibt Minuten
  // Minuten gehen von 0-59
  //also Modulo 60 rechnen
  m = Math.floor(t/60) %60;

  // Sekunden berechnen
  s = t %60;

  //Zeiten formatieren
  d = (d >  0) ? d+"d ":"";
  h = (h < 10) ? "0"+h : h;
  m = (m < 10) ? "0"+m : m;
  s = (s < 10) ? "0"+s : s;

  // Ausgabestring generieren
  strZeit =d + h + ":" + m + ":" + s;




  // Falls der Countdown noch nicht zurückgezählt ist
  if(time > 0)
  {
    //Countdown-Funktion erneut aufrufen
    //diesmal mit einer Sekunde weniger
    window.setTimeout('countdown('+ --time+',\''+id+'\')',1000);
  }
  else
  {
    //führe eine funktion aus oder refresh die seite
    //dieser Teil hier wird genau einmal ausgeführt und zwar
    //wenn die Zeit um ist.
    strZeit = "loginzeit abgelaufen";
  }
  // Ausgabestring in Tag mit id="id" schreiben
  document.getElementById(id).innerHTML = strZeit;
}
//Helfer Funktion erlaubt Counter auch ohne Timestamp
//countdown2(Tage,Stunden,Minuten,Sekunden,ID)
function countdown2(d,h,m,s,id)
{
  countdown(d*60*60*24+h*60*60+m*60+s,id);
}


// TOOLTIP AK
function popload(id) {
	document.getElementById(id).style.visibility = 'visible';
}

function popunload(id) {
	document.getElementById(id).style.visibility = 'hidden';
}
// DRAG N DROP
$(document).ready(
	function(){
	$('.icons').sortable({
		'connectWith':['.icons']
	});


});

// DATEPICKER 1
$(function() {
		$('#datepicker').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker2').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker2').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker3').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker3').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker4').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker4').datepicker('option', {dateFormat: 'd.m.yy'});
		$('#datepicker5').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker5').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker6').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker6').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker7').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker7').datepicker('option', {dateFormat: 'd.m.yy'});

		$('#datepicker8').datepicker({
			numberOfMonths: 3,
			showButtonPanel: true,

		});
		$('#datepicker8').datepicker('option', {dateFormat: 'd.m.yy'});

});

// AUFKLAPPEN
function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
  } else {
    e.style.display="none"
  }
  return true;
}
// AUSBLENDEN
$(document).ready(function(){
						   $(".latest_img").fadeTo("slow", 0.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
						   $(".latest_img").hover(function(){
						   $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
						   },function(){
						   $(this).fadeTo("slow", 0.0); // This should set the opacity back to 30% on mouseout
						   });
						   });
$(document).ready(function(){
        //  Focus auto-focus fields
        $('.auto-focus:first').focus();

    });

/*BBCODE*/
$(function(){
				$('textarea[name=inhalt]').bbcodeeditor(
				{
					bold:$('.bold'),vorschlag:$('.vorschlag'),italic:$('.italic'),underline:$('.underline'),link:$('.link'),quote:$('.quote'),code:$('.code'),image:$('.image'),
					usize:$('.usize'),dsize:$('.dsize'),nlist:$('.nlist'),blist:$('.blist'),litem:$('.litem'),
					back:$('.back'),forward:$('.forward'),back_disable:'btn back_disable',forward_disable:'btn forward_disable',
					exit_warning:false,preview:$('.preview')
				});
			});
startList = function() {
if (document.all&&document.getElementByName) {
navRoot = document.getElementByName("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;


