//SHOWSOURCE ENABLED
// Returns true if string is not email
//Accepte ? dans mot de passe suite demande pnt
var reValidName="^[a-zA-Z0-9_'\\-. ]+$";
var acceptValidName="l'alphabet sans accents, les chiffres, le tiret, le point, le caractère de soulignement, l'apostrophe et les espaces."
var reValidFileName="^[a-zA-Z0-9_.#-+@ ]+$";
var acceptValidName="l'alphabet sans accents, les chiffres, le tiret, le caractère de soulignement, -+@# et les espaces."
var reValidInput="^[a-zA-Z0-9\\-_+/[\\]@~=*%!?: ()]+$";//Doit accepter ? * et [ ]  % ( ) :
var acceptValidInput="l'alphabet sans accents, les chiffres, le tiret, +  / _ [ ] ! ? @ = ~ * et les espaces"
var reValidUrl="^http://[a-zA-Z0-9\\-_+/[\\]@~=*%?&:()+.]+$";//Doit accepter * et [ ]  % ( ) :
var acceptValidUrl="l'alphabet sans accents, les chiffres, le tiret, +  / _ [ ] ( ) @ = ~ + * ? % & ."
function isAlphanumeric (s,regstr)

{   var i;
    var reAlphanumeric =new RegExp(regstr);
    if (isEmpty(s))
       return true;
    else {
       return reAlphanumeric.test(s)
    }
}

