$(document).ready(function(){
	$("#contact-form").submit(function() {
		var bAllValid = true;
		$("input.required").each(function() {
			if(this.value == "") {
				bAllValid = false;
				$(this).addClass("invalid");				
				$("label[for='" + this.id + "']").each(function() {
					$(this).addClass("invalid");
				});
			} else {
				$(this).removeClass("invalid");				
				$("label[for='" + this.id + "']").each(function() {
					$(this).removeClass("invalid");
				});
			}
		});
		
		$("select.required").each(function(sValue, oElement) {
			if(this.value == 0) {
				bAllValid = false;
				$(this).addClass("invalid");				
				$("label[for='" + this.id + "']").each(function() {
					$(this).addClass("invalid");
				});
			} else {
				$(this).removeClass("invalid");				
				$("label[for='" + this.id + "']").each(function() {
					$(this).removeClass("invalid");
				});
			}
		});
		
		if(bAllValid == false) {
			$("#form-validation-error").addClass("show");
		} else {
			$("#form-validation-error").removeClass("show");
		}
		
		return bAllValid;
	});

	var SLABELS 		= new Array('Search for...', 'Suche nach...');
	var SLABELORIG	= $('#generic-search-input').attr('value');
	var SLABELGOOD	= (SLABELORIG == SLABELS[0] || SLABELORIG == SLABELS[1])? true : false;

	$('#generic-search-input').focus(function(){
		$(this).addClass('focus');
		if ($(this).attr('value') == SLABELORIG && SLABELGOOD){
			$(this).attr('value', '');
		}
	});
	
	$('#generic-search-input').blur(function(){
		$(this).removeClass('focus');
		if (!$(this).attr('value')) {
			$(this).attr('value', SLABELORIG);
		}
	});
});