function ctl_email() 
{ 
 var e=document.form1.mailcontr.value;
 re = /^([a-zA-Z0-9]+(([\.\-\_]?[a-zA-Z0-9]+)+)?)\@(([a-zA-Z0-9]+[\.\-\_])+[a-zA-Z]{2,4})$/gi; 
 result = e.match(re) ; 
 if (result==null) 
  {  
   j="0"; 
  } 
 else
  { 
   j="1"; 
  }
}
function isNumeric(Data)
{
numChars = "0123456789";
var isNum = true;
var index = 0;
while ((index <= Data.length) && (isNum))
     {
     isNum = (numChars.indexOf(Data.charAt(index)) != -1);
     index ++;
     }
if ((isNum) && (Data.length > 1))
{return true;}
}
function confsuppann(exid)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette annonce ?" ) ;
  if( confirmation )
  {
    document.location.href = "annsupp.php?did="+exid+"";
  }
}
function confsuppnews(ident,ordre)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette news ?" ) ;
  if( confirmation )
  {
    document.location.href = "newsupp.php?did="+ident+"&o="+ordre+"";
  }
}
function confsuppjt(ident,ann)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette JT ?" ) ;
  if( confirmation )
  {
    document.location.href = "jtsupp.php?did="+ident+"&a="+ann+"";
  }
}
function confsuppcycle(ident,ordre)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer ce cycle ?" ) ;
  if( confirmation )
  {
    document.location.href = "cyclesupp.php?did="+ident+"&o="+ordre+"";
  }
}
function confsuppout(ident,ordre,port)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cet outil ?" ) ;
  if( confirmation )
  {
    document.location.href = "outsupp.php?p="+port+"&did="+ident+"&o="+ordre+"";
  }
}
function confsuppphota(exid)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette photo ?" ) ;
  if( confirmation )
  {
    document.location.href = "photannsupp.php?did="+exid+"";
  }
}
function confsuppphot(exid)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette photo ?" ) ;
  if( confirmation )
  {
    document.location.href = "photexpsupp.php?did="+exid+"";
  }
}
function confsuppphotm(exid)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette photo ?" ) ;
  if( confirmation )
  {
    document.location.href = "photmisssupp.php?did="+exid+"";
  }
}
function confsuppphotv(exid)
{
  var confirmation = confirm( "Voulez-vous vraiment supprimer cette photo ?" ) ;
  if( confirmation )
  {
    document.location.href = "photevesupp.php?did="+exid+"";
  }
}
function affiche() {
var imag = document.form1.ttphot.value;
document.getElementById("imagec").src = imag;
document.form1.nomim.value = imag;
}
function valcontr()
{
  var t="1"; 
  var tit = document.form1.nomcontr.value; 
  var agr = document.form1.precontr.value; 
  var txt = document.form1.mailcontr.value;   
  if ((tit == " " || tit.length < 2) && t == "1")
          {alert("Votre nom est obligatoire");
          document.form1.nomcontr.focus();
           t="0";}
  if ((agr == " " || agr.length < 2) && t == "1")
          {alert("Votre prénom est obligatoire");
          document.form1.precontr.focus();
           t="0";}
  if ((txt == " " || txt.length < 5) && t == "1")
          {alert("Votre adresse email est obligatoire");
          document.form1.mailcontr.focus();
           t="0";}           
if (t=="1")         
{ctl_email();}
if (t=="1" && j == "0")
        {alert("Votre adresse e-mail est incorrecte");
        document.form1.mailcontr.focus();
         t="0";}
  if (t=="1") document.form1.submit();         
}
function valjt()
{
  var t="1"; 
  var tit = document.form1.titjta.value; 
  var dem = document.form1.demjta.value;
  var niv = document.form1.nivjta.value;
  var ani = document.form1.anijta.value;
  var vil = document.form1.villejta.value;
  var cpo = document.form1.cposjta.value;
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("L'intitulé est obligatoire");
          document.form1.titjta.focus();       
          t="0";}
  if ((dem == " " || dem.length == 0) && t == "1")
          {alert("Le demandeur est obligatoire");
          document.form1.demjta.focus();       
          t="0";}
  if ((niv == " " || niv.length == 0) && t == "1")
          {alert("Le niveau est obligatoire");
          document.form1.nivjta.focus();       
          t="0";}
  if ((ani == " " || ani.length == 0) && t == "1")
          {alert("Animal (ou animaux) obligatoire(s)");
          document.form1.anijta.focus();       
          t="0";}
  if ((vil == " " || vil.length == 0) && t == "1")
          {alert("Le lieu de la JT est obligatoire");
          document.form1.villejta.focus();       
          t="0";}
  if ((cpo == " " || cpo.length == 0) && t == "1")
          {alert("Le code postal est obligatoire");
          document.form1.cposjta.focus();       
          t="0";}                                                
  if (document.form1.depidjta.value == '0' && t == "1") {
   alert("Choisissez le département");
  document.form1.depidjta.focus();
   t="0";}
  if (document.form1.debjta.value == '0' && t == "1") {
   alert("Choisissez la date de début de la JT");
  document.form1.debjta.focus();
   t="0";}
  if (document.form1.finjta.value == '0' && t == "1") {
   alert("Choisissez la date de fin de la JT");
  document.form1.finjta.focus();
   t="0";}   
  if (document.form1.finjta.value < document.form1.debjta.value && t == "1") {
   alert("La date de fin de la JT ne peut être inférieure à la date de début");
  document.form1.finjta.focus();
   t="0";}
  if (t=="1") document.form1.submit();         
}
function valtxtnews()
{
  var t="1"; 
  var txt = document.form1.txtnew.value;   
  if ((txt == " " || txt.length < 5) && t == "1")
          {alert("Le texte est obligatoire");
           t="0";}           
  if (t=="1") document.form1.submit();         
}
function valtxtmiss()
{
  var t="1"; 
  var tit = document.form1.titmiss.value; 
  var agr = document.form1.agrmiss.value; 
  var txt = document.form1.txtmiss.value;   
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("Le titre est obligatoire");
          document.form1.titmiss.focus();
           t="0";}
  if ((agr == " " || agr.length == 0) && t == "1")
          {alert("Le nom des adhérents est obligatoire");
          document.form1.agrmiss.focus();
           t="0";}
  if ((txt == " " || txt.length < 15) && t == "1")
          {alert("Le texte est obligatoire");
           t="0";}           
  if (t=="1") document.form1.submit();         
}
function valtxtann()
{
  var i="1"; 
  var nom = document.form1.nomann.value; 
  var pre = document.form1.preann.value; 
  var txt = document.form1.txtann.value;   
  if ((nom == " " || nom.length == 0) && i == "1")
          {alert("Le nom est obligatoire");
          document.form1.nomann.focus();
           i="0";}
  if ((pre == " " || pre.length == 0) && i == "1")
          {alert("Le prénom est obligatoire");
          document.form1.preann.focus();
           i="0";}         
  if (document.form1.tel1anna.value.length == 0 && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1anna.focus();
           i="0";}
  if ((!isNumeric(document.form1.tel1anna.value) || document.form1.tel1anna.value <= 0 || document.form1.tel1anna.value > 99) && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1anna.focus();
           i="0";}
  if (document.form1.tel1annb.value.length == 0 && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annb.focus();
           i="0";}
  if ((!isNumeric(document.form1.tel1annb.value) || document.form1.tel1annb.value < 0 || document.form1.tel1annb.value > 99) && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annb.focus();
           i="0";}
  if (document.form1.tel1annc.value.length == 0 && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annc.focus();
           i="0";}
  if ((!isNumeric(document.form1.tel1annc.value) || document.form1.tel1annc.value < 0 || document.form1.tel1annc.value > 99) && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annc.focus();
           i="0";}
  if (document.form1.tel1annd.value.length == 0 && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annd.focus();
           i="0";}
  if ((!isNumeric(document.form1.tel1annd.value) || document.form1.tel1annd.value < 0 || document.form1.tel1annd.value > 99) && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1annd.focus();
           i="0";}
  if (document.form1.tel1anne.value.length == 0 && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1anne.focus();
           i="0";}
  if ((!isNumeric(document.form1.tel1anne.value) || document.form1.tel1anne.value < 0 || document.form1.tel1anne.value > 99) && i == "1")
          {alert("Veuillez saisir un numéro de téléphone valide (2 chiffres par case), SVP");
          document.form1.tel1anne.focus();
           i="0";}   
  if (i=="1" && document.form1.mailcontr.value.length > 0)         
  {
  	ctl_email();
  if (i=="1" && j == "0")
        {alert("Votre adresse e-mail est incorrecte");
        document.form1.mailcontr.focus();
         i="0";}
  }
  if ((txt == " " || txt.length < 15) && i == "1")
          {alert("Le texte est obligatoire");
           i="0";} 
  if (i=="1") document.form1.submit();         
}
function valtxtout()
{
  var t="1"; 
  var tit = document.form1.titout.value; 
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("Le titre de l'outil est obligatoire");
          document.form1.titout.focus();
           t="0";}      
  if (t=="1") document.form1.submit();         
}
function valtxteve()
{
  var t="1"; 
  var tit = document.form1.titeve.value; 
  var agr = document.form1.agreve.value; 
  var txt = document.form1.txteve.value;   
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("Le titre est obligatoire");
          document.form1.titeve.focus();
           t="0";}
  if ((agr == " " || agr.length == 0) && t == "1")
          {alert("Le nom des adhérents est obligatoire");
          document.form1.agreve.focus();
           t="0";}
  if ((txt == " " || txt.length < 15) && t == "1")
          {alert("Le texte est obligatoire");
           t="0";}           
  if (t=="1") document.form1.submit();         
}
function valtxtexpe()
{
  var t="1"; 
  var tit = document.form1.titexpe.value; 
  var agr = document.form1.agrexpe.value; 
  var txt = document.form1.txtexpe.value;   
  if (document.form1.typexp.value == '0' && t == "1") {
   alert("Choisissez expérience ou portrait");
  document.form1.typexp.focus();
   t="0";}
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("Le titre est obligatoire");
          document.form1.titexpe.focus();
           t="0";}
  if ((agr == " " || agr.length == 0) && t == "1")
          {alert("Le nom des adhérents ou du formateur est obligatoire");
          document.form1.agrexpe.focus();
           t="0";}
  if ((txt == " " || txt.length < 15) && t == "1")
          {alert("Le texte est obligatoire");
           t="0";}           
  if (t=="1") document.form1.submit();         
}
function valtxtart()
{
  var t="1"; 
  var tit = document.form1.titart.value; 
  var txt = document.form1.txtart.value;   
  if ((tit == " " || tit.length == 0) && t == "1")
          {alert("Le titre est obligatoire");
          document.form1.titart.focus();
           t="0";}
  if ((txt == " " || txt.length < 15) && t == "1")
          {alert("Le texte est obligatoire");
           t="0";}           
  if (t=="1") document.form1.submit();         
}
//----------------------
// popup jt
//---------------------
function InfJT(nom,page,w,h) {
var w=304, h=418;
NewWin = window.open(nom,page,
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no');
NewWin.focus();
}
//----------------------
// popup barre crans
//---------------------
function WinBC(page) {
var w=640, h=590;
window.open(page,'barreacrans',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=no');
}
//----------------------
// popup chgt outil
//---------------------
function WinCO(page) {
var w=980, h=590;
window.open(page,'changement',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=no');
}
//----------------------
// popup expe
//---------------------
function WinExpe(page) {
var w=640, h=526;
window.open(page,'photo',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=no');
}
//----------------------
// popup annonce
//---------------------
function WinAnn(page) {
var w=400, h=320;
window.open(page,'annonce',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=no');
}
//----------------------
// la meme sans legende
//---------------------
function WinSans(page) {
var w=640, h=500;
window.open(page,'livre',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=no');
}
//----------------------
// impression
//---------------------
function PosiImp(impr) 
{
if (document.all)
{var xMax = screen.width, yMax = screen.height;}
else
{var xMax = window.outerWidth, yMax = window.outerHeight;}
var w = 730;
var h = (yMax - 100);
window.open(impr,'impri',
'width='+w+',height='+h+',screenX=0,screenY=0,top=0,left=0,scrollbars=yes,menubar=yes');
}
/******************************************************************************
* posilien.js                                                            *
*                                                                             *
* Ouvrir fenêtre des liens avec taille fixe (dans fonction) et positionner           *
*                                                                             *
******************************************************************************/
//----------------------
// maj
//---------------------
function posimaj(mapagel) {
window.open(mapagel,'pagemaj',
'width=682,height=500,screenX=25,screenY=40,top=40,left=25,scrollbars=no');
}
//----------------------
// zoom
//---------------------
function centerwinz(mapage) {
var w=486, h=355;
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset =(xMax)?(xMax-w)/2:100, yOffset =(yMax)?(yMax-h)/2:100;
window.open(mapage,'zoom',
'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}
//----------------------
// zoomimp
//---------------------
function centerwinzp(mapage) {
var w=674, h=543;
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset =(xMax)?(xMax-w)/2:100, yOffset =(yMax)?(yMax-h)/2:100;
window.open(mapage,'zoom',
'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}
//----------------------
// devis
//---------------------
function posidev(mapagel)
{
var w=700;
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var g = yMax*4/5;
var h = Math.round(g);
var xOffset =(xMax)?(xMax-w)/2:100, yOffset =((yMax)?(yMax-h)/2:100) - 30;
window.open(mapagel,'pagedev',
'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=yes');
}
