// DEFINE GLOBAL vars
var friend_id = 0;
var friend_pid = "";
var	friend_purl = "";
var friend_photos = new Array();
var	friend_rid = 0;

var victim_id = 0;
var victim_guess = 0;
var victim_aid = 0;
var victim_last_chance = "false";

var site_lang = "en";	// values : en / fr
var site_age = 0;

var current_title;


// *** FNCS PERMANENTS (DO NOT CHANGE) JS -> FLASH

function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];  
}

function callFlashSetBackgroundId(bgid) {
	getFlashMovie("backgroundFlash").setBackgroundId(bgid);
}

function callFlashSetTitle(title, description)
{
	getFlashMovie("backgroundFlash").setTitleAndDescription(title, description);
}

function callFlashOpenPhotoEditor(fbid, fbphotourl) {
	getFlashMovie("backgroundFlash").openPhotoEditor(fbid, fbphotourl);
}

function callFlashCatchError(errorString) {
	getFlashMovie("backgroundFlash").catchError(errorString);
}

function callFlashOpenClues() {
	getFlashMovie("backgroundFlash").openClues();
}

function callFlashBackToClues() {
	// hide box, and send back to clues
	$('box1').hide();
	getFlashMovie("backgroundFlash").backToClues();
}

function callFlashVictimGoHome() {
	// hide box, reset vars and show homepage
	$('box1').hide();
	
	victim_id = 0;
	victim_guess = 0;
	victim_aid = 0;
	victim_last_chance = "false";

	getFlashMovie("backgroundFlash").victimGoHome();
}

function callFlashHidePage() {
	getFlashMovie("backgroundFlash").hidePage();
}

function callFlashAssassinGoHome() {
	// hide box, reset vars and show homepage
	$('box1').hide();
	
	friend_id = 0;
	friend_pid = "";
	friend_purl = "";
	friend_photos = new Array();
	friend_rid = 0;
	
	getFlashMovie("backgroundFlash").assassinGoHome();
}

function callFlashHideTopLayer() {
	getFlashMovie("backgroundFlash").hideTopLayer();
}

function callFlashShowTopLayer() {
	getFlashMovie("backgroundFlash").showTopLayer();
}


//*** JS FNCS : global

function acCloseBox1() {
	$('box1').hide();
}

function acCloseBox2() {
	$('box2').hide();
	callFlashHideTopLayer();
}


//*** JS FNCS : age gate

function acSetAgeLang(age, lang) {
	// call ajax, save session in php ...
	//alert("acSetAgeLang >> " + age + " , " + lang);
	
	// set cookie + global vars
	createCookie("ac2_ageLang", age + '||' + lang, '');
	
	// update global vars
	site_age = age;
	site_lang = lang;
}

function acGetAgeLang() {
	// check if user has a cookie, and return contents
	var cookieval;
	cookieval = readCookie("ac2_ageLang");
	
	//alert("acGetAgeLang >>");
	if ( !cookieval ) { return -1; }
	else return cookieval;
}


//*** JS FNCS : facebook login

//Event Handlers : Login to FB success
function acOnLoginHandler(){
	acOpenDiv("assassinfacebookfriends");
}

//Event Handlers : Login to FB success
function acVictimOnLoginHandler() {
	//alert(victim_id);
	// start ajax request
	new Ajax.Request('php/victim_validate.php', {

		parameters: { site_lang: site_lang, victim_id: victim_id },
		onSuccess: function(transport) {
			
			// load the response, and convert JSON into regular array
			var response = transport.responseText;
			var jsonObj = response.evalJSON();
			
			// verify validation status 
			if (jsonObj.status == 'ok') {
				// go to victim clues page
				callFlashOpenClues();
			} else {
				// error
				callFlashVictimGoHome();
			}
			
		},
		onFailure: function() {
			alert('Error in communication with server!');
		}
	});
}


//*** JS FNCS : facebook steps

