var $j = jQuery.noConflict();

$j(function(){
    
	var cache = ['wp-content/uploads/ss1.jpg', 'wp-content/uploads/ss2.jpg','wp-content/uploads/ss3.jpg', 'wp-content/uploads/ss4.jpg', 'wp-content/uploads/ss5.jpg'];
	
	for(var i = 0; i < cache.length; i++)
	{    
	   
	   img = new Image();
	   img.src = cache[i];
	   $j("#frame").append(img);
	   	   
	}
	   
        var images = $j("#frame img"), i =0;
        images[0].className = 'active';
        
     function slides() 
		{   
			
			function swapout(){
				var $active = $j("#frame .active");
				var $next = ($j("#frame .active").next().length > 0) ? $j("#frame .active").next() : $j("#frame img:first");
				 
				$active.fadeOut(900,function(){
					$active.removeClass('active');
					
				}) ;
				$next.fadeIn(900).addClass('active');
			}
			
		     inter = setInterval(swapout, 2000); 
	   
			$j("#controller button").stop().toggle( function(){
				 										clearInterval(inter);
				                                                                  
				                                         $j("#controller button").text("Start");
				                                        },
				                                        function(){
				                                              slides();
					                                          $j(this).text("Stop");
					                                         
			                                             });     
		}   
		  
		slides();  
       $j("#slideshow").mouseenter( function(){ $j("#controller").slideDown().stop(true,true) }) ;
       $j("#controller").mouseleave(function(){ $j(this).slideUp(); })
	     
  
   
});