function echo(str)
{
	document.write(str);	
}


function png2ie6(id)
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
		  var img = $(id);
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
		  }
	}
}


var is_sound = true;
function toggleSound()
{
	if(is_sound==true)
	{
		$('imgToggleSound').src = dirImg+'son_on.gif';
		is_sound = false;
		$('soundAction').update('');
		$('soundActionLoopPlane').update('');
		$('soundActionLoopAlarm').update('');
		
	} else {
		$('imgToggleSound').src = dirImg+'son_off.gif';
		is_sound = true;
	}
}


function windowpopup(url, width, height) {
	var Left = window.screen.width/2 - width/2;
	var Top = window.screen.height/2 - height/2;
	var windowpopup = window.open(url,'_blank','scrollbars=yes,width='+width+',height='+height+',left=' + Left + ', top=' + Top);
	windowpopup.focus();
}

function windowpopupnoscrollbars(url, width, height) {
	var Left = window.screen.width/2 - width/2;
	var Top = window.screen.height/2 - height/2;
	var windowpopup = window.open(url,'_blank','scrollbars=no,width='+width+',height='+height+',left=' + Left + ', top=' + Top);
	windowpopup.focus();
}


function getLang(identifiant)
{
	if(langtxt[identifiant] != undefined)
	{
		return langtxt[identifiant];
	} else {
		return '__NOT_DEFINED__';
	}	
}


function end_video(value)
{
	switch(value)
	{
		case 'zoomMadagascar': setTimeout("initGame()", 500);
			break;
		
		case 'intro_decollage': setTimeout("startPlane()", 500);
			break;
			
		case 'crash': setTimeout("crashStage()", 500);
			break;	
	}	
}


function end_sound(value)
{
	if(value == 'voix_perso' || value == 'message_direction')
	{
		is_sound_perso = false;
	}
}


function getFlash(swf, width, height)
{
	return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width',width,'height',height,'id','myFlash','src',swf,'quality','high','bgcolor','#CCCCCC','name','myFlash','swliveconnect','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',swf, 'allowScriptAccess', 'always', 'wmode', 'transparent' );
}

function getFlashPlayerVideo(flv, width, height)
{
	return '<object type="application/x-shockwave-flash" data="player_flv_mini.swf" width="'+width+'" height="'+height+'"><param name="movie" value="player_flv_mini.swf" /><param name="FlashVars" value="flv=FLV/'+flv+'.flv&amp;autoload=1&amp;autoplay=1&amp;width='+width+'&amp;height='+height+'" /></object>';
}

function getPreloadVideo(flv)
{
	return '<object type="application/x-shockwave-flash" data="player_flv_mini.swf" width="1" height="1"><param name="movie" value="player_flv_mini.swf" /><param name="FlashVars" value="flv=FLV/'+flv+'.flv&amp;autoload=1&amp;autoplay=0" /></object>';
}


function getFlashVideo(id_video, video_name, width, height)
{
	return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width',width,'height',height,'id','myFlash','src','player','quality','high','bgcolor','#CCCCCC','name','myFlash','swliveconnect','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','player', 'FlashVars','id_video='+id_video+'&file=FLV/'+video_name+'.flv', 'allowScriptAccess', 'always', 'wmode', 'transparent' );
}

function getFlashVideo460(id_video, video_name, width, height)
{
	return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width',width,'height',height,'id','myFlash','src','video460x400','quality','high','bgcolor','#CCCCCC','name','myFlash','swliveconnect','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','video460x400', 'FlashVars','id_video='+id_video+'&file=FLV/'+video_name+'.flv', 'allowScriptAccess', 'always', 'wmode', 'transparent' );
}

function getFlashSound(idsound, mp3)
{
	return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','1','height','1','id','myFlash','src','mp3player','quality','high','bgcolor','#CCCCCC','name','myFlash','swliveconnect','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','mp3player', 'FlashVars','idsound='+idsound+'&mp3=mp3/'+mp3+'.mp3', 'allowScriptAccess', 'always', 'wmode', 'transparent' );
}

function getFlashSoundLoop(mp3)
{
	return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','1','height','1','id','myFlash','src','mp3playerloop','quality','high','bgcolor','#CCCCCC','name','myFlash','swliveconnect','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','mp3playerloop', 'FlashVars','mp3=mp3/'+mp3+'.mp3', 'allowScriptAccess', 'always', 'wmode', 'transparent' );
}


function popup_open(content, top, left, width, height)
{
	if(isRequest) return false;

	$('popup').style.top = top + 'px';
	$('popup').style.width = width + 'px';
	$('popup').style.height = height + 'px';
	$('popup').style.marginLeft = (left==false ? (-1 * Math.round(width/2)) : left) + 'px';
	$('popup').update(content);
	$('popup').show();
}


function popup_close()
{
	$('popup').update('');
	$('popup').hide();
}

function getRandomElement(myArray)
{
	if(myArray.length==0)
		return false;
		
	else if(myArray.length==1)
		return myArray[0];
		
	else
		return myArray[ Math.floor( Math.abs( Math.random() * myArray.length - 0.1 ) ) ];
}






