
//OAS_url ='http://rmf.reussir.tm.fr/';
//OAS_listpos = 'Right,TopRight';
OAS_url ='http://rmf.reussir.tm.fr/';
OAS_listpos = 'TopRight,Position2,Position3';
OAS_query = '?search=';
//end of configuration
OAS_version = 10;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String (Math.random()); OAS_rns = OAS_rn.substring (2, 11);


function Init_OAS(){
/*
	OAS_version = 11;
	if (navigator.userAgent.indexOf('Mozilla/3') != -1)
	OAS_version = 10;
	if (OAS_version >= 11)
	//document.write('<SC'+'RIPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + '4/' + OAS_sitepage + '/1' + OAS_rns +
	//'@' + OAS_listpos + OAS_query + '"><\/SCRIPT>');
	
	return '<SC'+'RIPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + '4/' + OAS_sitepage + '/1' + OAS_rns +
	'@' + OAS_listpos + OAS_query + '"><\/SCRIPT>';
	*/
	return ""
}

function OAS_NORMAL(pos) {
/*
document.write('<A HREF="' + OAS_url + '1c/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos +
OAS_query + '" TARGET=_top>');
document.write('<IMG SRC="' + OAS_url + '1/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos +
OAS_query + '" BORDER=0 ALT="Click!"></A>');
	*/
	return ""
}

function OAS_AD(pos) {
/*
if (OAS_version >= 11 && typeof(OAS_RICH)!='undefined')
OAS_RICH(pos);
else
OAS_NORMAL(pos);
	*/
}

function Media(id, media) { 
    if (document.getElementById) { 
	document.getElementById(id).innerHTML = media; 
    } 
}

this.oldmenu="false";
this.oldbouton="false";

var oldCol;
function CH(tr, mode) {
	if (mode == 0) {
		oldCol = tr.className;
		tr.className = 'tdOver';
	}
	else {
		tr.className = oldCol;
	}
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}

function AgendaMois(m){
	document.f0.action='default.asp?Mois='+m;
	document.f0.submit();
}

function AfficheLienInterne(URL, mode){
	if(mode){
		URL=(URL.indexOf("?") == -1)?URL+'?mode=popup':RL=URL+'&mode=popup'
		var w=window.open(URL,"popup",'left=10,top=10,height=600,width=615,location=no,scrollbars=yes,resizable=yes,menubar=no,status=no');
		w.document.close();
		w.focus();
	}
	else{
		document.location.href=URL;
	}
}


/*	Récupération de la position de la souris dans la fenetre en cours	*/
function position( e ){
  var DocRef;    // Variable pour IE uniquement
  if(e){                     // Dans ce cas on obtient directement la position dans la page
    xCursor = e.pageX;
    yCursor = e.pageY;
  }
  else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
    xCursor = event.clientX;
    yCursor = event.clientY;
    //-- Il faut traiter le CAS des DOCTYPE sous IE
    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
	DocRef = document.documentElement;		// Dans ce cas c'est documentElement qui est réfèrence
    else
	DocRef = document.body;				// Dans ce cas c'est body qui est réfèrence
    //-- On rajoute la position liée aux ScrollBars
    xCursor += DocRef.scrollLeft;
    yCursor += DocRef.scrollTop;
  }
}

if(navigator.appName.substring(0,3) == "Net")
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = position;
	
	
function ZommPhoto(src,h,w){
	var l = xCursor + 50;
	var t = yCursor + 100;
	wPopup=window.open(src,'Zoom','left='+ l +',top='+ t +',height='+h+',width='+w+',location=no,scrollbars=auto,resizable=yes,menubar=no,status=no,toolbar=no')
	wPopup.focus();
}

function openPopup(theURL,winName,features) {
  var w=window.open(theURL,winName,features);
    w.document.close();
    w.focus();
  }

function entre(nom){
	document.images[nom].src=chemin+nom+"_F2.gif";
	this.oldbouton=nom;
}

function sort(){
	if(this.oldbouton!="false"){
		document.images[oldbouton].src=chemin+oldbouton+".gif";
		this.bouton="false";
	}
}

function change(nom,lien)
{document.images[nom].src=lien;}

