
function popup(url)
{
	detail= window.open(url,'detail','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=400,height=400');
}

var newwin;
function launchwin(winurl,winname,winfeatures)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	newwin = window.open(winurl,winname,winfeatures);
	//if(javascript_version > 1.0)
	//{
	//delay a bit here because IE4 encounters errors
	//when trying to focus a recently opened window
	setTimeout('newwin.focus();',300);
	//}
}

function popupGrd(url)
{
	detail= window.open(url,'detail','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=700');
}


/**
 * Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 *
 * @param   object   the link : le lien
 * @param   object   the sql query : le message
 *
 * @return  boolean  whether to run the query or not
 */
 
function confirmLink (theLink, message)
{
	var confirmMsg  = 'Voulez-vous vraiment ';
    // Confirmation is not required in the configuration file
    /*if (confirmMsg == '') {
        return true;
    }*/

    var is_confirmed = confirm(confirmMsg + ' :\n' + message);
    if (is_confirmed==true) {
       // theLink.href += '&is_js_confirmed=1';
	   //return is_confirmed;
	  window.location="theLink";
	
	  
    }

    //return is_confirmed;
} // end of the 'confirmLink()' function

function valideSupprime(nomElement) 
{
  alert ("Vous allez "+ nomElement+" ?");
}



//Fonction qui vérifie que le champ cand_fichier_cv n'est pas vide
function submit_login()
{
    //
	if (document.formpostul.cand_fichier_cv.value == "") 
	{
        alert ('Veuillez télécharger votre CV');
        document.formpostul.cand_fichier_cv.focus();
        return false;
    }  
	else 
	{
        return true;
    }
}

function test(f)
{
			 if (f.elements[1].value=="") 
				 	{
					alert("LE CHAMP NOM DOIT ETRE REMPLI");
					f.elements[1].focus();
					return false;
					}
			 return true;
}

function verif_rempli(formul,message)
{
    //
	if (document.forms.elements.value == "") 
	{
        alert ('message');
        document.forms.elements.focus();
        return false;
    }  
	else 
	{
        return true;
    }
}

//fct_verifEmail
//Fonction qui vérifie la validité (True) d'un email passé en référence 

function fct_verifEmail (MonChampT) {
      var sEmail, nIndex, nDotIndex;
	  var MonChamp=MonChampT;
      nIndex = MonChamp.lastIndexOf("@");
      if (nIndex < 2) { 
			return(false);
      }
      nDotIndex = MonChamp.lastIndexOf("." );
      if (nDotIndex < nIndex + 4) {
			return(false);
      }

      if (nDotIndex > (MonChamp.length- 2)) {
      		return(false);
      }
      return(true);
}


//Fonction qui renvoie true si nombre false sinon
function fct_VerifNombre (MonChamp){
   var estNombre = true;
   for(i=0;i<MonChamp.length;++i) {
     if ((MonChamp.charAt(i) < "0") || (MonChamp.charAt(i) > "9")) {
	    estNombre = false;
	 }
   }
   return(estNombre);
}

//Fonction qui renvoie true si la date est bonne, false sinon

function VerifDate(objName) {
var strDatestyle = "EU";  //European US pour US
var strDate,strDateArray,strDay,strMonth,strYear;
var intday,intMonth,intYear;
var booFound = false;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";

strDate = objName.value;

for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
	if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
	   strDateArray = strDate.split(strSeparatorArray[intElementNr]);
	   if (strDateArray.length != 3) {
	   	  err = 1;
		  return false;
	   }
	   else {
	   		strDay = strDateArray[0];
			strMonth = strDateArray[1];
			strYear = strDateArray[2];
	   }
	booFound = true;
    } //if
} //for

if (booFound == false) {
   if (strDate.length>5) {
   	  strDay = strDate.substr(0, 2);
	  strMonth = strDate.substr(2, 2);
	  strYear = strDate.substr(4);
   }
}

if (strYear.length == 2) {
   strYear = '20' + strYear;
}

