
$(document).ready(function() {
	$("div.person").each(function() {
		var  $cl = $(".column-left", this)
			,$cr = $(".column-right", this)
			,clh = $cl.height()
			,crh = $cr.height()
		;

		if (clh > crh) {
			$cr.css({ 'padding-top': clh - crh + 'px' });
		}
	});


	$(window).resize(function() {
		$("div.line").remove();

		var  $line = $("<div>").addClass('line')
			,body = { width: $("body").width(), height: $("body").height() }
		;


		var  $mainMenu = $("ul.main-menu")
			,mainMenu = { height: $mainMenu.height() }
		;
		jQuery.extend(mainMenu, $mainMenu.offset());

		$line.clone().css({
			 top: mainMenu.top + 30 + 'px'
			,left: mainMenu.left + 'px'
			,width: body.width - mainMenu.left + 'px'
		}).appendTo("body");


		var  $footerMenu = $("ul.footer-menu")
			,footerMenu = { height: $footerMenu.height(), paddingLeft: parseInt($footerMenu.css('padding-left')) }
		;
		jQuery.extend(footerMenu, $footerMenu.offset());

		$line.clone().css({
			 top: footerMenu.top + footerMenu.height + 10 + 'px'
			,left: footerMenu.left + footerMenu.paddingLeft + 'px'
			,width: body.width - footerMenu.left - footerMenu.paddingLeft + 'px'
		}).appendTo("body");


		$("h2.page-name, .person .column-left .person-name span").each(function() {
			var  $element = $(this)
				,element = { height: $element.height(), width: $element.width() }
			;
			jQuery.extend(element, $element.offset());

			$line.clone().css({
				 top: element.top + element.height + 7 + 'px'
				,left: 0
				,width: element.left + element.width + 'px'
			}).appendTo("body");
		});


		$(".person .column-right").each(function() {
			var  $element = $(this)
				,element = { height: $element.height(), paddingTop: parseInt($element.css('padding-top')) }
			;
			jQuery.extend(element, $element.offset());

			$line.clone().css({
				 top: element.top + element.height + element.paddingTop - 7 + 'px'
				,left: element.left + 'px'
				,width: body.width - element.left + 'px'
			}).appendTo("body");
		});


		$(".line-to-righteous").each(function() {
			var  $element = $(this)
				,element = { height: $element.height() }
			;
			jQuery.extend(element, $element.offset());

			$line.clone().css({
				 top: element.top + element.height - 7 + 'px'
				,left: element.left + 'px'
				,width: body.width - element.left + 'px'
			}).appendTo("body");
		});
	});

	$(window).trigger('resize');
});
