// JavaScript Document

function getRootDomain(currentDir) {
	path = window.location.pathname;
	host  = window.location.host;

	root = "http://"+host;
	if (currentDir.length == 0) return root+"/";

	root2Pos = path.lastIndexOf(currentDir);

	if (root2Pos == -1) return -1;
//	alert('Current dir = '+currentDir+"\n Path = "+path+"\n Resultat: "+path.substr(0,root2Pos));
	root_url =  root + path.substr(0,root2Pos);

	if (root_url.lastIndexOf("/") < root_url.length-1 ) root_url+= "/";
//	alert('root domain = ' + root_url);
	return root_url;
}

function setColorBox(obj,cond)
{
	var NColor = "#cc6666";
	var HColor = "#FF0000";
	var cCond = ((obj.value =='') || cond);
	(cCond)?obj.style.backgroundColor = HColor : obj.style.backgroundColor = NColor;
	return (cCond);
}

function verify(fieldalias,element1,element2)
{
	var passed=false
	if (element1.value=='')
	{
		alert("Veuillez entrer votre "+fieldalias+" dans le premier champ!")
		element1.focus()
	}
	else if (element2.value=='')
	{
		alert("Veuillez confirmer votre "+fieldalias+" dans le second champ!")
		element2.focus()
	}
	else if (element1.value!=element2.value)
	{
		alert("Le champ "+fieldalias+" doit être identique sur les deux lignes!")
		element1.select()
	}
	else
	passed=true
	return passed
}

function checkMail(x)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {  return true; }
	else return false;
}

function ajax(myForm,proxyLoc)
{
	var xhr=null;
	if(proxyLoc.lastIndexOf("/") < proxyLoc.length) proxyLoc+= "/";
	proxyUrl = proxyLoc+'resa_proxy.php';
//	alert(proxyUrl);

	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xhr==null)
	{
		alert ("La version de votre navigateur ne peut pas traiter cette demande.")
	}

	//on définit l'appel de la fonction au retour serveur
	var timer= setTimeout("timeOut_function()", 20000);

	xhr.onreadystatechange = function() {
		alert_ajax(xhr,timer);
	}

	if (window.XMLHttpRequest) {
		xhr.onerror = function () {
			alert('Erreur xmlhttpRequest : Status = '+xhr.status);
		}
	}

	//on appelle le fichier reponse.txt
//	alert('proxyURL = '+proxyUrl);
	xhr.open("POST", proxyUrl, true);

	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.send(getParamStr(myForm));

}


function alert_ajax(xhr,timer)
{
	if (xhr.readyState == 4) {
		clearTimeout(timer);
		var httpstat = xhr.status;
		if (httpstat == 200) {
			var docXML= xhr.responseXML;
			var status = docXML.getElementsByTagName("STATUS")[0].firstChild.data;
			if (status == "OK") {
				var x = docXML.getElementsByTagName("PARA").length;
				for (i=0;i<x;i++) {
					var parag = document.createElement("p");
					var alignement = document.createAttribute("align");
					alignement.nodeValue = "center"
					parag.setAttributeNode(alignement);
					var text = document.createTextNode(docXML.getElementsByTagName("PARA")[i].firstChild.data);
					parag.appendChild(text);
					document.getElementById ('resa_reply').appendChild(parag);
				}

				var nws = docXML.getElementsByTagName("NEWS");
				if (nws.length > 0) {
					nwsData = nws[0].firstChild.data;
					document.getElementById('resa_news').innerHTML = nwsData;
				}

				var signature = docXML.getElementsByTagName("SIGNATURE")[0].firstChild.data;
				document.getElementById('resa_sign').innerHTML = signature;
				resa_complete();

			} else {
				var status = docXML.getElementsByTagName("STATUS")[0].firstChild.data;
				document.getElementById('resa_statmsg').innerHTML = status;
				resa_nok();
			}
		} else {
			document.getElementById('resa_statmsg').innerHTML = 'Impossible de joindre le serveur proxy : '+httpstat;
			resa_nok();
		}
	}
}

