function RunFlash(fichier,largeur,hauteur)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largeur+'" height="'+hauteur+'">\n');
    document.write('<param name="movie" value="'+fichier+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="window" />\n');
	document.write('<embed src="'+fichier+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="Opaque" width="'+largeur+'" height="'+hauteur+'"></embed>\n');
    document.write('</object>\n');
}

function RunFlashRedim(fichier,largeur,hauteur,div)
{	//document.write("largeur dispo = "+screen.availWidth)
	
	marge_souhaite=15;
	manque_en_hauteur = (hauteur+marge_souhaite+190-screen.availHeight)/hauteur;
	manque_en_largeur = (largeur+marge_souhaite-screen.availWidth)/largeur;
	//document.write(manque_en_hauteur+"et"+manque_en_largeur);
	if (manque_en_largeur>manque_en_hauteur){
		//document.write(manque_en_hauteur+"et"+manque_en_largeur);
		if (screen.availWidth<largeur+marge_souhaite){
			newlargeur=screen.availWidth-marge_souhaite;
			hauteur = (newlargeur*hauteur)/largeur;
			largeur=newlargeur;
			document.getElementById(div).style.width=largeur+"px";
			document.getElementById(div).style.height=hauteur+"px";
    	}
	}

	else {
		
		if (screen.height<hauteur+marge_souhaite+190){
			
			newhauteur=screen.height-marge_souhaite-190;
			//newhauteur=410;
			largeur = (newhauteur*largeur)/hauteur;
			hauteur=newhauteur;
			document.getElementById(div).style.width=largeur+"px";
			document.getElementById(div).style.height=hauteur+"px";
			
			//document.write(manque_en_hauteur+"et"+manque_en_largeur+"et"+screen.availHeight+"et"+largeur+"et"+hauteur);
    	}
	}
	//css pour centrer le flash
	document.getElementById(div).style.zIndex=10;
	document.getElementById(div).style.position="absolute";
	document.getElementById(div).style.left="50%";
	document.getElementById(div).style.top="50%";
	margin_left = Math.round(-largeur/2);
	margin_top = Math.round(-hauteur/2);
	document.getElementById(div).style.marginTop=margin_top+"px";
	document.getElementById(div).style.marginLeft=margin_left+"px";
    
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largeur+'" height="'+hauteur+'">\n');
    document.write('<param name="movie" value="'+fichier+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="window" />\n');
	document.write('<embed src="'+fichier+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="window" width="'+largeur+'" height="'+hauteur+'"></embed>\n');
    document.write('</object>\n');
}



function PopupImage(img,comm) { 
titre="Agrandissement"; 
w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
w.document.write("<BODY onload='checksize()' onclick='window.close()' onblur='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
w.document.write('<TD valign="middle" align="center"><IMG src="'+img+'" border=0 title="'+comm+'" alt="'+comm+'">'); 
w.document.write("</TD></TR></TABLE>");
w.document.write("</BODY></HTML>"); 
w.document.close(); 
}

function masque(id) {
	document.getElementById(id).style.display='none';
}

function montre(id) {
	document.getElementById(id).style.display='block';
}


function validForm(nomform,array) {
	
	msg_alerte = false;
	for (var i=0; i<array.length; i++) {
		var valeur = array[i];
		//alert(valeur);
		 if (document.forms[nomform].elements[valeur].value.length == 0) {
			document.forms[nomform].elements[valeur].className="champsincomplet";
			msg_alerte = true;
		 }
		 else document.forms[nomform].elements[valeur].className="";
	}


	if (msg_alerte == true) {
		alert("Les champs de saisie sur fond rouge sont incomplets");
		return false;
	}
	
	else {
		
		montre('chargement');
		masque('debug');
		return true;
	}
}

function masque(elem) {
 
	// Quel est l'état actuel ?
	etat=document.getElementById(elem).style.display;
	if(etat=="none"){document.getElementById(elem).style.display="block";}
	else{document.getElementById(elem).style.display="none";}
}

function change_image (chemin)
{
	document.cadreimage.src = chemin;
}
