$(document).ready(function() {

	$('.tool2').mouseenter(function(){
		$('#tool2').css('display','block');
		$(this).css("z-index",100);
	}).mouseleave(function(){
		$('#tool2').css('display','none');
		$(this).css('z-index',1);
	});
	
	$('.tool3').mouseenter(function(){
		$('#tool3').css('display','block');
		$(this).css("z-index",100);
	}).mouseleave(function(){
		$('#tool3').css('display','none');
		$(this).css('z-index',1);
	});
	
	$('.tool4').mouseenter(function(){
		$('#tool4').css('display','block');
		$(this).css("z-index",100);
	}).mouseleave(function(){
		$('#tool4').css('display','none');
		$(this).css('z-index',1);
	});
	
	$('.tool5').mouseenter(function(){
		$('#tool5').css('display','block');
		$(this).css("z-index",100);
	}).mouseleave(function(){
		$('#tool5').css('display','none');
		$(this).css('z-index',1);
	});
	
	$('.tool6').mouseenter(function(){
		$('#tool6').css('display','block');
		$(this).css("z-index",100);
	}).mouseleave(function(){
		$('#tool6').css('display','none');
		$(this).css('z-index',1);
	});


	function cback() {
		this.after("<div id='cbox' />");
		$("#cbox")
		.text('Callback fired!')
		.addClass('red')
		.fadeIn(100)
		.fadeOut(1500);
	}

	$("select").not("#test").change(function() {
		binder();
	});

	function binder() {
		var opts = {};
		$("select").not("#test").each(function() {
			if ($(this).attr("id") != 'event' && $(this).attr("id") != 'layout') {
				opts[$(this).attr("id")] = eval($(this).val());
			}
			else {
				opts[$(this).attr("id")] = $(this).val();
			}
		});
		//console.log(opts);
		$("#clockpick1").unbind().unbind( "keydown" ).clockpick(opts);

		opts.valuefield = 'timefield1';
		$("#clockpick2").unbind().clockpick(opts, cback);

		opts.valuefield = 'timefield2';
		opts.useBgiframe = true;
		$("#clockpick3").unbind().clockpick(opts, cback);
	}

	binder();

});


$(document).ready(function(){
	$(".clockpick1").clockpick();
	$("#fieldformBuilderFieldclockpick1").clockpick(); });

function rotateNews(){
	//alert(nli);
	//alert($('div.featured ul').children('li'));
	//alert($('div.featured ul').children('li')[nli].nodeName);
	$('ul#slider li:visible').fadeOut();
	$($('ul#slider').children('li')[nli]).fadeIn('slow',function(){
		$('div#controls a').removeClass('on');
		$($('div#controls ul li.article').children('a')[nli]).addClass('on');
		nli++;
		var nlis = nli + '';
		if(nlis.length<2)nlis='0'+nlis;
		//$('div.fimagebgbott .cwd').html(nlis);
		if (nli==$('ul#slider').children('li').length) nli=0;
	});
}

var nli=1;


$(document).ready(function(){


	setTimeout(function(){

		if(document.getElementById('slider')){
			var rn = setInterval(rotateNews,7000);
			$('ul#slider').css({position:'relative',height:'320px'});
			$('ul#slider li').css({position:'absolute',left:'0px',top:'0px'});
		}




		$('div#controls li.article a').click(function(){
			clearInterval(rn);
			nli = $('ul#slider li').index($(this.hash));
			rotateNews();
			return false;
		});

		$('div#controls .next').click(function(){
			clearInterval(rn);
			//nli++;
			//if (nli==$('div.featured ul').children('li').length) nli=0;
			rotateNews();
			return false;
		});

		$('div#controls .back').click(function(){
			clearInterval(rn);
			if (nli==0){
				nli=$('ul#slider').children('li').length-2;
			}
			else{
				nli=nli-2;
			}
			if (nli<0)nli=$('ul#slider').children('li').length-1;
			rotateNews();
			return false;
		});
	},50);
});


$(document).ready(function(){

    $("li a#telefon").hover(
      function () {
        $("#text1").show();
      },
      function () {
        $("#text1").hide()
      }
    );


	$("li a#offnungszeiten").hover(
      function () {
        $("#text2").show();
      },
      function () {
        $("#text2").hide()
      }
    );

	$("li a#anfahrt").hover(
      function () {
        $("#text3").show();
      },
      function () {
        $("#text3").hide()
      }
    );

$("#text1").hover(
      function () {
		$("#text1").show();
		$("a#telefon").addClass("hover");
      },
      function () {
		$("#text1").hide();
		$("a#telefon").removeClass("hover");
      }
    );

	$("#text2").hover(
      function () {
		$("#text2").show();
		$("a#offnungszeiten").addClass("hover");
      },
      function () {
		$("#text2").hide();
		$("a#offnungszeiten").removeClass("hover");
      }
    );

	$("#text3").hover(
      function () {
		$("#text3").show();
		$("a#anfahrt").addClass("hover");
      },
      function () {
		$("#text3").hide();
		$("a#anfahrt").removeClass("hover");
      }
    );

  });


 $(function() { $(".datepicker").datepicker();});
