function startAutoPlay() {
	return setInterval(function() {

    $('#refRound').roundabout_animateToNextChild();	      	              
	}, 3000);
}

function CbImg(filename)
{
   var re = new RegExp("(.+)\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1-cb.$2");
}
function CoImg(filename)
{
   var re = new RegExp("(.+)-cb\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1.$2");
}

$(document).ready(function() {
  
      
  $('#aContactOpen').each(function(){
    var me = $(this);
    me.html(me.html().replace(/^([^\s]*)(.*)/, '<span>$1</span>$2'));
  });
  
  var contactBox = $('#contactBox');  
  	
  $('#aContactClose').click( function( event ){
    event.preventDefault();
    contactBox.hide();    
  });
	
	$('#aContactOpen').click(function( event ) {
    event.preventDefault();    
    if ( contactBox.is(":hidden") ) {
      contactBox.slideDown("fast");      
    } else {
      contactBox.hide();
    }
  });
    
    
  var interval;
				
	$('#refRound').roundabout({
                    minScale: 0.5,
                    maxScale: 0.5,
                    minOpacity: 0.0,
                    tilt: -2,  
                })
					      .hover(
						      function() {
  							    // oh no, it's the cops!
  							    clearInterval(interval);
						      },
      						function() {
      							// false alarm: PARTY!
      							interval = startAutoPlay();
      						}
                );
				
	// let's get this party started
	interval = startAutoPlay();        
});
