function doSubmit(){
  document.form.submit();
}
function language(langue, page)
{
  document.eq.action = 'language.asp?lang=' + langue + '&page=' + page;
  document.eq.submit();
}
function resize()
{
  window.moveTo(0,0);
  var w = Number(screen.availWidth);
  var h = Number(screen.availHeight);
  window.resizeTo(w,h);
}
function lib_bwcheck() //Browsercheck (needed)
{
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.nav=navigator.appName;
	this.dom=document.getElementById?1:0;
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && this.dom)?1:0;
	this.gecko=(parseInt(navigator.userAgent.indexOf("Gecko"))>-1)?1:0;
	this.firefox=(navigator.userAgent.indexOf("Firefox")>-1)?1:0;
	this.moz5=(navigator.userAgent.indexOf("mozilla/5.0")>-1)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns7=(this.dom && parseInt(this.ver) >= 7) ?1:0;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.nn=(this.ver.indexOf("Netscape")>-1)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.ns7 || this.opera5 || this.moz5);
	return this
}
var bw=lib_bwcheck()

function submitOnEnterKeyPressed(evenement, buttonId)
{
    var touche = window.event ? evenement.keyCode : evenement.which;
    if(touche == 13){
      document.getElementById(buttonId).click();
    }
}

var win=null
function newWindow(mypage,myname,w,h,t,l,bars)
{
  settings='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars='+bars+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable='+bars;
  win=window.open(mypage,myname,settings);
  if(win.focus){
    win.focus();
  }
}
function NewWindow(mypage,myname,w,h,t,l)
{
  settings="width="+w+",height="+h+",top="+t+",left="+l+",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
  win=window.open(mypage,myname,settings);
  if(win.focus){
    win.focus();
  }
}
function redir(u)
{
  window.location=u;
}
function openerRedir(u)
{
  if(opener){
    opener.window.location=u;
  }
}
function openerRedirClose(u)
{
  if(opener){
    opener.window.location=u;
  }
  window.close();
}
function omOver(el,cl)
{
  var pel=el.parentNode;
  var list=pel.childNodes;
  var n=list.length;
  for(var i=0;i<n;i++){
    list[i].className=cl;
  }
}
function omOut(el,cl)
{
  var pel=el.parentNode;
  var list=pel.childNodes;
  var n=list.length;
  for(var i=0;i<n;i++){
    list[i].className=cl;
  }
}
function show(elementId)
{
  document.getElementById(elementId).style.visibility = 'visible';
  document.getElementById(elementId).style.display = 'block';
}

function hide(elementId)
{
  if(bw.ns4){
    document.getElementById(elementId).visibility = 'hide';
  }else{
    document.getElementById(elementId).style.visibility = 'hidden';
  }
  document.getElementById(elementId).style.display = 'none';
}

