/* jquery document ready functions */

	
	$(document).ready(function() {

		//Add class js to body to trigger js enabled css
		$("body").addClass(" js");
		
		// Append shadow image to each LI
		$("#nav-shadow li").append('<img class="shadow" src="/fileadmin/template/template_2011/images/icons-shadow.jpg" width="150" height="25" alt="" />');
	
		// Animate buttons, shrink and fade shadow
		$("#nav-shadow li").hover(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "-14px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "-10px" }, 250);
		    });
		    $(e).find("img.shadow").stop().animate({ width: "80%", height: "20px", marginLeft: "15px", opacity: 0.25 }, 250);
		},function(){
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "4px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "0px" }, 250);
		    });
		    $(e).find("img.shadow").stop().animate({ width: "100%", height: "25px", marginLeft: "0", opacity: 1 }, 250);
		});
		
		
		// Home page slideshow
		//$('#slideshow').before('<div id="sshow-nav" class="sshow-nav">').cycle({
		$('#sshow-bottom').append('<div id="sshow-nav" class="sshow-nav">');	
		$('#slideshow').cycle({
			fx:     'fade',
			speed:  2000,
			timeout: 8000,
			pager:  '#sshow-nav',
			before:  onBefore
    		//after:   onAfter
		});
		
		/* testing
		$('a.sshow-stop').click(function() {
			$('#slideshow').cycle('stop');
			return false;
		});*/
		
		function onBefore() { 
			var imgTitle = $(this).children().attr('title');
			var imgLink = $(this).attr('href');
			$('#sshow-text').html('<a href="' + imgLink + '">' + imgTitle + '</a>'); 
		} 
		function onAfter() { 
			$('#sshow-text').html("Scroll complete for:<br>" + this.src) 
				.append('<h3>' + this.alt + '</h3>'); 
		}
		
		
	// End jQuery
	});
