var isIE = document.all?true:false;
var isNS = document.layers?true:false;



function onlyDigits(e) {
  var _ret = true;
  if (isIE) {
    if (window.event.keyCode < 46 || window.event.keyCode > 57) {
      window.event.keyCode = 0;
      _ret = false;
    }
  }
  if (isNS) {
    if (e.which < 46 || e.which > 57) {
      e.which = 0;
      _ret = false;
    }
  }
  return (_ret); 
}


function end_onlyDigits() {
  if (isNS) document.captureEvents(Event.KEYPRESS);
  document.onkeypress=onlyDigits;
}


function is_number(data) {
   var a = data.split("");
   for (var i in a) {
      if (!a[i].match(/\d/)) return false;
   }
   return true;
} 


function toggleT(_w,_h) {
  if (document.all) { // is IE
    if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
    if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
  } else { // is NS? -- just guessing for this simple example...
    if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
    if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
  }
}


function confirme() {
   return confirm("Etes vous sûr?");
}

function popup(popW,popH,url,nom,options) {
var w = 800, h = 600;
if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}
var topPos = (h - popH)/2;
var leftPos = (w - popW)/2;

var newWindow=window.open(url,nom,'width='+popW+',height='+popH+',top='+topPos+',left='+leftPos+',resizable=0,status=0,titlebar=0,scrollbars=1'+options);
newWindow.window.focus();

return false;

}


function admin_move() {

if (document.liste.repdst.value!="") {
   document.liste.action.value='move'; 
   document.liste.submit(); 
} 

}




var ns4=(document.layers)? true:false;
var ns6=(document.getElementById)? true:false;
var ie4=(document.all)? true:false;
var ie5=false;
if(ie4){
if((navigator.userAgent.indexOf('MSIE 5')> 0)||(navigator.userAgent.indexOf('MSIE 6')> 0)){
ie5=true;
}
if(ns6){
ns6=false;
}
}

function writelayer(ID,sText) {
 if (document.layers) {
   var oLayer;
   if(parentID){
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   }else{
     oLayer = document.layers[ID].document;
   }
   oLayer.open();
   oLayer.write(sText);
   oLayer.close();
 }
 else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
   document.getElementById(ID).innerHTML = sText;
 }
 else if (document.all) document.all[ID].innerHTML = sText
}



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];}
}

/*--------Verif Formulaire ----------------*/
/* utilisé dans activ!                     */
/* NE PAS SUPPRIMER MERCI!!                */
/*-----------------------------------------*/

function VerificationEmail(elm)
{
if (elm.value.indexOf("@") != "-1" &&
    elm.value.indexOf(".") != "-1" &&
    elm.value != "")
    return true;

return false;
}

function VerificationFormulaire()
{
if (VerificationEmail(document.modify.NEWEMAIL) == false)
    {
    alert("Adresse email invalide\n\n Veuillez la corriger");
    document.modify.NEWEMAIL.focus();
   
    return false;
    }
 modify.submit();
return true;
}

function VerificationFormulaireContact()
{
if (!document.contact.MESSAGE.value) {
   alert("Message vide\n\nVeuillez saisir votre message");
   document.contact.MESSAGE.focus();
   return false;
}

if (VerificationEmail(document.contact.EMAIL) == false)
    {
    alert("Adresse email invalide\n\n Veuillez la corriger");
    document.contact.EMAIL.focus();
   
    return false;
    }
 modify.submit();
return true;
}



/*--------testRegex-----------------*/
/* compare une chaine à un pattern  */
/* utilisé dans activ!              */
/* NE PAS SUPPRIMER MERCI!!         */
/*----------------------------------*/
function testRegex(valeur,modele){
 valeur.replace(/(^\s*)|(\s*$)/g,'');  //-- nettoie la chaine <=> trim
 return(modele.test(valeur));
}

function lostPassword(){
    xx=(screen.width-602)/2;
    yy=(screen.height-450)/2;
    str="left=" + Math.round(xx) + ",top=" + Math.round(yy);
    detail = window.open('lostpassword.php','activ','height=450,width=602,toolbar=no,scrollbars=yes,'+str);
    detail.focus();
}

function printablePage(tpl){
    w=602;
    h=400;
    xx=(screen.width-w)/2;
    yy=(screen.height-h)/2;
    str="left=" + Math.round(xx) + ",top=" + Math.round(yy);
    //detail = window.open('index.php?t='+tpl+'&printable=go','','height='+h+',width='+w+',toolbar=yes,scrollbars=yes,'+str);
    detail = window.open(tpl+'&printable=go','','height='+h+',width='+w+',toolbar=yes,scrollbars=yes,'+str);
    detail.focus();
}

function disclaimer(){
    w=400;
    h=400;
    xx=(screen.width-w)/2;
    yy=(screen.height-h)/2;
    str="left=" + Math.round(xx) + ",top=" + Math.round(yy);
    detail = window.open('disclaimer.html','','height='+h+',width='+w+',toolbar=no,scrollbars=yes,'+str);
    detail.focus();
}


function writeEmail(name,domain){
	
txt = '<a href="mailto:please@nospam.com">please@nospam.com</a>';
re1 = new RegExp("(please)","g");
re2 = new RegExp("(nospam.com)","g");
txt = txt.replace(re1,name);
txt = txt.replace(re2,domain);
document.write(txt);
}

