jQuery(document).ready(function ready($) {	
	jQuery('#storyCarousel').jcarousel({
      	scroll: 8,
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: storyCarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: storyCarousel_itemVisibleOutCallback}
    });

 	//track billboard hits
   	$("#billboardContent a").click(function () {
   		var thisHref=$(this).attr('href');
   		thisHref= window.location.pathname + thisHref;
   		//pageTracker._trackPageview(thisHref);
   		_gaq.push(['_setAccount', 'UA-131466-7']);
		_gaq.push(['_trackPageview']);
   		
   		}
   	); 



	$('#billboardContent').attr({scrollTop:0,scrollLeft:0});   
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#billboardContent', //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1500
	});
	
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#billboardContent', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});    

	//hotel page, view details popup
	$("#boxThree a.popup").click(function () {
   		var thisHref= $(this).attr('href');
     	displayWindow(thisHref, 550, 800,1);
     	return false;
    });   

	
	
});






var storyCarousel_itemList = [
    {url: '/weddings_and_parties/guests/images/arlo.jpg', title: 'arlo guthrie', href:'/experiences/guthrie/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/harris.jpg', title: 'emmylou harris', href:'/experiences/harris/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/williams.jpg', title: 'paul &amp; m williams', href:'/experiences/williams/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/shaw.jpg', title: 'tommy shaw', href:'/experiences/shaw/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/gowan.jpg', title: 'lawrence gowan', href:'/experiences/gowan/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/studs.jpg', title: 'studs terkel', href:'/experiences/terkel/', popup:'yes'},
    {url: '/weddings_and_parties/guests/images/bebe.jpg', title: 'bebe kooper', href:'/hotel/?picker=guests'}
 ];

function storyCarousel_itemVisibleInCallback(carousel, item, i, state, evt){
    var idx = carousel.index(i, storyCarousel_itemList.length);
    carousel.add(i, storyCarousel_getItemHTML(storyCarousel_itemList[idx - 1]));
};

function storyCarousel_itemVisibleOutCallback(carousel, item, i, state, evt){carousel.remove(i);};


function storyCarousel_getItemHTML(item){
var isPopup=item.popup;
var thisHTML="";

if (isPopup=='yes'){


    return  '<a href="#" onclick="displayWindow(\''+ item.href+'\',320,800,1)"><img src="' + item.url + '" width="94" height="88" alt="' + item.title + '" /><p>' +item.title+'</p></a>';
	//if you want to do this, look at the old code for the itsallhere js file
	//    return  '<a href="'+item.href+'?width=320&height=500" class="thickbox"><img src="' + item.url + '" width="94" height="88" alt="' + item.title + '" /><p>' +item.title+'</p></a>';
	//tb_init(DOMitem);


}else{

    thisHTML=  '<a href="'+item.href+'"><img src="' + item.url + '" width="94" height="88" alt="' + item.title + '" /><p>' +item.title+'</p></a>';
}
return thisHTML;

};