function getUser()
{	
	if(isRequest) return false;
	
	isRequest = true;
	
	$('userEmailLogin').disabled = true;
	
	var param = '';
	param += '&userEmail='+encodeURIComponent($('userEmailLogin').value);
	param += '&codeIdentifiant='+encodeURIComponent($('codeIdentifiant').value);
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=getUser' + param,
		onSuccess: function(transport) {
			isRequest = false;
			//alert('aloha');
			var response = transport.responseXML;
			var result = response.getElementsByTagName("result")[0].firstChild.nodeValue;
			
			$('userEmailLogin').disabled = false;
			//alert('result='+result);
			
			if((result*1) == 200)
			{
				User['codeIdentifiant'] = response.getElementsByTagName("codeIdentifiant")[0].firstChild.nodeValue;
				User['userName'] = response.getElementsByTagName("userName")[0].firstChild.nodeValue;
				User['userFirstName'] = response.getElementsByTagName("userFirstName")[0].firstChild.nodeValue;
				User['userEmail'] = response.getElementsByTagName("userEmail")[0].firstChild.nodeValue;
				User['userColorPlane'] = 1 * response.getElementsByTagName("userColorPlane")[0].firstChild.nodeValue;
				User['userLastStageReleased'] = 1 * response.getElementsByTagName("userLastStageReleased")[0].firstChild.nodeValue;
				User['userPostalCode'] = response.getElementsByTagName("userPostalCode")[0].firstChild.nodeValue;
				var goodiesId = response.getElementsByTagName("goodiesId");
				
				for(var i=0; i<goodiesId.length; i++)
				{
					UserGoodie[goodiesId[i].firstChild.nodeValue] = true;
				}
				
				$('codeIdentifiant').value = '';
				
				// => aller au dernier niveau débloqué
				idPlaneColor = User['userColorPlane'];
				dirPlaneImg = 'avion/plane'+idPlaneColor+'/';				
				var preload_imgs = '';
				for(var i=0; i<360; i=i+stepPlane)
				{
					preload_imgs += '<img src="'+urlServer + dirPlaneImg + 'plane' + i + '.png" height="1" width="1" />';
				}
				new Insertion.Bottom('preloadContent', preload_imgs);
				//$('preloadContent').update(preload_imgs);
				
				//idStage = User['userLastStageReleased']==6 ? 6 : User['userLastStageReleased']+1;
				idStage = User['userLastStageReleased'];
				loadgame();
				popup_close();
				$('soundAction').update('');
				
				if(idStage<6) $('game_maquette').update('<img src="'+dirImg+'etapes/maquette'+(idStage+1)+'.jpg" />');
				$('infoPiecesAvion').update((idStage==6 ? 5 : idStage) + ' ' + getLang('pieces_trouvees'));
				
				$('contentHTML').style.backgroundColor = "transparent";
				$('contentHTML').update(getFlashVideo460('felicitations', 'felicitations'+idStage, 460, 400));
				$('contentHTML').show();
				
				$('btnBegin').hide();
				$('btnMaps').hide();

				endStage();
				
			} else if((result*1) == 400)
			{
				alert(getLang('identification_incorrecte'));
			}
		}
	});
}



function setAnonymUser()
{
	if(isRequest) return false;
	
	isRequest = true;
	
	var param = '';
	param += '&countryId='+encodeURIComponent($('countryId').value);
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=setAnonymUser' + param,
		onSuccess: function(transport) {
			isRequest = false;
			//alert('aloha');
			var response = transport.responseXML;
			var result = response.getElementsByTagName("result")[0].firstChild.nodeValue;
			
			if((result*1) == 200)
			{
				var codeIdentifiant = response.getElementsByTagName("codeIdentifiant")[0].firstChild.nodeValue;
				$('codeIdentifiant').value = codeIdentifiant;
			}
		}
	});
}


function stageEnd()
{
	if(isRequest) return false;
	
	isRequest = true;
	
	//alert(User['codeIdentifiant'] + ' / '+$('codeIdentifiant').value);
	
	var param = '';
	param += '&stageNum=' + idStage;	
	param += '&codeIdentifiant=' + ( User['codeIdentifiant'] != undefined ? User['codeIdentifiant'] : encodeURIComponent($('codeIdentifiant').value) );
	param += '&countryId=' + ( User['countryId'] != undefined ? User['countryId'] : encodeURIComponent($('countryId').value) );
	param += '&userEmail=' + ( User['userEmail'] != undefined ? User['userEmail'] : '' );
	param += '&stageTimeFuelLevel=' + fuel;
	for(var i=0; i<UserGoodie.length; i++) if(UserGoodie[i]==true) param += '&goodies[]=' + i;
	
	//alert(param);
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=stageEnd' + param,
		onSuccess: function(transport) {
			isRequest = false;
			
			var response = transport.responseXML;
			var result = response.getElementsByTagName("result")[0].firstChild.nodeValue;
			//alert('result='+result);
		}
	});
}



