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

});


var storyCarousel_itemList = [
    {url: '/community/starpower/picker/mini/i/arlo.jpg', title: 'arlo guthrie', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/harris.jpg', title: 'emmylou harris', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/winchester.jpg', title: 'Jesse Winchester', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/leavell.jpg', title: 'Chuck Leavell', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/drescher.jpg', title: 'fran drescher', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/souther.jpg', title: 'JD Souther', href:'/community/starpower/Souther/'},
    {url: '/community/starpower/picker/mini/i/williams.jpg', title: 'paul &amp; m williams', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/shaw.jpg', title: 'tommy shaw', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/gowan.jpg', title: 'lawrence gowan', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/studs.jpg', title: 'studs terkel', href:'/community/coming-soon.shtml'},
    {url: '/community/starpower/picker/mini/i/parnell.jpg', title: 'lee roy parnell', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/miller.jpg', title: 'buddy miller', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/thornton.jpg', title: 'billy bob thornton', href:'/community/coming-soon.shtml'},

	{url: '/community/starpower/picker/mini/i/tucker.jpg', title: 'chris tucker', href:'/community/coming-soon.shtml'},

	{url: '/community/starpower/picker/mini/i/amos.jpg', title: 'shawn amos', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/baxter.jpg', title: 'skunk baxter', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/bishop.jpg', title: 'bonnie bishop', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/blades.jpg', title: 'jack blades', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/bonamassa.jpg', title: 'joe bonamassa', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/browne.jpg', title: 'jackson browne', href:'/community/coming-soon.shtml'},
	
	{url: '/community/starpower/picker/mini/i/akon.jpg', title: 'akon', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/griffin.jpg', title: 'patty griffin', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/atwood.jpg', title: 'magaret atwood', href:'/community/coming-soon.shtml'},


	{url: '/community/starpower/picker/mini/i/bryan.jpg', title: 'mark bryan', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/chaise.jpg', title: 'chaise lounge', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/cordell.jpg', title: 'cordell', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/dixon.jpg', title: 'don dixon', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/escovedo.jpg', title: 'alejandro escovedo', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/g.jpg', title: 'kenny g', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/graham.jpg', title: 'jon dee graham', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/harvey.jpg', title: 'billy harvey', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/howle.jpg', title: 'danielle howle', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/jackson.jpg', title: 'michael jackson', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/kooper.jpg', title: 'al kooper', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/kravitz.jpg', title: 'lenny kravitz', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/madison.jpg', title: 'madison violet', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/matt.jpg', title: 'matt the electrician', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/mcbride.jpg', title: 'molly mcbride', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/miller.jpg', title: 'buddy miller', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/moore.jpg', title: 'sam moore', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/phil.jpg', title: 'Punxsutawney Phil', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/scanlin.jpg', title: 'Doc Scanlin &amp; his Orchestra', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/sguthrie.jpg', title: 'sarah lee guthrie', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/spero.jpg', title: 'bear', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/troy.jpg', title: 'no second troy', href:'/community/coming-soon.shtml'},
	{url: '/community/starpower/picker/mini/i/wilkins.jpg', title: 'walt wilkins', href:'/community/coming-soon.shtml'},

    {url: '/community/starpower/picker/mini/i/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);
 	var thisItem = storyCarousel_itemList[idx - 1];  
 	//	if(window.console){console.log('storyCarousel_itemVisibleInCallback')};

	 $("a[href*=/forms/]","#storyCarousel").click(function() {
		//alert('hi');
		var myURL =  this.href;
		var theseParams = parseGetVars(myURL);
		var thisDept = unescape(theseParams['department']);
		var thisSubject = unescape(theseParams['subject']);
		var thisBody = unescape(theseParams['body']);
		//alert(thisDept);

			
		// Pass a value to thickbox window by updating parent page's hidden form field	
		// set the value of the hidden form field id='dept' in the calling page
		// to the 'department' value captured from the link clicked on, that is now stored in the var 'thisDept'
		//document.getElementById("dept").value = thisDept;
		document.globalStorage.field1.value = thisDept;
		document.globalStorage.field2.value = thisSubject;
		document.globalStorage.field3.value = thisBody;
	});	
 	
  	
    var thisItemHTML = storyCarousel_getItemHTML(thisItem,thisItem.thickbox,thisItem.complex) ;    
    var thisWidth = item.width;
    var thisHeight = item.height;
    // Create an object from HTML
    var DOMitem = jQuery(thisItemHTML).get(0);

 	
 	//Bubbles
 	if(thisItem.bubble){
		//initialize bubble
		var theSel= "#" + thisItem.bubble + " div.bubble";
		if(BrowserDetect.browser=="Explorer"){
 	 
 	  		$(DOMitem).hover(
				//ie(even 8) can't handle animating the opacity of a png with an alpha channel
      			function () {$(theSel).attr("style", "display:block");}, 
      			function () {}
    		);
  
		}else{
	 	
			$(DOMitem).hover(
				function () {$(theSel).fadeIn('fast');}, 
				function () {}
		);
	}
	}

 	 //Thickboxes
 	if(thisItem.thickbox){
 	
 	if(thisItem.complex!="yes"){
 		//Simple thickboxes
   		tb_init(DOMitem);
  	}else{
       	 //Complex thickboxes
       	if(BrowserDetect.browser=="Safari"||BrowserDetect.browser=="Chrome"){
       		//Safari and Chrome do popup
       		$(DOMitem).click(function () {
       			var thisHref= $(this).attr('href');
   				displayWindow(thisHref, 930,490,0);
   				return false;
   			});
       	}else{
         	//Complex thickboxes, FF, IE
			tb_init(DOMitem);
		}  
  	}
  	}
  	
	carousel.add(i, DOMitem);};

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;
};

