// JavaScript Document
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_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_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 writeFlash(fichier,_width,_height) {
	document.write('<object type="application/x-shockwave-flash" data="'+fichier+'" width="'+_width+'" height="'+_height+'">');
	document.write('	<param name="movie" value="'+fichier+'" />');
	document.write('	<param name="quality" value="high" />');
	document.write('	<param name="scale" value="noscale" />');
	document.write('	<param name="menu" value="false" />');
	document.write(' 	<embed src="'+fichier+'" quality="high" width="'+_width+'" height="'+_height+'" scale="noscale" menu="false"></embed>');
	document.write('</object>');	
}

function afficher(nbr){


	article = form.elements['pressRelease'].selectedIndex;
	
		for(i=0; i<nbr; i++){
				
				document.getElementById('release' + i).style.display = 'none';
		 
		}
			
	
	document.getElementById('release' + article).style.display = 'block';
		
	
	
    
}




function checkForm( form , erreur)
{

	if ( form.elements['email'] != undefined )
	{
		if ( !checkMail( form.elements['email'].value ) ) { 
		window.document.getElementById( 'error' ).style.display = 'block';
		return false;
		}
	}
	
// check du formulaire mobile
if( form.elements['msisdn'] != undefined && form.elements['surname'] != undefined && form.elements['name'] != undefined){
	    
		
		if(!checkTel(form.elements['msisdn'].value)){
			window.document.getElementById( 'error' ).style.display = 'block';
			return false;					   
		
		}
		
		
		if ( form.elements['msisdn'].value == 'Your mobile number' || form.elements['msisdn'].value == '')
		{
			
			window.document.getElementById( 'error' ).style.display = 'block';
			return false;
			
		}
		
		if ( form.elements['surname'].value == 'Your first name' || form.elements['surname'].value == '')
		{
			
			window.document.getElementById( 'error' ).style.display = 'block';
			return false;
			
		}
		if ( form.elements['name'].value == 'Your last name' || form.elements['name'].value == '')
		{
			
			window.document.getElementById( 'error' ).style.display = 'block';
			return false;
			
		}
		
	   if ( form.elements['cg'].checked == false)
		{
			
			window.document.getElementById( 'error' ).style.display = 'block';
			return false;
			
		}
		
		
}




	
	
	// check du formulaire de la vidéo d'anniversaire
		
	if ( form.elements['dest_email'] != undefined )
	{
		if ( !checkMail( form.elements['dest_email'].value ) ) { 
		window.document.getElementById( 'error' ).style.display = 'block';
		return false;
		}
	}
	if ( form.elements['exp_email'] != undefined )
	{
		if ( !checkMail( form.elements['exp_email'].value ) ) { 
		window.document.getElementById( 'error' ).style.display = 'block';
		return false;
		}
	}
	
	if ( form.elements['exp_prenom'].value == 'My first name'|| form.elements['exp_prenom'].value == 'Mein Vorname' || form.elements['exp_prenom'].value == 'Votre prénom' || form.elements['exp_prenom'].value == '' || form.elements['exp_prenom'].value == 'Il mio nome' || form.elements['exp_prenom'].value == '' )
	{
		window.document.getElementById( 'error' ).style.display = 'block';
		return false;
		
	}
	
	if ( form.elements['dest_prenom'].value == 'His/Her first name' || form.elements['dest_prenom'].value == 'Sein/ihr Vorname' || form.elements['dest_prenom'].value == 'Son prénom' ||form.elements['dest_prenom'].value == '' | form.elements['dest_prenom'].value == 'Il suo nome' ||form.elements['dest_prenom'].value == '')
	{
		
		window.document.getElementById( 'error' ).style.display = 'block';
		return false;
		
	}
	
	//alert ( "c cool" ) ;
	//window.open ('popups/send_video.php')
	 //window.open("popups/send_video.php","confirmation","menubar=no, status=no, scrollbars=no, menubar=no, width=353, height=248");
	 /*window.document.getElementById( 'validation' ).style.display = 'block';
	 window.document.getElementById( 'formulaire' ).style.display = 'none';
	 */
	return true;
	//return false;

}


function checkMail( ch )
{

	var t;
	
	if ( ch == '' ) {
		return false;
	}
	else
	{ 
		t = ch.split('@');
		
		if ( t.length == 2 )
		{ 
			t = t[1].split('.');
			
			if ( t.length >= 2 ) 
			{
				if ( t[1] == '' ) { 
					return false;
				}
			}
			else {
				return false;
			}
		}
		else {
			return false;
		}
	}
	
	return true;
}


// vérif numéro de téléphone
function checkTel( ch )
{
	if ( ch == '' ) {
		return false;
	}
	else
	{
		var ch = ch;
		
		if ( ch.length == 10 )
		{
			if ( ch.charAt(0) == '0' )
			{
				var _2 = parseInt( ch.charAt(1) );
				
				if ( !((_2 > 0) && (_2 < 9) && (_2 != 7)) ) {
					return false;
				}
				else
				{
					for ( i = 2; i < 10; i++ )
					{ 
						if ( isNaN( parseInt( ch.charAt(i) ) ) ) { 
							return false;
						}
					}
				}
			}
			else {
				return false;
			}
		} 
		else { 
			return false;
		}
	}
	
	return true;
}


function prechargimg() {
var doc=document;
	if(doc.images){ if(!doc.precharg) doc.precharg=new Array();
	var i,j=doc.precharg.length,x=prechargimg.arguments; for(i=0; i<x.length; i++)
	if (x[i].indexOf("#")!=0){ doc.precharg[j]=new Image; doc.precharg[j++].src=x[i];}}
}

function tempo() {
       	clearInterval();
	  	 window.document.getElementById( 'validation' ).style.display = 'none';
		 window.document.getElementById( 'formulaire' ).style.display = 'block';
   }
function alerte(){
	var timer=setInterval("tempo()", 3000);
}
