jQuery(document).ready(function() {  

	setButtonText();
	var speed = 4000;
	//var run = setInterval('rotate()', speed);
	
	 jQuery(".roomImg img, .boats img").each(function() {
        var src = jQuery(this).attr('src').replace('img_T','img_L');
        var a = jQuery('<a/>').attr('href', src).attr('rel', 'lightbox').addClass('gallery');
        jQuery(this).wrap(a);
    });
	
	jQuery('a[rel*=lightbox]').lightBox();


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

			jQuery('.rooms').fadeOut('slow', function() {
				//move the last item and put it as first item                 
				jQuery('.room:first').before(jQuery('.room:last'));             

				jQuery('.rooms').fadeIn('slow');
				setButtonText();
			
			});

  
        //cancel the link behavior              
        return false;  
              
    });  
	
	
  
   
    //if user clicked on next button  
    jQuery('#next').click(function() {  
      
		jQuery('.rooms').fadeOut('slow', function() {
				//move the last item and put it as first item                 
				jQuery('.room:last').after(jQuery('.room:first'));                                          
				jQuery('.rooms').fadeIn('slow');
				setButtonText();
        
		});

                   
        //cancel the link behavior  
        return false;  
          
    });          
    jQuery('.rooms').hover(

		function() {
			//clearInterval(run);
		},
		function() {
			//run = setInterval('rotate()', speed);
		}
	); 

          
});  

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

function setButtonText()
{
	jQuery('#prev').attr('title',jQuery('.room:last .roomName strong').html());

	jQuery('#next').attr('title',jQuery('.room:nth-child(2) .roomName strong').html());


}
  
