(function( $ ){
		  
  $.fn.philCaro = function(settings) { 
  
	//Delare settings for carousel
    settings = jQuery.extend({
			buildNav: 		'no'
	},settings);
	
	//Get the relevant information to build the carousel
	//How wide is the containing div
	containerWidth = parseFloat(this.width());
	containerHeight = parseFloat(this.height());
	
	//Get the id of the container block
	containerName = this.attr('id');
	
	//How many list items are there
	liSize = parseFloat($('#'+containerName+' ul li').length);
	
	//Housekeeping for poor coding
	$(this).css({
			'overflow': 'hidden',			
	});
	
	//Define which slide to start on
	var currentSlide = 1;
	
	//Turn off the built-in pagination by changing to 0
	var buildNav = 1;

	//Build the carousel Items
	$('#'+containerName+' ul').css({
		'backgroundColor':	'#ffffff',
		'width':			''+(containerWidth*liSize)+'px',
		'height':			containerHeight+'px',
		'margin':			'0px',
		'padding':			'0px',
		'position':			'relative',
		'left':				'0px'
  	});
	
	$('#'+containerName+' ul li').css({
		'float':			'left',
		'display':			'block',
		'width':			containerWidth+'px',
		'height':			containerHeight+'px'
	});
	
	//Add the buttons
	$(this).css('height',''+parseFloat((containerHeight+30))+'px');
	$(this).append('<div id="carouselButs"></div>');
	$('#carouselButs').css('text-align','right');
	
	if (buildNav == 1) {
		$('#carouselButs').append('<span id="carButPrev" class="carBut"><< Previous</span> |');
		
		for (i=1; i<=liSize; i++) {
			$('#carouselButs').append(' <span id="carBut'+i+'" class="carBut2">'+i+'</span> | ');
		}
		
		$( ".carBut2" ).each(
	 
		  // For each hottie, run this code. The "indIndex" is the
		  // loop iteration index on the current element.
		  function( intIndex ){
		  
			  // Bind the onclick event to simply alert the
			  // iteration index value.
			  $( this ).bind ("click",function(){
					$('#'+containerName+' ul').stop(true,true).animate({left:((intIndex*containerWidth)*-1)},"slow");
					currentSlide = intIndex+1;
				}
			  );
		  
		  }
		
		);
		
		$('#carouselButs').append(' <span class="carBut" id="carButNext" href="#">Next >></span>');
	
	}
	else {
		alert('Nav Off');	
	}
	
	
	$('.carBut').css({
		'fontFamily':		'Arial',
		'textDecoration':	'none',
		'color':			'#000000',
		'margin':			'10px 2px 10px 2px',
		'position':			'relative',
		'top':				'2px',
		'cursor':			'pointer'
		
	});
	
	$('.carBut2').css({
		'fontFamily':		'Arial',
		'textDecoration':	'none',
		'color':			'#000000',
		'margin':			'10px 2px 10px 2px',
		'position':			'relative',
		'top':				'2px',
		'cursor':			'pointer'
		
	});
	
	//Function for previous
	$('#carButPrev').unbind('click');
	$('#carButPrev').bind('click',function() {
			currLeft = (((currentSlide-1)*containerWidth)*-1);
			if (currLeft == 0) {

			}
			else {
				$('#'+containerName+' ul').stop(true, true).animate({left:parseFloat((currLeft+containerWidth))});
				currentSlide = currentSlide-1;
			}
			return false;
	});
	

	
	//Function for next
	$('#carButNext').unbind('click');
	$('#carButNext').bind('click',function() {
			currLeft = (((currentSlide-1)*containerWidth)*-1);
			if (currLeft == (-1*((containerWidth*liSize)-containerWidth))) {

			}
			else {
				$('#'+containerName+' ul').stop(true, true).animate({left:parseFloat((currLeft-containerWidth))});
				currentSlide = currentSlide+1;
			}
			return false;
	});
	
	
  };
})( jQuery );