function showHide(elementId)
{
  var css = document.getElementById(elementId).style;
  (css.visibility=='hidden')?show(elementId):hide(elementId);
}
function switchImg(obj,img1,img2)
{
  (obj.src.indexOf(img1)>0)?(obj.src=img2):(obj.src=img1);
}
function showTT(divName,posX,posY)
{
  var mouseX = 0;
  var mouseY = 0;
  var scrollTopWindow = 0;
  if((bw.moz5)||(bw.nn))
  {
    //alert("gecko=" + bw.agent.indexOf("gecko") + "\nfirefox=" + navigator.userAgent.indexOf("Firefox"));
    mouseX = Event.pageX;
    mouseY = Event.pageY;
  }else{
    //alert(navigator.userAgent + '\nAgent=' + bw.agent + '\nGecko=' + bw.agent.indexOf("gecko"));
    mouseX = event.x;
    mouseY = event.y;
    scrollTopWindow = document.body.scrollTop;
  }
  var d=document.getElementById('toolTip' + divName);
  d.style.top=mouseY+scrollTopWindow+posY;
  d.style.left=mouseX+10+posX;
  show('toolTip' + divName);
}
function hideTT(divName){
  hide('toolTip' + divName);
}
function testLoginForm(){
  var login = document.getElementById('username').value
  var password = document.getElementById('password').value
  if(login.length==0){
    alert("A login is required.");
    return false;
  }
  if(password.length==0){
    alert("A password is required.");
    return false;
  }
  return true;
}
function winStatus(text){
  window.status=text
  return true
}
function addToFav() {
  self.external.AddFavorite('http://www/.e-questionnaire.com','e Questionnaire THE MARKETING TOOL');
}
function checkedLine(CB,clOver,clOut){
  if (CB.checked){
    highLight(CB,clOver);
  }else{
    deLight(CB,clOut);
  }
}
function highLight(E,cl){
  if(document.all){
    while (E.tagName!="TR")
      {E=E.parentElement;}
  }else{
    while (E.tagName!="TR")
      {E=E.parentNode;}
  }
  E.className = cl;
}
function deLight(E,cl){
  if(document.all){
    while (E.tagName!="TR")
      {E=E.parentElement;}
  }else{
    while (E.tagName!="TR")
      {E=E.parentNode;}
  }
  E.className = cl;
}
function showDiv(thisDiv,l,t){
  document.getElementById(thisDiv).style.visibility = "visible"
  document.getElementById(thisDiv).style.left = l
  document.getElementById(thisDiv).style.top = t
}

function replace(string,text,by) {
// Replaces text with by in string
  var strLength = string.length, txtLength = text.length;
  if ((strLength == 0) || (txtLength == 0)) return string;

  var i = string.indexOf(text);
  if ((!i) && (text != string.substring(0,txtLength))) return string;
  if (i == -1) return string;

  var newstr = string.substring(0,i) + by;

  if (i+txtLength < strLength)
      newstr += replace(string.substring(i+txtLength,strLength),text,by);

  return newstr;
}
//-------------------------------------------------------------------
// Trim functions
//   Returns string with whitespace trimmed
//-------------------------------------------------------------------
function LTrim(str) {
	for (var i=0; str.charAt(i)==" "; i++);
	return str.substring(i,str.length);
}
function RTrim(str) {
	for (var i=str.length-1; str.charAt(i)==" "; i--);
	return str.substring(0,i+1);
}
function Trim(str) {
	return LTrim(RTrim(str));
}
//-------------------------------------------------------------------
//  isEmail(str)
//    Return true if the email str is correct
//-------------------------------------------------------------------
//function isEmail2(email){
//  var atPos = email.value.indexOf('@',0);
//  //alert(atPos);
//  if(atPos==-1 || email.value.indexOf('_',atPos)!=-1 || email.value.indexOf(' ',0)!=-1 || email.value.indexOf(';',0)!=-1 || email.value.indexOf('/',0)!=-1 || email.value.indexOf(':',0)!=-1 || email.value.indexOf('<',0)!=-1 || email.value.indexOf('>',0)!=-1 || email.value.indexOf('*',0)!=-1 || email.value.indexOf('|',0)!=-1 || email.value.indexOf("'",0)!=-1 || email.value.indexOf('&',0)!=-1 || email.value.indexOf('#',0)!=-1 || email.value.indexOf('$',0)!=-1 || email.value.indexOf('!',0)!=-1 || email.value.indexOf('(',0)!=-1 || email.value.indexOf(')',0)!=-1 || email.value.indexOf('[',0)!=-1 || email.value.indexOf(']',0)!=-1 || email.value.indexOf('{',0)!=-1 || email.value.indexOf('}',0)!=-1 || email.value.indexOf('"',0)!=-1 || email.value.length<=6){
//    //return false
//  }
//  return true
//}
//var reEmail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/
var reEmail = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/
function isEmail(s){
  return reEmail.test(s)
}

//-------------------------------------------------------------------
// isNull(value)
//   Returns true if value is null
//-------------------------------------------------------------------
function isNull(val) {
	if (val == null) { return true; }
	return false;
	}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val) {
	if (val == null) { return true; }
	for (var i=0; i < val.length; i++) {
		if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n")) { return false; }
		}
	return true;
	}
