
$(document).ready(function() { 




	$("#category dt").hover(
		function () {
		$(this).addClass("on");
		$(this).next().css("display","block");
		//$(this).next().css("margin-left","-"+(parseInt($(this).next().css("width"))+63));
		},
		function () {
		$(this).removeClass("on");
		$(this).next().css("display","none");
		}
	);


	$("#category dd").hover(
		function () {
		$(this).prev().addClass("on");
		$(this).css("display","block");
		},
		function () {
		$(this).prev().removeClass("on");
		$(this).css("display","none");
		}
	);






	//rotation speed and timer
	var speed = 2000;
	var run = setInterval('rotate()', speed);	
	
	//grab the width and calculate left value
	var item_width = $('#picinfo dl').outerWidth(); 
	var left_value = item_width * (-1); 
        
    //move the last item before first item, just in case user click prev button
	$('#picinfo dl:first').before($('#picinfo dl:last'));
	
	//set the default item to the correct position 
	$('#picinfo div').css({'left' : left_value});

    //if user clicked on prev button
	$('#prev').click(function() {

		//get the right position            
		var left_indent = parseInt($('#picinfo div').css('left')) + item_width;

		//slide the item            
		$('#picinfo div:not(:animated)').animate({'left' : left_indent}, 2000,function(){    

            //move the last item and put it as first item            	
			$('#picinfo dl:first').before($('#picinfo dl:last'));           

			//set the default item to correct position
			$('#picinfo div').css({'left' : left_value});
		
		});

		//cancel the link behavior            
		return false;
            
	});

 
    //if user clicked on next button
	$('#next').click(function() {
		
		//get the right position
		var left_indent = parseInt($('#picinfo div').css('left')) - item_width;
		
		//slide the item
		$('#picinfo div:not(:animated)').animate({'left' : left_indent}, 2000, function () {
            
            //move the first item and put it as last item
			$('#picinfo dl:last').after($('#picinfo dl:first'));                 	
			
			//set the default item to correct position
			$('#picinfo div').css({'left' : left_value});
		
		});
		         
		//cancel the link behavior
		return false;
		
	});        
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#picinfo').hover(
		
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('rotate()', speed);	
		}
	); 









});








function rotate() {
	$('#next').click();
}