function timeOut_function() {
	document.getElementById('resa_statmsg').innerHTML = 'Votre demande n\'a pu être transmise. Veuillez r&eacute;essayer ult&eacute;rieurement.';
	resa_nok();
}

function get_resaFormObject() {
	myFormName = "resa_request";
	if (arguments.length > 0) {
		myFormName = arguments[0];
	}
	nbForms = document.forms.length;
	for (i=0;i<nbForms;i++) {
		if (document.forms[i].name == myFormName) return document.forms[i];
	}
	return null;
}

function clear_resaForm() {
	myFormName = "resa_request";
	if (arguments.length > 0) {
		myFormName = arguments[0];
	}

	myForm = get_resaFormObject(myFormName);
	for (i=0;i<myForm.elements.length;i++) {
		if (myForm.elements[i].type == "text") myForm.elements[i].value=null;
		if (myForm.elements[i].type == "textarea") myForm.elements[i].value=null;
	}
}

function getParamStr(myForm) {

	var myStr = '';
	var first = true;
	for (i=0;i<myForm.elements.length;i++) {
		if(myForm.elements[i].id != null) {
			if ((myForm.elements[i].value != null) || (myForm.elements[i].id == 'MESSAGE')) {
				myStr += (first)?'':'&';
				first = false;
				myStr +=encodeURIComponent(myForm.elements[i].id)+'='+encodeURIComponent(myForm.elements[i].value);
			}
		} 		
	}
//	alert(myStr);
	return(myStr);
}

function getStub(funct,whereClause,tagName,tagOptions,proxyLoc,div) {
	
	var myStr = 'STUB_REQUEST='+encodeURIComponent(funct);
	myStr+=	'&WHERECLAUSE='+encodeURIComponent(whereClause);
	myStr+= '&TAGNAME='+encodeURIComponent(tagName);
	myStr+= '&TAGOPTIONS='+encodeURIComponent(tagOptions);
	myStr+= '&REM_FILE=demStub_XML.php';
	
	var xhr=null;
	if(proxyLoc.lastIndexOf("/") < proxyLoc.length) proxyLoc+= "/";
	proxyUrl = proxyLoc+'resa_proxy.php';

	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xhr==null)
	{
		alert ("La version de votre navigateur ne peut pas traiter cette demande.")
	}

	//on définit l'appel de la fonction au retour serveur
	var timer= setTimeout("timeOut_function()", 30000);

	xhr.onreadystatechange = function() {
		alert_ajaxStub(xhr,timer,div);
	}

	if (window.XMLHttpRequest) {
		xhr.onerror = function () {
			alert('Erreur xmlhttpRequest : Status = '+xhr.status);
		}
	}

	//on appelle le fichier reponse.txt
	xhr.open("POST", proxyUrl, true);
//	alert(proxyUrl + myStr);
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.send(myStr);
}

function alert_ajaxStub(xhr,timer,div)
{
	if (xhr.readyState == 4) {
		clearTimeout(timer);
		var httpstat = xhr.status;
		if (httpstat == 200) {
			var docXML= xhr.responseXML;
			var status = docXML.getElementsByTagName("STATUS")[0].firstChild.data;
			if (status == "OK") {
				var stub = docXML.getElementsByTagName("SELECT_TAG")[0].firstChild.data;
				document.getElementById(div).innerHTML = stub;
			} else {
				var status = docXML.getElementsByTagName("STATUS")[0].firstChild.data;
				document.getElementById(div).innerHTML = status;
			}
		} else {
			document.getElementById(div).innerHTML = 'Impossible de joindre le serveur proxy : '+httpstat;
		}
	}
}

function resa_submit(myForm,proxyLoc,scrollToTop) {
	if (!scrollToTop) scrollToTop = true;
	formDiv = document.getElementById("resa_reqForm");
	waitDiv = document.getElementById("resa_wait");
	boutDiv = document.getElementById("resa_homeButton");
	formDiv.style.display = "none";
	waitDiv.style.display = "block";
	boutDiv.style.display = "none";
	if (scrollToTop) window.scrollTo (0,0);
	ajax(myForm,proxyLoc);
}