// call function upon friend selection in acOpenDiv("assassinfacebookfriends")
function acChooseFriend() {
	if (friend_id == 0) {
		//alert('No friend selected!');
		$('facebook_error').show();
		return false;
	}
	
	$('box1').hide();
	
	// proceed to FB photo selection page of selected user
	acOpenDiv("assassinfacebookpictures");
}

// call function upon friend selection in acOpenDiv("victimfacebookfriends")
function acChooseAssassin() {
	if (victim_aid == 0) {
		//alert('No friend selected!');
		$('facebook_error').show();
		return false;
	}
	
	$('box1').hide();
	victim_guess++;
	
	// proceed to case where we display if the guess was sucess / fail
	acOpenDiv("victimGuess");
}

// call function upon photo selection in acOpenDiv("assassinfacebookpictures")
function acChooseFriendPhoto() {
	if (friend_pid == "") {
		//alert('No photo selected!');
		$('facebook_error').show();
		return false;
	}
	
	$('box1').hide();
	callFlashOpenPhotoEditor(friend_id, friend_photos[friend_pid]);
}

function acAssassinRepeat() {
	// hide box, reset vars and show homepage
	$('box1').hide();
	
	friend_id = 0;
	friend_pid = "";
	friend_purl = "";
	friend_photos = new Array();
	friend_rid = 0;
	
	acOpenDiv("assassinfacebookfriends");
}

// build facebook holder window with loading
function acFacebookWindowBuilder() {
	var output = "";
	
	output += '<div id="container_fb">';
	output += '		<!-- facebook div -->';
	output += '		<div id="facebook_divs">';
	output += '			<div id="facebook_divs_inner">';
	output += '				<div id="facebook_divs_close"><a href="#" onclick="callFlashAssassinGoHome(); return false;"><img src="images/btn_close_fb.gif" alt="" border="0" /></a></div>';
	output += '				<div id="facebook_friends_loader"><img src="images/facebook_loader.gif" alt="" border="0" /></div>';
	output += '				<div id="facebook_friends" class="facebook_overflow_box"><br /><br /><br /><br /><br /><br /><br /></div>';
	output += '				<div id="facebook_btns"></div>';
	output += '			</div>';
	output += '		</div>';
	output += '		<!-- facebook div -->';
	output += '</div>';

	return output;
}


//*** JS FNCS : non-facebook steps

// call function upon reason selection in acOpenDiv("assassinreason")
function acChooseFriendReason() {
	if (friend_rid == 0) {
		$('reason_error').show();
		return false;
	}
	
	$('box1').hide();
	
	// proceed to email send page - complete assassin process
	acOpenDiv("assassinemail");
}

// ajax request sent to validate form and send video
function acSendFormVideo(formName, sendTxt) {
	
	// init the form element
	var formid = $(formName);
	
	//alert ( $('friend_email').value );
	//return false;
	
	// collect data from form
	//var params = Form.serialize(formid, true);
	
	// show ajax loader, clean message display 
	$('ajax_loader_email').show();
	$('video_message_display').update('');
	
	// disable submit
	$('envoi_video_submit_btn').update('<a href="javascript:void(0);" class="disabled">' + sendTxt + '</a>');
	
	// start ajax request
	new Ajax.Request('php/assassin_participation.php', {

		parameters: { site_lang: site_lang, site_age: site_age, friend_id: friend_id, friend_pid: friend_pid, friend_purl: friend_purl, friend_rid: friend_rid, friend_email: $('friend_email').value, user_email: $('user_email').value },
		onSuccess: function(transport) {
			
			// load the response, and convert JSON into regular array
			var response = transport.responseText;
			var jsonObj = response.evalJSON();
			
			// verify validation status 
			if (jsonObj.status == 'ok') {
				
				// success
				//$('video_message_display').update(jsonObj.detail);
				
				// proceed to confirmation page - complete assassin process
				acOpenDiv("assassinconfirm");
				
			} else if (jsonObj.status == 'error-flow') {
				// go back to the specified page
				acOpenDiv(jsonObj.detail);
				
			} else {
				// error
				$('video_message_display').update(jsonObj.detail);
				
			}
			
			// hide ajax loader for both cases
			$('ajax_loader_email').hide();
			
			// re-enable submit
			$('envoi_video_submit_btn').update('<a href="javascript:void(0);" onclick="acSendFormVideo(\'send_video\', \'' + sendTxt + '\');" onfocus="this.blur();">' + sendTxt + '</a>');
			
		},
		onFailure: function() {
			alert('Error in communication with server!');
		}
	});
}


