function totalrotate() {
	var slidelength = 0;
	var i = 1;
	var rotate;
	
	function rotation() {
		if (i < slidelength) {
			$('.activeslide').next().trigger('click');
			i++;
		}
		else {
			$('.homeslide').hide();
			$('#slide_id0').fadeIn();
			$('#slidecontrols a').removeClass('activeslide');
			$('#slidecontrols a:first-child').addClass('activeslide');
			i = 1;
		}
	}
	
	function startrotate() {
	    rotate = setInterval(rotation, 6000);
		$('#pausebutton').removeClass('pauseactive');
		$('#playbutton').addClass('playactive');
		return false;
	}
	
	$(document).ready(function(){
		startrotate();
		$('.homeslide').hide();
		$('#slidecontrols a.whichslide').each(function(index) {
			slidelength++;
			$(this).click(function() {
				$('.homeslide').hide();
				$('#slide_id' + index).fadeIn();
				$('#slidecontrols a').removeClass('activeslide');
				$(this).addClass('activeslide');
				return false;
			}).attr({
				'id' : 'toggle_id' + index
			});
		});
		
		$('#slideshow .homeslide').each(function(index) {
			$(this).hide().attr({
			'id' : 'slide_id' + index
			});
		});
		
		$('#slide_id0').slideDown('fast');
		$('#slidecontrols a:first-child').addClass('activeslide');
		

		$('#playbutton').click(function() {
		    startrotate();
			return false;
		});
		
		$('#pausebutton').click(function() {
		    clearInterval(rotate);
			$('#playbutton').removeClass('playactive');
			$(this).addClass('pauseactive');
			return false;
		});
		return false;
	});
	
}