// Déployer les sous-menus
function deploy(baliseId)
{
	if (document.getElementById && document.getElementById(baliseId) != null)
	{
		document.getElementById(baliseId).style.height='auto';
		
		if(window.navigator.userAgent.toLowerCase().match("msie"))
		{
			document.getElementById(baliseId).style.maxHeight='';
		}
		else
		{
			document.getElementById(baliseId).style.maxHeight='auto';
		}
		
		document.getElementById(baliseId).style.overflow='auto';
	}
}

function reploy(baliseId)
{
	if (document.getElementById && document.getElementById(baliseId) != null)
	{
		document.getElementById(baliseId).style.height=''; //Laisser vide, ce script est appelé plusieurs fois pour des blocs de hauteur initiales différentes
		document.getElementById(baliseId).style.overflow='hidden';
	}
}

// Afficher / Cacher

var afficheTimeout = 0;
function affiche(baliseId, delais)
{
	clearTimeout(cacheTimeout);
	
	if(!delais)
	{
		if (document.getElementById && document.getElementById(baliseId) != null)
		{
			if(document.getElementById(baliseId).className.match("hide"))
			{
				document.getElementById(baliseId).className = document.getElementById(baliseId).className.replace("hide", "");
			}
			
			document.getElementById(baliseId).style.display='block';
			document.getElementById(baliseId).style.height='auto';
			document.getElementById(baliseId).style.width='auto';
		}
	}
	else
	{
		afficheTimeout = setTimeout("affiche('"+baliseId+"')", delais);
	}
}

////////////////////

var cacheTimeout = 0;
function cache(baliseId, delais)
{
	clearTimeout(afficheTimeout);
	
	if(!delais)
	{
		if (document.getElementById && document.getElementById(baliseId) != null)
		{
			if(!document.getElementById(baliseId).className.match("hide"))
			{
				document.getElementById(baliseId).className += " hide";
			}
			
			document.getElementById(baliseId).style.display='none';
			document.getElementById(baliseId).style.height='';
			document.getElementById(baliseId).style.width='';
		}
	}
	else
	{
		cacheTimeout = setTimeout("cache('"+baliseId+"')", delais);
	}
}

////////////////////

function GetById(NodeID)
{
	return(document.getElementById(NodeID));
}

////////////////////

function GrisePage(Active)
{
	if(Active)
	{
		document.getElementById("grised_layer").style.display = "block";
	}
	else
	{
		document.getElementById("grised_layer").style.display = "none";
	}
}

////////////////////

function checkPlanPresseForm() 
{
	var form=new Array()
	form=document.getElementById('formPlanPresse');
	var tab=new Array();
	tab=document.getElementsByTagName('input');
	var erreur=new String;
	erreur="";
	if(document.getElementById('factOk').checked==true)
	{
		for(i=0; i<tab.length-1; i++)
		{
			if (tab[i].parentNode.id == 'formPlanPresse')
			{
				tab[i].style.backgroundColor = "#ffffff";
				if(tab[i].type=="text")
				{
				
					if(tab[i].name=="mail")
						{		
							mailerr="";
							
							if(tab[i].value!="")
								{
									indexAroba = tab[i].value.indexOf('@');
									indexPoint = tab[i].value.indexOf('.');
							
									if ((indexAroba < 0) || (indexPoint < 0))		
									{
										tab[i].style.backgroundColor = "#ffdaca";
										mailerr= "Le mail est incorrect";
									}
								}
						}

						
					if (tab[i].value=="")
						{
							erreur+=tab[i].id;
							
							if(i<tab.length-2)
							erreur+=', '
							
							tab[i].style.backgroundColor="#ffdaca";
						}
				}
			}
		}
		if(erreur!="" || mailerr!="")
		{
			mess="";
			if(erreur!="")
				mess="vous n\'avez pas rempli les champs suivants : ";
			alert(mailerr+mess+erreur+'.')
			return false;
		}
	}
	if(document.getElementById('cgvOk').checked==false)
	{
		alert("Vous devez accepter les conditions générales de vente");
		return false;
	}
	return true;
}

function formationCheck ()
{
	var form=new Array()
	form=document.getElementById('formationForm');
	var tab=new Array();
	tab=document.getElementsByTagName('input');
	var erreur=new String;
	erreur="";
	for(i=0; i<tab.length; i++)
	{
		tab[i].style.backgroundColor = "#ffffff";
		if(tab[i].type=="text" && tab[i].parentNode.className=='input')
		{
			if (tab[i].value=="")
			{
				erreur+=tab[i].id;
				erreur+=', ';
				tab[i].style.backgroundColor="#ffdaca";
			}
			else
			{
				if (tab[i].name=="mail")
				{
					indexAroba = tab[i].value.indexOf('@');
					indexPoint = tab[i].value.indexOf('.');
					if ((indexAroba < 0) || (indexPoint < 0))		
					{
						erreur+=tab[i].id;
						erreur+=', ';
						tab[i].style.backgroundColor = "#ffdaca";
					}
				}
			}
		}
	}
	if(erreur!="")
	{
		var mess;
		mess="Certaines informations sont manquantes ou d'un format incorrect";
		$('error').innerHTML = mess;
		$('error').style.display='block';
		return false;
	}
	else
		$('formationForm').submit();
}
////////////////////

function Ouvrir_Spplus()
{
	self.name="Offremedia.com";
	var PopupSpplus_largeur = 750;
	var PopupSpplus_hauteur = 560;
	var PopupSpplus_top =((screen.height-PopupSpplus_hauteur)/2);
	var PopupSpplus_left =((screen.width-PopupSpplus_largeur)/2);
	var win = window.open('', "SPPLUS","status=yes,top="+PopupSpplus_top+",left="+PopupSpplus_left+",width="+PopupSpplus_largeur+",height="+PopupSpplus_hauteur);
	win.focus();
}

////////stats////////
function hit(type,arg1,arg2,arg3)
{
	arg1 = arg1!=undefined ? arg1 : '';
	arg2 = arg2!=undefined ? arg2 : '';
	arg3 = arg3!=undefined ? arg3 : '';
	
	(new Image()).src = '/argosSites/offremedia/php/hit.php?time='+new Date().getTime()+'&type='+type+'&arg1='+arg1+'&arg2='+arg2+'&arg3='+arg3;
	return true;
}

function maj_prix(value, valuepp)
{
	var newprix = value*valuepp;
	var prix = String(newprix+newprix*19.6/100);
	if (prix.indexOf('.') != -1)
		prix = prix.substr(0,prix.indexOf('.')) + '.' + Math.round(parseInt(prix.substr(prix.indexOf('.')+1,2))); 
	$('prix_content').innerHTML = prix + '&euro;';
	$('prixht_content').innerHTML = newprix + '&euro;';
}
		

