var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
/*** ***** Utiliser ***** ***/

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
	}

function mailing_valider() {
        mail = document.mailing.mail.value;
        if(mail == "" || mail.indexOf("@") == "-1" || mail.indexOf(".") == "-1") {
                alert("Vous n'avez pas saisi de mail correct.\n");
                document.mailing.mail.focus();
                return;
                }
        popup("mailing_valid.php?mail="+ mail,320,220);
		document.mailing.mail.value = "votre e-mail";
//        document.location.href = "mailing_valid.php?mail="+ mail;
        }

function emoticon(text) {
 text = '' + text + '; ';
 if (opener.document.forms['documentation'].famille_machine.createTextRange && opener.document.forms['documentation'].famille_machine.caretPos) {
  var caretPos = opener.document.forms['documentation'].famille_machine.caretPos;
  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  opener.document.forms['documentation'].famille_machine.focus();
 } else {
 opener.document.forms['documentation'].famille_machine.value  += text;
 opener.document.forms['documentation'].famille_machine.focus();
 }
}

function contact() { 
	window.open('contact.php','contact','width=500,height=400'); 
} 

function valid_newsletter(mail) {  
	if(mail.indexOf("@") != "-1" && mail.indexOf(".") != "-1" && mail != "") document.location="mailing_valid.php?mail=" + mail;
	else alert("Veuillez saisir une adresse e-mail correcte.");
	}  

function popup(pop_url,pop_width,pop_height) {
	pop_name = pop_url.substring(0,3);
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	window.open(pop_url,pop_name,"left=" + pop_left + ",top=" + pop_top + ",width=" + pop_width + ",height=" + pop_height + ",scrollbars=no,noresize");
	}

function loadOne() {
        window.location.reload();
        }

function agrandir(img_src,link_color,bg_color) {
	var pop_width = 640;
	var pop_height = 480;
	var pop_img = new Image();
	pop_img.src = img_src;
	pop_win = window.open("","","width="+ pop_width +",height="+ pop_height +",scrollbars=no");
	pop_win.document.open();
	pop_win.document.write("<head><title>"+ pop_img.src +"</title></head>");
	pop_win.document.write("<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0");
	pop_win.document.write(" link='"+ link_color +"' alink='"+ link_color +"' vlink='"+ link_color +"' bgcolor='"+ bg_color +"'>");
	pop_win.document.write("<table width='100%' height='100%' border=0>");
	pop_win.document.write("<tr><td align=center valign=middle><img src='"+ pop_img.src +"'></td></tr>");
	pop_win.document.write("<tr><td align=center valign=middle><font size='1' face='Verdana, Arial, Helvetica, sans-serif'>");
	pop_win.document.write("<a href='javascript:window.close();'>Fermer la fen&ecirc;tre</a>");
	pop_win.document.write("</font></td></tr>");
	pop_win.document.write("</table>");
	pop_win.document.write("</body>");
	pop_win.document.close();
	if(pop_img.width != 0 || pop_img.height != 0) {
		pop_width = pop_img.width + 40;
		pop_height = pop_img.height + 80;
		pop_win.resizeTo(pop_width,pop_height);
		}
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	pop_win.moveTo(pop_left,pop_top);
	}

function afficher_menu(menu) {
	if(menu == "entreprise") {
		alert(menu);
		}
	if(menu == "produits") {
		alert(menu);
		}
	if(menu == "marques") {
		alert(menu);
		}
	}

function openwindow(url,name,width,height)
{
	window.open(url,name,'toolbar=0,menubar=0,scrollbars=no,resizable=0,width=' + width + ',height=' + height + ',top=100,left=100');
}

/*** Fonction DreamWeaver ***/

function MM_openBrWindow(theURL,winName,features) { //v2.0 
  window.open(theURL,winName,features); 
}

function MM_preloadImages() { //v3.0  
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();  
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)  
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}  
}  
  
function MM_swapImgRestore() { //v3.0  
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;  
}  
  
function MM_findObj(n, d) { //v4.0  
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {  
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  
  if(!x && document.getElementById) x=document.getElementById(n); return x;  
}  
  
function MM_swapImage() { //v3.0  
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)  
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}  
}  
 
function MM_validateForm() { //v4.0 
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; 
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); 
    if (val) { nm=val.name; if ((val=val.value)!="") { 
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); 
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse e-mail.\n'; 
      } else if (test!='R') { 
        if (isNaN(val)) errors+='- '+nm+' doit contenir un nombre.\n'; 
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); 
          min=test.substring(8,p); max=test.substring(p+1); 
          if (val<min || max<val) errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n'; 
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est requis.\n'; } 
  } if (errors) alert('Veuillez saisir les champs obligatoires suivants:\n'+errors); 
  document.MM_returnValue = (errors == ''); 
}
  
function emoticon(text) {
 text = '' + text + '; ';
 if (opener.document.forms['documentation'].famille_machine.createTextRange && opener.document.forms['documentation'].famille_machine.caretPos) {
  var caretPos = opener.document.forms['documentation'].famille_machine.caretPos;
  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  opener.document.forms['documentation'].famille_machine.focus();
 } else {
 opener.document.forms['documentation'].famille_machine.value  += text;
 opener.document.forms['documentation'].famille_machine.focus();
 }
}

/************************** mainTextScroller
 *
 *
 *
 */

var mainTextScroller_startPosition=0;
function mainTextScroller(myMainMessage,speed,scrollingRegion) {
	var mainMessage = myMainMessage;
	var tempLoc = (scrollingRegion*3/mainMessage.length) + 1;
	if (tempLoc < 1) {
		tempLoc = 1
		}
	var counter;
	for(counter = 0;counter <= tempLoc;counter++) mainMessage += mainMessage;
	document.mainTextScrollerForm.mainTextScroller.value = mainMessage.substring(mainTextScroller_startPosition,mainTextScroller_startPosition+scrollingRegion);
	mainTextScroller_startPosition++;
	if(mainTextScroller_startPosition > scrollingRegion) mainTextScroller_startPosition = 0;
	setTimeout("mainTextScroller(\""+ myMainMessage +"\","+ speed +","+ scrollingRegion +")",speed); 
	}

/************************** loaded 1.3 2004-02-27
 * Auteur : Sebastien Poubelle
 *
 * Appelle la page supprimer.php qui permet de supprimer
 * l'enregistrement 'id' de la table 'table' de la base
 * de donnée courante.
 * 'url' est l'adresse de retour et 'arg' est la chaine
 * de caractères correspondant aux argument à retourner.
 *
 */

function loaded(color) {
        getRef("nowLoading").innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
        }

function IsNumeric(strString)
// check for valid numeric strings
{
        var strValidChars = "0123456789.- ";
        var strChar;
        var blnResult = true;

        if (strString.length == 0) return false;

        // test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1) blnResult = false;
        }
        return blnResult;
}