//*** JS FNCS : top 20

// show next page of Top 20 results
function acTop20ShowNext() {
	$('top_20_wrapper').hide();
	$('top_20_nav').hide();
	
	$('top_20_wrapper_next').show();
	$('top_20_nav_next').show();
}

// show prev page of Top 20 results
function acTop20ShowPrev() {
	$('top_20_wrapper_next').hide();
	$('top_20_nav_next').hide();
	
	$('top_20_wrapper').show();
	$('top_20_nav').show();
}


//*** JS FNCS : newsletter

// ajax request sent to validate inscription form for ubi.com login
function acSendFormInscription(formName) {
	
	// init the form element
	var formid = $(formName);
	
	// collect data from form
	var params = Form.serialize(formid, true);
	
	// start ajax request
	new Ajax.Request('php/ubi_inscription.php', {

		parameters: params,
		onSuccess: function(transport) {
			
			// load the response, and convert JSON into regular array
			var response = transport.responseText;
			var jsonObj = response.evalJSON();
			
			// verify validation status 
			if (jsonObj.status == 'ok') {
				
				// success
				//$('inscription_message_display').update(jsonObj.detail);
				acOpenDiv("newsletterconfirm");
				
			} else {
			
				// error
				//$('inscription_message_display').update(jsonObj.detail);
				
				// build error output
				var output = "";
				errors = jsonObj.detail;
				for (var j = 0; j < errors.length; j++) {
					output += " " + errors[j];
				}
				
				$('inscription_message_display').update(output.substr(1));
			
			}
			
		},
		onFailure: function() {
			alert('Error in communication with server!');
		}
	});
	
}


//*** JS FNCS : acOpenDiv : main controller for divs

