function getParam(param_str) {
	temp_array = new Array();
	urlParam = window.location.search.substring(1);
	aTempParam = new Array();
	aTempParam = urlParam.split("&");
	for(i=0; i < aTempParam.length; i++) {
		strId = aTempParam[i].split("=")[0];
		strValue = aTempParam[i].split("=")[1];
		temp_array[strId] = strValue;
	}
	if(param_str != undefined) {
		if(temp_array[param_str] == undefined) {
			return "";
		}
		else {
			return temp_array[param_str];
		}
	}
	else {
		return temp_array;
	}
}
//
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var HEIGHT_MIN = 560;
var HEIGHT_MAX = 760;
if ( navigator.userAgent.indexOf('Mac') != -1 ) {
	HEIGHT_MAX = HEIGHT_MAX - 50;
}
var WIDTH_MIN = 980;
var footerHeight = 50;

var allowResize = true;
var resizeInterval;
function resizeWindow(){
	clearInterval(resizeInterval);
	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth, screen.availHeight);
	} else if (document.getElementById || document.layers) {
		if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	allowResize = true;
	top.window.onresize = onResizeEvent;
}
function onResizeEvent() {
	clearInterval(resizeInterval);
	resizeInterval = setInterval("resizeWindow()",500);
}
function resizeFooter(param_flashMaskWidth_int, paramFlashTotalWidth_int){
	var footer = MM_findObj("footer");
	var flashcontent = MM_findObj("flashcontent");
	var flashTop = 0;
	var windowHeight = getWindowHeight();
	footer.style.width = (param_flashMaskWidth_int) + 'px';
	if (document.all)	{
		footer.style.width = (param_flashMaskWidth_int + 5) + 'px';
	}
	footer.style.left = Math.round((paramFlashTotalWidth_int - param_flashMaskWidth_int) / 2) + 'px';
	//
	if(windowHeight >= HEIGHT_MAX + footerHeight){
		flashTop = Math.round(Math.abs(windowHeight - HEIGHT_MAX - footerHeight) / 2);
		if(flashTop < 15){
			flashTop = 0;
		}
	}
	flashcontent.style.top = flashTop + 'px';
	footer.style.top = (getFlashHeight() + flashTop) + 'px';
	footer.style.display = "block";
	//alert("footer.style.top=" + footer.style.top);
}

