// JavaScript Document


jQuery(document).ready(function() {
	
	//Beim Start einfahren
	$('#sidebar').css('right','-364px');
	
	//nach wenigen Sekunden ausfahren
	window.setTimeout(function() {
		$('#sidebar').animate({
			right: '-1',
			opacity: '100%'
			}, 3000,'swing');
				},2000);
	
	
	//parameter:
	sb_opacity=0.3;
	opatimeout=20000;
	sb_status='ov';//ov=open&visible
	
	$("a#sidebarControl").click().toggle(
	function() {
		//einfahren
		$('#sidebar').stop(true, true).animate({
			right: '-364px',
			opacity: sb_opacity
		}, 'slow');
		//img auf open stellen
		$('#sidebarControl img').attr("src","/gui/sidebar_open.png");
;
	},
	function() {
		//ausfahren
		$('#sidebar').animate({
			right: '-1',
			opacity: '100%'
		}, 'slow');
		//img auf close stellen
		$('#sidebarControl img').attr("src","/gui/sidebar_close.png");
;
	}
	);
	
	//nach x Sekunden faden	
	function sb_fadeout(){
		window.setTimeout(function() {
			$('#sidebar').stop(true, true).animate(
				{opacity: sb_opacity},
				'slow');
			},opatimeout);
	}
	sb_fadeout(); //erststart

	//bei mouseover sichtbar machen
	$("#sidebarContent").mouseenter(
		function() {
		if(sb_status=='ov'){
			$('#sidebar').animate(
				{opacity: '100%'},
				5000);
			}
		}
	);
	
	//bei mouseout unsichtbar werden lassen
	$("#sidebarContent").mouseleave(
		function() {
		if(sb_status=='ov'){sb_fadeout()}
		});
	
});//ready