// note : 2nd parameter is optional : ex. case = facebookpictures : 2nd param = FBid
// note 2 : show divs in appropriate box (1 or 2) over the flash, and communicate back and forth ... setting title, bgs, operations.
function acOpenDiv(pageName) {	
	switch (pageName) {
		case "top20":
			// show the specific div over the flash ... pased on pageName we know which maquette to load
			// ex. document.getElementById("box1").style.visibility = "visible";
			// show in box2 div
			//alert("acOpenDiv >> " + pageName);
			
			callFlashShowTopLayer();
			
			// start ajax request
			new Ajax.Request('php/getTop20.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box2').update(response);
					$('box2').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
			
		case "newsletter":
			// open series of pages to communicate with Ubi SSO
			// show in box2 div
			//alert("acOpenDiv >> " + pageName);
			
			// open link to external Ubi login
			//window.open("https://secure.ubi.com/login/Login.aspx");
			
			// start ajax request
			new Ajax.Request('php/ubi_registration.php', {
		
				parameters: { site_lang: site_lang, site_age: site_age },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box2').update(response);
					$('box2').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
		
		case "newsletterconfirm":
			// show in box2 div
			//alert("acOpenDiv >> " + pageName);
			
			// start ajax request
			new Ajax.Request('php/ubi_registration_complete.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box2').update(response);
					$('box2').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
		
		
		case "assassinfacebookconnect":
			// open div with iframe for connection to Facebook
			//alert("acOpenDiv >> " + pageName);
			
			FB.Connect.requireSession( acOnLoginHandler );
			
			break;
			
		case "assassinfacebookfriends":
			// display choice of friends
			//alert("acOpenDiv >> " + pageName);
			
			callFlashHidePage();
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Qui sera votre victime?" : "Who is your victim?";
			
			callFlashSetBackgroundId(2);
			callFlashSetTitle(current_title, "");
			
			// set box 1 to Facebook builder content
			$('box1').update( acFacebookWindowBuilder() );
			$('box1').show();
			
			// start ajax request
			new Ajax.Request('php/facebook_friends.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
					// Prototype code to add rollover to each friend item
					var chosen_friend = "";
					$$('.friend').each(function(friend) {
						Event.observe(friend, 'mouseover', function(event) {
							this.addClassName('friend_over');
						});
						Event.observe(friend, 'mouseout', function(event) {
							if (!this.hasClassName('friend_on')) {
								this.removeClassName('friend_over');
							}
						});
						Event.observe(friend, 'click', function(event) {					
							
							// verify if there is a chosen friend, if yes, remove last chosen friend's over class
							if (chosen_friend != "") {
								$(chosen_friend).removeClassName('friend_over');
								$(chosen_friend).removeClassName('friend_on');
							}
							
							// add on class to clicked friend
							this.addClassName('friend_over');
							this.addClassName('friend_on');
							
							// and assign the new chosen_friend to var and hidden input
							chosen_friend = this.id;
							//$('chosen_friend').value = chosen_friend;
							
							// only grab ID from chosen_friend
							friend_id = chosen_friend.substr( chosen_friend.indexOf("_") + 1 );
							//alert("you chose : " + friend_id);
						});
					});
					
					// script for png fix
					if (Prototype.Browser.IE6) {
						DD_belatedPNG.fix('#facebook_divs');
					}
					
					/*
					Event.observe(facebook_friend, 'submit', function(event) {
						if ( $('chosen_friend').value != "" ) {
							$('box1').hide();
							acOpenDiv("assassinfacebookpictures", $('chosen_friend').value);
						}
					});
					*/
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
			
		case "assassinfacebookpictures":
			// display pictures for a selected facebook user, determined by main var : friend_id
			
			//callFlashSetTitle(title, description);
			//alert("acOpenDiv >> " + pageName);
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Choisissez une photo de votre victime" : "Select a photo of your victim";
			
			//callFlashSetBackgroundId(2);
			callFlashSetTitle(current_title, "");
			
			// reset the var
			friend_photos = new Array();
			
			// set box 1 to Facebook builder content
			$('box1').update( acFacebookWindowBuilder() );
			$('box1').show();
			
			//alert("get photos for : " + friend_id);
			
			// start ajax request
			new Ajax.Request('php/facebook_photos.php', {
		
				parameters: { chosen_friend: friend_id, site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
					// Prototype code to add rollover to each photo item
					var chosen_photo = "";
					$$('.friend').each(function(photo) {
						Event.observe(photo, 'mouseover', function(event) {
							this.addClassName('friend_over');
						});
						Event.observe(photo, 'mouseout', function(event) {
							if (!this.hasClassName('friend_on')) {
								this.removeClassName('friend_over');
							}
						});
						Event.observe(photo, 'click', function(event) {					
							
							// verify if there is a chosen photo, if yes, remove last chosen photo's over class
							if (chosen_photo != "") {
								$(chosen_photo).removeClassName('friend_over');
								$(chosen_photo).removeClassName('friend_on');
							}
							
							// add on class to clicked friend
							this.addClassName('friend_over');
							this.addClassName('friend_on');
							
							// and assign the new chosen_photo to var and hidden input
							chosen_photo = this.id;
							
							// only grab ID from chosen_photo
							friend_pid = chosen_photo.substr( chosen_photo.indexOf("_") + 1 );
							//alert(friend_pid);
						});
					});
					
					// script for png fix
					if (Prototype.Browser.IE6) {
						DD_belatedPNG.fix('#facebook_divs');
					}
					
					/*
					Event.observe(facebook_friend, 'submit', function(event) {
						if ( $('chosen_photo').value != "" ) {
							callFlashOpenPhotoEditor(arguments[1], $('chosen_photo'));
							$('box1').hide();
						}
					});
					*/
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
		
		case "assassinreason": // params: FBid, temp_photo_path
			// display radio button page with options
			
			//alert("acOpenDiv >> " + pageName);
			
			// load and check params
			tmp_fbid = arguments[1];
			tmp_photo_path = arguments[2];
			//alert(tmp_photo_path);
			
			// if params missing
			if ( tmp_fbid != friend_id || tmp_photo_path == "" ) {
				callFlashCatchError("assassinreason");
			} else {
				friend_purl = tmp_photo_path;
			}
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Le motif de l'assassinat" : "Motive for the assassination";
			
			callFlashSetTitle(current_title, "");
			
			// start ajax request
			new Ajax.Request('php/assassin_reasons.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			break;
		
		case "assassinemail":
			// display send to friend form
			// save all data in DB
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Envoi de la vid&eacute;o" : "Send the video";
			
			callFlashSetTitle(current_title, "");
			
			// start ajax request
			new Ajax.Request('php/assassin_email.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			//alert("acOpenDiv >> " + pageName);
			break;
			
		case "assassinconfirm":	
			// display confirmation page
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Confirmation de l'envoi" : "Email sent confirmation";
			
			callFlashSetTitle(current_title, "");
			
			// start ajax request
			new Ajax.Request('php/assassin_confirm.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			//alert("acOpenDiv >> " + pageName);
			break;
			
		case "victimfacebookconnect":
			// open div with iframe for connection to Facebook
			
			// check that FB login ID matches the FB id of the video ...
			//alert("acOpenDiv >> " + pageName);
			
			FB.Connect.requireSession( acVictimOnLoginHandler );
			
			break;
			
		case "victimfacebookfriends":
			// display choice of friends
			
			// acOpenDiv() MUST receive 2nd param : victimId
			// acOpenDiv() MUST receive 3rd param : lastChance = true/false
			
			// load and check params
			tmp_victim_id = arguments[1];
			tmp_last_chance = arguments[2];
			
			// if params missing
			if ( tmp_victim_id != victim_id || tmp_last_chance == "" ) {
				callFlashCatchError("victimfacebookfriends");
			} else {
				victim_last_chance = tmp_last_chance;
			}
			
			// determine title to show
			current_title = (site_lang == "fr") ? "Qui est ton assassin ?" : "Who is your assassin?";
			
			callFlashSetBackgroundId(4);
			callFlashSetTitle(current_title, "");
			
			// reset victim_aid
			victim_aid = 0;
			
			// set box 1 to Facebook builder content
			$('box1').update( acFacebookWindowBuilder() );
			$('box1').show();
			
			// start ajax request
			new Ajax.Request('php/facebook_friends_victim.php', {
		
				parameters: { site_lang: site_lang },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					
					$('box1').update(response);
					$('box1').show();
					
					// Prototype code to add rollover to each friend item
					var chosen_friend = "";
					$$('.friend').each(function(friend) {
						Event.observe(friend, 'mouseover', function(event) {
							this.addClassName('friend_over');
						});
						Event.observe(friend, 'mouseout', function(event) {
							if (!this.hasClassName('friend_on')) {
								this.removeClassName('friend_over');
							}
						});
						Event.observe(friend, 'click', function(event) {					
							
							// verify if there is a chosen friend, if yes, remove last chosen friend's over class
							if (chosen_friend != "") {
								$(chosen_friend).removeClassName('friend_over');
								$(chosen_friend).removeClassName('friend_on');
							}
							
							// add on class to clicked friend
							this.addClassName('friend_over');
							this.addClassName('friend_on');
							
							// and assign the new chosen_friend to var and hidden input
							chosen_friend = this.id;
							//$('chosen_friend').value = chosen_friend;
							
							// only grab ID from chosen_friend
							victim_aid = chosen_friend.substr( chosen_friend.indexOf("_") + 1 );
							//alert("you chose : " + victim_aid);
						});
					});
					
					// script for png fix
					if (Prototype.Browser.IE6) {
						DD_belatedPNG.fix('#facebook_divs');
					}
					
					/*
					Event.observe(facebook_friend, 'submit', function(event) {
						if ( $('chosen_friend').value != "" ) {
							$('box1').hide();
							acOpenDiv("assassinfacebookpictures", $('chosen_friend').value);
						}
					});
					*/
					
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			//alert("acOpenDiv >> " + pageName);
			break;
		
		case "victimGuess":
			// display success / failed guess of assassin
			
			// *** This no longer applies ...
			// acOpenDiv() MUST receive 2nd param : victimId
			// acOpenDiv() MUST receive 3rd param : lastChance = Y/N
			// acOpenDiv() MUST receive 4th param : assassinId
			
			// call ajax to check if the guess was right ... and display the appropriate maquette
			
			// if params missing
			//callFlashCatchError(errorString);
			
			// start ajax request
			new Ajax.Request('php/victim_guess.php', {
		
				parameters: { site_lang: site_lang, victim_id: victim_id, aid: victim_aid, last_chance: victim_last_chance, num_guess: victim_guess },
				onSuccess: function(transport) {
					
					// load the response, and convert JSON into regular array
					var response = transport.responseText;
					var jsonObj = response.evalJSON();
					
					// verify guess status 
					if (jsonObj.status == 'success') {
						// determine title to show
						current_title = (site_lang == "fr") ? "F&eacute;licitations !" : "Congratulations!";
					} else if (jsonObj.status == 'fail') {
						// determine title to show
						current_title = (site_lang == "fr") ? "D&eacute;sol&eacute; !" : "Sorry!";
					} else {
						// error : no match or already complete
						callFlashBackToClues();
						return false;
					}
					
					// set background + title
					//callFlashSetBackgroundId(5);
					callFlashSetTitle(current_title, "");
					
					// display the proper html contents
					$('box1').update(jsonObj.detail);
					$('box1').show();
				},
				onFailure: function() {
					alert('Error in communication with server!');
				}
			});
			
			//alert("acOpenDiv >> " + pageName);
			break;
		
		case "preorder":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			window.open("http://www.assassinscreed.com/ordernow");
			
			break;
			
		case "aboutubi":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			if (site_lang == "fr") {
				window.open("http://www.ubi.com/FRCA/default.aspx");
			} else {
				window.open("http://www.ubi.com/ENCA/default.aspx");
			}
			
			break;
		
		case "ubilive":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			window.open("http://ubi.li/W2SAa");
			
			break;
			
		case "ebgames":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			if (site_lang == "fr") {
				window.open("http://www.ebgames.ca/fr/default.asp");
			} else {
				window.open("http://www.ebgames.ca/default.asp");
			}
			
			break;
		
		case "playstation":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			window.open("http://www.playstation.ca/");
			
			break;
			
		case "xbox":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			if (site_lang == "fr") {
				window.open("http://www.xbox.com/fr-CA/");
			} else {
				window.open("http://www.xbox.com/en-CA/");
			}
			
			break;
		
		case "esrb":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			window.open("http://www.esrb.org/");
			
			break;
			
		case "esrbratings":
			current_title = (site_lang == "fr") ? "Vous devez autoriser temporairement les fen&ecirc;tres publicitaires intempestives pour visionner ce site." : "You need to temporarily allow pop-ups to view this site.";
			if (isSafari) { alert( html_entity_decode(current_title) ); }
			
			// open link to external Ubi
			
			
			if (site_lang == "fr") {
				window.open("http://www.esrb.org/ratings/ratings_guide_fr.jsp");
			} else {
				window.open("http://www.esrb.org/ratings/ratings_guide.jsp");
			}
			
			break;
			
		default:
			// problem, so start over
			callFlashAssassinGoHome();
			break;
	}
}