// JavaScript Document

/****************************/
/*  Champs Obligatoires    */
/**************************/

	function Check_Input(tChamps_Oblig,tChamps_Oblig_Name) {
		
		var vValid_Message ="";
		var vSaisi = true
		
		for (i=0; i<tChamps_Oblig.length; i++) {
			vID_Champ = tChamps_Oblig[i];
			vID_Champ_Nom = tChamps_Oblig_Name[i];
			
			var vType = eval("document.forms[1]."+vID_Champ+".type");

if ((vType == 'textarea') ||(vType == 'text') || (vType == 'hidden')) {vSaisi = eval("document.forms[1]."+vID_Champ+".value != ''");}
			if (vType == 'select-one') {vSaisi = eval("document.forms[1]."+vID_Champ+".options[document.forms[1]."+vID_Champ+".selectedIndex].text != ''");}
			
			if (vType == 'radio') {
				var TempNomChamp = vID_Champ.substr(0,vID_Champ.length-3);
				var TempTabLength = eval("document.forms[1]."+TempNomChamp+".length");
				vSaisi = false;
				for (j=0; j<(TempTabLength) ;j++) {
					if(eval("document.forms[1]."+TempNomChamp+"["+j+"].checked")) {vSaisi = true;};
				}
			}
			
			if (vSaisi == false) {
				vValid_Message = vValid_Message + "> \""+vID_Champ_Nom+"\" doit être renseigné.\n"
			}
		}
		
		if (vValid_Message != '') {
			//var vMessage = "Votre demande n'a pas été envoyé pour les raisons suivantes :\n";
			//var vMessage = vMessage + "----------------------------------------------------------------\n";
			alert (vValid_Message);
			return false;
		}
		else {
			return true;
		}
	}


/****************************/
/*  Test navigateur        */
/**************************/

function cherche_navigateur() {

// on crée la variable qui accueillera le message relatif au navigateur
var navigateur = "";

// Attention, l'ordre de recherche est important !! Parce que IE reprend la mention 'Mozilla' et Opera reprend la mention 'MSIE' !!
// on teste si on trouve la mention 'Opera...' dans le nom du navigateur
if ( navigator.userAgent.indexOf('Opera') != -1 ) { navigateur = 'Gecko';}
else if ( navigator.userAgent.indexOf('Firefox') != -1 ) { navigateur = 'Gecko'; }

// on teste si on trouve la mention 'MSIE...' dans le nom du navigateur
else if ( navigator.userAgent.indexOf('MSIE') != -1 ) { navigateur = 'IE'; }

// on teste si on trouve la mention 'Mozilla...' dans le nom du navigateur
else if ( navigator.userAgent.indexOf('Mozilla/5.0') != -1 ) { navigateur = 'Gecko'; }

// si rien n'a été reconnu...
else { navigateur = 'Inconnu'; }

// on affecte la variable 'navigateur' au formulaire
return navigateur;
}

/****************************/
/*  Open popup        */
/**************************/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/****************************/
/*  Recuperer la hauteur de la page.*/
/**************************/
function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}
/****************************/
/*  ajuster le footer de la page.*/
/**************************/


function setFooter() {
	//alert ( "1" );
    if (document.getElementById) {
		//alert ( "2" );
        var windowHeight=getWindowHeight();
		//alert ( "3" );
        if (windowHeight>0) {//alert ( "4" );
            var contentHeight=document.getElementById('Conteneur2').offsetHeight;
			//alert ( contentHeight);
            var footerElement=document.getElementById('Conteneur3');
            var footerHeight=footerElement.offsetHeight;
			//alert ( contentHeight+" d "+footerHeight );
        if (windowHeight-(contentHeight+footerHeight)>=0) {
			//alert ( "5" );
			//alert ( contentHeight+" "+footerHeight );
            footerElement.style.position='relative';
            //footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';
			
			//alert ( contentHeight+" "+footerHeight );
        }
        else {
            footerElement.style.position='static';
        }
       }
      }
}

function setContent() {
    if (document.getElementById) {
        var windowHeight=getWindowHeight();
      	//alert(windowHeight);
	  	if (windowHeight>0) {
			var headerHeight=document.getElementById('Conteneur').offsetHeight;
			var contentHeight=document.getElementById('Conteneur2').offsetHeight;
            var footerHeight=document.getElementById('Conteneur3').offsetHeight;
            //alert("contentHeight: "+contentHeight);
       
	   if (windowHeight-( headerHeight+contentHeight+footerHeight)>=0) {
           // contentHeight.style.position='relative';
            document.getElementById('Conteneur2').style.height=(windowHeight-(headerHeight+footerHeight))+'px';
			//alert("REdim cont2: "+document.getElementById('Conteneur2').style.height);
			
        }
        else {
            //contentHeight.style.position='static';
        }
       }
      }
}

//insertFlash.js
var fc_2 = false;
var fc_3 = false;
var fc_4 = false;
var fc_5 = false;
var fc_6 = false;
var fc_7 = false;
var fc_8 = false;

var fc_highestVersion = 0;

// -------------------------------------------------------------------------------------------------

// DETECT FLASH

function detectFlash() { 

	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

	if(isIE && isWin){
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('fc_2 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('fc_3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('fc_4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('fc_5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
		document.write('fc_6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
		document.write('fc_7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		document.write('fc_8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
		document.write('</SCR' + 'IPT\> \n');
	}
	
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			fc_2 = flashVersion == 2;
			fc_3 = flashVersion == 3;
			fc_4 = flashVersion == 4;
			fc_5 = flashVersion == 5;
			fc_6 = flashVersion == 6;
			fc_7 = flashVersion == 7;
			fc_8 = flashVersion >= 8;
		}
	}

	for (var i = 2; i <= 8; i++) { 
		if (eval("fc_" + i) == true) 
			fc_highestVersion = i;
	}
	
}

detectFlash();

// EMBED FLASH
function embedFlash(i, f, w, h, c, fv, m, e) {
	//scale
	if (e==0){
		var echelle = 'noscale';
	}else{
		var echelle = 'autohigh';
	}
	//
	var embedCode_flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
	+ 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'
	+ 'width="'+w+'" height="'+h+'"'
	+ 'id="'+i+'">'
	+ '<param name="movie" value="'+f+'">'
	+ '<param name="quality" value="high">'
	+ '<param name="menu" value="'+m+'">'
	+ '<param name="bgcolor" value="'+c+'">'
	+ '<param name=flashvars value="'+fv+'">'
	+ '<param name="allowScriptAccess" value="always">'
	+ '<param name="WMODE" value="transparent ">'
	+ '<param name="SCALE" value="'+echelle+'">'
	//////////EMBED
	+ '<embed src="'+f+'"'
	+ 'menu="'+m+'"'
	+ 'quality="high"'
	+ 'bgcolor="'+c+'"'
	+ 'width="'+w+'" height="'+h+'"'
	+ 'allowScriptAccess="always"'
	+ 'WMODE="transparent"'
	+ 'SCALE="'+echelle+'"'
	+ 'name="'+i+'"'
	+ 'type="application/x-shockwave-flash"'
	+ 'flashvars="'+fv+'"'
	+ 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	+ '</embed>'
	+ '</object>';
	document.write(embedCode_flash);
}
