//list of upcoming artists. enables buy tix links 
var artistList = new Array("McBride");

jQuery(document).ready(function($) {	
	parseURLParams();
	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbsSRO ul.thumbs li').css('opacity', onMouseOutOpacity)
	.hover(
		function () {
			$(this).not('.selected').fadeTo('fast', 1.0);
		}, 
		function () {
			$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
		}
	);
			
			
			
	// Initialize Advanced Galleriffic Gallery
	var galleryAdv = $('#gallerySRO').galleriffic('#thumbsSRO', {
					delay:                  2500,
					numThumbs:              quanThumbs,
					preloadAhead:           10,
					enableTopPager:         true,
					enableBottomPager:      true,
					imageContainerSel:      '#slideshowSRO',
					controlsContainerSel:   '#controlsSRO',
					captionContainerSel:    '#captionSRO',
					loadingContainerSel:    '#loadingSRO',
					renderSSControls:       true,
					renderNavControls:      true,
					playLinkText:           'Play',
					pauseLinkText:          'Pause',
					prevLinkText:           ' ',
					nextLinkText:           ' ',
					nextPageLinkText:       'Next &rsaquo;',
					prevPageLinkText:       '&lsaquo; Prev',
					enableHistory:          true,
					autoStart:              false,
					onChange:               function(prevIndex, nextIndex) {
						$('#thumbsSRO ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
						swapContent(prevIndex,nextIndex);
												
							
					},
					onTransitionOut:        function(callback) {
						$('#slideshowSRO, #captionSRO').fadeOut('fast', callback);
					},
					onTransitionIn:         function() {
						$('#slideshowSRO, #captionSRO').fadeIn('fast');
						initContactLinks();
					},
					onPageTransitionOut:    function(callback) {
						$('#thumbsSRO ul.thumbs').fadeOut('fast', callback);
					},
					onPageTransitionIn:     function() {
						$('#thumbsSRO ul.thumbs').fadeIn('fast');
					}
	});
				

});
			

function swapContent(prevIndex,nextIndex){
	var theSelector = '#thumbsSRO li:eq('+ nextIndex+ ')',
	theDir = $(theSelector).attr('class'),
	theType= $(theSelector).attr('data-type');
	
	//LOG(theType);
	
	if(theType=="book"){
		$("#SROheadline").attr("src", "/sro/images/SRO-book-headline.gif");
	}else{
		$("#SROheadline").attr("src", "/sro/images/SRO-headline.gif");

	}

	//duplicate the arrows up higher for IE/small screens
	if( $('div.ss-controls a.play').text()=="Play"){
		//remove any previously duplicated arrows
		$('.clone').remove();
		//then add clone arrows
		$('#outerWrapper .nav-controls').clone().prependTo('#controlsSRO').addClass('clone');
	}
	
	//ditto play/pause
	//$('#outerWrapper .ss-controls').clone().prependTo('#controlsSRO').addClass('clone');
	
	
	
	
	
	//fade out
	$("#sroContent").animate({ opacity: 0.0 }, 500, function(){
		//load content
		var ajaxURL = "/sro/" + theDir + "/content-inc.shtml"
		$("#sroContent").load(ajaxURL).animate({  opacity: 1.0 }, 500, function(){
			//re-attach thickbox to ajax content
			tb_init('#sroButtonGroup .thickbox,  #sroSideBox .thickbox');
			
			//re-attach lightbox to ajax content (balupton ed. kills page)
			//removed @ in a[@rel*= as it is incompatible w/jquery 1.3
			$("#sroButtonGroup a[rel*=lightbox]").lightBox();
 


		});	
	} );
	
	
	//track SRO hits by artist name (will result in double counting, since page is tracked anyway)
   	var thisHref="/sro/" + theDir;
   	pageTracker._trackPageview(thisHref);


	
	//fix buy tix buttons/urls
	var tixURL="";
	//compare theDir to array of upcoming artists
	for(var i = 0; i < artistList.length; i++) {
		//alert(artistList[i] +" "+ theDir);
		if(artistList[i]==theDir) {
			//alert('match');
			tixURL= "https://www.omansion.com/museum/sro/reservation.shtml?Event="+theDir //+"/Dinner";
			
			//if(theDir=="Leavell"){$('.times730').hide();$('.times530').show();}else{$('.times530').hide();$('.times730').show();}
			
		}
	}

	//if not an upcoming artist
	if(tixURL==""){
		//hide .buyTix 
		$('.buyTix').hide();
	}else{
		//upcoming, show button AND set link
		$('.buyTix').show().attr('href',tixURL);
	}
	
	
}			




function parseURLParams(){
	var tb = unescape($.getURLParam("tb"));
	var width = unescape($.getURLParam("width"));
	var height = unescape($.getURLParam("height"));
	if(width =="null"){width =  "900"}	
	if(height =="null"){height =  "450"}
	
	if(tb !="null"){
		tbURL = tb + "?width="+width+"&height=" + height;
		tb_show("", tbURL, null);
	}
}


