if (typeof(console) == "undefined") { console = {}; } 
if (typeof(console.log) == "undefined") { console.log = function() { return 0; } }
// JavaScript Document
			var autoplayValue = 0; // Default youtube autoplay.
            // Serialization utility
            var serialize = function(obj, re) {
                var result = [];
                $.each(obj, function(i, val) {
                    if ((re && re.test(i)) || !re)
                        result.push(i + ': ' + (typeof val == 'object' ? val.join 
                            ? '\'' + val.join(', ') + '\'' : serialize(val) : '\'' + val + '\''));
                });
                return '{' + result.join(', ') + '}';
            };
			
            $.address.init(function(event) {
                console.log('init: ' + serialize({
                    value: $.address.value(), 
                    path: $.address.path(),
                    pathNames: $.address.pathNames(),
                    parameterNames: $.address.parameterNames(),
                    queryString: $.address.queryString()
                }));
				
            }).change(function(event) {
                console.log('change: ' + serialize(event, /parameters|parametersNames|path|pathNames|queryString|value/));
                var names = $.map(event.pathNames, function(n) {
                    return n.substr(0, 1).toUpperCase() + n.substr(1);
                }).concat(event.parameters.id ? event.parameters.id.split('.') : []);
                /*var links = names.slice();
                var match = links.length ? links.shift() + ' ' + links.join('.') : 'Home';
                $('a').each(function() {
                    $(this).toggleClass('selected', $(this).text() == match);
                });
                $.address.title([title].concat(names).join(' | '));
				*/
				if($.address.value() === "/trailer"){
					console.log("$.address.value() === trailer")
					autoplayValue = 1;
					doNav('trailer');
				} else if ($.address.value() === "/gallery"){
					console.log("$.address.value() === gallery")
					autoplayValue = 0;
					doNav('gallery');										
				}else if ($.address.value() === "/story"){
					console.log("$.address.value() === story")
					autoplayValue = 0;
					doNav('story');										
				} else if ($.address.value() === "/games"){
					console.log("$.address.value() === games")
					autoplayValue = 0;
					doNav('games');					
				} else {
					autoplayValue = 1;
					console.log("$.address.value() === default/trailer")
					doNav('trailer');
				}
            });



$(document).ready(function() {
	$(".numeric").numeric();
	$(function(){ 
			    // find all the input elements with title attributes
				$('input[title!=""]').hint();
			});
		$("#tS1").thumbnailScroller({ 
			scrollerType:"clickButtons", 
			scrollerOrientation:"horizontal", 
			scrollSpeed:2, 
			scrollEasing:"easeOutCirc", 
			scrollEasingAmount:600, 
			acceleration:4, 
			scrollSpeed:800, 
			noScrollCenterSpace:10, 
			autoScrolling:0, 
			autoScrollingSpeed:2000, 
			autoScrollingEasing:"easeInOutQuad", 
			autoScrollingDelay:500 
		});
		$("#tS2").thumbnailScroller({ 
			scrollerType:"clickButtons", 
			scrollerOrientation:"horizontal", 
			scrollSpeed:2, 
			scrollEasing:"easeOutCirc", 
			scrollEasingAmount:600, 
			acceleration:4, 
			scrollSpeed:800, 
			noScrollCenterSpace:10, 
			autoScrolling:0, 
			autoScrollingSpeed:2000, 
			autoScrollingEasing:"easeInOutQuad", 
			autoScrollingDelay:500 
		});
	// do stuff when DOM is ready
	// Set up the map/bio tabs
	$("#thumb0").css({'background-position': '0 -0px'});
	console.log("About to init nav");
	console.log("Address Value "+ $.address.value());
	//doNav('trailer');
	//doNav('gallery');
	Shadowbox.init();
	if( $.client.os == "Windows"){
		$('#header_social').css({'margin-right':'4px'});
	} else {
		$('#header_social').css({'margin-right':'17px'});
	}
	setReleaseDate();
	// IM GOING TOUT
	setCountdownClock();
	$(imGoingRollover).hide();
	var countdownInt = 	window.setInterval(setCountdownClock, 1000);
	$('#imGoingButton').hover(
		function(){
			$(imGoingRollover).show();
		},
		function(){
			//$(imGoingRollover).hide();
		}
	);
	$('#imGoingRollover').hover(
		function(){
			//$(imGoingRollover).show();
		},
		function(){
			$(imGoingRollover).hide();
		}
	);
	
	var $zip = $('#zipcode');
		$('#fandango').click(function(event){
				var zipURL = "http://www.fandango.com/thewomaninblack_136701/movietimes?location=";
				var overviewURL = "http://www.fandango.com/thewomaninblack_136701/movieoverview";
				if($zip.val() === "ZIP CODE"){
					window.open(overviewURL, 'tickets', 'toolbar=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes');
				} else {
					window.open(zipURL+$zip.val(), 'tickets', 'toolbar=yes,location=yes,menubar=no,resizable=yes,scrollbars=yes');
				}
				console.log($zip.val());
			});
		$('#movietickets').click(function(event){
				var zipURL = "http://www.movietickets.com/movie_detail.asp?movie_id=117659&tstate=3&rel=&mdGo=Go&SearchRadius=30&SearchZip=";
				var overviewURL = "http://www.movietickets.com/movie_detail.asp?movie_id=117659";
				if($zip.val() === "ZIP CODE"){
					window.open(overviewURL, 'tickets', 'toolbar=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes');
				} else {
					window.open(zipURL+$zip.val(), 'tickets', 'toolbar=yes,location=yes,menubar=no,resizable=yes,scrollbars=yes');
				}
				console.log($zip.val());
			});
});