function SendInvitation()
{
	if(isRequest) return false;
	
	isRequest = true;
	$('btnSetUser').hide();
	$('waitSetUser').show();
	
	var nbChampInvites = 4;
	
	
	for(var i=1; i<=nbChampInvites; i++) if($('invitesFirstName_'+i).value!='' || $('invitesEmail_'+i).value!='')
	{
		$('invitesFirstName_'+i).style.backgroundColor = '#ffffff';
		$('invitesEmail_'+i).style.backgroundColor = '#ffffff';
	}
	
	for(var i=1; i<=nbChampInvites; i++)
	{
		$('invitesFirstName_'+i).style.backgroundColor = '#ffffff';
		$('invitesEmail_'+i).style.backgroundColor = '#ffffff';
		$('invitesFirstName_'+i).disabled = true;
		$('invitesEmail_'+i).disabled = true;
	}
	
	$('userFirstName').style.backgroundColor = '#ffffff';
	$('userFirstName').disabled = true;
	
	$('userEmail').style.backgroundColor = '#ffffff';
	$('userEmail').disabled = true;
	$('zone_email').style.backgroundColor = 'transparent';
	
	var error_validation = false;
	
	if(error_validation == true)
	{
		for(var i=1; i<=nbChampInvites; i++)
		{
			$('invitesFirstName_'+i).disabled = false;
			$('invitesEmail_'+i).disabled = false;
		}
		
		$('userFirstName').disabled = false;
		$('userEmail').disabled = false;
		return;
	}
	
	var userEmail = $('userEmail').value;
	
	var param = '';
	param += '&userFirstName='+encodeURIComponent($('userFirstName').value);
	param += '&countryId='+encodeURIComponent($('countryId').value);
	
	for(var i=1; i<=nbChampInvites; i++) if($('invitesFirstName_'+i).value!='' || $('invitesEmail_'+i).value!='')
	{
		param += '&invites[userFirstName][]=' +encodeURIComponent($('invitesFirstName_'+i).value);
		param += '&invites[userEmail][]=' + encodeURIComponent($('invitesEmail_'+i).value);	
	}
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=SendInvitation' + param,
		onSuccess: function(transport) {
			isRequest = false;
			
			var response = transport.responseXML;
			var result = 1 * response.getElementsByTagName("result")[0].firstChild.nodeValue;
			
			for(var i=1; i<=nbChampInvites; i++)
			{
				$('invitesFirstName_'+i).disabled = false;
				$('invitesEmail_'+i).disabled = false;
			}
			
			$('userFirstName').disabled = false;
			$('userEmail').disabled = false;
			
			if(result == 200)
			{
				$('game_link_identifier').hide();
				$('form1').hide();
				$('form1').update('');
				
				User['codeIdentifiant'] = true;
				endStage();
				return;
				
			} else if(result == 303) // userFirstName trop court
			{
				$('userFirstName').style.backgroundColor = '#ffff55';

			} else if(result == 350) // invités (userFirstName) trop court
			{
				for(var i=1; i<=nbChampInvites; i++) if($('invitesEmail_'+i).value != '' && $('invitesFirstName_'+i).value == '')
				{
					$('invitesFirstName_'+i).style.backgroundColor = '#ffff55';
				}
				
			} else if(result == 351) // invités (userEmail) erroné
			{
				for(var i=1; i<=nbChampInvites; i++) if($('invitesEmail_'+i).value != '' || $('invitesFirstName_'+i).value != '' && $('invitesEmail_'+i).value == '')
				{
					$('invitesEmail_'+i).style.backgroundColor = '#ffff55';
				}
			} else
			{
				alert('Error. Result='+result);
			}
			
			$('waitSetUser').hide();
			$('btnSetUser').show();			
		}
	});
}



