// JavaScript Document

//boolean for quotes
var showQuotes = true;

//boolean for tickets
var showTickets = true;


function init ()
{
	if(showQuotes)
	{
		setTimeout(function(){
		$.ajax({
			type: "GET",
			url: "assets/xml/reviews.xml",
			dataType: "xml",
			success: parseXml
		});
		},5000);
	}
	if(showTickets)
	{
		setTimeout(function(){
			$('#ticket_slogan_wrapper').fadeIn(500);
		},5000);
	}
}
function openTweetWin (url) {
	window.open(url, '', 'width=550,height=450,toolbar=no,scrollbars=no');
}
function openReg() {
	window.open('pops/register/', '', "width=466,height=559,toolbar=no,scrollbars=no");
}
function shareTwitterIpad($dateStr){
	openTweetWin("http://twitter.com/intent/tweet?d=0&text=The%20Devil%20Inside%20-%20"+$dateStr+"%20%40TweetYourScream%20http%3A%2F%2Fwww.devilinsidemovie.com%2F");
}
function shareFacebookIpad($dateStr){
	shareFacebook("http%3A%2F%2Fwww.devilinsidemovie.com%2F","No soul is safe. Watch this video for The Devil Inside on the official movie site. "+$dateStr+". Like us on http%3A%2F%2Fwww.Facebook.com%2FTheDevilInsideMovie");
}
var filmCreditsOn = false;
function showCredits()
{
	filmCreditsOn = !filmCreditsOn;
	
	if( filmCreditsOn )
	{
		$('#filmCredits').fadeIn();
	} else {
		$('#filmCredits').fadeOut();
	}
		
}
function hideCredits()
{
	filmCreditsOn = false;
	$('#filmCredits').fadeOut();
}
function showRestricted()
{
	window.location = "restricted/";
}
function showRestrictedTrailer()
{
	window.open('http://www.traileraddict.com/trailer/the-devil-inside/red-band-trailer', '');
}
function getApp()
{
	window.open('http://itunes.apple.com/us/app/the-devil-inside/id488969562?mt=8', '');
}
function showHoliday()
{
	window.open('http://www.holidaycards2011.com', '');
}
function showRossi()
{
	window.open('http://www.therossifiles.com/', '');
}

var reviews = [];
var curr_review = 0;

function parseXml(xml)
{
	
  $(xml).find("reviews").each(function()
  {
	var review = $(this).attr("review");
	var author = $(this).attr("author");
	reviews.push({'review':review,'author':author});
  });
  
  var htmlStr = (reviews[curr_review].author.length>1) ? '"'+reviews[curr_review].review+'"' : '<strong>'+reviews[curr_review].review+'</strong>';
  $('#ticker_review_top').html(htmlStr);
  
  var htmlStr2 = (reviews[curr_review].author.length>1) ? '- '+reviews[curr_review].author : reviews[curr_review].author;
  $('#ticker_review_bottom').html(htmlStr2);
  
  setTimeout(getNextReview,8000);
  
  $('#reviews').fadeIn(500);
  
}

function getNextReview(){
	setTimeout(getNextReview,8000);
	
	curr_review++;
	if(curr_review >= reviews.length){
		 curr_review = 0;	
	}
	 
	$('#ticker_review').fadeOut(500,function() {
		// Animation complete. 
		 var htmlStr = (reviews[curr_review].author.length>1) ? '"'+reviews[curr_review].review+'"' : '<strong>'+reviews[curr_review].review+'</strong>';
  $('#ticker_review_top').html(htmlStr);
  
  var htmlStr2 = (reviews[curr_review].author.length>1) ? '- '+reviews[curr_review].author : reviews[curr_review].author;
  $('#ticker_review_bottom').html(htmlStr2);
		 $('#ticker_review').fadeIn(500);
	});
}


init();
