	var $bt = jQuery.noConflict();
	$bt(document).ready(function(){
	  var currentPosition = 0;
	  var timePosition = 0;
	  var slideWidth = generalWidth;
	  var varDuration = duration * 1000;
	  var slides = $bt('.slide');
	  var numberOfSlides = slides.length;
	  var interval = "";
	
	  // Remove scrollbar in JS
	  $bt('#slidesContainer').css('overflow', 'hidden');
	  $bt('#slideLink').css('overflow', 'hidden');
	  // Wrap all .slides with #slideInner div
	  slides
	    .wrapAll('<div id="slideInner"></div>')
	    // Float left to display horizontally, readjust .slides width
		.css({
	      'float' : 'left',
	      'width' : slideWidth
	    });

	  // Set #slideInner width equal to total width of all slides
	  $bt('#slideInner').css('width', slideWidth * numberOfSlides);

	  // Insert controls in the DOM
	  $bt('#slideshow')
	//   .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
	//    .prepend('<span class="control" id="rightControl">Clicking displays another image in the slideshow</span>');

	  // Hide left arrow control on first load
	  manageControls(currentPosition);

	  // Create event listeners for .controls clicks
/*	  $bt('.control')
	    .bind('click', function(){
	    // Determine new position
		if(currentPosition==numberOfSlides-1) {
			currentPosition = 0;
		} else {
			currentPosition = ($bt(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
		}
		// Hide / show controls
	    manageControls(currentPosition);
	    // Move slideInner using margin-left
	    $bt('#slideInner').animate({
	      'marginLeft' : slideWidth*(-currentPosition)
	    });
	  });
*/
	
	  $bt('.carousel a').bind('click', function(){
	  	
			moveToDivPosition($bt(this).attr('id')-1);
			window.clearInterval(interval);
			interval = "";
			interval = window.setInterval(function(){moveToDivTimerPosition()}, varDuration );
		});

	$bt('.carousel a').hover(function(){
		$bt(this).addClass('hover');
	}, function(){ 	
		$bt(this).removeClass('hover'); 
		
	});

	
	  // manageControls: Hides and Shows controls depending on currentPosition
	  function manageControls(position){
		// Hide left arrow if position is first slide
		// if(position==0){ $bt('#leftControl').hide() } else{ $bt('#leftControl').show() }
		// Hide right arrow if position is last slide
		// if(position==numberOfSlides-1){ $bt('#rightControl').hide() } else{ $bt('#rightControl').show() }

		$bt('.carousel a').each(function(){
			$bt(this).removeClass('selected');
		});

		$bt('.carousel').find('#' + (position + 1)).addClass('selected');

//		console.log("managecontrols");
	}

	// move to a set div order
	function moveToDivPosition(position){
		//alert("currentPosition = " + currentPosition + " position = " + position);
		currentPosition = position;
		timePosition = currentPosition;
		//$bt('#slideInner').animate({opacity: 0.0}, 500);
		$bt('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
		//$bt('#slideInner').animate({opacity: 1.0}, 500);
//		console.log("moveToDivPosition");

		manageControls(currentPosition);
		
	}
	function moveToDivTimerPosition(){
		 if (timePosition >= numberOfSlides -1 ) {
			timePosition = 0
		}
		else
		{
			timePosition ++;
		}
		//alert(timePosition + " and " + numberOfSlides);
		
		currentPosition = timePosition;
		$bt('#slideInner').animate({opacity: 0.0}, 500);
		$bt('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)}, 0);
		$bt('#slideInner').animate({opacity: 1.0}, 500);

//		console.log("moveToDivTimerPosition");

		manageControls(currentPosition);
	}
	
	
	$bt(function() {
		if (numberOfSlides > 1) {
	    interval = window.setInterval(function(){moveToDivTimerPosition()}, varDuration );
		}
	});

});
	
	
	
	
	
