// ##### FLASH #####
function CreateFlash(id, chemin, width, height, vars){	
	document.observe('dom:loaded', function() {  
    //id : id de l'element dans lequel on va ecrire le flash    
    var d = document.getElementById(id);
    var 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="' + width + '" height="' + height + '">' +
    '<param name="movie" value="' + chemin + '" />' +
    '<param name="quality" value="high" />' +
    '<param name="wmode" value="transparent" />' +
    '<param name="flashvars" value="' + vars + '">' +
    '<embed src="' + chemin + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="' + vars + '" width="' + width + '" height="' + height + '"></embed></object>'
    d.innerHTML = flash
    });
}

function ShowHide(id){
 var obj = document.getElementById(id)
 if(obj.style.display=='none'){obj.style.display='block'; return}
 obj.style.display='none'
}



// ##### popup #####
var isIE = document.all?true:false;

function init(chemin){
	if (!isIE)document.getElementById('c').style.marginLeft = (window.innerWidth - document.getElementById('i').width )/2  + 'px'
}

function ouvreflash(id, chemin, width, height, vars){
	if(document.getElementById('filtre')){
		document.getElementById('filtre').style.display='block';	
	}
	document.getElementById('c').style.display='block';
	var flash = '<img src="../../images/bt_fermer.gif" id="btfermer" width="20" height="20" onclick="hideimage();"><br/><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="' + width + '" height="' + height + '">' +
	    '<param name="movie" value="' + chemin + '" />' +
	    '<param name="quality" value="high" />' +
	    '<param name="flashvars" value="' + vars + '">' +
	    '<param name="wmode" value="transparent">' +
	    '<embed src="' + chemin + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" flashvars="' + vars + '" width="' + width + '" height="' + height + '"></embed></object>'	
	
	document.getElementById('c').innerHTML = flash
	if (!isIE)document.getElementById('c').style.marginLeft = (window.innerWidth - 1023)/2  + 'px'
}

function centre(){
	 if(!document.getElementById('c')) return
    var el = document.getElementById('c') 
    if(typeof window.pageYOffset=='number'){
        el.style.top = parseInt(window.pageYOffset) + parseInt(window.innerHeight)/2 - el.offsetHeight/2 + 'px'
        el.style.left = parseInt(window.pageXOffset) + parseInt(window.innerWidth)/2 - el.offsetWidth/2 + 'px'   
    }
    else{
        var p = document.documentElement
        el.style.top = parseInt(p.scrollTop) + parseInt(p.clientHeight)/2 - el.offsetHeight/2 + 'px'
        el.style.left = parseInt(p.scrollLeft) + parseInt(p.clientWidth)/2 - el.offsetWidth/2 + 'px'
    }
}

function popin(chemin,largeur,hauteur){
	document.getElementById('filtre').style.display='block';
	document.getElementById('c').style.display='block';
	var contenu = '<a href="#a" onclick="popinclose();"><img src="../../images/bt_fermer.gif" border="0" /></a><br/><iframe height="'+hauteur+'" width="'+largeur+'" frameborder="0" src="'+chemin+'" scrolling="no"></iframe>'	
	document.getElementById('c').innerHTML = contenu	

	if(!document.getElementById('c')) return
    centre();   
}

window.onresize = function(){
	centre();
}

function popinclose(){
	top.document.getElementById('filtre').style.display='none';
	top.document.getElementById('c').style.display='none';
	top.document.getElementById('c').innerHTML = '&nbsp';	
}

function clickimage(img){	
	document.getElementById('c').style.display='block';
	document.getElementById('c').innerHTML = '<img src="../../images/bt_fermer.gif" id="btfermer" width="20" height="20" onclick="hideimage()"><br/><img id="i" src="' + img + '" border=0 title="cliquez sur cette image pour revenir au site" alt="cliquez sur cette image pour revenir au site" onclick="hideimage()">';
	if (!isIE)document.getElementById('c').style.marginLeft = (window.innerWidth - document.getElementById('i').width )/2  + 'px'
}