//-------------------------------------------------------------------
// isEmpty(value)
//   Returns true if value is null and/or only contains spaces
//-------------------------------------------------------------------
function isEmpty(value){
  if(isNull(value)||isBlank(value)){
    return true
  }
  return false
}


//-------------------------------------------------------------------
// isNumeric(value)
//   Returns true if value contains a positive float value
//-------------------------------------------------------------------
function isNumeric(val) {
	var dp = false;
	for (var i=0; i < val.length; i++) {
		if (!isDigit(val.charAt(i))) {
			if (val.charAt(i) == '.') {
				if (dp == true) { return false; } // already saw a decimal point
				else { dp = true; }
				}
			else {
				return false;
				}
			}
		}
	return true;
}

//-------------------------------------------------------------------
// isDigit(value)
//   Returns true if value is a 1-character digit
//-------------------------------------------------------------------
function isDigit(num) {
	var string="1234567890";
	if (string.indexOf(num) != -1) {
		return true;
		}
	return false;
}
//-------------------------------------------------------------------
// isAlpha(s)
//   Returns true if s is only composed of alphanumeric digits and _.
//-------------------------------------------------------------------
var regExAlpha = /^[a-zA-Z0-9_.]*$/
function isAlpha(s) {
	return regExAlpha.test(s);
}
var regExNumeric = /^[0-9,.]*$/
function isNumber(s){
	return regExNumeric.test(s);
}
function isInteger(s) {
	var regExInteger = /^[0-9]*$/
	return regExInteger.test(s);
}
function halfScreen(page){
  var largeur
  var hauteur
  var leftPos
  if(document.all){
    largeur=window.screen.availWidth/2;
    hauteur=window.screen.availHeight-28;
    leftPos=largeur-10;
  }else{
    largeur=window.screen.availWidth/2;
    hauteur=window.screen.availHeight-45;
    leftPos=largeur-5;
  }
  largeur = "820px";
  window.open(page,"EQuestionnaire",'width='+largeur+',height='+hauteur+',menubar=no,resizable=yes,scrollbars=2,toolbar=no,top=0,left='+leftPos+'');
}

function askIfOk(texte){
  if(!confirm(texte)){
    return false;
  }
}

function validAll(val){
  var myInputs=document.getElementsByTagName('INPUT')
  var n = myInputs.length-1
  for(var i=0;i<n;i++){
    if(myInputs[i].name.indexOf(val,0)==0){
      myInputs[i].checked = !myInputs[i].checked
    }
  }
}

// ouvre une fenetre modale
// =====================================
function ModalWindow(url, title, h, w){
  var sVal = window.showModalDialog(url, title, "center=yes;help=no;status=no;resizable=no;scroll=0;edge=sunken;unadorned=yes;dialogHeight:"+h+";dialogWidth:"+w+";")
  if (sVal!=null && sVal != ''){
    location.reload();
  }
  return false;
}

function Modal(mypage,myname,w,h)
  {
    var wBrowser = 480, hBrowser = 340;
    if (navigator.appName=="Microsoft Internet Explorer") {
      settings = 'center=yes;' +
                 'help=no;' +
                 'status = no;' +
                 'resizable=no;' +
                 'scroll=0;' +
                 'edge=sunken;' +
                 'unadorned=yes;' +
                 'dialogHeight:'+h+'px;' +
                 'dialogWidth:'+w+'px';
      win=showModalDialog(mypage,myname,settings);
    }
    else {
      Popup(mypage,myname,w,h);
    }
  }

function Popup(mypage,myname,w,h){
  var wBrowser = 480, hBrowser = 340;
  wBrowser = top.document.body.clientWidth;
  hBrowser = top.document.body.clientHeight;
  tBrowser = top.window.screenTop;
  lBrowser = top.window.screenLeft;
  var leftPos = (wBrowser-w)/2+lBrowser, topPos = (hBrowser-h)/2+tBrowser;
  settings = 'directories = no,' +
             'menubar = no,' +
             'status = no,' +
             'location = no,' +
             'scrollbars = yes,' +
             'resizable = yes,' +
             'height = '+h+',' +
             'width = '+w+',' +
             'left = '+leftPos+',' +
             'top = '+topPos+',' +
             'fullscreen = no';
  win=window.open(mypage,myname,settings);
  if(win.focus){
    win.focus();
  }
}

