$(document).ready(function() {
	$('input[type="text"],input[type="password"],textarea').bind('focus', function() {
		if(!$(this).attr('rel') && $(this).attr('rel')!="") {
			$(this).attr('rel',$(this).val());
		}
		if($(this).attr('rel')==$(this).val()) {		   
		   $(this).val('');
		}
	});
	$('input[type="text"],input[type="password"],textarea').bind('blur', function() {
		if($(this).val()=="") {
			$(this).val($(this).attr('rel'));
		}
	});
});

$(document).ready(function() {
	$("#kontakt_form").submit(function(e){
		e.preventDefault();
		$.ajax({
			type: 'POST',
			data: $(this).serialize(),
			url: webpath+$(this).attr('action'),
			success: function(text){
				$('#kontakt_log').fadeTo(1000,0,function() {
					$('#kontakt_log').html(text).fadeTo(500,1);
				});
			}
		});
	});
});

$(document).ready(function() {
	$('#register_form').submit(function(e){
		var status;
		var thisform = $(this);
		$.ajax({
			type: 'POST',
			async: false,
			data: $(this).serialize(),
			url: webpath+"requests/chk_registrierung.php",
			dataType: 'json',
			success: function(echo){
				status = echo.status;
				thisform.find(".ajax-message").html(echo.message);
			}
		});
		if(status==1) {
			e.preventDefault();
			$.ajax({
				type: 'POST',
				data: $(this).serialize(),
				url: $(this).attr('action'),
				success: function(text){
					thisform.delay(2000).fadeTo(1000,0,function() {
						thisform.html(text).fadeTo(500,1);
					});
				}
			});
		}
		else {return false;}
	});
});

$(document).ready(function() {
	$('#eiswein-gallery').galleryView({
		panel_width: 850,
		panel_height: 475,
		frame_width: 100,
		frame_height: 100
	});
});

$(document).ready(function() {
	$('.lightbox-gallery a').lightBox();
});