function resa_complete() {

	waitDiv = document.getElementById("resa_wait");
	replDiv = document.getElementById("resa_reply");
	boutDiv = document.getElementById("resa_homeButton")
	waitDiv.style.display = "none";
	replDiv.style.display = "block";
	boutDiv.style.display = "block";
	clear_resaForm();
}

function resa_nok() {
	waitDiv = document.getElementById("resa_wait");
	statDiv = document.getElementById("resa_statmsg");
	boutDiv = document.getElementById("resa_homeButton");
	waitDiv.style.display = "none";
	statDiv.style.display = "block";
	boutDiv.style.display = "block";
	clear_resaForm();
}

/**********************************************/
/** Custom code below *************************/
/**********************************************/
/**
* Création d'un bloc "Vous"
*
**/
function resa_blockFormName(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+ '> <legend>Vous</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%">');
	document.writeln('<label>Civilit&eacute;</label>');
	document.writeln('</td>');
	document.writeln('<td>');
	document.writeln('<select name="CIVIL" '+myRealFormClass+' id="CIVIL">');
	document.writeln('<option value="Mme.">Madame</option>');
	document.writeln('<option value="Melle.">Mademoiselle</option>');
	document.writeln('<option value="M.">Monsieur</option>');
	document.writeln('</select>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Votre pr&eacute;nom :</label></td>');
	document.writeln('<td><input name="PRENOM" type="text" '+myRealFormClass+' id="PRENOM" size="40" maxlength="64">&nbsp;(*)</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Votre nom :</label></td>');
	document.writeln('<td><input name="NOM" type="text" '+myRealFormClass+' id="NOM" size="40" maxlength="64">&nbsp;(*) ');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table> </fieldset>');
}

function resa_blockFormAdress(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+'><legend>Vos Coordonn&eacute;es</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%"><label>Votre adresse</label></td>');
	document.writeln('<td colspan="3"><textarea name="ADRESSE" cols="40" rows="2" '+myRealFormClass+' id="ADRESSE"></textarea></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Code Postal</label> </td>');
	document.writeln(' <td><input name="CODEPOSTAL" type="text" '+myRealFormClass+' id="CODEPOSTAL" size="10" maxlength="10"></td>');
	document.writeln('<td><label>Ville :</label></td>');
	document.writeln('<td><input name="VILLE" type="text" '+myRealFormClass+' id="VILLE" size="40" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Pays</label></td>');
	document.writeln('<td colspan="3"><input name="PAYS" type="text" '+myRealFormClass+' id="PAYS" size="40" maxlength="40"></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
}

function tag2tagCpy() {
	$('S_ADRESSE').value = $('F_ADRESSE').value;
	$('S_CODEPOSTAL').value = $('F_CODEPOSTAL').value;
	$('S_VILLE').value = $('F_VILLE').value;
}

function selectCpy() {
	var source = $('F_PAYS');
	var dest = $('S_PAYS');
	dest.selectedIndex = source.selectedIndex;
}

function getCountriesTag(tagName,tagOptions,proxyDir,tagDiv) {
	var myStr = 'PROD_REQUEST='+encodeURIComponent('COUNTRY_LIST');
	myStr+= '&TAGNAME='+encodeURIComponent(tagName);
	myStr+= '&TAGOPTIONS='+encodeURIComponent(tagOptions);
	myStr+= '&REM_FILE=prodStub_XML.php';
	if(proxyDir.lastIndexOf("/") < proxyDir.length) proxyDir+= "/";
	proxyUrl = proxyDir+'resa_proxy.php';

	new Ajax.Request(proxyUrl, {
  		method: 'post',
		parameters: myStr,
  		onSuccess: function(transport) {
    		docXML = transport.responseXML;
			if (docXML.getElementsByTagName('STATUS')[0].firstChild.data == 'OK') {
				$(tagDiv).innerHTML = docXML.getElementsByTagName('TAG')[0].firstChild.data;
			} else {
				alert('Erreur : '+docXML.getElementsByTagName('STATUS')[0].firstChild.data);
			}
  		}
	});
}

