jQuery.noConflict();

jQuery(document).ready(function($){
	

	/*
	 * -- Galerie
	 */
	
	$(".gallery-small").each(function(){
		var gallery = this;
		$(this).find(".thumbs a").mouseover(function() {
			$(gallery).find(".first").css("visibility","hidden");
			$(gallery).find(".pic").append('<img src="'+$(this).attr("rel")+'" class="preview" />');
			$(gallery).find(".preview").css({
				"position":"absolute",
				"top":"0px",
				"left":"0px",
				"border":"0px solid #000",
				"zIndex":"100"
			});
		});
		$(this).find(".thumbs a").mouseout(function() {
			$(gallery).find(".first").css("visibility","visible");
			$(gallery).find(".preview").remove();
		});
	});
	
	
	
	/*
	 * -- CONTACT
	 */
	
	$("#contact").submit(function(e) {
		if(checkFormular(this)) return;
		else e.preventDefault();
	});
});

/*
 * -- Labels in Inputs anzeigen
 */
function labelit() {
	$ = jQuery;
	
	$("input.labelit, textarea.labelit").each(function(){
		
		/*
		 * --	Label Inhalt in Inputs schreiben
		 */
		$(this).parents("form").find("label[for="+$(this).attr("id")+"]").hide();
		if( $(this).val()=="" ) $(this).val($(this).parents("form").find("label[for="+$(this).attr("id")+"]").text());
		
		/*
		 * --	Focus Event
		 */
		$(this).focus(function(e){
			$(this).css("color","");
			if( $(this).parents("form").find("label[for="+$(this).attr("id")+"]").text() == $(this).val() ) {
				$(this).val("");
			}
		});
		$(this).blur(function(e) {
			if( $(this).val()=="" ) {
				$(this).val($(this).parents("form").find("label[for="+$(this).attr("id")+"]").text());
			}
		});
	});
}

/*
 * -- Check Formular
 */
function checkFormular(form) {
	var $ = jQuery;
	var error = false;
	$(form).find(".error").removeClass("error");
	$(form).find(".check-filled").each(function() {
		if($(this).val()=="") {
			error = true;
			$(this).addClass("error");
		}
		if($(this).hasClass("labelit")) {
			if($(this).val() == $(this).parents("form").find("label[for="+$(this).attr("id")+"]").text()) {
				error = true;
				$(this).addClass("error");
			}
		}
	});
	$(form).find(".check-email").each(function() {
		if($(this).val().indexOf("@")==-1) {
			error = true;
			$(this).addClass("error");
		}
		if($(this).hasClass("labelit")) {
			if($(this).val() == $(this).parents("form").find("label[for="+$(this).attr("id")+"]").text()) {
				error = true;
				$(this).addClass("error");
			}
		}
	});
	if(error) return false;
	else return true;
}
