$(document).ready(function() {
	// Rounded Corners!
	//$('.contentBlock').corner('12px');
	//$('.newsBox').corner('12px');

	$("#ticketNav li").hover(	
		function() { $(this).removeClass("inactive").addClass("active"); },
		function() { $(this).removeClass("active").addClass("inactive"); }
	);
	
	// flash headers throughout site (using new dynamic detection method)
	$('.popup600x500').click(function() { 
		window.open( "popup.php", "myWindow", "status = 0, height = 500, width = 600, resizable = 0" );
		return false;
		});
		
	$('.popup450x500').click(function() {
	  window.open(this.href, "privacyPolicy", "status=0, height=500, width=450, resizable=0, scrollbars=yes");
	  return false;	
	});
	
	if($('#homeVideo').length > 0) {
	    var so = new SWFObject("../flash/BE_home_v12_blackquote.swf", "mymovie", "927", "550", "8", "#ffffff");
	    so.addParam("quality", "high");
	    so.addParam("wmode", "transparent");
	    so.write("homeVideo");
	}	
	
	if($('#homeVideo_staged').length > 0) {
		var so = new SWFObject("../flash/BE_home_041808.swf", "mymovie", "814", "550", "8", "#ffffff");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.write("homeVideo_staged");
	}	
	
	if($('#homeVideo_staged2').length > 0) {
		var so = new SWFObject("../flash/BE_home_042908.swf", "mymovie", "927", "550", "8", "#ffffff");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.write("homeVideo_staged2");
	}	
	
	if($('#newsVideo').length > 0) {
		   var so = new SWFObject("../flash/BE_news.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("newsVideo");
	}
	
	if($('#billysWorldVideo').length > 0) {
		   var so = new SWFObject("../flash/BE_billysWorld.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("billysWorldVideo");
	}
	
	if($('#aboutVideo').length > 0) {
		   var so = new SWFObject("../flash/BE_about.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("aboutVideo");
	}
	
	if($('#ticketsVid').length > 0) {
		   var so = new SWFObject("../flash/BE_tickets.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("ticketsVid");
			bindCalEvent();

	}
	
	if($('#castCreativeVideo').length > 0) {
		   var so = new SWFObject("../flash/BE_castcreative.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("castCreativeVideo");
	}
	
	if($('#castCreativeVideoStopped').length > 0) {
		   var so = new SWFObject("../flash/BE_castcreative_stopped.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("castCreativeVideoStopped");
	}
	
	if($('#sightsAndSoundsVideo').length > 0) {
		   var so = new SWFObject("../flash/BE_sightssounds.swf", "mymovie", "774", "346", "8", "#ffffff");
		   so.addParam("quality", "high");
		   so.write("sightsAndSoundsVideo");
	}
	
	if($('#cal').length) {
		bindCalEvent();
	}
	
	// activating quiz stuff
	if($('.quizQuestion').length > 0) {
		currentQuestion = 0;
		$('.quizQuestion li').click(function() {
			addNextOnce();
		})
		
		$('.quizQuestion input').focus(function() {
			$(this).parent().addClass('selected'); 
			$('.quizQuestion .selected').corner('10px');
		})
	
		$('.quizQuestion input').blur(function() {
			$(this).parent().removeClass('selected');
		})
	}
});

var cur = null;
function swap(id) {
  if($('#results').length > 0 && document.getElementById('results').style.display != 'none') { $('#results').fadeOut('fast'); }
  if(cur != id) {
    $('#' + (cur ? cur : 'billysWorld')).fadeOut('fast', function() {
      $('#' + id).fadeIn('slow');
    });
    cur = id;
  }
}

// addNextONCE
function addNextOnce() {
	// add next link
	if($('.quizQuestion:nth-child('+(currentQuestion+1)+') .nextLink').length == 0 && currentQuestion < 9) {
		$('<a href="#" class="nextLink"><img src="images/next_arrow.gif" alt="Next" /></a>').appendTo($('.quizQuestion')[currentQuestion]);
		
		// enable onclick event
		$('.quizQuestion:nth-child('+(currentQuestion+1)+') .nextLink').click(function() { 
						jumpSlide('.quizQuestion:nth-child('+(currentQuestion+2)+')','.quizBox',null,null);
						currentQuestion++;
						return false; });
	}

	// add prev link
	if($('.quizQuestion:nth-child('+(currentQuestion+1)+') .prevLink').length == 0 && currentQuestion < 10 && currentQuestion != 0) {
		$('<a href="#" class="prevLink"><img src="images/last_arrow.gif" alt="Previous" /></a>').appendTo($('.quizQuestion')[currentQuestion]);
		
		// enable onclick event
		$('.quizQuestion:nth-child('+(currentQuestion+1)+') .prevLink').click(function() { 
						jumpSlide('.quizQuestion:nth-child('+currentQuestion+')','.quizBox',null,null);
						currentQuestion--;
						return false; });
	}

}


function jumpSlide(slide,slider,trigger,slideNav) {
	var slideWidth = $(slide).outerWidth({margin: true});

	// get target's offset
	var targetOffset = $(slide).position().left;
	
	
	// divide offset by slide width to get slide diff & multiply it by slide width
	var moveAmount = (slideWidth*(targetOffset/slideWidth));
	
	// get target's height
	var slideHeight = $(slide).outerHeight();

	// slide slider and change height to fit target slide's height
	$(slider+" > div").animate({left: -moveAmount}, {'easing': 'swing', 'duration': 1500});
	//$(slider).animate({height: slideHeight},1500);
	
	// change states of triggers - turn all off
	$(slideNav+" > li").removeClass('active');
	
	// change states of triggers - turn active one on
	$(trigger).addClass('active');
}
function display(time)
{
}