function setUser()
{
	if(isRequest) return false;
	
	var nbChampInvites = 4;
	
	if(form_is_skipable == true)
	{
		if($('userEmail').value=='')
		{
			SendInvitation();
			return;
		}
	}
	
	isRequest = true;
	$('btnSetUser').hide();
	$('waitSetUser').show();	
	
	for(var i=1; i<=nbChampInvites; i++) if($('invitesFirstName_'+i).value!='' || $('invitesEmail_'+i).value!='')
	{
		$('invitesFirstName_'+i).style.backgroundColor = '#ffffff';
		$('invitesEmail_'+i).style.backgroundColor = '#ffffff';
	}
	
	for(var i=1; i<=nbChampInvites; i++)
	{
		$('invitesFirstName_'+i).style.backgroundColor = '#ffffff';
		$('invitesEmail_'+i).style.backgroundColor = '#ffffff';
		$('invitesFirstName_'+i).disabled = true;
		$('invitesEmail_'+i).disabled = true;
	}
	
	if(form_is_question == true)
	{
		$('userComments').style.backgroundColor = '#ffffff';
		$('userComments').disabled = true;
	}
	
	$('userFirstName').style.backgroundColor = '#ffffff';
	$('userFirstName').disabled = true;
	
	$('userEmail').style.backgroundColor = '#ffffff';
	$('userEmail').disabled = true;
	
	if(form_is_question == true) $('zone_reglement').style.backgroundColor = 'transparent';
	$('zone_email').style.backgroundColor = 'transparent';
	
	var error_validation = false;
	
	if(!$('checkbox_email').checked)
	{
		$('zone_email').style.backgroundColor = '#ff0000';
		isRequest = false;
		$('btnSetUser').show();
		$('waitSetUser').hide();
		error_validation = true;
	}
	
	if(form_is_question == true)
	{
		if($('checkbox_reglement').checked && $('userComments').value=='')
		{
			$('userComments').style.backgroundColor = '#ffff55';
			isRequest = false;
			$('btnSetUser').show();
			$('waitSetUser').hide();
			error_validation = true;
			
		} else if(!$('checkbox_reglement').checked && $('userComments').value!='')
		{
			$('zone_reglement').style.backgroundColor = '#ff0000';
			isRequest = false;
			$('btnSetUser').show();
			$('waitSetUser').hide();
			error_validation = true;
		}
	}
	
	if(error_validation == true)
	{
		for(var i=1; i<=nbChampInvites; i++)
		{
			$('invitesFirstName_'+i).disabled = false;
			$('invitesEmail_'+i).disabled = false;
		}
		
		$('userFirstName').disabled = false;
		$('userEmail').disabled = false;
		if(form_is_question == true) $('userComments').disabled = false;
		return;
	}
	
	var userEmail = $('userEmail').value;
	
	var param = '';
	param += '&userFirstName='+encodeURIComponent($('userFirstName').value);
	param += '&userEmail='+encodeURIComponent(userEmail);
	param += '&userColorPlane='+idPlaneColor;
	param += '&userLastStageReleased='+idStage;
	param += '&userFormatEmail='+( $('userFormatEmail_html').checked==true ? 'html' : 'text' );
	param += '&countryId='+encodeURIComponent($('countryId').value);
	param += '&codeIdentifiant='+encodeURIComponent($('codeIdentifiant').value);
	if(form_is_question == true) param += '&userComments='+encodeURIComponent($('userComments').value);
	
	for(var i=1; i<=nbChampInvites; i++) if($('invitesFirstName_'+i).value!='' || $('invitesEmail_'+i).value!='')
	{
		param += '&invites[userFirstName][]=' +encodeURIComponent($('invitesFirstName_'+i).value);
		param += '&invites[userEmail][]=' + encodeURIComponent($('invitesEmail_'+i).value);	
	}
	
	//alert(param);
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=setUser' + param,
		onSuccess: function(transport) {
			isRequest = false;
			
			var response = transport.responseXML;
			var result = 1 * response.getElementsByTagName("result")[0].firstChild.nodeValue;
			
			for(var i=1; i<=nbChampInvites; i++)
			{
				$('invitesFirstName_'+i).disabled = false;
				$('invitesEmail_'+i).disabled = false;
			}
			
			$('userFirstName').disabled = false;
			$('userEmail').disabled = false;
			if(form_is_question == true) $('userComments').disabled = false;
			
			//alert('result = '+result);
			
			if(result == 200)
			{
				User['codeIdentifiant'] = response.getElementsByTagName("codeIdentifiant")[0].firstChild.nodeValue;
				User['userEmail'] = userEmail;
				$('game_link_identifier').hide();
				$('form1').hide();
				$('form1').update('');
				endStage();
				return;
				
			} else if(result == 300) // email invalide
			{
				alert(getLang('email_invalide'));
				$('userEmail').style.backgroundColor = '#ffff55';
				
			} else if(result == 303) // userFirstName trop court
			{
				$('userFirstName').style.backgroundColor = '#ffff55';
				
			} else if(result == 310) // email déjà en base
			{
				alert(getLang('email_deja_enregistre'));
				$('userEmail').style.backgroundColor = '#ffff55';
				
			} else if(result == 350) // invités (userFirstName) trop court
			{
				for(var i=1; i<=nbChampInvites; i++) if($('invitesEmail_'+i).value != '' && $('invitesFirstName_'+i).value == '')
				{
					$('invitesFirstName_'+i).style.backgroundColor = '#ffff55';
				}
				
			} else if(result == 351) // invités (userEmail) erroné
			{
				for(var i=1; i<=nbChampInvites; i++) if($('invitesEmail_'+i).value != '' || $('invitesFirstName_'+i).value != '' && $('invitesEmail_'+i).value == '')
				{
					$('invitesEmail_'+i).style.backgroundColor = '#ffff55';
				}
			} else
			{
				alert('Error. Result='+result);
			}
			
			$('waitSetUser').hide();
			$('btnSetUser').show();			
		}
	});
}



