$(document).ready(function() {

	/* Guestbook load */
	$('#guestbook').load('list.php');
	
	/* Single Image -  Fancybox */
	
	$("a#single_image").fancybox();
	
	/* Inline content - Fancybox */
	
	$("a.inline").fancybox({
		'hideOnContentClick': false
	});

	/* Group Images - Fancybox */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});

	/* Ajax send request - Guestbook */
	$(".form").submit(function(){
	
	var str = $(this).serialize();
	
	$.ajax({
		type: "POST",
		url: "send.php",
		data: str,
		success: function(msg){
	
		$("#descr").ajaxComplete(function(event, request, settings){
	
		if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
			{
				result = '<div class="notification_ok">Deine Nachricht wurde gesendet. Danke!</div>';
				$("#comments").fadeOut('slow');
				$('#guestbook').load('list.php').fadeIn("slow");
			}
			else
			{
				result = msg;
			}
	
			$(this).html(result);
	
		});
	
		}
	
	});
	
	return false;
	
	});

	$("#login_form").bind("submit", function() {
	
		if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
		    $("#login_error").show();
		    $.fancybox.resize();
		    return false;
		}
	
		$.fancybox.showActivity();
	
		$.ajax({
			type		: "POST",
			cache	: false,
			url		: "login.php",
			data		: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data);
			}
		});
		return false;
	});	

			$(function() {
			$(".delete_button").click(function() {
			var id = $(this).attr("id");
			var dataString = 'id='+ id ;
			var parent = $(this).parent();
			
			$.ajax({
			type: "POST",
			url: "delete.php",
			data: dataString,
			cache: false,
			
			success: function()
			{
			if(id % 2)
			{
			parent.fadeOut('slow', function() {$(this).remove();});
			}
			else
			{
			parent.slideUp('slow', function() {$(this).remove();});
			}
			}
			});
			
			return false;
			});
			});

});

/* Disable right click */
$(document).bind("contextmenu",function(e){
	return false;
});

