function redirect(url) {
	window.location.replace(url);
}

function Ferme(popup) {
	popup.window.close();
}

function popup_dim(url,width,height,name) {
	window.close('header');
	var html = '<html><head><title>Visualisation</title><meta http-equiv="imagetoolbar" content="no"></head><body leftmargin=0 marginwidth=0 topmargin=0 marginheight=0 onClick="window.close()"><img src="'+url+'" border="0"></body></html>';
	var name = window.open('',"_blank","height="+height+",width="+width+",left="+((screen.width - width)/2)+",top="+((screen.height - height)/2)+",menubar='no',toolbar='no',location='no',status='no',scrollbars='yes'");
	name.document.open();
	name.document.write(html);
	name.document.close();
}

function popup(url,width,height,name) {
	var name = window.open(url,"","height="+height+",width="+width+",left="+((screen.width - width)/2)+",top="+((screen.height - height)/2)+",menubar='no',toolbar='no',location='no',status='no',scrollbars='yes'");
}

function pop_it(url,titre,width,height) {
	//var width = 400;
	//var height = 400;
	
	var T = window.open(url, titre, "height="+height+"px,width="+width+"px,left="+((screen.width - width)/2)+",top="+((screen.height - height)/2)+",menubar='no',toolbar='no',location='no',status='no',scrollbars='yes'");
	T.window.focus();
}

function chiffres(event){
// Compatibilité IE / Firefox
 if(!event && window.event){
    event=window.event;
  }
  
  // IE
 if((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46 && event.keyCode != 43 && event.keyCode != 32 && event.keyCode != 47 && event.keyCode != 45){
    event.returnValue = false;
    event.cancelBubble = true;
  }
 
 // DOM
 if((event.which < 48 || event.which > 57 ) && event.which != 46 && event.which != 43 && event.which != 32 && event.which != 47 && event.which != 45 && event.which != 8 && event.which != 13 && event.which != 0){
    event.preventDefault();
    event.stopPropagation();
  }
}

function verifiermail(mail)
{
 if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0))
 {
  return true
 }
 else
 {
  return false
 }
}

function form_devis(theForm)
{
	if (theForm.refmeca.value == "")
	{
		alert("Champ \"Référence\" manquant.");
		theForm.refmeca.focus();
		return (false);
	}
	
	if ((theForm.spemat.value == "") && (theForm.spemat_autre.value == ""))
	{
		alert("Champ \"Spécification matiére\" manquant.");
		theForm.spemat.focus();
		return (false);
	}
	
	if ((theForm.spetrait.value == "") && (theForm.spetrait_autre.value == ""))
	{
		alert("Champ \"Spécification traitement\" manquant.");
		theForm.spetrait.focus();
		return (false);
	}	

	if (theForm.poids.value == "")
	{
		alert("Champ \"Poids\" manquant.");
		theForm.poids.focus();
		return (false);
	}

	if (theForm.quantitean.value == "" )
	{
		alert("Champ \"Quantité annuelle\" manquant.");
		theForm.quantitean.focus();
		return (false);
	}
	
	if (theForm.quantitelot.value == "" )
	{
		alert("Champ \"Quantité par lot\" manquant.");
		theForm.quantitelot.focus();
		return (false);
	}
	
	if (theForm.nom.value == "" )
	{
		alert("Champ \"Nom\" manquant.");
		theForm.nom.focus();
		return (false);
	}
	
	if (theForm.prenom.value == "" )
	{
		alert("Champ \"Prenom\" manquant.");
		theForm.prenom.focus();
		return (false);
	}
	
	if (theForm.societe.value == "" )
	{
		alert("Champ \"Société\" manquant.");
		theForm.societe.focus();
		return (false);
	}
	
	if (theForm.email.value == "" )
	{
		alert("Champ \"E-mail\" manquant.");
		theForm.email.focus();
		return (false);
	}
	
	if (!verifiermail(theForm.email.value))
	{
		alert("Champ \"E-mail invalide\".");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.tel.value == "" )
	{
		alert("Champ \"Telephone\" manquant.");
		theForm.tel.focus();
		return (false);
	}
	
	return (true);
}