function setPostalAddress()
{
	if(isRequest) return false;
	
	isRequest = true;
	$('btnSetPostalAddress').hide();
	$('waitSetPostalAddress').show();
	
	$('userFirstName').style.backgroundColor = '#ffffff';
	$('userFirstName').disabled = true;	
	$('userName').style.backgroundColor = '#ffffff';
	$('userName').disabled = true;	
	$('userAddress').style.backgroundColor = '#ffffff';
	$('userAddress').disabled = true;
	$('userPostalCode').style.backgroundColor = '#ffffff';
	$('userPostalCode').disabled = true;
	$('userCity').style.backgroundColor = '#ffffff';
	$('userCity').disabled = true;
	
	$('zone_reglement').style.backgroundColor = 'transparent';
	
	var param = '';
	param += '&userFirstName='+encodeURIComponent($('userFirstName').value);
	param += '&userName='+encodeURIComponent($('userName').value);
	param += '&userAddress='+encodeURIComponent($('userAddress').value);
	param += '&userPostalCode='+encodeURIComponent($('userPostalCode').value);
	param += '&userCity='+encodeURIComponent($('userCity').value);
	param += '&userColorPlane='+idPlaneColor;
	param += '&userEmail='+User['userEmail'];
	param += '&countryId='+encodeURIComponent($('countryId').value);
	param += '&codeIdentifiant='+User['codeIdentifiant'];
	param += '&isConnected=1';
	
	
	if(!$('checkbox_reglement').checked)
	{
		isRequest = false;
		$('zone_reglement').style.backgroundColor = '#ff0000';		
		
		$('userFirstName').disabled = false;
		$('userName').disabled = false;
		$('userAddress').disabled = false;
		$('userPostalCode').disabled = false;
		$('userCity').disabled = false;
		
		$('waitSetPostalAddress').hide();
		$('btnSetPostalAddress').show();
		
		return;
	}

	//alert(param);
	
	new Ajax.Request(scriptsphp, {
		method: 'post',
		parameters: 'action=setPostalAddress' + param,
		onSuccess: function(transport) {
			isRequest = false;
			
			var response = transport.responseXML;
			var result = 1 * response.getElementsByTagName("result")[0].firstChild.nodeValue;

			//alert('result = '+result);
			
			if(result == 200)
			{
				User['codeIdentifiant'] = response.getElementsByTagName("codeIdentifiant")[0].firstChild.nodeValue;
				User['userEmail'] = User['userEmail'];
				User['userPostalCode'] = encodeURIComponent($('userPostalCode').value);
				$('game_link_identifier').hide();
				$('form2').hide();
				$('form2').update('');
				endStage();
				return;
				
			} else if(result == 302) // userName trop court
			{
				$('userName').style.backgroundColor = '#ffff55';
				
			} else if(result == 303) // userFirstName trop court
			{
				$('userFirstName').style.backgroundColor = '#ffff55';
				
			} else if(result == 305) //  address non renseignée
			{
				$('userAddress').style.backgroundColor = '#ffff55';
				
			} else if(result == 306) // code postal non renseigné
			{
				$('userPostalCode').style.backgroundColor = '#ffff55';
				
			} else if(result == 307) // Ville non renseignée 
			{
				$('userCity').style.backgroundColor = '#ffff55';

			} else
			{
				alert('Error. Result='+result);
			}

			$('userFirstName').disabled = false;
			$('userName').disabled = false;
			$('userAddress').disabled = false;
			$('userPostalCode').disabled = false;
			$('userCity').disabled = false;
			
			$('waitSetPostalAddress').hide();
			$('btnSetPostalAddress').show();			
		}
	});
}







function loadintro()
{
	setAnonymUser();
	
	$('imgHome').show();
	
	var preload_imgs = '';
	
	preload_imgs += '<img src="'+dirImg+'etapes/feuille_route_1_fr.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'game_fr.jpg" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel1.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel2.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel3.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel4.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel5.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'fuel5.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'blancbg.png" width="1" height="1" border="0" />';
	preload_imgs += getPreloadVideo(getLang('flv_decollage'));
	preload_imgs += '<img src="'+dirImg+'comment_jouer_title_fr.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'comment_jouer_fr.png" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'btn-decollage-immediat.gif" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'btn-feuille-route.png" width="1" height="1" border="0" />';	
	preload_imgs += '<img src="'+dirImg+'etapes/maquette1.jpg" width="1" height="1" border="0" />';
	preload_imgs += '<img src="'+dirImg+'personnalise_avion_fr.png" width="1" height="1" />';

	for(var i=1; i<=5; i++)
	{
		preload_imgs += '<img id="imgplane'+i+'" src="avion/plane'+i+'/plane135.png" border="0" width="1" height="1" />';
	}
	preload_imgs += '<img src="'+dirImg+'goodies_title_fr.png" border="0" width="1" height="1" />';		
	for(var i=1; i<listgoodies.length; i++)
	{
		preload_imgs += '<img src="'+dirImg+'goodies_'+listgoodies[i]+'_off.jpg" border="0" width="1" height="1" />';
		preload_imgs += '<img src="'+dirImg+'goodies_'+listgoodies[i]+'_on.jpg" border="0" width="1" height="1" />';
	}
	//$('preloadContent').update(preload_imgs);
	new Insertion.Bottom('preloadContent', preload_imgs);
}