function ResizeTabHeight(id){
  var hBrowser = 340;
  hBrowser = document.body.clientHeight;
  document.getElementById(id).style.height=hBrowser-260;
}

function Help(URL){
  var HelpWindowW = 300;
  var screenW = 640, screenH = 480;
  if (parseInt(navigator.appVersion)>3) {
   screenW = screen.availWidth;
   screenH = screen.availHeight;
  }
  top.window.resizeTo(screenW-HelpWindowW-12,screenH);
  top.window.moveTo(0,0);
  HelpWindowL = screenW-HelpWindowW-12;
  HelpWindowH = screenH-38;
  settings = 'directories = no,' +
             'menubar = no,' +
             'status = no,' +
             'location = no,' +
             'scrollbars = yes,' +
             'resizable = yes,' +
             'height = '+HelpWindowH+',' +
             'width = 300,' +
             'left = '+HelpWindowL+',' +
             'top = 0,' +
             'fullscreen = no';
  win=window.open(URL,'Help',settings);
  if(win.focus){
    win.focus();
  }
}
/*
function popPromo(){
  <%
  '- display pop-up message window
  Dim mois, jourFin
  mois = 1
  jourFin = 28
  if datepart("M",date)=mois and datepart("D",date)<=jourFin then
  %>
  var win=null;
  win=window.open('homepopup.htm','annonce','width=250,height=200,top=100,left=100,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=1');
  win.focus;
  <%end if%>
}

function getIt(T,val){
  //cherche val dans T et si il existe renvoi son rang sinon -1
  var i=0,found=false;
  while((i<T.length)&&(!found)){
    if(T[i]==val){found=true;}else{i++;}
  }
  if(!found){return -1;}else{return i;}
}

function tasseIt(T,i){
  while(i<T.length){
    T[i]=T[i+1];
  }
  T[i+1]="";
  return T;
}
*/

/***** desactivation du click droit *****/
/*var sorry = "action disabled"
function noClick(e){
  if(document.all){
    if(event.button == 2){
      alert(sorry);
      return false;
    }
  }
  if(document.layers){
    if(e.which == 3){
      alert(sorry);
      return false;
    }
  }
}
*/
/***** a inserer dans le document a proteger *****/
/*
if(document.layers){
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=noClick;
*/
/**************************************************/

//----------------------------------------------------------------------------
// renvoie true si le parametre n'est pas vide
//----------------------------------------------------------------------------
function isBlank(s){
  var R = true;
  for (var i = 0; i < s.length; i++) {
    if ((s.charAt(i) != ' ') && (s.charAt(i) != "\t") && (s.charAt(i) != "\n")) {R = false;}
  }
  return R;
}

//----------------------------------------------------------------------------
// renvoie true si le parametre est un entier positif
//----------------------------------------------------------------------------
function isInteger(s){
  var integerRegex = /^-?[0-9]*$/
  return integerRegex.test(s);
}

//----------------------------------------------------------------------------
// renvoie true si le parametre est un numérique
//----------------------------------------------------------------------------
function isNumeric(s){
  var numericRegex = /^-?[0-9]+([.|,][0-9]+)?$/
  return numericRegex.test(s);
}

//----------------------------------------------------------------------------
// renvoie true si le parametre est une date
//----------------------------------------------------------------------------
function isDate(s){
	var   dateRegex=/^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/]\d\d\d\d$/
  return dateRegex.test(s);
}

//----------------------------------------------------------------------------
// supprime les espaces en début et fin de chaine de characteres
//----------------------------------------------------------------------------
function trim(string)
{return string.replace(/(^\s*)|(\s*$)/g,'');}

