// javascript for homepage - gme
$(function() {	
	// 	BIND SLIDESHOW SLIDES FROM SOURCE HTML
	//	retrieve html from source file
	//	iterate html and strip h3 tags 
	//	apply 'title' attribute to all img tags
	$.ajax({
	  url: "slides.html",
	  cache: true,
	  success: function(html){
		$("#featured_item_slide").append(html);
		$("#featured_item_slide > h3").remove(); 
		$("#featured_item_slide > img").attr("title", function() {
			return this.alt;
			
		});
		startSlideshow();		
	  }
	});
	
	function startSlideshow() {			
		var $slideshow = $('#featured_item_slide'); 
		var totalSlideCount=5;
		
		// start slideshow 
		$('#featured_item_slide').cycle({ 
			fx: 'fade', 
			startingSlide: 0,
			speedIn: 1800,
			speedOut: 2000,
			sync: true,
			timeout: 8000,
			pause: 0,
			delay: 0,
			before:  onBefore,
			after:   onAfter					
		});
			
		function onBefore(curr, next, opts, fwd) {
			//$('#featured_item_copy').html('loading...'); 
			if (!opts.addSlide) 
				return; 
				 
			// have we added all the slides? 
			if (opts.slideCount == totalSlideCount) 
				return;
		}; 
			
		function onAfter(curr, next) {
			if(this.title != '' || this.title != ' ')
			{
				$('#featured_item_copy').html(this.title);
			}
		}; 
	};
		
	
});

