
$.noConflict();
jQuery(document).ready(function($)
{
	/* globals */
	var msie = $.browser.msie;
	
	/* menue */
	if(msie) {
		$('#menu li').hover(function(){ $(this).find("ul").css("display", "block");
		}, function(){ $(this).find("ul").css("display", "none"); });
	}
	/* menue ende */
	
	
	/* filter fn’s */
	$('#Form_filter_Jahr').change(function() {
		$('#Form_filter').submit();
	});
	
	/* filter fn’s end*/
	
	$(".central-container-small, .central-container-big").hover(function(){
		$(this).addClass("central-container-hover");
		$(this).find(".mehr").css("background", textColor);
	}, function(){
		$(this).removeClass("central-container-hover");
		$(this).find(".mehr").css("background", hoverColor);
	});
	
	$(".central-container-small, .central-container-big").click(function(){
		if($(this).find(".mehr").length > 0){
			var url = $(this).find(".mehr").attr("href");
			window.location.href = url;
		}
	});

	
	$("#searchbox a").click(function(){
		$(this).css("display","none");
		$("#searchform").css("display","inline");
		$("#searchfield").focus();
		return false;
	});
	
	$("#searchfield").blur(function(){
		setTimeout(function(){
			$("#searchform").css("display","none");
			$("#searchbox a").css("display","inline"); 
		}, 200);
	});
	
	var inputVal = "";
	$("form ul input, form ul textarea").focus(function(){
		inputVal = $(this).attr("value");
		$(this).attr("value","");
	});
	
	$("form ul input, form ul textarea").blur(function(){
		if($(this).attr("value") == "") $(this).attr("value",inputVal);
		inputVal = "";
	});
	
	var inputVals = [];
	$(function(){
		$("form ul input").each(function(){
			inputVals.push( $(this).attr("value") );
		})
	});
	
	$("#Form_ContactForm_action_SendContactForm").click(function(){
		
		var isError = false;
		
		$("form ul input").each(function(index){ 
			if( $(this).hasClass("form-error") ) $(this).removeClass("form-error");
			var value = $(this).attr("value");
			if( value == "" || value == inputVals[index] ){ $(this).addClass("form-error"); isError = true; }
		});
		
		if($("#Form_ContactForm_Email").length > 0 && $("#Form_ContactForm_Email2").length > 0 ){
			var e1 = $("#Form_ContactForm_Email");
			var e2 = $("#Form_ContactForm_Email2");
			if( e1.attr("value").search('@') == -1){ e1.addClass("form-error"); isError = true; }
			if( e1.attr("value").search('.') == -1){ e1.addClass("form-error"); isError = true; }
			if( e2.attr("value").search('@') == -1){ e2.addClass("form-error"); isError = true; }
			if( e2.attr("value").search('.') == -1){ e2.addClass("form-error"); isError = true; }
			if( e1.attr("value") != e2.attr("value") ){ e2.addClass("form-error"); isError = true; }
		}
		else if($("#Form_ContactForm_Email").length > 0) {
			var e1 = $("#Form_ContactForm_Email");
			if( e1.attr("value").search('@') == -1){ e1.addClass("form-error"); isError = true; }
			if( e1.attr("value").search('.') == -1){ e1.addClass("form-error"); isError = true; }
		}
		
		
		
		if(isError == true) return false;
	});
	
	if($.browser.msie) /* some rude fixes for our best friend */
	{
		/* cufon pullldown problem fix */
		$('<div id="ie-menue-fixer"></div>').insertAfter("#menue"); /* ie-menue-fixer @ navbar.css */
		$("#menue").css("position", "absolute");
		$("#menue").css("z-index", "9999");

		/* .mehr pointer fix */
		$(".mehr").each(function(){
			var elWidth = $(this).width();
			$(this).css("width", elWidth+"px");
			if($.browser.version == 8.0){
				$(this).css("padding", "0 7px 3px");
				$(this).css("line-height", "1.8em");
			}else{
				$(this).css("padding", "0 7px");
			}
			$(this).css("display", "block");
		})
	}

	/* fago-reg, fago-med hover */
	$('a.fago-reg, a.fago-med').hover(function(){
		$(this).addClass("fago-hover");
		$(this).css("color", hoverColor);
		Cufon.refresh();
	}, function(){
		$(this).removeClass("fago-hover");
		if(!$(this).hasClass("section") && !$(this).hasClass("current")) $(this).css("color", textColor);
		Cufon.refresh();
	});
	
	$('a.fago-45-reg, a.fago-45-med').hover(function(){
		$(this).addClass("fago-45-hover");
		$(this).css("color", hover45Color);
		Cufon.refresh();
	}, function(){
		$(this).removeClass("fago-45-hover");
		if(!$(this).hasClass("section") && !$(this).hasClass("current")) $(this).css("color", textColor);
		Cufon.refresh();
	});
	
	var lessBlackSRC = _THEMEDIR + 'images/bb-mehr.gif';
	var mehrBlackSRC = _THEMEDIR + 'images/bb-mehr-black.gif';
	
	$(".cbm45").hover(function(){
		$(this).find(".mehr").addClass("mehr-black-hover");
		$(this).find(".mehr img").attr("src", lessBlackSRC);
		Cufon.refresh();
	}, function(){
		$(this).find(".mehr").removeClass("mehr-black-hover");
		$(this).find(".mehr img").attr("src", mehrBlackSRC);
		Cufon.refresh();
	});
});