function resa_blockFormOrder(myFieldSetClass,myFormClass,autoCopy) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	var copyAction = '';
	if (autoCopy) copyAction = ' onKeyUp="tag2tagCpy()" ';
	
	document.writeln('<fieldset '+myRealFSClass+ '> <legend>Vous</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%" align="right">');
	document.writeln('<label>Civilit&eacute;&nbsp;(*)</label>');
	document.writeln('</td>');
	document.writeln('<td align="left" colspan="3">');
	document.writeln('<select name="CIVIL" '+myRealFormClass+' id="CIVIL">');
	document.writeln('<option value="Mme.">Madame</option>');
	document.writeln('<option value="Melle.">Mademoiselle</option>');
	document.writeln('<option value="M.">Monsieur</option>');
	document.writeln('</select>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Votre pr&eacute;nom :&nbsp;(*)</label></td>');
	document.writeln('<td align="left" colspan="3"><input name="PRENOM" type="text" '+myRealFormClass+' id="PRENOM" size="40" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Votre nom :&nbsp;(*)</label></td>');
	document.writeln('<td align="left" colspan="3"><input name="NOM" type="text" '+myRealFormClass+' id="NOM" size="40" maxlength="64">');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table> </fieldset>');
	document.writeln('<fieldset '+myRealFSClass+'><legend>Coordonn&eacute;es de Facturation</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%" align="right"><label>Adresse Compl&egrave;te(*):</label></td>');
	document.writeln('<td colspan="3" align="left"><textarea name="F_ADRESSE" cols="40" rows="2" '+myRealFormClass+copyAction+' id="F_ADRESSE"></textarea></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Code Postal(*):</label> </td>');
	document.writeln(' <td align="left"><input name="F_CODEPOSTAL" type="text" '+myRealFormClass+copyAction+' id="F_CODEPOSTAL" size="10" maxlength="10"></td>');
	document.writeln('<td align="right"><label>Ville(*):</label></td>');
	document.writeln('<td align="left"><input name="F_VILLE" type="text" '+myRealFormClass+copyAction+' id="F_VILLE" size="32" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Pays(*):</label></td>');
	document.writeln('<td colspan="3" align="left"><div id="F_PAYS_DIV"></div></td>');
//					 <input name="F_PAYS" type="text" '+myRealFormClass+copyAction+' id="F_PAYS" size="40" maxlength="40"></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
	document.writeln('<fieldset '+myRealFSClass+'><legend>Adresse de livraison</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td align="right" width="30%"><label>Adresse Compl&egrave;te&nbsp;(*):</label></td>');
	document.writeln('<td colspan="3" align="left"><textarea name="S_ADRESSE" cols="40" rows="2" '+myRealFormClass+' id="S_ADRESSE"></textarea></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Code Postal&nbsp;(*):</label></td>');
	document.writeln(' <td align="left"><input name="S_CODEPOSTAL" type="text" '+myRealFormClass+' id="S_CODEPOSTAL" size="10" maxlength="10"></td>');
	document.writeln('<td align="right"><label>Ville&nbsp;(*):</label></td>');
	document.writeln('<td align="left"><input name="S_VILLE" type="text" '+myRealFormClass+' id="S_VILLE" size="32" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right"><label>Pays&nbsp;(*):</label></td>');
	document.writeln('<td colspan="3" align="left"><div id="S_PAYS_DIV"></div></td>');
//					 <input name="S_PAYS" type="text" '+myRealFormClass+' id="S_PAYS" size="40" maxlength="40"></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
	getCountriesTag('F_PAYS',myRealFormClass+' onChange="selectCpy()" ','../RESA_V3','F_PAYS_DIV');
	getCountriesTag('S_PAYS',myRealFormClass,'../RESA_V3','S_PAYS_DIV');
}

