function carousel(slideWidth, slideHeight, slideSpeed, showSlideNav, showSlideLinks) {

	// Clone first slide
	$('#slideArea div:nth-child(2)').clone().appendTo($('#slideArea')).addClass('clone');
	
	var cloneSwitch = 1;
    var activeSlide = 0;
    var slides = $('.slide');
    var numberOfSlides = slides.length;

    // Remove scrollbar in JS
    $('#slideArea').css('overflow', 'hidden');
    // Set Slider Height / Width
    $('#carousel').css({
        'width': slideWidth,
        'height': slideHeight
    });

	// Set SlideArea Height / Width
    $('#carousel.slideArea').css({
        'width': slideWidth,
        'height': slideHeight
    });

    // Wrap all .slides with #slideWrapper div
    slides.wrapAll('<div id="slideWrapper"></div>')
    // Modify CSS to float slides left and readjust their width
    .css({
        'float': 'left',
        'width': slideWidth,
        'height': slideHeight
    });

	 // Loop through each slide
    $(".slide").each(
		function (intIndex) {
			// Bind the onclick event to simply alert the
			// iteration index value.
			$('#slideLinks').append('<div id="slide' + intIndex + '" class="slideSlctr">' + (intIndex + 1) + '</div>');
			$('#slide' + intIndex).bind('click', function () {
				// Clear out the current timer
				clearTimeout(slideTimer);
				// Set the activeSlide to the current slide
				activeSlide = intIndex;
				// Check that the correct controls are displayed
				toggle(intIndex);
				// Animate the carousel
				$('#slideWrapper').animate({
					'marginLeft': slideWidth * (-intIndex)
				});
			})
		});
		
	//removed cloned slidelink
	$('#slideLinks div:last-child').remove();

    // Set #slideWrapper width equal to total width of all slides
    $('#slideWrapper').css('width', slideWidth * numberOfSlides);

    // Insert left and right controls in the DOM
    $('#carousel').prepend('<span class="controls_css" id="leftControl">Clicking moves left</span>').append('<span class="controls_css" id="rightControl">Clicking moves right</span>');

    // Hide left arrow control on first load
    toggle(activeSlide);

    // Create event listeners for .controls clicks
    $('.controls_css').bind('click', function () {
        // Clear out the current timer
        clearTimeout(slideTimer);
        // Determine new position
        activeSlide = ($(this).attr('id') == 'rightControl') ? activeSlide + 1 : activeSlide - 1;
        // Hide / show controls
        toggle(activeSlide);
        // Move slideWrapper using margin-left
        $('#slideWrapper').animate({
            'marginLeft': slideWidth * (-activeSlide)
        });
    });

    // toggle: Hides and Shows controls depending on the activeSlide

    function toggle(position) {
	
		// If showSlideNav is 1, then display Left and Right Controls
		if (showSlideNav == 1){
			// Hide left arrow if position is first slide
			if (position == 0) {
				$('#leftControl').hide()
			} else {
				$('#leftControl').show()
			}
			// Hide right arrow if position is last slide
			if (position == numberOfSlides - 1) {
				$('#rightControl').hide()
			} else {
				$('#rightControl').show()
			}
		}
		
		// If showSlideLinks is 0, then hide Carousel slideLinks
		if (showSlideLinks == 0){
			$('#slideLinks').hide()
		}


		if (position == numberOfSlides - 1) {
				cloneSwitch = 0.1;
		} else{
		cloneSwitch = 1;
		}
		
        // Set the slide time to switch in x seconds		
        slideTimer = setTimeout(function () {
            // Determine new position
            position = (position >= (numberOfSlides - 1)) ? position - numberOfSlides + 1 : position + 1;
            toggle(position);			
            // Move slideWrapper using margin-left
			if (position == 0){
				 $('#slideWrapper').css('marginLeft', 0);
				 position = 0;
				 activeSlide = 0;
			}else {
            $('#slideWrapper').animate({
                'marginLeft': slideWidth * (-position)
            });
			if (position == numberOfSlides - 1){
				$('#slideWrapper').css('marginLeft', 0);
				position = 0;
				activeSlide = 0;
			}
			}

        }, slideSpeed * 1000 * cloneSwitch);
	
		
        // Remove slideCurrent class
        $(".slideSlctr").each(function () {
            $(this).removeClass('slideCurrent');
        });
        // Add 'slideCurrent' class to current slideSlctr
		if (position == numberOfSlides - 1){
			$('#slide' + 0).addClass('slideCurrent');
		}
		else{
			$('#slide' + position).addClass('slideCurrent');
		}
		
    }
}