//
//
      function popup(page, title, features)
      {
        window.open(page, title, 'toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=no, status=no,'+features);  
      }
      //test si elem est numerique
      function isNumber(elem) 
      {
          var str = new String(elem);
          var re = /^[-]?\d*\.?\d*$/;
          return str.match(re);
      }
    
    // Valider un champ numerique et test si sa longueur= p_length
      function validNumericField(p_field, p_length)
      {
          l_ret = false;
    
          if (isNumber(p_field))
          {
           if (p_field.length == p_length)
            {
              l_ret =true;
            }
          }
          return l_ret;
      }
      // Valider un champ numerique et test si sa longueur>= p_length
      function validNumericFieldGT(p_field, p_length)
      {
          l_ret = false;
          if (isNumber(l_field))
          {
            if (l_field.length >= p_length)
            {
              l_ret =true;
            }
          }
          p_field = l_field;
          return l_ret;
      }
      // Valider un champ  si sa longueur= p_length
      function validLength(p_in_item,p_in_len) 
      {
    	 return (p_in_item.length == p_in_len);
      }
      // Valider un champ  si sa longueur>= p_length
      function validLengthGT(p_in_item,p_in_len) 
      {
    	 return (p_in_item.length >= p_in_len);
      }
      /* Valider un champ  Email si sa longueur> p_length
        avec @
      	avec .
      	sans blanc
      	nne contient pas  ]
      	ne contient pas  [
      	ne contient pas  )
      	ne contient pas  (
      	ne contient pas  {
      	ne contient pas  }
      	ne contient pas  |
      	ne contient pas  é
      	ne contient pas  è
      	ne contient pas  à
      */
      function validateEmail(p_in_item) 
      {
      	if (!validLengthGT(p_in_item,5)) return false;
      	if (p_in_item.indexOf('@',0) == -1) return false; // sans @
      	if (p_in_item.indexOf('.',0) == -1) return false; // sans .
      	if (p_in_item.indexOf(' ',0) != -1) return false; // sans blanc
      	if (p_in_item.indexOf(']',0) != -1) return false; // contient ]
      	if (p_in_item.indexOf('[',0) != -1) return false; // contient [
      	if (p_in_item.indexOf('(',0) != -1) return false; // contient )
      	if (p_in_item.indexOf(')',0) != -1) return false; // contient (
      	if (p_in_item.indexOf('{',0) != -1) return false; // contient {
      	if (p_in_item.indexOf('}',0) != -1) return false; // contient }
      	if (p_in_item.indexOf('|',0) != -1) return false; // contient |
      	if (p_in_item.indexOf('è',0) != -1) return false; // contient é
      	if (p_in_item.indexOf('è',0) != -1) return false; // contient è
      	if (p_in_item.indexOf('à',0) != -1) return false; // contient à
      	return true;
      }
      function skipBlank(p_field)
      {
        l_str = new String(p_field);
        l_field = new String(l_str.replace(' ','')); // enlève les blancs
//alert ('p_field=' + p_field + ' l_field=' + l_field);
        while (l_field != l_str)
        {
          l_str = l_field;
          l_field = l_str.replace(' ',''); // enlève les blancs
        }
        
        return l_field;

      }
      
      function recupValueRadio (chemin) {
        var nbreChoix = chemin.length;
        for(i=0;i<nbreChoix;i++){
          choix = chemin[i];
          if(choix.checked){
            var valueChoix = choix.value;
            break;
          }
        }
        return valueChoix;
      }
      function initAlertMessage() {
        obj = $('alertmessage');
        obj.innerHTML = "";
        obj.style.display = 'none';
      }
      
      function alertMessage(msg) 
      {
        obj = $('alertmessage');
        if(obj != null){
          obj.innerHTML = "<p>"+msg+"</p>";
          obj.style.display = 'block';
        }else{
          alert('le champ alertMessage n existe pas');
        }
      }
      /*
        Fonction permettant de retrouver la valeur d'un bouton radio
        en fonction de ce qui est coché
      */
      function valueRadio(p_obj)
      {
        l_ret = '';
        for (ix = 0 ; ix < p_obj.length;ix++)
        {
          if (p_obj[ix].checked)
          {
            l_ret = p_obj[ix].value ;
          } 
        }
        return l_ret;
      }

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}