function resa_block_FormContact(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+'><legend>Vous joindre</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%"><label>Adresse e-mail </label></td>');
	document.writeln('<td><input name="EMAIL" type="text" '+myRealFormClass+' id="EMAIL" size="40" maxlength="64">&nbsp;(*)</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Confirmez votre adresse e-mail </label></td>');
	document.writeln('<td><input name="EMAIL2" type="text" '+myRealFormClass+' id="EMAIL2" size="40" maxlength="64">&nbsp;(*) </td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Telephone (Mobile)</label></td>');
	document.writeln('<td><input name="TELMOB" type="text" '+myRealFormClass+' id="TELMOB" size="40" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Téléphone (Fixe)</label></td>');
	document.writeln('<td><input name="TELEPHONE" type="text" '+myRealFormClass+' id="TELEPHONE" size="40" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
}

function resa_block_FormMessage(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+'><legend>Votre message</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td align="center"><textarea name="MESSAGE" cols="72" rows="10" '+myRealFormClass+' id="MESSAGE"></textarea>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
}

function resa_block_FormNewsletter(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+' ><legend>"Newsletter"</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td align="right">Cochez cette case pour être informé régulièrement par e-mail sur nos activités :</td>');
	document.writeln('<td><select name="mailListe" '+myRealFormClass+' id="mailListe">');
	document.writeln('<option value="Non" selected>Non</option>');
	document.writeln('<option value="Oui">Oui</option>');
	document.writeln('</select>(**)');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><div align="right">Format de courrier electronique: </div></td>');
	document.writeln('<td><select name="format" id="format" '+myRealFormClass+'>');
	document.writeln('<option value="1">TXT</option>');
	document.writeln('<option value="2" selected>HTML</option>');
	document.writeln('</select>');
	document.writeln('<input type="hidden" name="liste" id="liste" value="2" />');
	document.writeln('<input type="hidden"  name="action" id="action" value="inscription"/>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
}

function resa_block_FormParameters(myTopic) {
	document.writeln('<input name="TOPIC" type="hidden" id="TOPIC" value="'+myTopic+'">');		
	document.writeln('<input name="REM_FILE" type="hidden" id="REM_FILE" value="deminfos_XML.php">');
}

function resa_block_FormParameters_with_select(myFieldSetClass,myFormClass,myDir,div) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+' ><legend>L\'objet de votre demande</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr><td width="30%"><label>Votre pr&eacute;f&eacute;rence :</label></td>');
	document.writeln('<td><div align="left" id="'+div+'"></div>');	
	document.writeln('<input name="REM_FILE" type="hidden" id="REM_FILE" value="deminfos_XML.php">');
	document.writeln('</td></tr></table></fieldset>');
	var rootDomain = getRootDomain(myDir);
	getStub('TYPE_SELECT',"adulte",'TOPIC',myRealFormClass,rootDomain+'RESA_V3',div);
}

function resa_block_FormCompany(myFieldSetClass,myFormClass) {
	var myRealFSClass = '';
	var myRealFormClass ='';
	if(myFieldSetClass != null) myRealFSClass = ' class = "'+myFieldSetClass+'" ';
	if(myFormClass != null) myRealFormClass = ' class = "'+myFormClass+'" ';
	document.writeln('<fieldset '+myRealFSClass+'><legend>Votre Entreprise</legend>');
	document.writeln('<table width="100%">');
	document.writeln('<tr>');
	document.writeln('<td width="30%"><label>Nom ou Raison Sociale :</label></td>');
	document.writeln('<td><input name="COMPANY" type="text" '+myRealFormClass+' id="COMPANY" size="40" maxlength="64">&nbsp;(*)</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Votre fonction :</label></td>');
	document.writeln('<td><input name="FUNCTION" type="text" '+myRealFormClass+' id="FUNCTION" size="40" maxlength="64">&nbsp;(*) </td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td><label>Service/D&eacute;partement</label></td>');
	document.writeln('<td><input name="DIVISION" type="text" '+myRealFormClass+' id="DIVISION" size="40" maxlength="64"></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</fieldset>');
}

          
/**
* Création du bouton de soumission du formulaire
*/
function resa_submitButton(myFunction,myDir,myValue,myClass) {
	var myRealClass = '';
	if (myClass != null) myRealClass = ' class="'+myClass+'" ';
	document.writeln('<input name="RESA_SUBMIT" type="button" '+myRealClass+' id="RESA_SUBMIT" value="'+myValue+'" style="cursor:pointer" onClick="if ('+myFunction+'(resa_request)) {	resa_submit(resa_request,getRootDomain(\''+myDir+'\')+\'RESA_V3\');}">');
}

