/*

	Supersized - Fullscreen Slideshow jQuery Plugin
	Version : 3.2.5
	Theme 	: CRA_TEMP (based on Shutter 1.1)
	
	Site	: www.charlesrosearchitects.com
	Author	: Sam Dunn / modified by Paul Voulgaris
	Company : One Mighty Roar (www.onemightyroar.com) / 67a2.com
	License : MIT License / GPL License

*/

(function($){
	
	theme = {
	 	/* Initial Placement
		----------------------------*/
	 	_init : function(){
	 		// Center Slide Links
	 		if (api.options.slide_links) $(vars.slide_list).css('margin-left', -$(vars.slide_list).width()/2);
	 		
			// Start progressbar if autoplay enabled
    		if (api.options.autoplay){
    			if (api.options.progress_bar) theme.progressBar();
			}else{
				if ($(vars.play_button).attr('src')) $(vars.play_button).attr("src", vars.image_path + "play.png");	// If pause play button is image, swap src
				if (api.options.progress_bar) $(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 );	//  Place progress bar
			}
			/* Navigation Items
			----------------------------*/
		    $(vars.next_slide).click(function() {
		    	api.nextSlide();
		    });
		    $(vars.prev_slide).click(function() {
		    	api.prevSlide();
		    });
		    $(vars.play_button).click(function() {
				api.playToggle();						    
		    });
			/* Window Resize
			----------------------------*/
			$(window).resize(function(){
				// Delay progress bar on resize
				if (api.options.progress_bar && !vars.in_animation){
					if (vars.slideshow_interval) clearInterval(vars.slideshow_interval);
					if (api.options.slides.length - 1 > 0) clearInterval(vars.slideshow_interval);
					$(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 );
					if (!vars.progressDelay && api.options.slideshow){
						// Delay slideshow from resuming so Chrome can refocus images
						vars.progressDelay = setTimeout(function() {
								if (!vars.is_paused){
									theme.progressBar();
									vars.slideshow_interval = setInterval(api.nextSlide, api.options.slide_interval);
								}
								vars.progressDelay = false;
						}, 1000);
					}
				}
			});	
	 	},
	 	/* Go To Slide
		----------------------------*/
	 	goTo : function(){
	 		if (api.options.progress_bar && !vars.is_paused){
				$(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 );
				theme.progressBar();
			}
		},
	 	/* Play & Pause Toggle // EDITED by 67a2 to use background-position
		----------------------------*/
	 	playToggle : function(state){
	 		if (state =='play'){
	 			// If image, swap to pause
				$(vars.play_button).css({'background-image': 'url("temp/img/pause.png")'} );
				if (api.options.progress_bar && !vars.is_paused) theme.progressBar();
	 		}else if (state == 'pause'){
	 			// If image, swap to play
				$(vars.play_button).css({'background-image': 'url("temp/img/play.png")'} );
        		if (api.options.progress_bar && vars.is_paused)$(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 );
	 		}
	 	},
	 	/* Before Slide Transition
		----------------------------*/
	 	beforeAnimation : function(direction){
		    if (api.options.progress_bar && !vars.is_paused) $(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 );
	 	},
	 	/* After Slide Transition
		----------------------------*/
	 	afterAnimation : function(){
	 		if (api.options.progress_bar && !vars.is_paused) theme.progressBar();	//  Start progress bar
	 	}, 	
	 	/* Progress Bar
		----------------------------*/
		progressBar : function(){
    		$(vars.progress_bar).stop().animate({left : -$(window).width()}, 0 ).animate({ left:0 }, api.options.slide_interval);
    	}
	 };
	 /* Theme Specific Variables
	 ----------------------------*/
	 $.supersized.themeVars = {
	 	// Internal Variables
		progress_delay		:	false,				// Delay after resize before resuming slideshow
		thumb_page 			: 	false,				// Thumbnail page
		thumb_interval 		: 	false,				// Thumbnail interval
		image_path			:	'temp/img/',				// Default image path											
		// General Elements							
		play_button			:	'#pauseplay',		// Play/Pause button
		next_slide			:	'#nextslide',		// Next slide button
		prev_slide			:	'#prevslide',		// Prev slide button					
		progress_bar		:	'#progress-bar'		// Progress bar												
	 };												
	 /* Theme Specific Options
	 ----------------------------*/												
	 $.supersized.themeOptions = {								   
		progress_bar		:	1,		// Timer for each slide											
	 };
})(jQuery);
