FlashHeader_Bridge = function(ctx) 
{
	this.currentMode;
	this.flashStarted = false;
	this.swfObj = null;

	/**
	*	Change Mode
	*	@param mode:String ("home" / "search")
	*/
	this.init = function(obj){
		this.swfObj = obj;
	//	alert("init "+obj);
		//this.checkInit();
	}
//	this.js2as_changeMode = function (mode)
//	{			
//		if(this.currentMode!=mode){
//			this.currentMode=mode;
//			//alert("changeMode "+mode+" "+this.swfObj);
//			if(this.swfObj!=null && this.flashStarted){
//				this.swfObj.js2as_changeMode(mode);
//				
//			}
//			
//		}
//	}
	this.checkInit=function(){
		//alert("checkInit "+this.flashStarted+" "+this.swfObj.js2as_changeMode);
		if(!this.flashStarted){
//			if(this.currentMode!=null)
//				this.swfObj.js2as_changeMode(this.currentMode);
			//alert("checkInit "+this.currentMode);
			delayedRemoveLike();
			this.flashStarted=true;
		}
	}
	
	/**
	*	Change Theme
	*	@param theme:String
	*/
	this.js2as_changeTheme = function (theme)
	{
		removeLike();
		if(theme==null)
			theme=1;
		this.swfObj.js2as_changeTheme(theme);
		this.js2as_setMostDownloadedList(theme,"false");
		this.js2as_setZoomList(theme);
		return false;
	}



	this.js2as_setZoomList = function (theme)
	{
		
		if(theme==null)
			theme = jQuery.url.param("themeId");
		
		if(theme==null) 
			theme=ThemeId;
		if(theme==null)
			theme=1;
		var swfObj = this.swfObj ;
		
		$.getJSON(ctx+"/dyn/json/albumsAccueil"+theme+".json",function(json){
			
			//alert("Liste: " +json.list[0].artist);		
			
			var myJson = JSON.stringify(json);	
			
			
			swfObj.js2as_setZoomList(myJson);
			
		});
		
	}

	this.js2as_setMostDownloadedList = function (theme,mp3)
	{
		if(theme==null)
			theme = jQuery.url.param("themeId");
		//theme = themeId[1];
		
		if(mp3==null)
			mp3="false";
		if(theme==null) 
			theme=ThemeId;
		if(theme==null)
			theme=1;
		var swfObj=this.swfObj;
		
		$.getJSON(ctx+"/memberTop.htm",{theme:theme,mp3:mp3},function(jsonObj,textStatus){
			
			//alert(jsonObj);
			
			var myJson = JSON.stringify(jsonObj);
			
			//alert(myJson);
			
			swfObj.js2as_setMostDownloadedList(myJson);
			
		});

		
	}	

	
	
	this.js2as_setPlaylist = function (playlistId, playlistJson)
	{
		this.swfObj.js2as_setPlaylist(playlistId, JSON.stringify(playlistJson));
	}		

	

	
	this.js2as_playTitre = function (playlistId, titreIndex)
	{
		this.swfObj.js2as_playTitre(playlistId, titreIndex);
	}
	


	
	
	/**
	*	JS 2 AS
	*	Actions sur le SoundPlayer =============================================================================================================
	*/
	
	/**
	*	Play
	*/
	this.js2as_SoundPlayer_resume = function ()
	{
		this.swfObj.js2as_SoundPlayer_resume();
	}
	
	/**
	*	Pause
	*/
	this.js2as_SoundPlayer_pause = function ()
	{
		this.swfObj.js2as_SoundPlayer_pause();
	}
	
	/**
	*	Next
	*/
	this.js2as_SoundPlayer_next = function ()
	{
		this.swfObj.js2as_SoundPlayer_next();
	}
	
	/**
	*	Previous
	*/
	this.js2as_SoundPlayer_previous = function ()
	{
		this.swfObj.js2as_SoundPlayer_previous();
	}
	
	/**
	*	Loop activation
	*	@param val : Boolean
	*/
	this.js2as_SoundPlayer_setLoop = function (val)
	{
		this.swfObj.js2as_SoundPlayer_setLoop(val);
	}
	
	/**
	*	Random activation
	*	@param val : Boolean
	*/
	this.js2as_SoundPlayer_setRandom = function (val)
	{
		this.swfObj.js2as_SoundPlayer_setRandom(val);
	}
	
	/**
	*	Volume
	*	@param val : Number (min : 0, max : 1);
	*/
	this.js2as_SoundPlayer_setVolume = function (val)
	{
		this.swfObj.js2as_SoundPlayer_setVolume(val);
	}
	
	
	
	/**
	*	JS 2 AS
	*	Chargement des pubs ====================================================================================================================
	*/
	
	/**
	*	Chargement de la pub sur la home
	*	@param val : String : url du swf � charger
	*/
	this.js2as_SetPub_Home = function (val)
	{
		this.swfObj.js2as_SetPub_Home(val);
	}
	
	/**
	*	Chargement de la pub sur la page recherche
	*	@param val : String : url du swf � charger
	*/
//	this.js2as_SetPub_Search = function (val)
//	{
//		this.swfObj.js2as_SetPub_Search(val);
//	}
	
	
	

	
	/**
	*	AS 2 JS
	*	=========================================================================================================================================
	*/
	
	this.as2js_selectTitle = function (titleIndex, playlistId)
	{
		//alert("as2js_selectTitle " + titleIndex);
		removeLike();
	}
	
	
	this.as2js_downloadTitle = function (val)
	{
		//alert("as2js_downloadTitle " + val);
		location.href = val;
		trackId = val;
	}
	
	this.as2js_gotoArtistPage = function (val)
	{
		//alert("as2js_gotoArtistPage " + val);
		location.href = val;
	}
	
	this.as2js_searchTitle = function (val)
	{
		//alert("as2js_searchTitle " + val);
		location.href = val;
	}


	/**
	*	Play
	*/
	this.as2js_SoundPlayer_resume = function ()
	{
		//alert("as2js_SoundPlayer_resume");
	}
	
	/**
	*	Pause
	*/
	this.as2js_SoundPlayer_pause = function ()
	{
		//alert("as2js_SoundPlayer_pause");
	}
	
	/**
	*	Next
	*/
	this.as2js_SoundPlayer_next = function ()
	{
		//alert("as2js_SoundPlayer_next");
	}
	
	/**
	*	Previous
	*/
	this.as2js_SoundPlayer_previous = function ()
	{
		//alert("as2js_SoundPlayer_previous");
	}
	
	/**
	*	Loop activation
	*	@param val : Boolean
	*/
	this.as2js_SoundPlayer_setLoop = function (val)
	{
		//alert("as2js_SoundPlayer_setLoop " + val);
	}
	
	/**
	*	Random activation
	*	@param val : Boolean
	*/
	this.as2js_SoundPlayer_setRandom = function (val)
	{
		//alert("as2js_SoundPlayer_setRandom " + val);
	}
	
	/**
	*	Volume
	*	@param val : Number (min : 0, max : 1);
	*/
	this.as2js_SoundPlayer_setVolume = function (val)
	{
		//alert("as2js_SoundPlayer_setVolume " + val);
	}
	
	
	
	
	// TMP
	this.as2js_getZoomList = function ()
	{
		
		
		this.js2as_setZoomList();
		
	}
	// TMP
	this.as2js_getMostDownloadedList = function ()
	{
		this.checkInit();
		this.js2as_setMostDownloadedList();
	}


	
}// fin FlashHeader_Bridge 

