Ext.onReady(function(){
					 
	var tempOffLink = Ext.select('.page_temp_off');
	
	if(tempOffLink){

		tempOffLink.on('click', function(){alert('This page is temporary offline or under construction. Sorry for the inconvenience. / Cette page est temporairement hors service ou en construction. Merci.');});
		
	}
					 
});

function swfSwitch(lang) {
	//var rand = Math.floor(Math.random()*(A+1));
	var rand = Math.floor(Math.random()*(1+1));
	var swfPath = 'flash/pub_header_default.swf';
	
	if (rand == 0) {
		swfPath = 'flash/pub_home_banner-'+lang+'.swf';
	}
	else if (rand == 1) {
		swfPath = 'flash/pub_home_banner-'+lang+'.swf';
	}
	swfobject.embedSWF(swfPath, "header_pub_flashContainer", "728", "90", "9.0.0", "flash/expressInstall.swf", null, {'wmode': 'transparent'});
	
}

function showVid(id)
{
	var allPlayer = Ext.select('.player').elements;
		
	var dh = Ext.DomHelper;
	for(var i = 0; i < allPlayer.length; i++)
	{
		dh.overwrite(allPlayer[i].id, '');
	}

	var html  = '<div class="video_yt_container"><object width="550" height="340">';
		html += 	'<param name="movie" value="http://www.youtube.com/v/'+id+'&hl=fr_FR&fs=1&autoplay=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&enablejsapi=1"></param>';
		html += 	'<param name="allowFullScreen" value="true"></param>';
		html += 	'<param name="wmode" value="opaque" ></param>';
		html += 	'<param name="allowscriptaccess" value="always"></param>';
		html +=		'<embed src="http://www.youtube.com/v/'+id+'&hl=fr_FR&fs=1&autoplay=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&enablejsapi=1" type="application/x-shockwave-flash" wmode="opaque" allowscriptaccess="always" allowfullscreen="true" width="550" height="340"></embed>';
		html += '</object></div>'
	dh.overwrite('player_'+id, html);
}

/* FONCTIONS RELIÉES A LA NEWSLETTER */

function addMember()
{
	var valLname = Ext.get('lname').getValue();
	var valFname = Ext.get('fname').getValue();
	var valEmail = Ext.get('email').getValue();
	var valAccept = Ext.get('accept').dom.checked;
	
	Ext.get('errorfield').setStyle('color', '#FF0000');
	
	if((valLname !== "") && (valFname !== "") && (valEmail !== "") && (valAccept !== false)){
		
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				
		if(filter.test(valEmail) == false){
		
			Ext.get('errorfield').dom.innerHTML = BASE.lang.nl_error_mail;
		}
		else{
			Ext.Ajax.request({
				url : 'utils/subscribe_newsletter.php',
				method	: 'POST',
				params	: {
					email : valEmail,
					lname : valLname,
					fname : valFname
				},
				success	: function(response){
					var responses 	= Ext.decode(response.responseText);
					var html = "";
					switch(responses.msg)
					{
						case "error_params":
							html = BASE.lang.nl_error_params;
							break;
						case "error_subscribe":
							html = BASE.lang.nl_error_cant_subscribe;
							break;
						case "success_subscribe":
							Ext.get('errorfield').setStyle('color', '#2e8eb4');
							Ext.get('lname').dom.value = '';
							Ext.get('fname').dom.value = '';
							Ext.get('email').dom.value = '';
							Ext.get('accept').dom.checked = false;
							html = BASE.lang.nl_success_subscribe;
							break;
					}
					
					Ext.get('errorfield').dom.innerHTML = html;
				}
			});
		} 	
	}
	else{
		Ext.get('errorfield').dom.innerHTML = BASE.lang.nl_error_field;
	}
}

//Function pour cacher les iFrame

function setIframeVisible(e){
	Ext.get(e).fadeIn();
} 

//Function pour calculer la hauteur d'une iFrame

function setHeight(id){
	var newHeight;
	newHeight = document.getElementById(id).contentWindow.document.body.scrollHeight;
	if (newHeight >= 270) { // 270 = taille 'min-height' du div dans css
		document.getElementById(id).style.height = newHeight+25+"px";
	}
}