function show_personnalisation_plane()
{
	var content = '<div style="background-image:url('+dirImg+'blancbg.png); width:440px;">';
	content += '<a href="#" onclick="popup_close(); return false;"><img src="'+dirImg+'personnalise_avion_fr.png" style="margin:0; padding:0; display:block" border="0" width="440" height="26" /></a>';
	
	content += '<table align="center"><tr>';
	for(var i=1; i<=5; i++)
	{
		content += '<td><div id="plane'+i+'" '+(idPlaneColor==i ? ' class="plane_selected" ' : '')+'><a href="#" onclick="selectPlane('+i+'); return false;"><img id="imgplane'+i+'" src="avion/plane'+i+'/plane135.png" border="0" width="124" height="124" /></a></div></td>';
		if(i==3) content += '</tr><tr>';
	}
	content += '<td align="center"><a href="#" onclick="popup_close(); return false;" style="color:#000; font-weight:bold" />'+getLang('btn_save')+'</a></td></tr>';
	content += '</table>';
	content += '</div>';
	
	popup_open(content, 150, -72, 440, 350);
	
	for(var i=1; i<=5; i++) png2ie6('imgplane'+i);
}


function show_goodies()
{
	var content = '<div style="background-image:url('+dirImg+'blancbg.png); width:440px; padding-bottom:2px;">';
	content += '<a href="#" onclick="popup_close(); return false;"><img src="'+dirImg+'goodies_title_fr.png" style="margin:0; padding:0; display:block" border="0" width="440" height="26" /></a>';	
	
	var mapLang = $('mapLang').value;
	
	for(var i=1; i<listgoodies.length; i++)
	{
		if(UserGoodie[i]!=true)
		{
			content += '<div style="margin:4px 2px 4px 6px;"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td width="1%"><img src="'+dirImg+'goodies_'+listgoodies[i]+'_off.jpg" border="0" style="margin-right:10px;" /></td>';
			content += '<td width="99%">'+getLang('goodie_libelle_'+i)+'</td></tr></table></div>';
			
		} else {
			content += '<div style="margin:4px 2px 4px 6px;"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td width="1%"><img src="'+dirImg+'goodies_'+listgoodies[i]+'_on.jpg" border="0" style="margin-right:10px;" /></td>';
			content += '<td width="99%"><a href="goodies/'+mapLang+'/goodies_'+listgoodies[i]+'.zip" style="color:#000">'+getLang('goodie_libelle_'+i)+'</a>';
			if(goodieBonus[i]!=undefined) content += '<br /><a href="#" onclick="show_video_goodie(\''+goodieBonus[i]['video']+'\', '+goodieBonus[i]['width']+', '+goodieBonus[i]['height']+'); return false;" style="color:#000">'+goodieBonus[i]['libelle']+'</a>';
			content += '</td></tr></table></div>';
		}
	}
	content += '</div>';
	
	popup_open(content, 150, -72, 440, 400);
}


function show_video_goodie(goodie, width, height)
{
	var content = '<div style="background-color:#000; width:440px; padding-bottom:2px;">';
	content += '<a href="#" onclick="popup_close(); return false;"><img src="'+dirImg+'videogoodies_title_fr.png" style="margin:0; padding:0; display:block" border="0" width="440" height="26" /></a><br />';
	
	if(width>400)
	{
		height = Math.round(height * 440 / width);
		width = 400;
	}
	
	content += '<div align="center">'+getFlashPlayerVideo(goodie, width, height)+'</div>';	
	content += '<br />&nbsp;</div>';
	
	popup_open(content, 150, -72, 440, 400);
}


function selectPlane(idPlaneColorSelected)
{
	$('plane'+idPlaneColor).className = '';
	$('plane'+idPlaneColorSelected).className = 'plane_selected';
	idPlaneColor = idPlaneColorSelected;
	dirPlaneImg = 'avion/plane'+idPlaneColorSelected+'/';
	
	myPlane.setImage(urlServer + dirPlaneImg + 'plane'+ numeroPlane + '.png');
	
	var preload_imgs = '';
	for(var i=0; i<360; i=i+stepPlane)
	{
		preload_imgs += '<img src="'+urlServer + dirPlaneImg + 'plane' + i + '.png" height="1" width="1" />';
	}
	//$('preloadContent').update(preload_imgs);
	new Insertion.Bottom('preloadContent', preload_imgs);
}


function show_bande_annonce()
{
	var content = '<div style="background-color:#000; width:440px;">';
	content += '<a href="#" onclick="popup_close(); return false;"><img src="'+dirImg+'bandeannonce_title_fr.png" style="margin:0; padding:0; display:block" border="0" width="440" height="26" /></a>';	
	content += '<div align="center">'+getFlashPlayerVideo(getLang('flv_trailer'), 240, 180)+'</div>';	
	content += '<br />&nbsp;</div>';	
	popup_open(content, 160, -220, 440, 350);
}


function show_roadmap(idStage)
{
	var content = '<a href="#" onclick="popup_close(); return false;"><img id="imgfeuille_route_'+idStage+'" src="'+dirImg+'etapes/feuille_route_'+idStage+'_fr.png" style="margin:0; padding:0; display:block" border="0" width="754" height="400" /></a>';	
	popup_open(content, 125, -377, 754, 400);
	
	png2ie6('imgfeuille_route_'+idStage);
}