function isNotEmail(s) {
    var reEmail=new RegExp("^([a-z0-9_]|\-|\\.)+@(([a-z0-9_]|\-)+\\.)+[a-z]{2,4}$","gi");
    return (! reEmail.test(s));
}
// Returns true if string is not matricule
function isNotMatricule(s) {
    var reMatricule = new RegExp("^[m|M]?[0-9]{6,8}$");
    return (! reMatricule.test(s));
}
// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s)
{
    // whitespace characters as defined by this sample code
    var whitespace = " \t\n\r";
    var reWhitespace = new RegExp("^\s+$");

       // Is s empty?
    return (isEmpty(s) || reWhitespace.test(s));
}
function isForbidden(s) {
    var reForbidden=new RegExp("[\"]");
    return (reForbidden.test(s));
}
function isForbiddenAlert(thefield) {
    var reForbidden=new RegExp("[\"]");
    if(reForbidden.test(thefield.value)){
        alert("Retrait du Caractère \" interdit");
        value=thefield.value;
        thefield.value=value.replace(reForbidden,"");
        thefield.focus;
        return false;
    }else{
        return true;
    }
}
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 P7_Snap() { //v2.63 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0.2
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0.2
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

function P7AniMagic(el, x, y, a, b, c, s) { //v2.8 PVII
 var g,elo=el,f="",m=false,d="";x=parseInt(x);y=parseInt(y);
 var t = 'g.p7Magic = setTimeout("P7AniMagic(\''+elo+'\','; 
 if ((g=MM_findObj(el))!=null) {d=(document.layers)?g:g.style;}else{return;}
 if (parseInt(s)>0) {eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
 var xx=(parseInt(d.left))?parseInt(d.left):0;
 var yy=(parseInt(d.top))?parseInt(d.top):0;
 if(parseInt(c)==1) {x+=xx;y+=yy;m=true;c=0;}
 else if (c==2) {m=false;clearTimeout(g.p7Magic);}
 else {var i=parseInt(a);
  if (eval(g.moved)){clearTimeout(g.p7Magic);}
  if (xx<x){xx+=i;m=true;if(xx>x){xx=x;}}
  if (xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
  if (yy<y){yy+=i;m=true;if(yy>y){yy=y;}}
  if (yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
 if (m){if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& navigator.userAgent.indexOf("Opera")==-1){
    xx+="px";yy+="px";}
  d.left=xx;d.top=yy;g.moved=true;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');
  }else {g.moved=false;}
}

function P7_ReDoIt() { //v1.21 by PVII
 if(document.layers) {MM_reloadPage(false);}
}
function AX_getXY(t,a){ //GetImage offsetx or offset y used by AxMenu
	var el,obj,lx=0,ly=0,r;if((obj=MM_findObj(a)) !=null){
    	if (document.layers) {lx=obj.x;ly=obj.y}else{for (var lx=0,ly=0;obj!=null;lx+=obj.offsetLeft,ly+=obj.offsetTop,obj=obj.offsetParent);}}
  	if(t=="x"){r=lx;}else{r=ly;}return r; 
}
function P7_getHW(t,a) { //v2.08 by PVII used by AxMenu
  var r,p,h=0,w=0;if((p=MM_findObj(a)) !=null){
  if(document.all || document.getElementById){h=parseInt(p.offsetHeight);w=parseInt(p.offsetWidth);
  if(!h){h=parseInt(p.style.pixelHeight);w=parseInt(p.style.pixelWidth);}
  }else if(document.layers){h=parseInt(p.clip.height);w=parseInt(p.clip.width);}}
  if(t=="width"){r=w;}else{r=h;}return r; 
}

function AX_initMenu() { //Compute offset menu size
	var x,y,t,s,h;
	x=AX_getXY('x','menuSnapImg')
	y=AX_getXY('y','menuSnapImg')
	s=parseInt(P7_getHW('height','DivUnderMenu'))
	h=parseInt(P7_getHW('height','axMenuOnLayer'))
	if (!document.AX_mp) document.AX_mp=new Array;
	document.AX_mp["HideX"]=x+10
	document.AX_mp["HideY"]=y+86+s
	document.AX_mp["ShowY"]=h+y+10
	document.AX_mp["ShowX"]=x+10
	var menuMode=readCookie('AirProx_prefs_menuMode')
	var theForm=MM_findObj('menuModeForm')
	theForm.radiobutton[1].checked=true       
	if(menuMode=='clic')theForm.radiobutton[0].checked=true;
			P7AniMagic('axMenuBottom',document.AX_mp["HideX"],document.AX_mp["HideY"],100,20,0,0);
			P7_autoLayers(9,'axMenuOffLayer','DivUnderMenu');
			formvis="visible";
}
function AX_triggerMenu(){
	var x,y,args=AX_triggerMenu.arguments,n=args.length;

	if (n==2 && !MM_findObj('menuModeForm').radiobutton[args[1]].checked) return; //args[2] is optionnally the radiobutton number to check	
	var s=(n==0) ? "toggle" : args[0];
	var vis=(document.layers) ? ".visibility" : ".style.visibility";
	var test=MM_findObj('axMenuOnLayer')
    var formvis=eval("MM_findObj('menuModeForm')"+vis)
	if(eval("MM_findObj('axMenuOnLayer')"+vis).substr(0,3)=="hid"){
		// Show the menu
		if (s!='hide'){
			P7AniMagic('axMenuBottom',document.AX_mp["ShowX"],document.AX_mp["ShowY"],100,20,0,0);
			formvis="hidden";
			P7_autoLayers(9,'axMenuOnLayer','axMenuMouseOutLayer');
		}	
	}else{
		if (s!='show'){
		// Hide the menu		
			P7AniMagic('axMenuBottom',document.AX_mp["HideX"],document.AX_mp["HideY"],100,20,0,0);
			P7_autoLayers(9,'axMenuOffLayer','DivUnderMenu');
			formvis="visible";
		}
	}
}
// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

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_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
function displayWindowUL(theURL,winName,width,height,features) {
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + width + ',height=' + height + ',top=0,left=0,' + features + '');
    newWindow.focus();
}
function displayWindow(theURL,winName,width,height,features) { //v3.1
// Made by Eddie Traversa modified from Macromedia Code
// http://nirvana.media3.net/
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '');
    newWindow.focus();
}
function pop_etoile(id_film,width,height,note) {
     displayWindow("p/Fichier_Note.php?fid="+id_film+"&note="+note,'note',220,220,'resizable=yes');
     myimage='image'+id_film;
}
function setmout_etoile(id_film,note)
{
     myimage='image'+id_film;
     document.images[myimage].src='i/etoiles/e_'+note+'.gif';
     document.images[myimage].onmouseout="document.images["+myimage+"].src='i/etoiles/e_"+note+".gif'";
     document.images[myimage].mout      ="i/etoiles/e_"+note+".gif";
}
function aff_etoile_nc(id_film,img_e)
{
var contenu = "<img src=\""+img_e+"\" width=\"92\" height=\"19\" border=\"0\" usemap=\"#e"+id_film+"\" name=\"image"+id_film+"\"><map name=\"e"+id_film+"\"><area coords=\"0,1,18,18\" onMouseover=\"image"+id_film+".src='i/etoiles/e1.gif'\" onMouseout=\"mout_etoile('image'+"+id_film+");\" alt=\"cliquez ici pour donner 1 &eacute;toile comme note à ce programme\" href=\"javascript:pop_etoile("+id_film+",200,190,1)\"><area coords=\"18,1,37,18\" onMouseover=\"image"+id_film+".src='i/etoiles/e2.gif'\" onMouseout=\"mout_etoile('image'+"+id_film+");\" alt=\"cliquez ici pour donner 2 &eacute;toiles comme note à ce programme\" href=\"javascript:pop_etoile("+id_film+",200,190,2)\"><area coords=\"37,1,56,18\" onMouseover=\"image"+id_film+".src='i/etoiles/e3.gif'\" onMouseout=\"mout_etoile('image'+"+id_film+");\" alt=\"cliquez ici pour donner 3 &eacute;toiles comme note à ce programme\" href=\"javascript:pop_etoile("+id_film+",200,190,3)\"><area coords=\"56,1,75,18\" onMouseover=\"image"+id_film+".src='i/etoiles/e4.gif'\" onMouseout=\"mout_etoile('image'+"+id_film+");\" alt=\"cliquez ici pour donner 4 &eacute;toiles comme note à ce programme\" href=\"javascript:pop_etoile("+id_film+",200,190,4)\"><area coords=\"75,1,92,18\" onMouseover=\"image"+id_film+".src='i/etoiles/e5.gif'\" onMouseout=\"mout_etoile('image'+"+id_film+");\" alt=\"cliquez ici pour donner 5 &eacute;toiles comme note à ce programme\" href=\"javascript:pop_etoile("+id_film+",200,190,5)\"></map>";
document.write(contenu);
document.images['image'+id_film].mout=img_e;
}
function mout_etoile(myimage)
{
    document.images[myimage].src=document.images[myimage].mout;
}
function enCode(n) {
var dtable = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','.','_');

  var o1 = o2 = o3 =o4 = 0;
  var text = "";
  j = 0;
  for (var i = 0; i < n.length; i += 3) {
    t = Math.min(3, n.length - i);
    if (t == 1) {
       x = n.charCodeAt(i);
       text += dtable[(x >> 2)];
       text += dtable[((x & 0X00000003) << 4)];
       text += '-';
       text += '-';
    } else if (t == 2) {
       x = n.charCodeAt(i);
       y = n.charCodeAt(i+1);
       text += dtable[(x >> 2)];
       text += dtable[((x & 0X00000003) << 4) | (y >> 4)];
       text += dtable[((y & 0X0000000f) << 2)];
       text += '-';
    } else {
       x = n.charCodeAt(i);
       y = n.charCodeAt(i+1);
       z = n.charCodeAt(i+2);
       text += dtable[x >> 2];
       text += dtable[((x & 0x00000003) << 4) | (y >> 4)];
       text += dtable[((y & 0X0000000f) << 2) | (z >> 6)];
       text += dtable[z & 0X0000003f];
    }
  }
  return text;
}
// Tooltip-like help pop-ups used in forms

function formtooltip(el,flag){
elem = document.getElementById(el);
if (flag) {
  elem.parentNode.parentNode.style.zIndex=1000;
  elem.parentNode.parentNode.style.borderRight='0px solid #000';
  // ugly , yes .. but neccesary to avoid a small but very annoying bug in IE6
  elem.style.visibility='visible';
}
else {
  elem.parentNode.parentNode.style.zIndex=1;
  elem.parentNode.parentNode.style.border='none';
  elem.style.visibility='hidden' };
}