function hideit(action,nom_layer) {
  if (document.layers) {
    // Netscape 4 stuff
    var cible = document.layers[nom_layer];
  } else if (document.getElementById) {
    // IE 5 and Netscape 6
    var cible = document.getElementById(nom_layer);
  } else if (document.all) {
    // IE 4 ??
    var cible = document.all(nom_layer);
  } else {
    alert("Probl&egrave;me avec votre navigateur");
  }

  if (cible.style)
  {
    // IE4 ??, IE5, Netscape 6

    if (action) { cible.style.visibility = "hidden"; }
	else { cible.style.visibility = "visible"; }
  }
  else {
    // Netscape 4
    if (action) { cible.visibility = "hide";}
	else { cible.visibility = "show"; }
  }
}

function hideall() {
	hideit(true,"lactualite1");
	hideit(true,"lactualite2");
	hideit(true,"lactualite3");
}

function AtteindreLien(nomlayer){
	var htmlLayer=document.getElementById(nomlayer).outerHTML;
	var debutLien = htmlLayer.indexOf('href=')+6
	var finLien = htmlLayer.indexOf('>',debutLien )-1
	var lien = htmlLayer.substring(debutLien,finLien)
	alert(lien)
	document.location.href=lien;
	//document.location.href='http://www.google.fr'
	alert('fin')
}


function montre(nomlayer)
{
hideit(false,nomlayer);
hideit(false,"zone1");
hideit(false,"zone2");
this.oldmenu=nomlayer;

}


function cache(){
	hideit(true,"zone1");
	hideit(true,"zone2");
	if(this.oldmenu!="false"){
		hideit(true,oldmenu);
		this.oldmenu="false";
	}
}
function verifie() {
var chaine = "";
if (document.forms[0].elements.nom.value ==""){ chaine = chaine + "- Nom\n"; }
if (document.forms[0].elements.sujet.value ==""){ chaine = chaine + "- Sujet\n"; }
if (document.forms[0].elements.email.value ==""){ chaine = chaine + "- Email\n"; }
if (document.forms[0].elements.message.value ==""){ chaine = chaine + "- Message\n"; }
if (chaine != "")
        {
        alert("ERREUR\nLes champs suivants sont obligatoires :\n" + chaine);
        return false;
        }
else { return true;}
}
function verifie2() {
var chaine = "";
if (document.forms[0].elements.nom.value ==""){ chaine = chaine + "- Name\n"; }
if (document.forms[0].elements.email.value ==""){ chaine = chaine + "- Email\n"; }
if (document.forms[0].elements.message.value ==""){ chaine = chaine + "- Message\n"; }
if (chaine != "")
        {
        alert("ERREUR\nYou must fill the following fields :\n" + chaine);
        return false;
        }
else { return true;}
}

function ValeurParDefault(f){
	for(i=0;i<jsElement.length;i++){
		var elt=eval('document.'+f.name+'.'+jsElement[i][0])
		if(elt){
			elt.value=jsElement[i][3]
		}
	}
}

function CheckDate(d){
if(d){
  // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
  // Le séparateur est défini dans la variable separateur
  var siecle=20; // permet de ne n'avoir à saisir que 2 chiffres
  var amin=1990; // année mini
  var amax=2099; // année maxi
  var separateur="/"; // separateur entre jour/mois/annee
  var j=(d.substring(0,2));
  var m=(d.substring(3,5));
  var a=(d.substring(6));
  var ok=1;
  if(a.length==2){
  	a=siecle+a
  }
  if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
	 alert("Le jour n'est pas correct."); ok=0;
  }
  if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
	 alert("Le mois n'est pas correct."); ok=0;
  }
  if ( ((isNaN(a))||(a<amin)||(a>amax)) && (ok==1) ) {
	 alert("L'année n'est pas correcte."); ok=0;
  }
  if ( ((d.substring(2,3)!=separateur)||(d.substring(5,6)!=separateur)) && (ok==1) ) {
	 alert("Les séparateurs doivent être des "+separateur); ok=0;
  }
  if (ok==1) {
	 var d2=new Date(a,m-1,j);
	 j2=d2.getDate();
	 m2=d2.getMonth()+1;
	 a2=d2.getYear();
	 if (a2<=100) {a2=1900+a2}
	 if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
		alert("La date "+d+" n'existe pas !");
		ok=0;
	 }
  }
  return ok;
 }
 else{return 1}
}