/*
function ensavoirplus(idStage)
{
	popup_open(getLang('ensavoirplus_etape'+idStage+'_titre'), getLang('ensavoirplus_etape'+idStage+'_description'), 110, 450, 200);
}
*/

function howToPlay()
{
	var content = '<a href="#" onclick="popup_close(); return false;"><img src="'+dirImg+'comment_jouer_title_fr.png" style="margin:0; padding:0; display:block" border="0" width="440" height="26" /></a><img src="'+dirImg+'comment_jouer_fr.png" style="margin:0; padding:0; display:block" width="440" height="275" />';
	
	if(is_sound)
	{
		var rndSound = getRandomElement(soundGame['comment_jouer']);
		if(rndSound)
		{
			$('soundAction').update(getFlashSound('comment_jouer', rndSound));
		}
	}
	
	popup_open(content, 150, -72, 440, 301);
}

function skip_form()
{
	$('game_link_identifier').hide();
	$('form1').hide();
	$('form1').update('');
	
	User['codeIdentifiant'] = true;
	endStage();
}

function show_setUser()
{
	var html = '';
	html += '<div id="form1_content" style="padding-top:120px; padding-left:106px; width:740px;">';
	html += '<a href="#" onclick="$(\'form1\').update(\'\');$(\'form1\').hide();"><img id="imgClose" src="'+dirImg+'close.png" border="0" width="12" height="12" align="right" vspace="10" /></a>';
	
	if(form_is_question != true) html += '<br><br><br><br><br>';
	
	html += '<table cellpadding="0" cellspacing="0" border="0" width="700">';
	html += '<tr><td colspan="2"><img id="imgform_title1" src="'+dirImg+'form_title1.png" alt="" width="591" height="37" /></td></tr>';
	html += '<tr><td colspan="2"><table cellpadding="2" cellspacing="0" border="0" width="100%">';
	html += '<tr>';
	html += '<td nowrap="nowrap">'+getLang('prenom_pseudo')+'* :</td>';
	html += '<td nowrap="nowrap">'+getLang('adresse_email')+(form_is_skipable==true ? '': '*')+' :</td>';
	html += '<td rowspan="2">&nbsp;</td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap" valign="top"><input id="userFirstName" type="text" size="35" maxlength="250" /></td>';
	html += '<td nowrap="nowrap" valign="top"><input id="userEmail" type="text" size="35" maxlength="250" /></td>';
	html += '<td rowspan="2" style="font-size:10px; font-weight:normal;"  valign="top"><div id="zone_email"><input id="checkbox_email" type="checkbox" '+(form_is_skipable==true ? '': 'checked="checked"')+' style="float:left; margin-right:10px; margin-bottom:10px;" /><label for="checkbox_email">'+getLang('accepter_email')+'</label></div></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td colspan="2" style="font-size:9px; font-weight:normal;">'+getLang('champs_obligatoires')+'</td>';
	html += '</tr>';
	html += '</table></td></tr>';
	html += '<tr><td colspan="2"><table cellpadding="2" cellspacing="0" border="0" width="100%"><tr><td nowrap="nowrap" width="10%">'+getLang('format_email')+'</td><td width="90%"><input id="userFormatEmail_html" name="userFormatEmail" type="radio" checked="checked" value="html" style="vertical-align:middle" /> <label for="userFormatEmail_html">'+getLang('format_email_html')+'</label>&nbsp;&nbsp;<input id="userFormatEmail_text" name="userFormatEmail" type="radio" value="text" style="vertical-align:middle" /> <label for="userFormatEmail_text">'+getLang('format_email_text')+'</label></td></tr>';
	html += '</table></td></tr>';
	html += '<tr><td colspan="2"><img id="imgform_title2" src="'+dirImg+'form_title2.png" alt="" width="379" height="38" /></td></tr>';
	html += '<tr><td colspan="2"><table cellpadding="0" cellspacing="0" border="0"><tr>';
	html += '<td>'+getLang('prenom_pseudo')+' :</td>';
	html += '<td>&nbsp;&nbsp;</td>';
	html += '<td>'+getLang('adresse_email')+' :</td></tr>';
	html += '<tr>';
	html += '<td><input id="invitesFirstName_1" type="text" size="35" maxlength="250" /></td>';
	html += '<td>&nbsp;&nbsp;</td>';
	html += '<td><input id="invitesEmail_1" size="35" maxlength="250" type="text" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td><input id="invitesFirstName_2" type="text" size="35" maxlength="250" /></td>';
	html += '<td>&nbsp;&nbsp;</td>';
	html += '<td><input id="invitesEmail_2" size="35" maxlength="250" type="text" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td><input id="invitesFirstName_3" type="text" size="35" maxlength="250" /></td>';
	html += '<td>&nbsp;&nbsp;</td>';
	html += '<td><input id="invitesEmail_3" size="35" maxlength="250" type="text" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td><input id="invitesFirstName_4" type="text" size="35" maxlength="250" /></td>';
	html += '<td>&nbsp;&nbsp;</td>';
	html += '<td><input id="invitesEmail_4" size="35" maxlength="250" type="text" /></td>';
	html += '</tr>';
	html += '</table></td></tr>';
	
	if(form_is_question == true)
	{
		html += '<tr><td colspan="2"><img id="imgform_title3" src="'+dirImg+'form_title3.png" alt="" width="575" height="37" /></td></tr>';
		html += '<tr><td colspan="2"><table cellpadding="2" cellspacing="0" border="0" width="100%">';
		html += '<tr><td colspan="2">'+getLang('form_libelle_question')+'</td></tr>';
		html += '<tr><td colspan="2"><textarea id="userComments" cols="72" rows="2"></textarea></td></tr>';
		html += '<tr><td colspan="2" style="font-size:10px; font-weight:normal;">'+getLang('form_libelle_question_complement')+'</td></tr>';
		html += '<tr>';
		html += '<td style="font-size:9px; font-weight:normal;"><div id="zone_reglement"><input id="checkbox_reglement" type="checkbox" style="float:left; margin-right:10px;" /> <label for="checkbox_reglement">'+getLang('form_libelle_question_autorisation')+'</label></div></td>';
	
	} else {
		html += '<tr><td colspan="2">&nbsp;</td></tr>';
		html += '<tr>';
		html += '<td>&nbsp;</td>';
	}
	
	html += '<td><div id="btnSetUser">';
	
	if(form_is_skipable==true)
	{
		html += '<a href="#" onclick="skip_form(); return false;"><img id="imgform_skip" src="'+dirImg+'skip.png" alt="" width="103" height="29" border="0" align="right" /></a>';
	}
	
	html += '<a href="#" onclick="setUser(); return false;"><img id="imgbtn_valider_form" src="'+dirImg+'btn_valider_form.png" alt="" border="0" width="206" height="30" /></a>';

	html += '</div><div id="waitSetUser" style="display:none;"><img src="'+dirImg+'loader.gif" /></div>';
	html += '</td></tr>';
	
	html += '</table></td>';
	html += '</tr>';
	html += '</table>';
	html += '</div>';
	
	$('form1').update(html);
	$('form1').show();
	
	png2ie6('imgbtn_valider_form');
	png2ie6('imgform_title1');
	png2ie6('imgform_title2');
	png2ie6('imgClose');
	
	if(form_is_skipable==true) png2ie6('imgform_skip');
	
	if(form_is_question == true) png2ie6('imgform_title3');
}