function form_devis_plastique(theForm)
{
	if (theForm.refmeca.value == ""){
		alert("Champ \"Référence\" manquant.");
		theForm.refmeca.focus();
		return (false);
	}
	
	if ((theForm.spemat.value == "") && (theForm.spemat_autre.value == "")){
		alert("Champ \"Spécification matiére\" manquant.");
		theForm.spemat.focus();
		return (false);
	}	

/*	if (theForm.traitdetail.value == ""){
		alert("Champ \" Détail de la spécification matiére\" manquant.");
		theForm.traitdetail.focus();
		return (false);
	}

if (theForm.finition.value == ""){
		alert("Champ \"Finition\" manquant.");
		theForm.finition.focus();
		return (false);
	}*/

	if (theForm.quantitean.value == "" ){
		alert("Champ \"Quantité annuelle\" manquant.");
		theForm.quantitean.focus();
		return (false);
	}
	
	if (theForm.quantitelot.value == "" ){
		alert("Champ \"Quantité par lot\" manquant.");
		theForm.quantitelot.focus();
		return (false);
	}
	
	if (theForm.nom.value == "" )
	{
		alert("Champ \"Nom\" manquant.");
		theForm.nom.focus();
		return (false);
	}
	
	if (theForm.prenom.value == "" )
	{
		alert("Champ \"Prenom\" manquant.");
		theForm.prenom.focus();
		return (false);
	}
	
	if (theForm.societe.value == "" )
	{
		alert("Champ \"Société\" manquant.");
		theForm.societe.focus();
		return (false);
	}
	
	if (theForm.email.value == "" )
	{
		alert("Champ \"E-mail\" manquant.");
		theForm.email.focus();
		return (false);
	}
	
	if (!verifiermail(theForm.email.value))
	{
		alert("Champ \"E-mail invalide\".");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.tel.value == "" )
	{
		alert("Champ \"Telephone\" manquant.");
		theForm.tel.focus();
		return (false);
	}
	
	return (true);
}

function form_devis_cable(theForm)
{
	if (theForm.refmeca.value == ""){
		alert("Champ \"Référence\" manquant.");
		theForm.refmeca.focus();
		return (false);
	}
	

	if (theForm.quantitean.value == "" ){
		alert("Champ \"Quantité annuelle\" manquant.");
		theForm.quantitean.focus();
		return (false);
	}
	
	if (theForm.quantitelot.value == "" ){
		alert("Champ \"Quantité par lot\" manquant.");
		theForm.quantitelot.focus();
		return (false);
	}
	
	
	if (theForm.nom.value == "" ){
		alert("Champ \"Nom\" manquant.");
		theForm.nom.focus();
		return (false);
	}
	
	if (theForm.prenom.value == "" ){
		alert("Champ \"Prenom\" manquant.");
		theForm.prenom.focus();
		return (false);
	}
	
	if (theForm.societe.value == "" ){
		alert("Champ \"Société\" manquant.");
		theForm.societe.focus();
		return (false);
	}
	
	if (theForm.email.value == "" ){
		alert("Champ \"E-mail\" manquant.");
		theForm.email.focus();
		return (false);
	}
	
	if (!verifiermail(theForm.email.value)){
		alert("Champ \"E-mail invalide\".");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.tel.value == "" ){
		alert("Champ \"Telephone\" manquant.");
		theForm.tel.focus();
		return (false);
	}
	
	return (true);
}


function form_contact(theForm)
{
	if (theForm.nom.value == "" )
	{
		alert("Champ \"Nom\" manquant.");
		theForm.nom.focus();
		return (false);
	}
	
	if (theForm.prenom.value == "" )
	{
		alert("Champ \"Prenom\" manquant.");
		theForm.prenom.focus();
		return (false);
	}
	
	if (theForm.societe.value == "" )
	{
		alert("Champ \"Société\" manquant.");
		theForm.societe.focus();
		return (false);
	}
	
	if (theForm.email.value == "" )
	{
		alert("Champ \"E-mail\" manquant.");
		theForm.email.focus();
		return (false);
	}
	
	if (!verifiermail(theForm.email.value))
	{
		alert("Champ \"E-mail invalide\".");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.pays.value == "" )
	{
		alert("Champ \"Pays\" manquant.");
		theForm.pays.focus();
		return (false);
	}
	
	if (theForm.msg.value == "" )
	{
		alert("Champ \"Message\" manquant.");
		theForm.msg.focus();
		return (false);
	}
	
	return (true);
}

function Affiche(texte,commentaire,id,count,largeur)
{
	for(i=1;i<=count;i++)
	{
		var divborder = document.getElementById(i);
		divborder.style.border = '2px solid #FFFFFF';
	}
	
	var divborder = document.getElementById(id);
	divborder.style.border = '2px solid #8CCF33';
	var englobe = document.getElementById("englobe");
	englobe.style.width = largeur+'px';
	englobe.style.border = '3px solid #6C7C8C';
	englobe.style.padding = '8px';
	englobe.style.backgroundColor ='#E0E8EF';
	//englobe.style.width = largeur;

	var divA = document.getElementById("affichage");
	var divB = document.getElementById("footer_miniature");
	divA.innerHTML = '<img src="images/galerie/'+texte+'"><br />';
	divB.innerHTML = commentaire;
}

function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function Mouse_over(id,bg,col,lien)
{
	var color = document.getElementById(id);
	if (lien != '')
	{
		var lien_a = document.getElementById(lien);
		lien_a.style.color = col;
	}
	
	color.style.backgroundColor = bg;
	color.style.color = col;
}

function Mouse_out(id,bg,col,lien)
{
	var color = document.getElementById(id);
	color.style.backgroundColor = bg;
	if (lien != '')
	{
		var lien_a = document.getElementById(lien);
		lien_a.style.color = col;
	}
	color.style.color = col;
}
// JavaScript Document