// JavaScript Document
function PopupCentrer(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
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_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_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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

///////////////////


// JavaScript Document
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
	{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
	}
  catch (e)
	{
	// Internet Explorer
	try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}
  return xmlHttp;
}

function updateEmailNewsletter(email){
	//alert('ok');
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null){
		alert("Votre fureteur ne supporte pas ajax.");
		return;
	}
		
	var url = "newsletter.php?email="+email;
	alert("newsletter.php?email="+email);
	
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState == 4 && xmlHttp.responseText!=""){			
			alert(xmlHttp.responseText);//'Merci de votre inscription' or 'error'
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function checkRegisterNewsletter() {
	register = document.forms["newsletter-form"];	
	error = false;
	errormail = false;
	email = new RegExp ( "^\\w[\\w+\.\-]*@[\\w\-]+\.\\w[\\w+\.\-]*\\w$", "gi" ) ;
	if ( !register.email.value ) {
		error = true;	
	}
	if ( register.email.value.search(email) == -1 ) {
		errormail = true;
	}
	if ( error ) {
		alert("Vous devez renseigner tous les champs.");
		register.email.focus();
		return false;
	}
	else if ( errormail ) {
		alert("Merci d'indiquer une adresse e-mail valide.");
		register.email.focus();
		return false;
	}
	
	updateEmailNewsletter(register.email.value);
	return false;
}


function valideEmail(str) {
	parob = str.indexOf('@');
		if (parob!=-1) {
			if (str.lastIndexOf('.') < parob) {
				return false;
			}
		} else {
			return false;
		}
	return true;
}

function checkFields() {
	register = document.forms["newsletter-form"];
	//alert("totot"+register.email.value);
	if (!valideEmail(register.email.value)){
		alert('Merci de saisir une adresse e-mail valide.');
		register.email.focus();
		register.email.value='Votre e-mail';
		return false;
	}
}



function viewVideo(docId){
	var div_obj=document.getElementById('media_video');
	var div_slide=document.getElementById('media_image');	
	
	var div_btn_video=document.getElementById('btn_video');
	var div_btn_close_video=document.getElementById('btn_close_video');	
	
	if(div_obj.style.display==''){
		div_obj.innerHTML='';
		div_obj.style.display='none';
		div_btn_video.style.display='';
		div_btn_close_video.style.display='none';

		div_slide.style.display='';

	}else{
		
		var content='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="654" height="360">';
		content+='<param name="movie" value="swf/videoModule.swf?doc_id='+docId+'" />';
		content+='<param name="quality" value="high" />';
		content+='<embed src="swf/videoModule.swf?doc_id='+docId+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="654" height="360"></embed>';
	    content+='</object>';
		
		div_obj.innerHTML=content;
		div_obj.style.display='';

		div_btn_video.style.display='none';
		div_btn_close_video.style.display='';

		div_slide.style.display='none';
	}		
}

function hideVideo(){
	viewVideo(0);
}

function viewSlide(docId){
	var div_obj=document.getElementById('media_image');
	var div_slide=document.getElementById('media_video');	
	
	var div_btn_images=document.getElementById('btn_images');
	var div_btn_video=document.getElementById('btn_video');	
	
	if(div_obj.style.display==''){
		div_obj.innerHTML='';
		div_obj.style.display='none';
		div_btn_images.style.display='';
		div_btn_video.style.display='none';

		div_slide.style.display='';

	}else{
		
		var content='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="655" height="357">';
        content+='<param name="movie" value="swf/slide_liste_form.swf?docId='+docId+'&genreId=1" />';
        content+='<param name="quality" value="high" />';
        content+='<embed src="swf/slide_liste_form.swf?docId='+docId+'&genreId=1" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="655" height="357"></embed>';
        content+='</object>';
		
		div_obj.innerHTML=content;
		div_obj.style.display='';

		div_btn_images.style.display='none';
		div_btn_video.style.display='';

		div_slide.style.display='none';
	}		
}

function hideSlide(){
	viewSlide(0);
}



function viewSound(docId){
	var div_obj=document.getElementById('media_sound');
	//var div_slide=document.getElementById('media_image');	
	
	var div_btn_sound=document.getElementById('btn_sound');
	var div_btn_close_sound=document.getElementById('btn_close_sound');	
	
	if(div_obj.style.display==''){
		div_obj.innerHTML='';
		div_obj.style.display='none';
		div_btn_sound.style.display='';
		div_btn_close_sound.style.display='none';

		//div_slide.style.display='';

	}else{
		
		var content='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="654" height="37">';
		  content+='<param name="movie" value="swf/soundModule.swf?doc_id='+docId+'" />';
		  content+='<param name="quality" value="high" />';
		  content+='<embed src="swf/soundModule.swf?doc_id='+docId+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="654" height="37"></embed>';
		content+='</object>';

		div_obj.innerHTML=content;
		div_obj.style.display='';

		div_btn_sound.style.display='none';
		div_btn_close_sound.style.display='';

		//div_slide.style.display='none';
	}		
}

function hideSound(){
	viewSound(0);
}