// US style
if (strDatestyle == "US") {
   strTemp = strDay;
   strDay = strMonth;
   strMonth = strTemp;
}
//gestion du jour
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
   err = 2;
   return false;
}
//gestion du mois
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
   for (i = 0;i<12;i++) {
   	   if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
	   	  intMonth = i+1;
	   	  strMonth = strMonthArray[i];
	   	  i = 12;
   	   }
   }   
   if (isNaN(intMonth)) {
   	  err = 3;
	  return false;
   }
}
//gestion de l'annee
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
   err = 4;
   return false;
}
if (intMonth>12 || intMonth<1) {
   err = 5;
   return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
   err = 6;
   return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
   err = 7;
   return false;
}
if (intMonth == 2) {
   if (intday < 1) {
   	  err = 8;
	  return false;
   }
   if (LeapYear(intYear) == true) {
   	  if (intday > 29) {
	  	 err = 9;
		 return false;
	  }
   }
   else {
   		if (intday > 28) {
   	       err = 10;
	  	   return false;
   		}
   }
}

if (strDatestyle == "US") {
   objName.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
objName.value = intday + " " + intMonth + " " + strYear;
  // objName.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}

//Fonction Bissextile
function LeapYear(intYear) {
   if (intYear % 100 == 0) {
   	  if (intYear % 400 == 0) { return true; }
   }
   else {
	  if ((intYear % 4) == 0) { return true; }
   }
   return false;
}

//Place le focus sur le premier champ d'un formulaire
function placeFocus() {
  if (document.forms.length > 0) {
  	 var field = document.forms[0];
  	 for (i = 0; i < field.length; i++) {
  	    if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
	  	    document.forms[0].elements[i].focus();
	  	    break;
         }
      }
  }
}

function renvoieDate() 
{
  var aujourd_hui = new Date();
  var temp;
  temp=aujourd_hui.getDate()+' / '+aujourd_hui.getMonth()+1+' / '+aujourd_hui.getFullYear();
  return(temp);
}

/******** DEBUT DES FONCTIONS POUR CHOISIR UNE OPTION
EN TAPANT PLUSIEURS LETTRES DANS UN INPUT TEXT **************/

function SelObj(formname,selname,textname,str)
	    {
        this.formname = formname;	// name du formulaire
	    this.selname = selname;		//name du select, donc le champ où s'applique la fonction
	    this.textname = textname;
	    this.select_str = str || '';
	    this.selectArr = new Array();
	    this.initialize = initialize;
	    this.bldInitial = bldInitial;
	    this.bldUpdate = bldUpdate;
	    }

      function initialize()
	    {
	    if (this.select_str =='')
	      {
		  for(var i=0; i<document.forms[this.formname][this.selname].options.length; i++)
		    {
		    this.selectArr[i] = document.forms[this.formname][this.selname].options[i];
		    this.select_str += document.forms[this.formname][this.selname].options[i].value+":"+document.forms[this.formname][this.selname].options[i].text+",";
		    }
		  }
	    else
	      {
		  var tempArr = this.select_str.split(',');
		  for(var i=0; i<tempArr.length; i++)
		    {
		    var prop = tempArr[i].split(':');
		    this.selectArr[i] = new Option(prop[1],prop[0]);
		    }
		  }
	    return;
	    }

      function bldInitial()
	    {
	    this.initialize();
	    for(var i=0; i<this.selectArr.length; i++)
		  {
	      document.forms[this.formname][this.selname].options[i] = this.selectArr[i];
		  }
	    document.forms[this.formname][this.selname].options.length = this.selectArr.length;
	    return;
	    }

      function bldUpdate()
	    {
	    var str = document.forms[this.formname][this.textname].value.replace('^\\s*','');
	    if(str == '')
	      {
		  this.bldInitial();
		  return;
	      }
	    this.initialize();
	    var j = 0;
	    pattern1 = new RegExp("^"+str,"i");
	    for(var i=0; i<this.selectArr.length; i++)
	    if (pattern1.test(this.selectArr[i].text))
	    document.forms[this.formname][this.selname].options[j++] = this.selectArr[i];
	    document.forms[this.formname][this.selname].options.length = j;
	    if (j == 1)
	      {
	 	  document.forms[this.formname][this.selname].options[0].selected = true;
		  }
	    }

      function SetUp(menuform,itemlist,entry)
	    {
	    obj1 = new SelObj(menuform,itemlist,entry);
	    obj1.bldInitial();
	    }

/******** FIN DES FONCTIONS POUR CHOISIR UNE OPTION
EN TAPANT PLUSIEURS LETTRES DANS UN INPUT TEXT **************/