// STUDIO DE LÀ ®
// reproduction même partiel interdite

// [FONCTION] verifMail v2
function verifMail(a) {
	testm =	false ;
	
	// on donne les caracteres autorisés
      testchaine = 'ok';
      chaine = a;
      var alphabet     = 'a-z';     // alphabet
      var chiffre      = '0-9';     // chiffre
      var trait        = '\\-';     // trait d'union
      var underscore   = '\\_';     // underscore
      var caract_ok    = '['+alphabet+chiffre+trait+underscore+'@\.]';
      // on test les caractere valides
      jeTest = a;
      for (var j=0 ; j<(jeTest.length) ; j++) {
            var mon_exp = new RegExp (caract_ok, 'gi');
            var x = mon_exp.test(jeTest.charAt(j));
            var lepasbon = jeTest.charAt(j);
            if (lepasbon==' '){lepasbon = 'ESPACE';}
            if ( x == false ) {
            	alert('Le caractère \''+ lepasbon +'\' n\'est pas valide dans une adresse Email');
            	testchaine = 'ko';
                  return false;
            	}
            }
      // on regarde la coherence de la structure du mail
	for (var j=1 ; j<(a.length) ; j++) {
            if (a.charAt(j)=='@') {
			if (j<(a.length-4)){
				for (var k=j ; k<(a.length-2) ;	k++) {
					if (a.charAt(k)=='.') testm = true;
						}
				}
			}
		}
	if (testm==false) { alert('adresse e-mail incorrecte.');return false}
	else { return true; }
	
		// ELSE	facultatif ; la	fonction retournant testm, la suite du traitement du formulaire	peut donc avoir	lieu
	return testm ; 
	}

defaultvalue_prenom     = 'votre prénom';
defaultvalue_email      = 'connaissance@email.com';

function check_recovideo(o){
      //alert('yes');
     	couleurFocus = '#FFD8BA';
        
      if ( o.prenom.value == '' || o.prenom.value == defaultvalue_prenom) {
	      alert('Veuillez saisir votre "prénom"');
	      o.prenom.style.background=couleurFocus;
	      o.prenom.focus();
	      return false;
	      }
      verifMail(o.email.value);
      if (testm==false) { 
      	o.email.style.background=couleurFocus;
      	o.email.focus();
      	return false;
      	}
      if ( o.email.value == defaultvalue_email ) {
	      alert('Veuillez saisir l\'Email de votre destinataire');
	      o.email.style.background=couleurFocus;
	      o.email.focus();
	      return false;
	      }
      if ( o.page.value == '' ) {
	      alert('Erreur');
	      return false;
	      }
      if ( o.video.value == '' ) {
	      alert('Erreur');
	      return false;
	      }
      }

// efface champs 1.1
// onFocus="effaceChamps(this.form.name,this.name,'mots clés');
function effaceChamps (o,s,textToErase) {
	if (textToErase == document.forms[o].elements[s].value){ document.forms[o].elements[s].value="" }
	}

function c2la_video(flv, titre, swf, L, H, P){

      Lswf = 300;
      Hswf = 280;
      if(L){Hswf = L;}
      if(H){Hswf = H;}
      couleur = "#FFFFFF";
      if(swf){SWFFILE = swf;}else{SWFFILE = 'video';}
      Fswf = SWFFILE+".swf?rep=video&flv="+flv+".flv";
      
      var codeFlash = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
          + 'WIDTH="'+Lswf+'" HEIGHT="'+Hswf+'"'
          + 'CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="video" align="middle">'
          + '<PARAM NAME="MOVIE" VALUE="'+Fswf+'">'
          + '<PARAM NAME="QUALITY" VALUE="high">'
          + '<PARAM NAME="MENU" VALUE="false">'
          + '<PARAM NAME="SCALE" VALUE="noscale">'
          + '<PARAM NAME="BGCOLOR" VALUE="'+couleur+'">'
          + '<PARAM NAME="allowScriptAccess" VALUE="sameDomain" />'
          + '<EMBED SRC="'+Fswf+'" ' 
          + 'WIDTH="'+Lswf+'" HEIGHT="'+Hswf+'" ' 
          + 'bgcolor="'+couleur+'" ' 
          + 'name="video" '
          + 'align="middle" '
          + 'allowScriptAccess="sameDomain" '
          + 'QUALITY="high" ' 
          + 'SCALE="noscale" ' 
          + 'MENU="false" ' 
          + 'TYPE="application/x-shockwave-flash" ' 
          + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> '
          + '</EMBED>'
          + '</OBJECT>';
      urlnow = window.location.pathname;
      //alert(urlnow);
      if(fromme!=''){prenom=fromme;}else{prenom=defaultvalue_prenom;}
      if(P){var donwload = '<div align=right><b>Téléchargez</b> cette vidéo ('+P+'): <a href="dl.php?video='+flv+'">cliquez ici</a></div><br>';}else{var donwload='<br>';}
      var contenu = '<form name=recovideo method=post action="/rv.php" onSubmit="return(check_recovideo(this));" style="border: 1px dashed #6C7CE1;padding:5px;margin:0;">'
                + '<b style="color:#6C7CE1;font-size:11px;">'+titre+'</b><br>'+donwload+''
                + '<input type=hidden name=page value="'+urlnow+'">'
                + '<input type=hidden name=video value="'+flv+'">'
                + '<input type=hidden name=titre value="'+escape(titre)+'">'
                + 'Recommandez cette vidéo :<br> '
                + '<table border=0><tr><td><i>(vous)</i></td><td><input type=text name=prenom value="'+prenom+'" size=27 onFocus="effaceChamps(this.form.name,this.name, \''+defaultvalue_prenom+'\')"></td></tr><tr><td>recommande à </td><td><input type=text name=email value="'+defaultvalue_email+'" size=27 onFocus="effaceChamps(this.form.name,this.name, \''+defaultvalue_email+'\')"> <input type=submit value="Ok" class=form_but></td></tr></table>'
                + '</form>';
        document.getElementById("descriptions").innerHTML = codeFlash+contenu;  // IE ok, Fire ok
        }

// [FONCTION] tof v1.0
// popUp dynamique image
function tof(monImage){
	w = window.open('','chargement','width=700,height=500');
	w.document.write( "<html><head><title>Photo</title>\n" );
	w.document.write( "<script language='JavaScript'>\n");
	w.document.write( "IE5=NN4=NN6=false;\n");
	w.document.write( "if(document.all)IE5=true;\n");
	w.document.write( "else if(document.getElementById)NN6=true;\n");
	w.document.write( "else if(document.layers)NN4=true;\n");
	w.document.write( "function autoSize() {\n");
	w.document.write( "if(IE5) self.resizeTo(document.images[0].width+10,document.images[0].height+28);\n");
	w.document.write( "else if(NN6) self.sizeToContent();\n");
	w.document.write( "else window.resizeTo(document.images[0].width,document.images[0].height+15);\n");
	w.document.write( "self.focus();\n");
	w.document.write( "}\n</scri");
	w.document.write( "pt>\n");
	w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" );
	w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0 alt='Cliquez pour FERMER'></a>" );
	w.document.write( "</body></html>" );
	w.document.close();
	}

// [FONCTION] quit_frame v1.0
function quit_frame(){
        if (parent.frames.length > 0)
        	{
        	window.top.location.href = location.href;
        	}
	}
