
$(document).ready(function(){
	$("#contact-btn").click(showContactForm); 
	$(".contact-btn").click(showContactForm);
	
	moveZackenBG();
	$(window).resize(moveZackenBG);
	
	
	$("a.colorbox").colorbox();

	
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));
		}

		$(this).focus(function() {
			if($(this).val() === $(this).attr('title')) {
				$(this).val('');
			}
		});

		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title'));
			}
		});
	});

	if (document.location.hash.indexOf("usermessage")!=-1)
	{
		$('#contactFormContainer').css({
			right: -628,
			top: -628
		});
		
		$('#contactForm').css({
			opacity: 1
		});
	}
	
	
	if ($('#usermessagea').html().indexOf('Danke') != -1) 
	{
		$('#contactFormContainer').delay(1500).animate({
			right: -1257,
			top: -1257,
			opacity: 0
		}, 600, 'easeOutBack');
	}
	
	$('.maillink').attr('title', '');
	

}); 

function moveZackenBG()
{
    $("body").css({"background-position" : $(window).width()-628 + "px -628px" });
}

function showContactForm()
{ 
	$('#contactFormContainer').animate({
		right: -628,
		top: -628
	}, 600, 'easeOutBack');
	
	$('#contactForm').animate({
		opacity: 1
	}, 1000);
	
	return false;
}

function hideContactForm()
{
	$('#contactFormContainer').animate({
		right: -1257,
		top: -1257
	}, 600, 'easeOutCirc');
	
	/*
	$("#messageSent").show("slow");
	setTimeout('$("#messageSent").hide(); $("#contactForm").slideUp("slow")', 2000);
	*/
}




function UnCryptMailto( s )
{
    var n = 0;
    var r = "";
    for( var i = 0; i < s.length; i++)
    {
        n = s.charCodeAt( i );
        if( n >= 8364 )
        {
            n = 128;
        }
        r += String.fromCharCode( n - 1 );
    }
    return r;
}

function linkTo_UnCryptMailto( s )
{
    location.href=UnCryptMailto( s );
}