function 	setCountdownClock(){
	var now = new Date();
	var releaseDate = new Date("February 03, 2012 00:00:00");	
	var miliseconds = releaseDate.getTime() - now.getTime();
	var days = ""+Math.floor((miliseconds / (60*60*24)) / 1000);
	var hours = ""+Math.floor((miliseconds / (60*60)) / 1000)% 24;
	var minutes = ""+Math.floor((miliseconds / (60)) / 1000) % 60;
	var seconds = ""+Math.floor((miliseconds ) / 1000) % 60;

	while(days.length <2){
		days = "0"+days;
	}
	while(hours.length <2){
		hours = "0"+hours;
	}
	while(minutes.length <2){
		minutes = "0"+minutes;
	}
	while(seconds.length <2){
		seconds = "0"+seconds;
	}
	if(miliseconds <=0){
		days = hours = minutes = seconds = "00";
		$('#countdown').hide();
	}
	$('#days').html(days);
	$('#hours').html(hours);		
	$('#minutes').html(minutes);
	$('#seconds').html(seconds);
	if(now.getTime() > releaseDate.getTime()){
		window.clearInterval(countdownInt);
		$('#countdown').hide();
	}

}
function setReleaseDate(){
	var releaseDateValue;
	var inTheaters= new Date("January 30, 2012 00:00:00");
	var nowPlaying = new Date("February 03, 2012 00:00:00");
	//inTheaters.setTime(Date.parse("01/30/2012"));
	//	nowPlaying.setTime(Date.parse("02/03/2012"));
	var now =  new Date();
	if (now.getTime() > nowPlaying.getTime()) {
		releaseDateValue = "Now Playing";		
	} else if (now.getTime() > inTheaters.getTime()) {
		releaseDateValue = "In Theaters Friday";
	} else {
		releaseDateValue = "IN THEATERS FEBRUARY 3, 2012";
	}
//	confirm("ReleaseDate"+releaseDateValue);
	$('#logo p').html(releaseDateValue);
	
	

	
	var $zip = $('#zipcode');
	$('#fandango').click(function(event){
			var zipURL = "http://www.fandango.com/thewomaninblack_136701/movietimes?location=";
			var overviewURL = "http://www.fandango.com/thewomaninblack_136701/movieoverview";
			if($zip.val() === "ZIP CODE"){
				window.open(overviewURL, 'tickets', 'toolbar=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes');
			} else {
				window.open(zipURL+$zip.val(), 'tickets', 'toolbar=yes,location=yes,menubar=no,resizable=yes,scrollbars=yes');
			}
			console.log($zip.val());
		});
	$('#movietickets').click(function(event){
		
	
			var zipURL = "http://www.movietickets.com/movie_detail.asp?movie_id=117659&tstate=3&rel=&mdGo=Go&SearchRadius=30&SearchZip=";
			var overviewURL = "http://www.movietickets.com/movie_detail.asp?movie_id=117659";
			if($zip.val() === "ZIP CODE"){
				window.open(overviewURL, 'tickets', 'toolbar=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes');
			} else {
				window.open(zipURL+$zip.val(), 'tickets', 'toolbar=yes,location=yes,menubar=no,resizable=yes,scrollbars=yes');
			}
			console.log($zip.val());
		});
}
/* jQuery.noConflict() for using the plugin along with other libraries. 
   You can remove it if you won't use other libraries (e.g. prototype, scriptaculous etc.) or 
   if you include jQuery before other libraries in yourdocument's head tag. 
   [more info: http://docs.jquery.com/Using_jQuery_with_Other_Libraries] */
