/**
 * @author Barney Powell
 * 
 */
if(!ds){
	var ds = {};	
}
 

ds.projectImages = {	
		timeout:0,
		imageIndex:0,
		waitFor: 2000,					
		init: function(){
			//this.showFirstImage();
			//this.timeout = setTimeout(this.rotateImages,this.waitFor);
			
			
			$('#project-gallery').cycle({
				fx: 'scrollLeft',
				after: this.afterCycle,
				pager:  '#gallery-pages', 
     
    			// callback fn that creates a thumbnail to use as pager anchor 
    			pagerAnchorBuilder: function(idx, slide) { 
        			return '<li><a href="#">&nbsp;</a></li>'; 
    			} 

			});
			
			$('#gallery-pages li a').click(this.setImage);					
			
		},
		
		showFirstImage: function() {
			//$('#project-gallery img:first').show();
			//$('#gallery-pages li a:first').addClass("selected");
			$('#gallery-pages li a').click(this.setImage);					
		},
		
		setImage: function(e) {
			
			$('#project-gallery').cycle('pause');
			
			//var idx = $('#gallery-pages li a').index(this);
			
			//$('#project-gallery img').hide();
			//$('#gallery-pages li a').removeClass("selected");
			
			//$(this).addClass("selected");

			//var img = $('#project-gallery img')[idx];
			
			//$(img).show();
			
			this.timeout = setTimeout("$('#project-gallery').cycle('resume');", 10000);
			
		},
		
		afterCycle: function() {

			//var idx = $('#project-gallery img').index(this);
			//$('#gallery-pages li a').removeClass("selected");			
		
			//var pg = $('#gallery-pages li a')[idx];
			//$(pg).addClass("selected");			
		
		},
		
		rotateImages: function() {
			
			//alert("rotating");

			//var img = $('#project-gallery img')[this.imageIndex];			
			//$(img).fadeOut('slow');
			
			//this.timeout = setTimeout("ds.projectImages.rotateImages();",this.waitFor);			
		}
		
		
}	


$().ready(function() {

	if ($('#project-gallery').length > 0) {

		ds.projectImages.init();
	}
	
});



