$(document).ready(function(){
	var pageOp;
	
	$('.heftLink').bind('click', function() {
		var link = $(this).attr('href');
		if(link == "") { $('#background').html(""); }
		else { $('#background').html("<img src='" + link + "'/>"); }
		$('.heftLink').attr('id','');
		$(this).attr('id','current');
		if($(this).html() == "t") {
			$('#heftMenu').addClass("onTitle");
		} else {
			$('#heftMenu').removeClass("onTitle");
		}
		return false;
	});
	
	if($('#leer').length) {
		//pageOp = .5;
		$(':not(#menu, #interaktiv, #kontext).stdBox').css({ 'display' : 'none' });
		//$('#menu, #interaktiv').css({opacity : .5});
		/*$('#heftMenu').css({
			'left' : ($('#background').width() * 0.5) + "px",
			'top' : '280px'
		});*/
		/*$('#page_margins').hover(
			function() {
				$('.stdBox').css({opacity : 1});
			},
			function() {
				$('.stdBox').css({opacity : pageOp});
			}
		);*/
	} else {
		//pageOp = 1;
		$('#heftMenu').css({
			'left' : "0px",
			'top' : "280px"
		});
	}
	
	//$('#heftMenu').css({opacity : .6});
	if($('#current').html() == "t") {
		$('#heftMenu').addClass("onTitle");
	}
			
	$('#heftMenu ul, #heftMenu p').hover(
		function() {
			$('.stdBox').css({opacity : 0});
			//$('#heftMenu').css({opacity : 1});
		},
		function() {
			$('.stdBox').css({opacity : 1});
			//$('#heftMenu').css({opacity : .6});
		}
	);			
	
	$('a, AREA').bind('click', function() {
		if($(this).attr('href').substr(0,5) == "index" && $(this).attr('href') != "index.php") {
			$(this).attr('href', $(this).attr('href') + "&heft=" + $('#current').html());
		}
	});
		
});