
(function($) {
		  
$(document).ready(function() {
				
	var footerCookieName = "footerPanelState";
	// the div that will be hidden/shown
	var panel = $("#t3v_footersitemap");
	//the button that will toggle the panel
	var button = $("#footerToggle a");
	// do you want the panel to start off collapsed or expanded?
	var initialState = "expanded"; // "expanded" OR "collapsed"
	// the class added when the panel is hidden
	var activeClass = "footerToggleOpen";
	// the text of the button when the panel's expanded
	var visibleText = "<img src='typo3conf/ext/t3v_footersitemap/files/mediaToggleOpen.png' id='imageFooterToggleClose' class='imageFooterToggleClose' width='31px' height='9px' >";
	// the text of the button when the panel's collapsed
	var hiddenText = "<img src='typo3conf/ext/t3v_footersitemap/files/mediaToggleClose.png'  id='imageFooterToggleOpen' class='imageFooterToggleOpen' width='31px' height='9px' >";
	// ausblenden Text
	var showState = "Sitemap einblenden";
	// einblenden text
	var hideState = "Sitemap ausblenden";
	
	var slideSpeed = 500;
	//---------------------------
	// don't    edit    below    this    line,
	// unless you really know what you're doing
	//---------------------------
			
	if($.cookie(footerCookieName) == undefined) {
		$.cookie(footerCookieName, initialState);
	} 
			
	var state = $.cookie(footerCookieName);
			
	if(state == "collapsed") {
		panel.hide();
		button.html(hiddenText);
		button.removeClass(activeClass);
		// link attribute alt
		$("#footerToggle a").attr("alt", showState);
		// link attribute title
		$("#footerToggle a").attr("title", showState);
		
	} else {
		
		// visible button code
		button.html(visibleText);
		button.addClass(activeClass);
		// link attribute alt
		$("#footerToggle a").attr("alt", hideState);
		// link attribute title
		$("#footerToggle a").attr("title", hideState);

	}
		   
	button.click(function(){
						  	
		if($.cookie(footerCookieName) == "expanded") {
			$.cookie(footerCookieName, "collapsed");
			// hidden button code
			button.html(hiddenText);
			button.removeClass(activeClass);
			// link attribute alt
			$("#footerToggle a").attr("alt", showState);
			// link attribute title
			$("#footerToggle a").attr("title", showState);
			opacityState = "0";
		} else {
			$.cookie(footerCookieName, "expanded");
			// visible button code
			button.html(visibleText);
			button.addClass(activeClass);
			// link attribute alt
			$("#footerToggle a").attr("alt", hideState);
			// link attribute title
			$("#footerToggle a").attr("title", hideState);
			opacityState = "1"; 
		}
		
		//panel.slideToggle("slow");

		// animate verbindet toggle und fade
		panel.animate({
			opacity: opacityState, 	// fade
			height: 'toggle'	// slide
			}, slideSpeed);		// speed
		
		return false;
	});
});

})(jQuery);

