/*
 Transporter – Visuelle Logistik, www.transporter.at, 2011
 Rainer Fabrizi
 */

/* !softscroll
 ****************************************************/
$(function() {
	var softscroll = $("a.softscroll");
	softscroll.click(function(event) {
		event.preventDefault();
		var href = $(this).attr("href");
		$('html,body').animate({
			scrollTop : $(href).offset().top
		}, {
			duration : 500,
			easing : 'easeInOutExpo'
		});
	});
});
/* !Simplest jQuery slideshow by Jonathan Snook
 ****************************************************/
if($('.slides img').length > 0) {
	function slidetext() {
		var slidetext = $('.slides :first-child').attr('data-text');
		$('.slidetext').html(slidetext);
		if(slidetext.length != 0) {
			$('.slidetext').show();
		} else {
			$('.slidetext').hide();
		}
	}

	$(function() {
		slidetext();
		setInterval(function() {
			$('.slides :first-child').fadeOut(1000).next('img').fadeIn(1000).end().appendTo('.slides');
			slidetext();
		}, 8000);
		// 1000 = 1 sec
	});
}

/* !wetter bunt und hell
 ****************************************************/
$(function() {
	$(".aktuelleswetter a").hover(function(event) {
		$("#wetterhell").hide();
		$("#wetterbunt").show();
	}, function(event) {
		$("#wetterhell").show();
		$("#wetterbunt").hide();
	});
});
/* !suchfocus und suchblur
 ****************************************************/
$(function() {
	var en = 0;
	var suchfeld = $("input.suchfeld");
	suchfeld.focus(function(event) {
		var myvalue = $(this).attr("value");
		if(myvalue == "Finden...") {
			$(this).val("");
		}
		if(myvalue == "Find...") {
			$(this).val("");
			en = 1;
		}
	});
	suchfeld.blur(function(event) {
		var myvalue = $(this).attr("value");
		if(myvalue == "") {
			if(en != 1) {
				$(this).val("Finden...");
			} else {
				$(this).val("Find...");
			}
		}
	});
});

/* !datepicker initialisierung
 ****************************************************/
$(function() {

	// Datepicker
	$('#datepicker').datepicker({
		inline : true
	});

	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(function() {
		$(this).addClass('ui-state-hover');
	}, function() {
		$(this).removeClass('ui-state-hover');
	});
});
/* !öffnet und schliesst #space
 ****************************************************/
var sV = 0;
var sitemap = $("p.sitemap a");
$(function() {
	sitemap.click(function(event) {
		if(sV == 0) {
			$('#space').show().animate({
				height : '600px'
			}, {
				duration : 500,
				easing : 'easeOutExpo'
			});
			sV = 1;
		} else if(sV == 1) {
			$('#space').animate({
				height : '0'
			}, {
				duration : 500,
				easing : 'easeOutExpo'
			}).hide();
			sV = 0;
		}
		event.preventDefault();
		$('html,body').animate({
			scrollTop : $('#alles').offset().top
		}, {
			duration : 500,
			easing : 'easeInOutExpo'
		});
	});
});

