
function threadOverview() {
	if ($('#new-post').html()!=null) {
		$('#content').append('<h3>Übersicht des Beitrages</h3><div id="thread" style="font-size:1em;margin:1.5em 12em 0 1.8em;padding:0 1em 1em;height:300px;overflow-y:scroll;border:1px solid #ccc;background:#f6f6f6"></div>');
		url = window.location.pathname;
		url = url.replace(/\/newPost/g,'');
		loadThreadContent(url);
	}
}

function loadThreadContent(url) {
	$.get(url,{},function(data) {
		data = $(data).find('#content');
		$(data).find('h2,h3,p.link:last,p.anwaelte').remove();
		$(data).find('*').css('margin-left','0');
		$(data).find('*').css('margin-right','0');
		$('#thread').html($(data).html());
		$('#thread #seiten a').click(function() {
			loadThreadContent($(this).attr('href'));
			$('#thread').scroll(0,0);
			return false;
		});
		anwaltKontakt();
	});
}

function anwaltKontakt() {
	$.each($('.posts li.anwalt .kontaktdaten'),function(key,obj) {
		$(obj).after('<p class="kontaktdaten-link"><a href="#">Kontaktdaten anzeigen</a></p>');
		$(obj).hide();
	});
	$.each($('.posts li.anwalt .kontaktdaten-link a'),function(key,obj) {
		$(obj).toggle(function() {
			$(obj).parent().parent().find('.kontaktdaten').show();
			$(this).html('Kontaktdaten verbergen');
			return false;
		}, function() {
			$(obj).parent().parent().find('.kontaktdaten').hide();
			$(this).html('Kontaktdaten anzeigen');
			return false;
		});
	});
}

$(document).ready(function() {
	threadOverview();
	anwaltKontakt();
});

// DOM ready
$(document).ready(function() {
	$("#ort").suggest("/plugins/anwaltsuche-ajax.php?land=D", { });
	// header bild
	rand = parseInt(Math.random()*(3)+1);
	$('#header form').css('background','transparent url(/images/layout/header-bild-'+rand+'.jpg) top left no-repeat');
});

// Document full loaded
$(window).load(function() {
	if ($('#content').height()<$('#navigation').height())
		$('#content').height($('#navigation').height()+20);
});

// IE 6 and below
/////////////////
/*@cc_on
	@if (@_jscript_version < 5.7)
		
		$(document).ready(function() {
			// max-width
			if ($('#container').width()/16 > 54)
				$('#container').css('width','54em');
			// min-width
			if ($('#container').width()/16 < 33)
				$('#container').css('width','33em');
			// abbr
			$.each($('abbr'), function(key,obj) {
				$(this).after('<acronym class="abbr">'+$(this).html()+'</acronym>');
				$(this).remove();
			});
			// table row hover
			$('tr').hover(function() { $(this).toggleClass('hover'); }, function() { $(this).toggleClass('hover'); });
		});
		
	@end
@*/