function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_showHideDIV() { //v6.0
  var i,p,v,obj,args=MM_showHideDIV.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='block')?'block':(v=='none')?'none':v; }
    obj.display=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}
function openWinImage(img) {
	var features = 'scrollbars=no,location=no,toolbar=no,menubar=no,status=no,resizable=yes,width=510,height=360,left=550,top=200';
	var name ='photos';
	new_window = window.open('',name,features);
  new_window.document.write('<html>\n<head>\n</head>\n<body style="margin:5px;background-color:black;">\n<img src='+img+'>\n</body>\n</html>');
  // <base href="http://www.release.ch">\n
  new_window.document.close();
  new_window.focus();
}

function postComm() { 
  var f = document.getElementById('addmaincomment');
	if (checkForm(f)) {   	
		return true;
	}else {
		return false;
	}
}
function postBlog() { 
  var f = document.getElementById('insertperson');
	if (checkForm(f)) {   	
		return true;
	}else {
		return false;
	}
}

function checkForm(f) {
	var lunghez = f.vcomment.value.length;
	// alert("Le message contient "+lunghez+" caractères");
	if (document.getElementById('thiscode').value != document.getElementById('verification').value)
	{
		alert("Le code n'est pas correct, il doit correspondre aux 4 caractères en rouge.");
		document.getElementById('verification').focus();
				return false;
	}
	if (lunghez < 10 ) {
		alert("Le message est un peu court... 10 caractères au minimum.");
		f.vcomment.focus();
		return false;
	} else {
		return true;
	}
}

function postTheme() { 
  var f = document.getElementById('newforumtheme');
	if (checkFormTheme(f)) {   	
		return true;
	}else {
		return false;
	}
}

function checkFormTheme(f) {
	var lunghez = f.fortit.value.length;
	if (document.getElementById('thiscode').value != document.getElementById('verification').value)
	{
		alert("Le code n'est pas correct, il doit correspondre aux 4 caractères gris.");
		document.getElementById('verification').focus();
				return false;
	}
	if (lunghez<5 ) {
		alert("Votre titre est un peu court... 5 caractères au minimum.");
		f.fortit.focus();
		return false;
	} else {
		return true;
	}
}
function postRep() { 
  var f = document.getElementById('addreponse');
	if (checkFormRep(f)) {   	
		return true;
	}else {
		return false;
	}
}

function checkFormRep(f) {
	var lunghez = f.vcomment2.value.length;
	if (document.getElementById('thiscode').value != document.getElementById('verification').value)
	{
		alert("Le code n'est pas correct, il doit correspondre aux 4 caractères gris.");
		document.getElementById('verification').focus();
				return false;
	}
	if (lunghez<5 ) {
		alert("Votre réponse est un peu courte... 5 caractères au minimum.");
		f.vcomment2.focus();
		return false;
	} else {
		return true;
	}
}
function confirmDelete() {
	if(document.getElementById('updateperson').effaceblog.checked == true){
    if (window.confirm("Voulez-vous vraiment effacer ce thème et toutes les contributions?\nAttention: pour le mettre aux archives, il faut plutôt enlever la coche \"public\".")) {
              document.getElementById('updateperson').effaceblog.checked = true;
    }else{
    document.getElementById('updateperson').effaceblog.checked = false;
  }
}
}



