Problem with picture slideshow

alright so I am trying to create a picture slideshow on the top of my website… I basically want something like this http://www.deadmau5.com/ where the pictures change after 5 sec… and there are buttons to go back and forth… I have almost got it working… The buttons control going back and forth between pictures… but something is messed up with the timmer… it switches 5 seconds just fine but if you press a button to go back or forward it adds additional number of times that it cycles through the pictures… ANY HELP WOULD BE MUCH APPRECIATED…

import flash.events.MouseEvent;stop();
color_mc1.cacheAsBitmap = true;   //color_mc1 is basically the first picture

mask_mc.cacheAsBitmap = true;  // is a mask layer that hids part of the pictures
color_mc1.mask = mask_mc;
dotbtn1.addEventListener(MouseEvent.CLICK, boom);  // these first 3 buttons let you                             choose what picture to go to
function boom(event:MouseEvent):void
{
	gotoAndPlay(1);
}
dotbtn2.addEventListener(MouseEvent.CLICK, boom2);
function boom2(event:MouseEvent):void
{
	gotoAndPlay(2);
}


dotbtn3.addEventListener(MouseEvent.CLICK, boom3);
function boom3(event:MouseEvent):void
{
	gotoAndPlay(3);
}


// these two buttons control going forward or back 
btn_3.addEventListener (MouseEvent.CLICK,backward);
btn_4.addEventListener (MouseEvent.CLICK,forward);


	function forward(event: MouseEvent) {
		if(this.currentFrame == this.totalFrames){
			
			gotoAndStop(1);
		}
		else{
			 nextFrame();
		}
												}
												  
												
	function backward(event: MouseEvent) {
		if(this.currentFrame == 1){
			
			gotoAndStop(this.totalFrames);
		}
		else{
			 prevFrame();
			
		}
		
												}
												


// this is the automatic timer that switches frames every 5 sec.
function wait() {
    gotoAndPlay(2); 
	
}stop();
setTimeout(wait, 4500);