/* JQuery */
	
$(document).ready( function() {
	
	/* Countdown Timer */
	function curtainsUp() {
		document.getElementById('defaultCountdown').innerHTML = "It's showtime!";
	}
	
	var showTime = new Array();
	
	// Blood Brothers
	showTime[0] = "Oct 29 2009 19:30:00";
	showTime[1] = "Oct 30 2009 19:30:00";
	showTime[2] = "Oct 31 2009 19:30:00";

	// Boogie Nights
	//showTime[x] = "Oct 29 2009 19:30:00";
	
	// Set myClock to the current time
	var myClock = new Date();
	var theEnd = "False";
	
	// Loop array
	for (x in showTime) {
		if (theEnd = "False") {
			if (Date.parse(myClock) < Date.parse(showTime[x])) {
				var timeMachine = new Date(showTime[x]);
				var tmYear = (timeMachine.getFullYear());
				var tmMonth = (timeMachine.getMonth());
				var tmDay = (timeMachine.getDate());
				var tmHour = (timeMachine.getHours());
				var tmMinute = (timeMachine.getMinutes());
				break;
			}
		}
	}
	
	var nextShow = new Date()
	nextShow = new Date(tmYear,tmMonth,tmDay,tmHour,tmMinute);	
	
	if ($("#defaultCountdown").length > 0) {
		$("#defaultCountdown").countdown({
			until: nextShow,
			format: 'dHM',
			layout: '<strong>The next show start in:</strong><br />{dn} <span class="tmLabel">{dl}</span> {hn} <span class="tmLabel">{hl}</span>  {mn} <span class="tmLabel last">{ml}</span>',
			onExpiry: curtainsUp
		});
	}

    $('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	
	if ($(".dynamicItem").length > 0) {
		$(".dynamicItem").quickpaginate({
			perpage: 5,
			showcounter: false,
			pager: $(".dynamicItem_counter")
		});
	}

	if ($(".galleryRow").length > 0) {
		$(".galleryRow").quickpaginate({
			perpage: 3,
			showcounter: false,
			pager: $(".galleryRow_counter")
		});
	}
	
	if ($("#newsletter").length > 0) {
		$("#newsletter").validate();
	}
	
	if ($(".gallery").length > 0) {
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.7, /* Value betwee 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: ' of ', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
		});
	}

	
	
});