//jQuery.noConflict(); 
/* calling thumbnailScroller function with options as parameters */
/*
(function($){
	
window.onload=function(){ 
	$("#tS1").thumbnailScroller({ 
		scrollerType:"clickButtons", 
		scrollerOrientation:"horizontal", 
		scrollSpeed:2, 
		scrollEasing:"easeOutCirc", 
		scrollEasingAmount:600, 
		acceleration:4, 
		scrollSpeed:800, 
		noScrollCenterSpace:10, 
		autoScrolling:0, 
		autoScrollingSpeed:2000, 
		autoScrollingEasing:"easeInOutQuad", 
		autoScrollingDelay:500 
	});
	$("#tS2").thumbnailScroller({ 
		scrollerType:"clickButtons", 
		scrollerOrientation:"horizontal", 
		scrollSpeed:2, 
		scrollEasing:"easeOutCirc", 
		scrollEasingAmount:600, 
		acceleration:4, 
		scrollSpeed:800, 
		noScrollCenterSpace:10, 
		autoScrolling:0, 
		autoScrollingSpeed:2000, 
		autoScrollingEasing:"easeInOutQuad", 
		autoScrollingDelay:500 
	});
}
})(jQuery);
*/
function doNav(pagename){
	//$(".tabs:eq(0)").attr("src", "images/tab_trailer_seleceted.png");	
	$('.tabs img:eq(0)').attr("src", "images/tab_games_deselected.png");
	$('.tabs img:eq(1)').attr("src", "images/tab_story_deselected.png");
	$('.tabs img:eq(2)').attr("src", "images/tab_gallery_deselected.png");
	$('.tabs img:eq(3)').attr("src", "images/tab_trailer_deselected.png");
	$('.tabs img:eq(0)').css({'position':'relative', 'top':'0px'});
	$('.tabs img:eq(1)').css({'position':'relative', 'top':'0px'});
	$('.tabs img:eq(2)').css({'position':'relative', 'top':'0px'});
	$('.tabs img:eq(3)').css({'position':'relative', 'top':'0px'});
	if(pagename == "trailer"){
		$('#video').show();
		$('#gallery').hide();
		$('#story').hide();	
		$('#games').hide();	
		$('.tabs img:eq(3)').attr("src", "images/tab_trailer_selected.png");
		$('.tabs img:eq(3)').css({'position':'relative', 'top':'-5px'});
		_gaq.push(['_setAccount', 'UA-25281243-1']);
		_gaq.push(['_trackEvent', 'Tabs', 'Clicked', 'Videos']);		
		$.address.value("trailer");
	} else 	if(pagename == "gallery"){
		$('#video').hide();
		$('#gallery').show();
		$('#story').hide();
		$('#games').hide();		
		stopVideo();
		$('.tabs img:eq(2)').attr("src", "images/tab_gallery_selected.png");
		$('.tabs img:eq(2)').css({'position':'relative', 'top':'-5px'});
		_gaq.push(['_setAccount', 'UA-25281243-1']);
		_gaq.push(['_trackEvent', 'Tabs', 'Clicked', 'gallery']);
		$.address.value("gallery");
		/*
		$("#tS2").thumbnailScroller({ 
			scrollerType:"clickButtons", 
			scrollerOrientation:"horizontal", 
			scrollSpeed:2, 
			scrollEasing:"easeOutCirc", 
			scrollEasingAmount:600, 
			acceleration:4, 
			scrollSpeed:800, 
			noScrollCenterSpace:10, 
			autoScrolling:0, 
			autoScrollingSpeed:2000, 
			autoScrollingEasing:"easeInOutQuad", 
			autoScrollingDelay:500 
		});
		*/
	} else 	if(pagename == "story"){
		$('#video').hide();
		$('#gallery').hide();
		$('#story').show();	
		$('#games').hide();	
		stopVideo();
		$('.tabs img:eq(1)').attr("src", "images/tab_story_selected.png");
		$('.tabs img:eq(1)').css({'position':'relative', 'top':'-5px'});
		_gaq.push(['_setAccount', 'UA-25281243-1']);
		_gaq.push(['_trackEvent', 'Tabs', 'Clicked', 'story']);
		$.address.value("story");
	}	else 	if(pagename == "games"){
		$('#video').hide();
		$('#gallery').hide();
		$('#story').hide();	
		$('#games').show();	
		stopVideo();
		$('.tabs img:eq(0)').attr("src", "images/tab_games_selected.png");
		$('.tabs img:eq(0)').css({'position':'relative', 'top':'-5px'});
		_gaq.push(['_setAccount', 'UA-25281243-1']);
		_gaq.push(['_trackEvent', 'Tabs', 'Clicked', 'games']);
		$.address.value("games");
	}
}

