var reg = new RegExp("http://[^\\/]*/([^\\.#]+)+/?", "");
var paramsUrl = location.href.match(reg);

var pathInFlash = (paramsUrl != null && paramsUrl.length > 1) ? paramsUrl[1] : "news/" ;

/* Modification pour compatibilité du paramètre envoyé au flash */
pathInFlash  = pathInFlash.replace(/chiffres_cles/, 'chiffres_clés');
pathInFlash  = pathInFlash.replace(/_/g, ' ');
pathInFlash += (pathInFlash.substr(pathInFlash.length-1, 1) == '/') ? '' : '/' ;

/*
 * Le flash ne gère pas les fiches news, recrutement et docs avec
 * exemple avec un url du type "news/10/actualite_du_jour"
 * On renvoie alors sur la rubrique adéquat "news/"
 */
var reg2 = new RegExp("^([^\\/]*)\\/\\d*\\/[^\\/]*\\/?$", "i");
pathInFlash = pathInFlash.replace(reg2, "$1/");

var flashvars = {
    address: "/" + pathInFlash
};

var params = {
    menu: "false",
    allowfullscreen: "true"
};

var attributes = {
    id: "website",
    name: "website"
};

var flashIsLoaded = false;
var jQT = new Object();

function setHTML(section, trame)
{
  var htmlContent = $('#htmlContent');
  var urlContent  = section;

  if (!(htmlContent.length>0))
  {
    htmlContent = $('<div id="htmlContent"></div>');
    htmlContent.appendTo('body');    
  }
  
  if (trame != '')
  {
    urlContent += "/" + trame ;
  }
  urlContent  = urlContent.replace(/chiffres_clés/, 'chiffres_cles');
  urlContent  = urlContent.replace(/ /g, '_');
  
  if (htmlContent.attr('class') != urlContent)
  {
    htmlContent.load(urlContent, {'altcontent':'1'});
    htmlContent.attr('class', urlContent);
  }
}

function outputStatus(e) {
	flashIsLoaded = e.success;
	if (flashIsLoaded == true) {
		jQuery('html, body, #website').css({'height':'100%','overflow':'hidden'});
		jQuery('body').css({'background':'#FFFFFF','font':'100% Arial, sans-serif'});		
	}
	else {
		if (jQuery.jQTouch) {
			jQT = new jQuery.jQTouch({});
			jQT.init();			
		}		
	}
}

swfobject.embedSWF('/altima_loader.swf', 'website', '100%', '100%', '9.0.45', '/expressinstall.swf', flashvars, params, attributes, outputStatus);