// Two functions for the menu system

// Open and close sections
function change(rubnum){
var UL, fold;
if (document.getElementById) {
UL = document.getElementById('rxx' + rubnum);
fold = document.getElementById('fold' + rubnum);
if (UL.className=="show") {UL.className="hide"; fold.src="IMG/fleche.gif";}
else {UL.className="show"; fold.src="IMG/fleche_bas.gif";}
}}

// Whole menu is expanded by default. On loading the page
// close the menu but leave the path to current item showing.
function menuset(){
	var BL=new Array();
	BL=document.getElementsByTagName("ul");
	for(i=0; i<BL.length; i++){
		if (((BL[i].id).substring(0,3) == "rxx") && ((rp.indexOf("-"+(BL[i].id).substring(3)+"-")) < 0)){
			change((BL[i].id).substring(3));
		}
	}
}

// - - for photo pages
function openPictureWindow(imageName,imageWidth,imageHeight,alt,posLeft,posTop,texte,curlang) {
// Add a bit of space to allow for title bar
imageWidth = Number(imageWidth) +30;
if (imageWidth +20 > screen.width) {
	imageWidth = (screen.width -20);
}
imageHeight = Number(imageHeight) +60;
if (imageHeight +20 > screen.height) {
	imageHeight = (screen.height -20);
}
	newWindow = window.open("","newWindow","scrollbars,resizable,width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
// force a resize (in case the window was already open)
	newWindow.resizeTo(imageWidth,imageHeight);
	newWindow.document.open();
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	newWindow.document.write('<html lang="' + curlang + '" xmlns="http://www.w3.org/1999/xhtml" xml:lang="' + curlang +'">');
//	newWindow.document.write('<head><title>'+alt+'</title></head><body style="margin: 0" onBlur="self.close()">');
	newWindow.document.write('<head><title>'+alt+'</title></head><body style="margin: 0">');
 	newWindow.document.write('<img src="'+imageName+'" alt="'+alt+'" />');
//	newWindow.document.write('<br />'+texte);
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

// - - stop pages being loaded into a frameset
 function wholewindow()
{
 if (top.location != location) {
	top.location.href = document.location.href ;
  }
}

// - - for download page
function getlink(path,form)
{
  {
  strlink = 'document.' + form + '.LangSelect.options[document.' + form +'.LangSelect.selectedIndex].value';
  document.location.href = './' + path + '/' + eval(strlink);
  }
}

// - -  for antispam system
// function dolink(ad){
//   link = 'mailto:' + ad.replace(/\.\..+t\.\./,"@");
//   return link;
// }

function CheckEmailFormat(email) {
  // Returns false if 'email' is in invalid format for an email address, otherwise true
  // Requires JavaScript 1.2
  var exclude=/[^_@\'\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check=/@[\w\-]+\./;
  // Check list at: http://www.icann.org/tlds/
  // var checkend=/\.[a-zA-Z]{2,4}$/;
  var checkend=/(\.[a-z]{2}$)|(\.aero$)|(\.arpa$)|(\.asia$)|(\.biz$)|(\.cat$)|(\.com$)|(\.coop$)|(\.edu$)|(\.gov$)|(\.info$)|(\.int$)|(\.jobs$)|(\.mil$)|(\.mobi$)|(\.museum$)|(\.name$)|(\.net$)|(\.org$)|(\.pro$)|(\.tel$)|(\.travel$)/i;

  if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){
	return false;
	}
  else {
	return true;
  }
}

function CheckDigits(checkStr) {
// Returns false if 'checkStr' contains any character other than digits
// Requires JavaScript 1.2
  var exclude=/[^\d]/;

  if(checkStr.search(exclude) != -1){
	return false;
	}
  else {
	return true;
  }
}

function RequiredDigits(checkStr) {
// Returns false if 'checkStr' is empty, contains only spaces, or contains any character other than digits.
// However the 'checkStr' may be "0".
// Requires JavaScript 1.2
  checkStr = TrimStr(checkStr)
  var exclude=/[^\d]/;

  if((checkStr.length == 0) || (checkStr.search(exclude) != -1)){
	return false;
	}
  else {
	return true;
  }
}

function TrimStr(StrIn) {
// Removes both leading and trailing spaces from a string
  while(StrIn.charAt(0) == " ") {
	StrIn = StrIn.substring(1);
  }
  while (StrIn.charAt(StrIn.length-1) == " ") {
	StrIn = StrIn.substring(0,StrIn.length-1);
  }
return StrIn;
}

function TrimNum(StrIn) {
// trims field and also removes leading zeros
  while((StrIn.charAt(0) == "0")||(StrIn.charAt(0) == " ")) {
	StrIn = StrIn.substring(1);
  }
  while (StrIn.charAt(StrIn.length-1) == " ") {
  	StrIn = StrIn.substring(0,StrIn.length-1);
  }
return StrIn;
}