jQuery(function($) {
	
	//contact form 
	var $line = $("#linie");
	var $route = $("#linienrichtung");

	if($line.length > 0 && $route.length > 0 ){
		var $routeOptions = $route.data('options', $("option[title]", $route));
		
		$route.attr('disabled', true);

		$line
			.bind('change click', function (){

				var $activeLineId = $('option:selected', $line).attr('title');
				var $routeText = "Bitte Richtung auswählen";

				$route
					.attr('disabled', false); 

				$("option[title]", $route)
					.remove();

				$routeOptions.data('options')
					.each(function() {
							var $this = $(this);
							if ($this.attr('title') == $activeLineId) {
								$route.append($this);
							}
							if ($activeLineId == "bus"){
								$routeText = "Keine Auswahl benötigt";
								$route
									.attr('disabled', true); 
							}
							if ($activeLineId.length == 0){
								$routeText = "Bitte Linie auswählen";
								$route
									.attr('disabled', true); 
							}
						}
					);

				$("option[value='none']", $route)
					.text($routeText);
			});
	}
	
	//contact form tooltip
	$(".tooltip").tooltip({
		cssClass: "tooltip-box",
		delay : 0,
		duration : 100,
		xOffset : 15,
		yOffset : 15,
		opacity : 0, 
		fadeDuration: 400 
	});


});