// get params to initialize lightbox
function getUrlVars(){
  var vars = [], hash;
  var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i=0; i < hashes.length; i++){
    hash = hashes[i].split('=');
    vars.push(hash[0]);
    vars[hash[0]] = hash[1];
  }                         
  return vars;
}

SA.redirection_mobile ({
         noredirection_param:"noredirection",
         mobile_prefix : "m",
         cookie_hours : "2" 
     });

$(document).ready(function(){
  

  

//hack to change url without messing with CF
$('a[href="/index.cfm/id/4/id2/116.html"]').attr('href', "http://press.sushisamba.com")
  
  newsletterInit();
	reservationPopupInit();
	partiesInit();     
	

  var urlAction = getUrlVars()["action"];
  if(urlAction == "reserveLink"){
   reservationPopup(); 
  }
  
  
});





// music popup
function musicPopup(){
	var stLocal			= {};
	stLocal.page = '/musicPlayer.cfm';
	settings = "toolbar=0,status=0,width=350,height=300,scrollbars=0";
	window.open( stLocal.page, null, settings);
}

/* newsletterInit */
function newsletterInit(){
	var stLocal			= {};
	
	if( $('.newsletterSignUp').size() != 0 ){
		$('.newsletterSignUp').click( function(){
			stLocal.title		= 'Newsletter Sign up';
			stLocal.URL			= '/newsletterSignUp.cfm';
			stLocal.URL			= stLocal.URL + '?KeepThis=true&modal=true&TB_iframe=true&height=300&width=710';
			tb_show(stLocal.title, stLocal.URL, '');
		});
	}
}

/* reservationPopup */
function reservationPopupInit(){
	var stLocal			= {};
	
	if( $('.reservation').size() != 0 ){
		$('.reservation').click( function(){
			stLocal.title		= 'Reservation';
			stLocal.URL			= '/reservation.cfm';
			stLocal.URL			= stLocal.URL + '?KeepThis=true&modal=false&TB_iframe=true&height=300&width=800';
			tb_show(stLocal.title, stLocal.URL, '');
		});
	}
}

function reservationPopup(){
	var stLocal			= {};
	
	stLocal.title		= 'Reservation';
	stLocal.URL			= '/reservation.cfm';
	stLocal.URL			= stLocal.URL + '?KeepThis=true&modal=false&TB_iframe=true&height=300&width=800';
	tb_show(stLocal.title, stLocal.URL, '');
}

/* genericPopup */
function genericPopup( title, pageId, width, height ){
	var stLocal			= {};
	
	stLocal.title		= title;
	stLocal.URL			= '/popupContent.cfm';
	stLocal.URL			= stLocal.URL + '?KeepThis=true&modal=false&id=' + pageId + '&TB_iframe=true&height=' + height + '&width=' + width;
	tb_show(stLocal.title, stLocal.URL, '');
}

/* partiesInit */
function partiesInit(){
	var stLocal			= {};
	
} 



/* 
	TWITTER WIDGET 
	ADDED BY MMG - 6.23.11 
*/
$(document).ready(function(){
  
  // js hack to show links on plan your party rather than modifying CF code
  // Added by J.Nolte 02.03.2012
  $("#partiesBottomContainer > a").attr('href', "http://s.sushisamba.com/plan-your-party/");

	/* Twitter plugin to load tweets */
    $(".tweet").tweet({
        username: "sushisamba",
        avatar_size: 32,
        count: 10
    });
    
   	/* Function to loop on interval. */
	function doTweet() {

    	var firstTweet = $('.tweet ul li:first'); // Get first tweet
    	
    	firstTweet.animate({opacity: 0}, 500).animate({marginTop: '-50px'}, 500, function() { // Animate out
    		$('.tweet ul').append( '<li>' +  firstTweet.html() + '</li>'); // Append to end of the list
    		firstTweet.remove(); // Remove the tweet from the list
    	});
    }
    
    setInterval(doTweet, 5000); // Interval.. every 5 secs
	
});