function getFlashWidth() {
	var flashWidth = getWindowWidth();
	if(flashWidth < WIDTH_MIN) {
		flashWidth = WIDTH_MIN;
	}
	return flashWidth;
}
function getFlashHeight() {
	var flashHeight = getWindowHeight();
	if(flashHeight > HEIGHT_MAX) {
		flashHeight = HEIGHT_MAX;
	} else if (flashHeight < HEIGHT_MIN){
		flashHeight = HEIGHT_MIN - footerHeight;
	} else {
		flashHeight -= footerHeight;
	}
	return flashHeight;
}
function getWindowHeight() {
	var windowHeight;
	if (document.all)	{
		windowHeight = document.body.offsetHeight;
	} else {
		windowHeight = window.innerHeight;
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth;
	if (document.all)	{
		windowWidth = document.body.offsetWidth - 29;
	} else {
		windowWidth = window.innerWidth;
	}
	return windowWidth;
}
//
function openMamanPDF(param_id_int) {
	window.open( "/graphics/nutrition/mums-corner/pdf/mcdo-maman-"+param_id_int+".pdf", 'pdf', 'top=10,left=20,width=750,height=450,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes');
}

function getMcDoFlashObject(param_directContent_str, param_directPage_str, param_redirectFirstLink_bool){
	var flashHeight = getFlashHeight();
	var flashWidth = getFlashWidth();
	var so = new SWFObject("/engine/engine.swf", "mainswf", flashWidth, flashHeight, "8,0,22,0", "#ffffff", true);  
	//alert("param_directContent_str: "+param_directContent_str);
	
	
	// ExpressInstall
	so.useExpressInstall('/engine/expressinstall/expressinstall.swf');
	
	so.addParam("xiRedirectUrl", window.location);
	so.addParam("align", "middle");
	so.addParam("scale", "noscale");
	so.addParam("salign", "C");
	so.addParam("allowScriptAccess", "always");
	so.addParam("loop", false);
	so.addParam("menu", false); 
	so.addParam("quality", "high");
	//so.addParam("wmode", "window");
	
	// Common FlashVars
	so.addVariable("fv_trace_bool", "true"); // Si on veut l'affichage des traces ou pas
	so.addVariable("fv_urlConfigurationXml", "/engine/data/configuration.xml"); // L'url de configuration.xml
	so.addVariable("fv_urlApplicationSwf", "/engine/applications/application.swf"); // L'url de application.swf
	so.addVariable("fv_urlGraphicApplicationSwf", "/graphics/common/common.swf"); // L'url de graphic-application.swf
	so.addVariable("fv_photoContestId", getParam("id")); // Variable pour photo contest
	so.addVariable("fv_pressId", getParam("pressid")); // Variable pour photo contest
	
	//Special FlashVars
	if(param_redirectFirstLink_bool == undefined){
		param_redirectFirstLink_bool = false;
	}
	if (param_directContent_str=="") {
		//var rnd = Math.floor(Math.random()*3)+1;
		//param_directContent_str = "vcve-"+rnd;
	}
	//
	var hash = window.location.href.split('#')[1];
	if(hash!=undefined && hash!=''){
		if(param_directContent_str==""){
			param_directContent_str=hash.split("/")[1];
		}
		if(param_directPage_str==""){
			param_directPage_str=hash.split("/")[2];
		}
	}else{
		if(param_directContent_str==""){
			param_directContent_str="home";
		}
	}
	//
	so.addVariable("fv_redirectFirstLink_bool", param_redirectFirstLink_bool);
	so.addVariable("fv_directContent", param_directContent_str); // Si on souhaite ouvrir une home ou une sous-section directement, on transmet son id
	so.addVariable("fv_directPage", param_directPage_str); // Si on souhaite une page precise du contenu charge directement, on transmet son id

	return so;
}
//popups

function videoscenedevie(num) {
	openSimplePopupWindow('/graphics/fondation/maisons-ronald/popup-films/popup-sdv' + num + '-flash.html','sdv',388,356);
}
function liencontactmecenat() {
	openScrollablePopupWindow('/graphics/fondation/contact/contact.html','mecenat',359,500);
}
function pdf(pdf) {
	openPopupWindow(pdf, 'pdf', 'top=10,left=20,width=750,height=450,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes');
}
//
function openNewsletterPopup() {
	openPopupWindow("/graphics/newsletter/newsletter.html","newsletter", "height=450, width=520, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no");
}
function openPopupWindow(url, name, param) {	
	//'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no'
	window.open (url, name, param);	
}
function JSReplace(inStr, inReplace, inReplacement){
	while(inStr.indexOf(inReplace) > 0){
		inStr = inStr.replace(inReplace,inReplacement);
	};
	return inStr;
};

function openSimplePopupWindow(url, name, width, height) {

	//name = name.replace("-", "");
	name = JSReplace(name,"-","");	
	openPopupWindow(url, name, 'height=' + height + ', width=' + width + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
	
}
function openScrollablePopupWindow(url,name,width, height) {
	name = name.replace("-", "");
	openPopupWindow(url, name, 'height=' +height + ', width=' +width + ', toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
}
function openFindRestaurantWindow(url, name) {
	openPopupWindow(url, name, 'height=510, width=820, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
}

//
function openPhotoContestUploadPhoto(title, description){
	openPopupWindow("/graphics/currently/photo-contest/upload.jsp?photodescription=" + description + "&phototitle=" + title, "uploadcontestphoto", "height=250, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
}