function show_setPostalAddress()
{
	var html = '';
	html += '<div id="form1_content" style="padding-top:126px; padding-left:106px; width:745px;">';
	html += '<a href="#" onclick="$(\'form2\').update(\'\');$(\'form2\').hide();"><img id="imgClose" src="'+dirImg+'close.png" border="0" width="12" height="12" align="right" vspace="10" /></a>';
	html += '<div style="padding-top:80px;">';	
	html += '<table cellpadding="2" cellspacing="0" border="0" width="400">';
	html += '<tr>';
	html += '<td nowrap="nowrap">'+getLang('prenom')+' :</td>';
	html += '<td nowrap="nowrap">'+getLang('nom')+' :</td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap" valign="top"><input id="userFirstName" type="text" size="35" maxlength="250" /></td>';
	html += '<td nowrap="nowrap" valign="top"><input id="userName" type="text" size="35" maxlength="250" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap">'+getLang('adresse')+' :</td>';
	html += '<td>&nbsp;</td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap" colspan="2"><input id="userAddress" type="text" size="75" maxlength="250" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap">'+getLang('code_postal')+' :</td>';
	html += '<td nowrap="nowrap">'+getLang('ville')+' :</td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td nowrap="nowrap" valign="top"><input id="userPostalCode" type="text" size="35" maxlength="250" /></td>';
	html += '<td nowrap="nowrap" valign="top"><input id="userCity" type="text" size="35" maxlength="250" /></td>';
	html += '</tr>';
	html += '<tr><td nowrap="nowrap" colspan="2">&nbsp;</td></tr>';
	
	html += '<tr><td colspan="2" style="font-size:9px; font-weight:normal;"><div id="zone_reglement" style=" margin-right:70px"><input id="checkbox_reglement" type="checkbox" style="float:left; margin-right:10px; margin-bottom:30px;" /> <label for="checkbox_reglement">'+getLang('form_libelle_question_autorisation')+'</label></div></td></tr>';
	
	html += '<tr><td nowrap="nowrap" colspan="2">&nbsp;</td></tr>';
	html += '<tr>';
	html += '<td align="center" colspan="2"><div id="btnSetPostalAddress" align="center"><a href="#" onclick="setPostalAddress(); return false;"><img id="imgbtn_valider_form" src="'+dirImg+'btn_valider_form.png" alt="" border="0" width="206" height="30" /></a></div><div id="waitSetPostalAddress" style="display:none;" align="center"><img src="'+dirImg+'loader.gif" /></div></td>';
	html += '</tr></table></td>';
	html += '</tr>';
	html += '</table>';
	html += '</div></div>';
	
	$('form2').update(html);
	$('form2').show();
	
	png2ie6('imgbtn_valider_form');
	png2ie6('imgClose');
}