var d = document;
function prechargement()
{
	var rep = 'img/';
	var tab = new Array('btn_accueil_on.gif','btn_presentation_on.gif','btn_formations_on.gif','btn_coaching_on.gif','btn_publications_on.gif','btn_liens_on.gif','btn_contact_on.gif','btn_blog_on.gif');
	
for(i = 0; i<tab.length; i++){
	var img = new Image;
	img.src = rep+tab[i];
	}
}

function rollover()
{
	var menu    = d.getElementById('menu');
	var tab_img = menu.getElementsByTagName('img');
	var tab_a   = menu.getElementsByTagName('a');
	tab_a[5].target = '_blank';
	for(i = 0; i<tab_img.length; i++)
	{
	var nb = i/2;
	
	if((nb.toString().search(/^[0-9]+$/) == 0) && nb!=2 && nb!=3) 
		{ 
		tab_img[i].onmouseover = function()
			{
			this.src = 'img/btn_'+this.id+'_on.gif';
			}
		tab_img[i].onmouseout = function()
			{
			this.src = 'img/btn_'+this.id+'_off.gif';
			}
		}
	}
}
function menuDeroulant()
{
	var menu_formations = d.getElementById('menu_formations');
	var btn_formations1 = d.getElementById('btn_formations');

btn_formations1.onmouseover = function(){
	menu_formations.style.visibility = 'visible';
	d.getElementById('btn_formations').src = 'img/btn_formations_on.gif';
	}
btn_formations1.onmouseout = function(){
	menu_formations.style.visibility = 'hidden';
	d.getElementById('btn_formations').src = 'img/btn_formations_off.gif';
	}
menu_formations.onmouseover = function(){
	d.getElementById('btn_formations').src = 'img/btn_formations_on.gif';
	this.style.visibility = 'visible';
	}
menu_formations.onmouseout = function(){
	d.getElementById('btn_formations').src = 'img/btn_formations_off.gif';
	this.style.visibility = 'hidden';
	}
}
function menuDeroulant2()
{
	var menu_coaching = d.getElementById('menu_coaching');
	var btn_coaching1 = d.getElementById('coaching');

btn_coaching1.onmouseover = function(){
	menu_coaching.style.visibility = 'visible';
	d.getElementById('coaching').src = 'img/btn_coaching_on.gif';
	}
btn_coaching1.onmouseout = function(){
	menu_coaching.style.visibility = 'hidden';
	d.getElementById('coaching').src = 'img/btn_coaching_off.gif';
	}
menu_coaching.onmouseover = function(){
	d.getElementById('coaching').src = 'img/btn_coaching_on.gif';
	this.style.visibility = 'visible';
	}
menu_coaching.onmouseout = function(){
	d.getElementById('coaching').src = 'img/btn_coaching_off.gif';
	this.style.visibility = 'hidden';
	}
}
function target_blank()
{
if(d.getElementById('les_liens'))
	{
	var div = d.getElementById('les_liens');
	var a = div.getElementsByTagName('a');

	for(i=0; i< a.length; i++)
		{
		a[i].onclick = function()
			{
			this.target = '_blank';
			}
		}
	}
}
function modification_taille_du_texte()
{
	if(d.getElementById('grande_taille'))
	{
		
		d.getElementById('grande_taille').onclick = function()
		{
			var classe = d.getElementById('contenu_page').className;
			
			switch(classe)
				{
					case 'texte10' : new_classe = 'texte';   break;
					case 'texte'   : new_classe = 'texte14'; break;
					case 'texte14' : new_classe = 'texte16'; break;
					case 'texte16' : new_classe = 'texte16'; break;
				}
				d.getElementById('contenu_page').className = new_classe;
		}
		d.getElementById('petite_taille').onclick = function()
		{
			var classe = d.getElementById('contenu_page').className;
			
			switch(classe)
				{
					case 'texte10' : new_classe = 'texte10'; break;
					case 'texte'   : new_classe = 'texte10'; break;
					case 'texte14' : new_classe = 'texte';   break;
					case 'texte16' : new_classe = 'texte14'; break;
				}
				d.getElementById('contenu_page').className = new_classe;
		}
	}
}
function popup()
{
	if(d.getElementById('telechargement'))
	{ 
	var top=(screen.height-700)/2;
	var left=(screen.width-740)/2;
	var image = d.getElementById('telechargement').getElementsByTagName('img');
	
	image[1].onclick = function()
		{ 
		var id = this.id.split('-');
		window.open("http://www.dominique-fromm.net/impression.php?id="+id[1],"detail","top="+top+",left="+left+",width=740,height=700,fullscreen=no, scrollbars=yes, resizable=yes");
		}
	}
}
function affichage_couverture()
{
	if(d.getElementById('affiche_couverture'))
	{
		var image = d.getElementById('contenu_page').getElementsByTagName('img');
		
		for(i = 0; i < image.length; i++)
		{
		image[i].onmouseover = function()
			{
				(document.body.scrollTop) ? scrollee = d.body.scrollTop :  scrollee = d.documentElement.scrollTop;
				(scrollee < 139) ? decalage = 139+'px' : decalage = scrollee+'px';
				
				d.getElementById('grande_couverture').src = this.src;
				d.getElementById('affiche_couverture').style.top = decalage;
				d.getElementById('affiche_couverture').style.visibility = 'visible';
			}
			image[i].onmouseout = function()
			{
				d.getElementById('affiche_couverture').style.visibility = 'hidden';
			}
		}
	}
}
function VerificationEmail(elm)
{
if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1" &&
    elm.value != "")
    return true;
else return false;
}
function espacesVides(champ)
{
obj        = d.getElementById(champ);
chaine     = obj.value;
lg         = chaine.length;
newChaine  = '';

for(i=0; i<lg; i++)
	{
	newChaine += chaine.substr(i,1).replace(' ','');
	}
			
	if(newChaine ==''){
		return false;
	}
}
function verification_formulaire()
{
	if(d.getElementById('formulaire'))
	{
	d.getElementById('formulaire').onsubmit = function()
		{
		if(espacesVides('identite')==false)  
			{
   			alert("Veuillez entrer un nom et un prénom.");
   			d.forms[0].identite.focus();
  			return false;
 			}
		if (!VerificationEmail(d.forms[0].email))
			{
			alert("Veuillez entrer un email valide.");
			d.forms[0].email.focus();
			return false;
  			}
			if(espacesVides('anti')==false)  
			{
   			alert("Veuillez entrer le code.");
   			d.forms[0].anti.focus();
   			return false;
 			}
 			if(espacesVides('message')==false)  
			{
   			alert("Veuillez écrire un message.");
   			d.forms[0].message.focus();
   			return false;
 			}
		}
	}
}
window.onload = function()
{
	prechargement();
	target_blank();
	menuDeroulant();
	menuDeroulant2();
	rollover();
	modification_taille_du_texte();
	popup();
	affichage_couverture();
	verification_formulaire();
}

