var scrollit;

$().ready(function() {
	if (screen.height - 200 > $(".page").height()) {
		$(".page").height(screen.height - 200);
	}

	$(".searchinput").focus(function() {
		if ($(this).val() == "Suche") {
			$(this).val("");
		}
	});
	$(".searchinput").blur(function() {
		if ($(this).val() == "") {
			$(this).val("Suche");
		}
	});
	if ($(".moving").length > 0) {
		$(window).scroll(function() {
			window.clearTimeout(scrollit);
			scrollit = setTimeout("moveStoerer()", 100);
		});
	}
	if ($(".piccaption").length > 0) {
		$(".piccaption p").each(function() {
			if ($(this).text() == "") {
				$(this).parent().hide();
			}
		});
	}
	if ($(".quotescroller").length > 0) {
		$(".quotescroller li").click(function(){
			var ele = $(this);
			$(".active").animate({
				'width': '50px'
				}, 150, function(){
					$(".active").removeClass("active");
				}
			);
			$(ele).animate({
				'width': '149px'
				}, 150, function(){
					$(ele).addClass("active");
				}
			);
			$(".qo").slideUp(200, function(){
				$("."+$(ele).attr("rel")).slideDown(200);
			});
			$(".quotepointer").animate({
				'background-position': "-"+$(ele).attr("alt")+"px 0"
			}, 150);
		});
	}
	if($(".tooltip").length > 0) {
		$(".tooltip").hover(function(){
			var p = $(this);
			var position = p.position();
			$('<div class="showtooltip" style="left: '+(position.left+20)+'px; top: '+(position.top+15)+'px">'+$(this).attr("rel")+'</div>').appendTo($(this).parent());
		},function(){
			$(".showtooltip").remove();
		});
	}
	if($(".videolayer").length > 0) {
		$(".videolayer").click(function(){
			$(window).scrollTop("0px");
			var youtubeid = $(this).attr("rel");
			$(".video_inner").html('<object width="600" height="395"><param name="movie" value="http://www.youtube.com/v/'+youtubeid+'&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+youtubeid+'&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="395"></embed></object>');
			$("#overlay").css("display", "block");
			return false;
		});
		$("#closeVideo").click(function(){
			$(".video_inner").html('');
			$("#overlay").css("display", "none");
			return false;
		});
	}
});

function moveStoerer() {
	$(".moving").animate( {
		top : $(window).scrollTop() + "px"
	}, 500);
}