function hideimage(){
	document.getElementById('c').style.display='none';
	document.getElementById('c').innerHTML = '<img id="i" src="" width="1" height="1">'
	document.getElementById('filtre').style.display='none';
}

function showFiltre(){
	if(document.getElementById('filtre')){
		document.getElementById('filtre').style.display='block';	
	}
}

//### formulaires
function FocusChamps(c){
		c.className = 'champfocus';
}
function BlurChamps(c){
		c.className = 'champcontact';
}

function VerifChamps(c){
	if (!c.value){
		c.className = 'champcontacterreur'; return false}
	else{
		c.className = 'champcontact'; return true}
}
function VerifMail(c){

	if (!c.value){
		c.className = 'champcontacterreur'; return false}
	else if(c.value.search(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*$/) == -1){
		c.className = 'champcontacterreur'; return false}
	else{
		c.className = 'champcontact'; return true}
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


var _nom, _prenom, _societe, _mail, _adresse, _cp, _ville, _pays, _langue

function VerifFormlive(){
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_nom"))){_nom = false} else{_nom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_prenom"))){_prenom = false} else{_prenom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_societe"))){_societe = false} else{_societe = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_selectlangue"))){_langue = false} else{_langue = true}
	if(!VerifMail(document.getElementById("ctl00_ContentPlaceHolder1_email"))){_mail = false} else{_mail = true}
	
	if(_langue==false || _nom==false || _prenom==false || _mail==false || _societe==false){
	    document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='block';
        return false
    }
	
	document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='none';	
	return true
}

function VerifFormtelechargement(){
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_nom"))){_nom = false} else{_nom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_prenom"))){_prenom = false} else{_prenom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_societe"))){_societe = false} else{_societe = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_selectlangue"))){_langue = false} else{_langue = true}
	if(!VerifMail(document.getElementById("ctl00_ContentPlaceHolder1_email"))){_mail = false} else{_mail = true}
	if(document.getElementById('ctl00_ContentPlaceHolder1_parcourrier').checked){
		if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_adresse"))){_adresse = false} else{_adresse = true}	
		if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_cp"))){_cp = false} else{_cp = true}	
		if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_ville"))){_ville = false} else{_ville = true}	
		if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_pays"))){_pays = false} else{_pays = true}	
	}
	
	if(_langue==false || _nom==false || _prenom==false || _mail==false || _societe==false || _adresse==false || _cp==false || _ville==false || _pays==false ){
	    document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='block';
        return false
    }
	
	document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='none';	
	return true
}


function VerifForm(){
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_nom"))){_nom = false} else{_nom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_prenom"))){_prenom = false} else{_prenom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder1_tel"))){_tel = false} else{_tel = true}
	if(!VerifMail(document.getElementById("ctl00_ContentPlaceHolder1_email"))){_mail = false} else{_mail = true}
	if(_nom==false || _prenom==false || _mail==false || _tel==false ){
	    document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='block';
        return false
    }
	
	document.getElementById("ctl00_ContentPlaceHolder1_laerror").style.display='none';	
	return true
}

function VerifFormPlanningForce(){
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder2_contact1_nom"))){_nom = false} else{_nom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder2_contact1_prenom"))){_prenom = false} else{_prenom = true}
	if(!VerifChamps(document.getElementById("ctl00_ContentPlaceHolder2_contact1_tel"))){_tel = false} else{_tel = true}
	if(!VerifMail(document.getElementById("ctl00_ContentPlaceHolder2_contact1_email"))){_mail = false} else{_mail = true}
	if(_nom==false || _prenom==false || _mail==false || _tel==false ){
	    document.getElementById("ctl00_ContentPlaceHolder2_contact1_laerror").style.display='block';
        return false
    }
	
	document.getElementById("ctl00_ContentPlaceHolder2_contact1_laerror").style.display='none';	
	return true
}
