(function($){
	
	$.fn.slider = function(options){
	var defaults = {
			speed : 700,
			pause : 6000,
			fadeSpeed : 700,
			width : '680px',
			height : '375px'
		}, interval, options = $.extend(defaults,options),paused=false,i=1;
	
		$('#slideshow').css({
			'width':options.width
		});
		
		$('.slide_content').hide();
	
		$('#slide_wrap').css({
			'width' : '99999px',
			'padding' : 0,
			'margin' : 0,
			'position' : 'relative'
		});
		
		$('.slide').each(function(){
			$(this).addClass('slide_'+i);
			
			$(this).css({
			'float': 'left',
			'overflow' : 'hidden',
			'width' : options.width,
			'height' : options.height
			});
			i++;
		});
		
		// add slide navigation here...
		
		$('.slide_nav').click(function(){
			if($(this).attr('rel') === 'forward') {
				clearInterval(interval);
				$('#slide_wrap').animate({'left':'-'+options.width},options.speed,function(){
					$('#slide_wrap').css('left',0).children(':first').appendTo('#slide_wrap');
				});
				interval=setInterval(interval_function, options.pause);
				return false;
			}else{
				clearInterval(interval);
				$('#slide_wrap').fadeOut(options.speed,function(){
					$('#slide_wrap').children(':last').prependTo('#slide_wrap');
					$('#slide_wrap').fadeIn(options.speed);
				});
				interval = setInterval(interval_function, options.pause);
				return false;
			}
		});
		
		
		
		var interval_function = function(){
			//$('.slide_content').fadeOut(options.fadeSpeed);
			$('#slide_wrap').animate({'left':'-'+options.width},options.speed,function(){
				$('#slide_wrap').css('left',0).children(':first').appendTo('#slide_wrap');
				//$('.slide_content').fadeIn(options.fadeSpeed);
			});
		}
		
		interval = setInterval(interval_function,options.pause);
		
		$('#slide_wrap').hover(function(){
			clearInterval(interval);
		},function(){
			interval = setInterval(interval_function,options.pause);
		});
		
		$('.slide_pause').click(function(){
			if(paused === false){
				clearInterval(interval);
				$(this).children('img').attr('src','/xcal/images/slider/play.png');
				paused = true;
				return false;
			}else
			{
				$(this).children('img').attr('src', '/xcal/images/slider/pause.png');
				interval=setInterval(interval_function,options.pause);
				paused = false;
				return false;
			}
			
		});
		
		
		
	}	
	Cufon.set('fontFamily', 'Pahuenga cass');
	Cufon.replace('.slide h2',{
		color : '#FFFFFF',
				fontSize : '32'
	})
	
})(jQuery);

