/*
	this file is part of SILEX
	SILEX : RIA developement tool - see http://silex.sourceforge.net/

	SILEX is (c) 2004-2007 Alexandre Hoyau and is released under the GPL License:

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License (GPL)
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.
	
	To read the license please visit http://www.gnu.org/copyleft/gpl.html
*/
/*
A FAIRE 
- pour flashvars dans autres browsers : MLAB_flash_setvariables.js

*/
// **
// fscommand
//
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function silex_DoFSCommand(command, args) {
	var silexObj = isInternetExplorer ? document.all.silex : document.silex;
	//alert("silex_DoFSCommand-"+command+"-"+args);
	if (command == "eval"){
		eval(unescape(args));
		//alert(unescape(args));
	}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub silex_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call silex_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
function SilexJsStart($flash_version,$php_default_website_name,$start_section,$config_files_list,$ENABLE_DEEPLINKING,$SILEX_ADMIN_DEFAULT_LANGUAGE,$SILEX_ADMIN_AVAILABLE_LANGUAGES,$websiteTitle,$preload_files_list,$bgcolor){
	if (!$bgcolor) $bgcolor="#FFFFFF";
	// **
	// SWF Object
	//
//	var fo = new SWFObject("fp"+$flash_version+"/loader.swf", "silex", "100%", "100%", $flash_version.toString(), "#FFFFFF");
	var fo = new SWFObject("loader.swf", "silex", "100%", "100%", $flash_version.toString(), $bgcolor);

	// retrieve commands passed from php
	eval($php_str);

	fo.addParam("scale", "noscale");

	fo.addParam("swLiveConnect", "true");
	fo.addParam("quality", "best");

	fo.addVariable("silex_result_str", "_no_value_");
	fo.addVariable("silex_exec_str", "_no_value_");
	if ($ENABLE_DEEPLINKING==false)
		fo.addVariable("ENABLE_DEEPLINKING", "false");
	
	fo.addVariable("flashPlayerVersion", $flash_version);
	
	fo.addVariable("SILEX_ADMIN_DEFAULT_LANGUAGE", $SILEX_ADMIN_DEFAULT_LANGUAGE);
	fo.addVariable("SILEX_ADMIN_AVAILABLE_LANGUAGES", $SILEX_ADMIN_AVAILABLE_LANGUAGES);

	// **
	// silex js object
	//
	// silexJsObj is used for deep link and tracking
	silexJsObj=new cSilex;
	$id_site=silexJsObj.init(fo,$php_default_website_name,$start_section,$websiteTitle);

	if ($id_site!=$php_id_site){
		//alert("case when you go directly to a website with # in the url - "+$id_site+"!=<?php echo $id_site; ?>");
		// case when you go directly to a website with # in the url
		//document.getElementById("theform").id_site=$id_site;
		//document.getElementById("theform").action="./#"+$id_site;
		//document.getElementById("theform").innerHtml='<FORM target="_self" action="./" method="post" id="theform"><INPUT type="hidden" name="id_site" value=$id_site></FORM>');
		document.write('<FORM target="_self" action="./#'+$id_site+'/'+silexJsObj._currentHashValue+'" method="post" id="theform"><INPUT type="hidden" name="id_site" value="'+$id_site+'"></FORM>');
		document.getElementById("theform").submit();
	}
	else{
		fo.addVariable('id_site', $id_site);
		if ($config_files_list && $config_files_list!="")
			fo.addVariable('config_files_list', $config_files_list);
		//alert($config_files_list);
		//fo.addVariable('preload_files_list', 	"./fonts/_sans.swf,./fonts/_serif.swf,./fonts/_typewriter.swf,./fonts/arial.swf,./fonts/arial_black.swf,./fonts/courier_new.swf,./fonts/impact.swf,./fonts/georgia.swf,./fonts/helvetica.swf,./fonts/tahoma.swf,./fonts/times_new_roman.swf,./fonts/verdana.swf");
		fo.addVariable('preload_files_list', $preload_files_list);
		//fo.addVariable('preload_files_list', "./fonts/text.swf");
		fo.write("flashcontent");
	}
	return silexJsObj;
}
