jQuery(document).ready(function($){
	
	//wrap #header so that we can add an additional bg image
	$('#header').wrap('<div class="headerWrap" />');
	
	//wrap the #branding div in another div to place the red stripe
	//$('#branding').wrap('<div class="stripe" />');
	
	$('.menu .menu-item a').each(function(){
		var menuLabel = $(this).text().replace(" ", "");
		$(this).parent('li').addClass(menuLabel).addClass('tagged');
	});
	
	
	
	
	/***************************************************/
	//target events based on venue (inside or outside)
	
		//widget inside
		$('.eventWidgetListing .title .venueLine:contains("Indoor"),.eventWidgetListing .title .venueLine:contains("indoor"),.eventWidgetListing .title .venueLine:contains("inside"),.eventWidgetListing .title .venueLine:contains("inside")')
		.each(function(){
			$(this).closest('.eventWidgetListing').addClass('inside');
			$(this).parent().append('<span class="stage">inside</span>');	
		});
	
		//widget outside
		$(
		'.eventWidgetListing .title .venueLine:contains("Outdoor"),.eventWidgetListing .title .venueLine:contains("outdoor"),.eventWidgetListing .title .venueLine:contains("outside"),.eventWidgetListing .title .venueLine:contains("outside")'
		)
		.each(function(){
			$(this).closest('.eventWidgetListing').addClass('outside');
			$(this).parent().append('<span class="stage">outside</span>');	
		});
		
		
		//eventlist 4 inside
		$('.eventsList.type4 .mainInfo .venue .venueHidden:contains("Indoor"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("indoor"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("inside"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("inside")')
		.each(function(){
			var timez = $(this).closest('.event').find('.meta .section.misc').html();
			$(this).closest('.event').addClass('inside');
			$(this).parent().append('<span class="stageTime inside"><span class="stage">inside</span></span>');	
			$(this).parent().find('.stageTime').append("<span class='time'> / "+timez+"</span>");
			//$(this).parent().find('.stageTime').append("<span class='time'> / </span>");
		});
	
		//eventlist 4 outside
		$(
		'.eventsList.type4 .mainInfo .venue .venueHidden:contains("Outdoor"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("outdoor"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("outside"),.eventsList.type4 .mainInfo .venue .venueHidden:contains("outside")'
		)
		.each(function(){
			var timez = $(this).closest('.event').find('.meta .section.misc').html();
			$(this).closest('.event').addClass('outside');
			$(this).parent().append('<span class="stageTime outside"><span class="stage">outside</span></span>');	
			$(this).parent().find('.stageTime').append("<span class='time'> / "+timez+"</span>");
		});
		
		//events featured
		

	//end stage target
	/***************************************************/
	
	//featured carousel
	if($('.custom-featuredCarousel.multi .container-featuredEvents:visible').length){
		$('.custom-featuredCarousel.multi').append('<div class="navigation"><a id="carouselPrevious"><span>Previous</span></a><a id="carouselNext"><span>Next</span></a></div>');
		$('.custom-featuredCarousel.multi .container-featuredEvents').carousel('#carouselPrevious', '#carouselNext');
	}
	
	$('.custom-featuredCarousel .banner a').click(function(){
		$('#carouselNext').click();
		return false;
	});
		
	var showInside = false;
	var showOutside = false;
	if($('.eventFeatured.relative-tonight.inside').length){ showInside = true;}
	if($('.eventFeatured.relative-tonight.outside').length){ showOutside = true;}
	if(showInside && showOutside){
		$('.eventFeatured.relative-tonight.outside').addClass('hasInside');
		$('.eventFeatured.relative-tonight.inside').addClass('hasOutside');
		$('.eventFeatured.relative-tonight:eq(1)').addClass('secondShowTonight');
	}else{
		if( $('.eventFeatured.relative-tonight').length ){
			$('.eventFeatured.relative-tonight').addClass('onlyShow');
		}
	}
	
	$('.custom-featuredEvents.single .banner a').attr('href',$('.menu .ConcertListings a').attr('href'));
		
		
	//adjust the image size to fit in the carousel container
	$('.custom-featuredEvents .carouselCart').each(function(){
		var thisId = $(this).find('.eventFeatured').attr('id');
		var maxHeight = $(this).height();
		var actualHeight = $(this).find('.eventFeatured').outerHeight(true);
		var imageStartHeight = $('#'+thisId +' .eventImage img').outerHeight(true);
		var heightChange = actualHeight - maxHeight;
		//alert(thisId + ' ' + heightChange);
		if(heightChange > 0){
			var imageNewHeight = (imageStartHeight - heightChange) - 15;
			$(this).find(' .eventImage img').css('height',imageNewHeight+'px').css('width','auto');
		}
	});
	

});