/**
* Cration du bloc de réponse
*/
function resa_responseBlock(retPage,currentDir,myClass) {
	var myRealClass = '';
	if (myClass != null) {
		myRealClass = 'class = "'+myClass+'" ' ;
	}
	document.writeln('<div id="resa_wait" style="display:none " align="center"><p>Veuillez patienter...</p></div>');
	document.writeln('<div id="resa_reply" style="display:none "></div>');
	document.writeln('<div id="resa_reply" style="display:none "></div>');
	document.writeln('<div id="resa_statmsg" style="display:none " align="center"></div>');
	document.writeln('<div id="resa_news"></div>');
	document.writeln('<div id="resa_sign" align="center" style="background-color:#FFFFCC "></div>');
	document.writeln('<div id="resa_homeButton" style="display:none ">');
	document.writeln('<table align="center">');
	document.writeln('<tr><td align="center">');
	document.writeln('<input name="RESA_RETOUR" type="button" '+myRealClass+' id="RESA_RETOUR" value="Retour" onClick="location=self.location.href.substr(0,self.location.href.indexOf(\''+currentDir+'\'))+\''+retPage+'\';">');
	document.writeln('</td></tr></table></div>');
}



function deminfo_subm(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}
	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	if (setColorBox(myForm.MESSAGE,false)) {
		cond = false;
		alert ('Vous devez compléter le champ message...');
	}
	return cond;
}

function deminfo_submEntreprise(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if (setColorBox(myForm.COMPANY,false)) cond = false;
	if (setColorBox(myForm.FUNCTION,false)) cond = false;
	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}
	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	if (setColorBox(myForm.MESSAGE,false)) {
		cond = false;
		alert ('Vous devez compléter le champ message...');
	}
	return cond;
}



function deminfo_submStage(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}
	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	return cond;
}

function orderSubm(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if (setColorBox(myForm.F_ADRESSE,false)) cond=false;
	if (setColorBox(myForm.F_CODEPOSTAL,false)) cond=false;
	if (setColorBox(myForm.F_VILLE,false)) cond=false;
	if (setColorBox(myForm.F_PAYS,false)) cond=false;
	if (setColorBox(myForm.S_ADRESSE,false)) cond=false;
	if (setColorBox(myForm.S_CODEPOSTAL,false)) cond=false;
	if (setColorBox(myForm.S_VILLE,false)) cond=false;
	if (setColorBox(myForm.S_PAYS,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}
	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	return cond;
}


function demadh_subm(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if (setColorBox(myForm.ADRESSE,false)) cond=false;
	if (setColorBox(myForm.CODEPOSTAL,false)) cond=false;
	if (setColorBox(myForm.VILLE,false)) cond=false;
	if (setColorBox(myForm.PAYS,false)) cond=false;
	if (setColorBox(myForm.TELMOB,false)) cond = false;

	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}

	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	return cond;
}

function webmaster_subm(myForm)
{
	var cond;
	cond = true;
	if (setColorBox(myForm.NOM,false)) cond=false;
	if (setColorBox(myForm.PRENOM,false)) cond=false;
	if (setColorBox(myForm.EMAIL,false)) cond=false;
	if (setColorBox(myForm.EMAIL2,false)) cond=false;
	if (setColorBox(myForm.USER1,false)) cond=false;
	if (setColorBox(myForm.USER2,false)) cond=false;
	if (setColorBox(myForm.USER3,false)) cond=false;
	if (setColorBox(myForm.USER4,false)) cond=false;
	if ((!verify("adresse email",myForm.EMAIL,myForm.EMAIL2)) || (!checkMail(myForm.EMAIL.value))) {
		setColorBox(myForm.EMAIL,true);
		setColorBox(myForm.EMAIL2,true);
		cond = false;
	}
	if (!cond)
	{
		alert ('Corriger les champs colores en rouge');
		return cond;
	}

	return cond;
}