px = {}

px.slide = function(dest)
{
    var dest = $(dest).offset().top - 45;
    $(this).show(1, function()
    {
		$('html:not(:animated),body:not(:animated)').animate({ scrollTop: dest}, 'slow', 'swing' );
	});
};

px.drucken = function ()
{
	$('.drucken').unbind('click').click(function()
	{
		window.print();
		return false;
	});
}

px.hilfe = {}

px.hilfe.show = function (id)
{
	if ($('.' + 'thema-' + id).hasClass('hilfe_open'))
	{
		$('.hilfe_open').slideUp('slow').removeClass('hilfe_open');
		$('html, body').animate({scrollTop:0}, 'slow');
	} else
	{
		$('.hilfe_open').slideUp('slow').removeClass('hilfe_open');
		$.post('/hilfe-ajax.html', { post_titel: id }, function(html)
		{
			if (html) {
				$('.' + 'thema-' + id).html(html).slideDown('slow', function()
				{
					px.slide(this);
					$(this).addClass('hilfe_open');
					var height = $(document).height();
					if(height*1.10 > screen.height)
					{
						$('.top').slideDown('slow');
					}
					$('.bottom').slideDown('slow');
	 			});
				px.drucken();
				px.hilfe.hide();
			} else {
				return true;
			}
		},'html');
	}
}

px.hilfe.hide = function ()
{
	$('.einklappen').unbind('click').click(function()
	{
		var href = $(this).attr('href');
		href = href.substring(13,href.length-5);
		
		$('html, body').animate({scrollTop:0}, 'slow');
		$('.' + 'thema-' + href).slideUp('slow', function()
		{
				var height = $(document).height();
				if(height*1.10 < screen.height)
				{
					$('.top').hide('slow');
				}
 			});
		return false;
	});
}

$(document).ready(function()
{

	$('.mehr_info').click(function() {
		$('#summary').toggle('fast');
		$('html, body').animate({scrollTop:0}, 'slow');
		$('#body').slideToggle('slow');
		$(this).toggleClass('mehr_info_zu');
		return false;
	});

	$('.hilfe_detail').unbind('click').click(function()
	{
		var href = $(this).attr('href');
		href = href.substring(13,href.length-5);
		
		px.hilfe.show(href);
		$(this).prev('.ar').toggleClass('ad');
		return false;
	});

	$('input').change(function()
	{
		$(this).css('background-color', '#fff');
	});

	$('textarea').change(function()
	{
		$(this).css('background-color', '#fff');
	});
	
	$('#file_delete_img').click(function()
	{
		var img = $('#file_upload_img').attr("src");
		$.post('/uploadify/uploadify.php', { del_img: img }, function(html)
		{
			$("#file_upload_img").hide('slow');
			$("#file_delete_img").hide();
			return false;
		},'html');
		return false;
	});
});
