
$(document).ready(
	function() {

//		elapsedTimer("Start Old-FMLayer.js");

		// DW: Breite des FMgr wird vom Cookie aus gesetzt
		if ($.cookie("cookie-fmgr-resizable-width")) {
			$("#fmgr-resizable").width($.cookie("cookie-fmgr-resizable-width") + "px");
		}
		
		
		// DW: FMgr wird resizable gesetzt
		$("#fmgr-resizable").resizable({
			//animate: true,
			//ghost: true,
			handles: "w",
			minWidth: 180,
			maxWidth: 500,
			// DW: Auslesen und Speichern der aktuellen Breite von FMgr in Cookie
			stop: function(event, ui) {
				$.cookie("cookie-fmgr-resizable-width", ui.size.width);
				$(".fm").css("left","");
				$(".fm").css("height","");
				$(".fm").css("position","");
			}
		});
		
		
		// DW: Start mit FMgr, FMkl aussliden
		$("#fmkl-slide").hide("slide", { direction: "right" }, 0);
		// DW: Start mit FMkl, FMgr aussliden
		//$("#fmgr-slide").hide("slide", { direction: "right" }, 0);
		
		
		// DW: Toggle FM wenn Status Cookie gesetzt ist
		if ($.cookie("cookie-fmgr-status")) fmtogglefm(0);
		
		
		// DW: FMgr und FMkl sichtbar machen
		$(".fmgr").css("visibility","visible");
		$(".fmkl").css("visibility","visible");
		
		
		// DW: Toggle FM
		$(".fm-icon-toggle").click(function() { $.cookie("cookie-fmgr-auto-status", "disabled"); fmtogglefm(1000); } );
		//$(".fmkl").click(function() { fmtogglefm(1000); } );
		
		
		// DW: Mouse Hover
		$(".fm-active").hover(
			function() { $(this).addClass("cursor_pointer"); },
			function() { $(this).removeClass("cursor_pointer"); }
		);
		
		JGO_Resize();
//		stopTimer();
		

		// DW: scrollFollow aktivieren
try {
	if( document.location.href == top.document.location.href )
		$(".fm").scrollFollow({
				speed: 1000,
				offset: 77
				//killSwitch: 'id',
				//onText: 'Disable Follow',
				//offText: 'Enable Follow'
			}
		);
		
} catch (e){}
		
		// DW: Nachdem die FMgr geresized wurde, wird ein von jQuery ein left gesetzt, dass wird beim window.resize auf "" gestellt, somit bleibt das FMgr auf right: 0
		var resizeTimer = null;
		$(window).bind('resize', function() {
			if (resizeTimer) clearTimeout(resizeTimer);
			resizeTimer = setTimeout(function(){$(".fm").css("left","");}, 100);
		});
	}
);


function fmtogglefm(fmspeed) {
	// DW: Fuer IE6 soll die Speed 0 - bedeutet keine Animation - sein, ansonsten gibt's Darstellungsfehler bei der Animation
	if (($.browser.msie) && (parseInt($.browser.version)<=6)) fmspeed = 0;
	
	// DW: Toggle Slide FMgr und FMkl
	$("#fmgr-slide").toggle("slide", { direction: "right" }, fmspeed);
	$("#fmkl-slide").toggle("slide", { direction: "right" }, fmspeed);
	
	// DW: Class wird getoggelt, und je nach Class ein Cookie fuer FMgr aktiv oder inaktiv gesetzt
	$("#fmgr-slide").toggleClass("fmgr-inaktiv");
	if ($("#fmgr-slide").is(".fmgr-inaktiv")) {
		$.cookie("cookie-fmgr-status", "fmgr-inaktiv");
	} else {
		$.cookie("cookie-fmgr-status", null);
	}
}

function fmchangehtml(fmid,fmhtml,fmclass) {
	if (fmhtml) { $(fmid).html(fmhtml); }
	
	if (fmclass == "fm-active") {
		$(fmid).removeClass("fm-inactive");
		$(fmid).addClass("fm-active");
		$(fmid).hover(
			function() { $(fmid).addClass("cursor_pointer"); },
			function() { $(fmid).removeClass("cursor_pointer"); }
		);
	}
	if (fmclass == "fm-inactive") {
		$(fmid).removeClass("fm-active");
		$(fmid).addClass("fm-inactive");
		$(fmid).hover(
			function() { $(fmid).removeClass("cursor_pointer"); },
			function() { $(fmid).removeClass("cursor_pointer"); }
		);
	}
}

