var theMaxImages							= 0;
var serverPath								= new String("");
var greetingId								= 0;
var savedHash								= "";
var autoPlayChapter							= false;
var safariBrowser							= false;
var theDuration								= 0;
var loadingCtn								= 0;
var thePromotion							= "";

function initializeVP(maxImages) {
	theMaxImages							= maxImages;
}

function loadGreeting() {
	if ( loadingCtn >= 100 ) {
		loadingCtn						= 0;
		startGreeting();
		return;
	}
	
	$("#progressbar").reportprogress(++loadingCtn);
	setTimeout("loadGreeting()",		100);
}

function initializeDefaults(server, greeting, hash, duration, promotionPath) {
	serverPath								= server;
	greetingId								= greeting;
	savedHash								= hash;
	thePromotion							= promotionPath;
}

function startShow() {
	showGreeting();
}

function showIntro() {
	showGreeting();
}

function stopShow() {
	var mov									= getFlashMovie("theProjectPlayer");
	mov.stopTheMovie();
}

function showGreeting() {
	var mov									= getFlashMovie("theProjectPlayer");
	
	mov.initializePromotion(serverPath, 	thePromotion);
	mov.loadGreeting(serverPath, greetingId, savedHash, theDuration);
}

function chapterEnd() {
	if ( autoPlayChapter ) {
		showGreeting();
	}
	
	var mov									= getFlashMovie("theProjectPlayer");
	mov.showPromotion();
}

function getPromotionNow(idx) {
	var mov									= getFlashMovie("theProjectPlayer");
	var theURL								= mov.getPromotionLink(idx); 
	if ( theURL != "" ) {
		window.location.href				= theURL;
	}
}

function getPromotion(idx) {
	setTimeout("getPromotionNow("+idx+")", 1);
}

