//window.defaultStatus = "Bienvenue sur notre site Internet";

function OpenWin (url,nomWin,confWin) {
    //var newWin;
    if (confWin == "") {
      var confWin = "width=800px,height=600px,left=15px,top=15px,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes";
    }
    window.open (url,'',confWin);
}

function VerifierDate (elm) {
    /*
	cette fonction vérifie le format français d'une date (ex: jj/mm/aaaa)
	avec 	0 < jj <= 31, 0 < mm <= 12, 1900 < aaaa < 2100
    */
    if (elm.value != "") {
        var items = elm.value.split ("/");
	
	if (items.length != 3)	return false;
	if ((items[0] < 1) || (items[0] > 31))	return false;
	if ((items[1] < 1) || (items[1] > 12))	return false;
	if ((items[2] < 1900) || (items[2] > 2100))	return false;
	return true;
    }
    return false;
}

function preloadImages() 
{
	document.preload = new Array();
	if (document.images) 
	{
		for (var i = 0; i < preloadImages.arguments.length; i++) {
			document.preload[i] = new Image();
			document.preload[i].src = preloadImages.arguments[i];
		}
	}
}

/*function VerifierHeure (elm) {
// cette fonction vérifie le format d'une heure (ex: hh:mm:ss)
// avec 	0 <= hh <= 24, 0 <= mm <= 60, 0 <= ss < 60
    if (elm.value != "") {
        var items = elm.value.split (":");
	
	if (items.length < 2)	return false;
	if ((items[0] < 0) || (items[0] > 24))	return false;
	if ((items[1] < 0) || (items[1] > 59))	return false;
	if (items.length > 2)
	    if ((items[2] < 0) || (items[2] > 59))	return false;
	return true;
    }
    return false;
}

function VerifierNumTel (elm) {
// vérification du format d'un numéro de téléphone / télécopie (ex: 0a23456789)
// avec 1 <= a <= 6
    if  (elm.value != ""){
      if (elm.value.length == 14) {
        var prefixe = elm.value.substring (1,2);
        
        if (elm.value.substring (0,1) != 0)	return false;
        if (elm.value.substring (2,3) != '.')	return false;
        if (elm.value.substring (5,6) != '.')	return false;
        if (elm.value.substring (8,9) != '.')	return false;
        if (elm.value.substring (11,12) != '.')	return false;
        if ((prefixe < 1) || (prefixe > 6))	return false;
        return true;
      }
    }
    return false;
}*/

function VerifierMailAddr (a) {
  testm = false ;
  
  //if(ereg("^[-._a-z0-9(]+@[-.a-z0-9]+\.[a-z]", $a))
  for (var j=1 ; j<(a.value.length) ; j++)
    if (a.value.charAt(j)=='@')
      if (j<(a.value.length-4))
        for (var k=j ; k<(a.value.length-2) ; k++)
          if (a.value.charAt(k)=='.') testm = true;
  return (testm);
}

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_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_findObj(n, d) { //v4.01  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 && d.getElementById) x=d.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 ConsulterClientDetails1(window_type, prj_id){
//
    if (window_type)
      OpenWin ('clients/details_clients.php?prj_id='+prj_id+'&affiche=success','','width=800px,height=600px,left=300px,top=150px,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes');
    else
      window.location = 'details_clients.php?prj_id='+prj_id;
}*/

function mailist () {
//
	if (VerifierMailAddr (document.newsletter.askml_email)) {
		document.newsletter.submit ();
	} else {
		alert ("Votre adresse Email ne suit pas la syntaxe 'user@domain.tld'");
	}
}

function extranet () {
//
	if ((document.extranet.login.value != '') && (document.extranet.password.value != '')) {
		document.extranet.submit ();
	} else {
		alert ("Veuillez saisir votre login et votre mot de passe");
	}
}

function LireSuiteComm (window_type, cnt_id) {
//
	if (window_type)
		OpenWin ('detail.php?cnt_id='+cnt_id, '','width=800px,height=600px,left=15px,top=15px,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes');
	else
		window.location = 'detail.php?cnt_id='+cnt_id;
}
   