<!-- YOUTUBE -->
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
	player = new YT.Player('player', {
	  height: '456',
	  width: '891',
	  videoId: 'UBn_a7VaMd4',
	  
	   playerVars: { 'autoplay':autoplayValue , 'rel': 0 },
	  events: {
		'onReady': onPlayerReady,
		'onStateChange': onPlayerStateChange
	  }
	});
}

// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
	player.setPlaybackQuality("hd720");
	if(autoplayValue === 1){
		event.target.playVideo();
	}
}

// 5. The API calls this function when the player's state changes.
//    The function indicates that when playing a video (state=1),
//    the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
	/*
	YT.PlayerState.ENDED
	YT.PlayerState.PLAYING
	YT.PlayerState.PAUSED
	YT.PlayerState.BUFFERING
	YT.PlayerState.CUED
	*/
	if (event.data == YT.PlayerState.PLAYING && !done) {
	  //setTimeout(stopVideo, 6000);
	  done = true;
	}
	if (event.data == YT.PlayerState.ENDED){
		console.log("PLAY ENDED:" + _gaq);
		// MAKE TRACKING CALL HERE FOR COMPLETE VIEW.	
		var videoID = 'Video URL: '+ escape(player.getVideoUrl());
		_gaq.push(['_setAccount', 'UA-25281243-1']);
		_gaq.push(['_trackEvent', 'Videos', 'Completed', videoID]);
	}
}

function stopVideo() {
	player.stopVideo();
}

function onThumbnailClicked(value){
	//console.log(value);
	var videoID;
	$("#thumb0").css({'background-position': '0 -87px'});
	$("#thumb1").css({'background-position': '0 -87px'});
	$("#thumb2").css({'background-position': '0 -87px'});		
	$("#thumb3").css({'background-position': '0 -87px'});		
	$("#thumb4").css({'background-position': '0 -87px'});		
	$("#thumb5").css({'background-position': '0 -87px'});		
	$("#thumb6").css({'background-position': '0 -87px'});		
	$("#thumb7").css({'background-position': '0 -87px'});		
	
	if(value == 0){
		videoID = "UBn_a7VaMd4";
		$("#thumb0").css({'background-position': '0 -0px'});
	} else if(value == 1){		
		$("#thumb1").css({'background-position': '0 -0px'});
		videoID = "L6k9f8QDrpc";
	} else if(value == 2){
		$("#thumb2").css({'background-position': '0 -0px'});
		videoID = "z4D-87X3vVc";
	} else if(value == 3){
		$("#thumb3").css({'background-position': '0 -0px'});
		videoID = "CV6E3PtAd4I";
	} else if(value == 4){
		$("#thumb4").css({'background-position': '0 -0px'});
		videoID = "iJMKE_fjRsY";
	} else if(value == 5){
		$("#thumb5").css({'background-position': '0 -0px'});
		videoID = "3fFdM-VPMaE";
	} else if(value == 6){
		$("#thumb6").css({'background-position': '0 -0px'});
		videoID = "4g6Jza4ZI90";
	} else if(value == 7){
		$("#thumb7").css({'background-position': '0 -0px'});
		videoID = "";
	}
	player.loadVideoById(videoID);	
}
var galleryIndex = 0;
function onGalleryThumbnailClicked(value){
	if(value == 0){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_01_small.jpg");
	} else 	if(value == 1){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_02_small.jpg");
	} else 	if(value == 2){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_03_small.jpg");
	} else 	if(value == 3){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_04_small.jpg");
	}else 	if(value == 4){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_05_small.jpg");
	}else 	if(value == 5){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_06_small.jpg");
	}else 	if(value == 6){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_07_small.jpg");
	//}else 	if(value == 7){
		//$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_08_small.jpg");
	}else if(value == 7){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_09_small.jpg");
	}else 	if(value == 8){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_10_small.jpg");
	}else 	if(value == 9){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_11_small.jpg");
	}else 	if(value == 10){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_12_small.jpg");
	}else 	if(value == 11){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_13_small.jpg");
	}else 	if(value == 12){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_14_small.jpg");
	}else 	if(value == 13){
		$('#galleryViewer img:eq(0)').attr("src", "images/gallery/photo_15_small.jpg");
	}
	galleryIndex = value;
}
function galleryViewLarge(){
	//console.log("galleryIndex:"+galleryIndex);
	Shadowbox.open([
		{content:'images/gallery/photo_01_full.jpg', player:'img', gallery:'photos', options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_02_full.jpg', player:'img', gallery:'photos', options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_03_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_04_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_05_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_06_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_07_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_09_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_10_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_11_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_12_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}},
		{content:'images/gallery/photo_13_full.jpg', player:'img', gallery:'photos',options:{counterType:'skip', continuous:true}}		
		]);
	Shadowbox.change(galleryIndex);
}