function showprov (div1,obje,valnam,txtare) {
	if (document.getElementById(obje).value==valnam )
		document.getElementById(txtare).focus();
	else
	document.getElementById(txtare).value='';
}
function doneit (tdnum) {
	if ( document.getElementById(tdnum) )
		document.getElementById(tdnum).className='itemdone';
}
function cleanit (tdnum) {
	if ( document.getElementById(tdnum) )
		document.getElementById(tdnum).className='';
}
function notdoneyet (tdnum) {
	if ( document.getElementById(tdnum) )
		document.getElementById(tdnum).className='q1';
}
function showdiv (div) {
	document.getElementById(div).className='showdiv';
}
function showme (txtar) {
	document.getElementById(txtar).className='textareahilight';
	document.getElementById(txtar).focus()
}
function hideme (txtar) {
	document.getElementById(txtar).className='txtareainvis';
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit être un nombre entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

var mmHideMenuTimer = null;
function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_showHideLayers('menuA','','hide','menuB','','hide','menuC','','hide','menuD','','hide','menuE','','hide','menuF','','hide','menuG','','hide','motivation','','hide','mobilisation','','hide','leadership','','hide','breadcrumbA','','show','breadcrumbB','','show','breadcrumbC','','show','breadcrumbD','','show','breadcrumbE','','show','breadcrumbF','','show','breadcrumbG','','show')", hideTimeout);	
}
function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function validateFormLogin() {
    if (isEMailAddr(document.getElementById('Email'),4,'email')) {
        if (isNotEmpty(document.getElementById('Firstname'),3,'First name')) {
            if (isNotEmpty(document.getElementById('FamilyName'),3,'Family name')) {
                            document.getElementById('Ccontact').submit();
            }
        }
    }
}
function validateFormBook()  {
    if (isEMailAddr(document.getElementById('Email'),4,'email')) {
        if (isNotEmpty(document.getElementById('Firstname'),3,'First name')) {
            if (isNotEmpty(document.getElementById('FamilyName'),3,'Family name')) {
				if (isNotEmpty(document.getElementById('Addressline1'),3,'Address line 1')) {
					if (isNotEmpty(document.getElementById('Town'),3,'Town')) {
						if (isNotEmpty(document.getElementById('Postcode'),3,'Postcode')) {
							if (isNotEmpty(document.getElementById('Country'),3,'Country')) {
								if (isChosen(document.getElementById('coursedate'))) {
                            		document.getElementById('Ccontact').submit();
								}
							}
						}
					}
				}
            }
        }
    }
}

// validates that the field value string has one or more characters in it
function isNotEmpty(elem,nchar,elemname) {
    var str = document.getElementById(elem).value;
	var strl = str.length;
   	if(!elemname)  var elemname = 'required field';
    if(!nchar) var nchar = 3;
    if(str == null || strl < nchar) {
        // alert("Please double check your code (min. "+nchar+" characters, mind the upper and lowercases).");
		if ( document.getElementById(elemname) )
			document.getElementById(elemname).className='itemNOTdone';
			document.getElementById(elemname).focus();
		// alert("Complétez votre réponse.");
        return false;
    } else {
		if ( document.getElementById(elemname) )
			document.getElementById(elemname).className='';
        return true;
    }
}

function isNotTheSameValue(elem1,elem2) {
	var str1 = document.getElementById(elem1).value;
	var str2 = document.getElementById(elem2).value;
	if(str1 != str2) {
			alert("The ID and confirmed ID do not match?!!");
			return false;
		} else {
			return true;
		}
}
// validates that the entry is formatted as an email address
function isEMailAddr(elem) {
    var str = document.getElementById(elem).value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Vérifiez le format de votre email.");
		document.getElementById(elem).className='itemNOTdone';
		document.getElementById(elem).focus();
        return false;
    } else {
		document.getElementById(elem).className='';
        return true;
    }
}

// validate that the user made a selection other than default
   
function isChosen(select,toselect,TD) {
    if (select.selectedIndex == -1 || select.selectedIndex == 0) {
        // alert("Select an item in the list '"+toselect+"'");
		document.getElementById(TD).className='itemNOTdone';
        return false;
    } else {
		document.getElementById(TD).className='';
		return true;
    }
}
function isChosen2(select,toselect,TD) {
    if (select.selectedIndex == -1 ) {
        // alert("Select an item in the list '"+toselect+"'");
		document.getElementById(TD).className='itemNOTdone';
        return false;
    } else {
		document.getElementById(TD).className='';
		return true;
    }
}
// validate that the user has checked one of the radio buttons
function isValidRadio(radio,txt) {
    var valid = false;
    for (var i = 0; i < radio.length; i++) {
        if (radio[i].checked) {
			if ( document.getElementById(txt) )
				document.getElementById(txt).className='';
            return true;
        }
    }
    // alert("Choisissez une option.");
	if ( document.getElementById(txt) ) {
		document.getElementById(txt).className='itemNOTdone';
		
	}
    return false;
}

