//---Scripts for Events page--//

// Selecciona el SWF dependiendo del navegador
// No olvidar modificar el nombre del swf en cada pagina var swfName = "home"; //
function mySWF(swfname)
{
	//console.log('RUN:mySWF');
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[swfname];
	} else {
		return document[swfname];
	}
}

//var userData = null;

var swfName = "header";
var oSessionData = null;
var oGarageData = null;
var isLoginForm = false;
var isJsReady = false; // Indica que el js esta listo
var isOnSession = false;
var bSession = false;

// Envia el valor de jsReady
function checkJSisReady()
{
	log('checkJSReady:'+isJsReady);
	return isJsReady;
}

// Envia el verdadero si el usuario esta en sesion
function getBSession()
{
	//log('isOnSession:'+isOnSession);
	return isOnSession;
}

/*
 * is sessid is loaded
 */
user.SessionLoaded = function()
{
	//log('SessionLoaded');
	isJsReady = true;
	isOnSession = true;
	bSession = true;
	userData = user.data;

//	03/22/2010	william@ciestudios.com
//	This is not being hidden per client request	
//	jQuery('#wlcmMssg').hide();
	jQuery('#wlcmMssg').fadeIn(2000);
	
	if(isLoginForm) {
		window.location="/whatsnew/";
	}
}

user.SessionNotLoaded = function()
{
	//log('SessionNotLoaded');
	isJsReady = true;
	isOnSession = false;
	bSession = false;
	userData = null;
		
	jQuery('#wlcmMssg').show();
//      03/22/2010      william@ciestudios.com
//      This is not faded out per client request
//	jQuery("#wlcmMssg").fadeIn(2000).fadeTo(5000, 1).fadeOut(2000); //work!!! 
}

scion.RegisterActivated = function(){}

//Se ejectua despues de globalEvalLogout, nunca hay error asi que siempre pasa
user.LogoutSuccess = function () {
	//log('user.LogoutSuccess');
	isOnSession = false;
	bSession = false;
	oGlobalUser = null; 
	mySWF(swfName).onLogOutComplete();
	//mySWF(swfName).onLogOutEdit();
}

user.LogoutFailed  = function (errors) {
	log("LogoutFailed" + errors);
}

var ScionAudioPlayer; // global variable
scion.popupAudioPlayer = function(song) {
	var url = '/audioplayer/?songKey=' + song;
	
	// most browsers can override default settings for window.open and will override anything set dynamically
    // only list the features you want enabled or rendered in the new window, the others (except titlebar, close and hotkeys) will be disabled by default	
	if(ScionAudioPlayer == null || ScionAudioPlayer.closed) { // if the window object does not exist create it
		ScionAudioPlayer = window.open(url, 'scionAudioPlayer', "location=1,width=350,height=200");
	} else { //it must exist
		if(ScionAudioPlayer.focus) { //it isn't closed
			ScionAudioPlayer.focus(); //set focus
		}
	}			
}