function TestEmail(elt){
  with (elt){
    apos=value.indexOf("@");        // Cherche position de "@"
    dotpos=value.lastIndexOf(".");  // Cherche dernière position de "."
    lastpos=value.length-1;         // Contrôle si l'adresse est vraisemblable
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2){
      elt.select();
      elt.focus();
      return false;
    }
    else{
      return true;
    }
  }
}

function CheckMail(m){
	if(m){
		//var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

		if (filter.test(m)){
			 return true;
		}
		else {
			alert("Le courriel est invalide !");
			return false;
		}
	}
	else{
		return true;
	}
}

function ControleCatalogueChamp(f,t){
	if(!ControleElementFormulaire(f,t)){
		t.focus();
	}
}




function ControleElementFormulaire(f,t){
	for(c=0;c<jsElement.length;c++){
		if(jsElement[c][0]==t.name){
			Format=jsElement[c][1]
			Obligatoire=jsElement[c][2]

			if(Format=='' || t.value==''){
				return true;
			}
			else if(Format=='date'){
				if(CheckDate(t.value)){return true;}
				else{return false;}
			}
			else if(Format=='e-mail'){
				if(CheckMail(t.value)){return true;}
				else{return false;}
			}

			else if(Format=='intP_'){
				strMsg='Données de type Entier.'
				if(isNaN(t.value)){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value.indexOf('.')!=-1){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value<0){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else{return true;}
			}
			else if(Format=='dblP_'){
				strMsg='Données de type Décimale.'

				if(isNaN(t.value)){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else if(t.value<0){alert(strMsg);document.f0.elements[t.name].select();return false;}
				else{t.value=DeuxDecimale(t.value);return true;}
			}
			else{return true}
		}
	}
}

function ControleFormulaire(f,t){
	for(cf=0;cf<jsElement.length;cf++){
		elt=eval(f.name+'.'+jsElement[cf][0])
		if(elt){
			if(jsElement[cf][2]==1 && !elt.value){
				if(elt.length){	//Cas des champs photos
					if(!elt[0].value && !elt[1].value){
						alert('Tous les champs marqués d\'un astérisque sont obligatoires');
						return false;
					}
				}
				else{
					alert('Tous les champs marqués d\'un astérisque sont obligatoires');
					return false;
				}
			}
		}
	}
	for(cf=0;cf<jsElement.length;cf++){
		if(eval(f.name+'.'+jsElement[cf][0])){
			if(jsElement[cf][1]!=''){
				var objElt=eval(f.name+'.'+jsElement[cf][0])
				if(!ControleElementFormulaire(f,objElt)){
				return false;
				}
			}
		}
	}
	return true;
}

function EnvoyerFormulaire(f,t){
	if(ControleFormulaire(f,t)){
		f.method='POST';
		f.encoding='multipart/form-data';
		f.action=pathTraitementFormulaire;
		f.target='';
		//alert(f.action)
		f.submit();
	}
}


//Functions necessaires à l'affichage du sous-menu (liste des pages)
function movedown(n){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (iens6&&parseInt(crossobj.style.top)>(contentheight*(-1)+CompozitTableH)){
		crossobj.style.top=parseInt(crossobj.style.top)-speed+"px";
	}
	else if (ns4&&crossobj.top>(contentheight*(-1)+CompozitTableH))
		crossobj.top-=speed
	if(n==1){movedownvar=setTimeout("movedown(1)",20)}
}

function moveup(n){
	if (window.movedownvar) clearTimeout(movedownvar)
	if (iens6&&parseInt(crossobj.style.top)<0)
		crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
	else if (ns4&&crossobj.top<0)
		crossobj.top+=speed
	if(n==1){moveupvar=setTimeout("moveup(1)",20)}
}

function stopscroll(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
	stopscroll()
	if (iens6)
		crossobj.style.top=0+"px"
	else if (ns4)
		crossobj.top=0
}

function getcontent_height(){
	if (iens6){
		contentheight=crossobj.offsetHeight
	}
	else if (ns4)
		document.nscontainer.document.nscontent.visibility="show"
}