function focusElement(elemID) {
	var elem = document.getElementById(elemID);
    elem.focus( );
}

function isNumber(fieldID,labelos,nchar,minos,maxos) {
    var str = document.getElementById(fieldID).value;
    var oneDecimal = false;
    var oneChar = 0;
	if( minos != null && maxos != null && ( str < minos || str > maxos )) {
		alert("Set a mumber between "+minos+" and "+maxos);
		if ( document.getElementById(fieldID) )
				setTimeout("focusElement('"+fieldID+"')", 0);
		if ( document.getElementById(labelos) )
				document.getElementById(labelos).className='itemNOTdone';
		return false;
	}
    // make sure value hasn't cast to a number data type
    str = str.toString( );
	if(str == null || str.length < nchar) {
		alert("Set a mumber between "+minos+" and "+maxos);
		if ( document.getElementById(fieldID) )
				setTimeout("focusElement('"+fieldID+"')", 0);
		if ( document.getElementById(labelos) )
				document.getElementById(labelos).className='itemNOTdone';
		return false;
	}
	
    for (var i = 0; i < str.length; i++) {
        oneChar = str.charAt(i).charCodeAt(0);
        // OK for minus sign as first character
        if (oneChar == 45) {
            if (i == 0) {
                continue;
            } else {
                alert("Only the first character may be a minus sign.");
                return false;
            }
        }
        // OK for one decimal point
        if (oneChar == 46) {
            if (!oneDecimal) {
                oneDecimal = true;
                continue;
            } else {
                alert("Only one decimal is allowed in a number.");
                return false;
            }
        }
        // characters outside of 0 through 9 not OK
        if (oneChar < 48 || oneChar > 57) {
            alert("Entrez "+nchar+" chiffre-s au minimum dans le champ.");
			if ( document.getElementById(fieldID) )
				setTimeout("focusElement('"+fieldID+"')", 0);
			if ( document.getElementById(labelos) )
				document.getElementById(labelos).className='itemNOTdone';
            return false;
        }
    }
	if ( document.getElementById(labelos) )
		document.getElementById(labelos).className='itemdone';
    return true;
}


function validateForm(form) {
    if (isNotEmpty(form.disciplines)) {
        if (isChosen(form.taux)) {
            if (isChosen(form.annees)) {
                    return true;
            }
        }
    }
    return false;
}


function validateFormQ_emailID(form) {
	if (isEMailAddr('emailID',12,'emailID')) {
        return true;
	}
	return false;
}

function validateFormQ_index(form) {
	if (isNotEmpty('sTudentID',12,'sTudentID')) {
	}
	else {
		alert('ID is made of 12 characters, \ncopy/paste from the email you received \nwhen you registered the first time.');
		return false;
	}
}
function validateFormQ00(form) {
	if (isValidRadio(form.Atessin1,'td1')) {
           	return true;
     }
	return false;
}

function validateFormQ01(form) { 
	if (document.getElementById('thiscode').value != document.getElementById('verification').value)
	{
		alert("Le code est faux: \ncopiez les 4 caractères exactement comme affichés.");
		document.getElementById('verification').focus();
				return false;
	}
	if (isNotEmpty('message1',1,'message1')) {

	}
	else {
	alert ('Le message ne peut rester vide...');
	document.getElementById('message1').focus();
	return false;
	}
	
	if (isNotEmpty('nom',1,'nom')) {

	}
	else {
	document.getElementById('nom').focus();
	return false;
	}
	if (isNotEmpty('prenom',1,'prenom')) {

	}
	else {
	document.getElementById('prenom').focus();
	return false;
	}
	if(isEMailAddr('email')) {

	}
	else {
		return false;
	}
	return true;
}
