/**
 * Forcer affichage en pleine page si frames
 */
if (parent.frames.length!=0){
	parent.location.href=location.href
}
/**
 * Détermine le navigateur
 */
var ron_ie = window.navigator.appName == "Microsoft Internet Explorer" ? true : false;

ron_doctype = null;
if (ron_ie)
{
   // This is an IE browser. What mode is the ron_doctype in?
   if (document.documentMode) // IE8
      ron_doctype = document.documentMode;
   else // IE 5-7
   {
      ron_doctype = 5; // Assume quirks mode unless proven otherwise
      if (document.compatMode)
      {
         if (document.compatMode == "CSS1Compat")
            ron_doctype = 7; // standards mode
      }
   }
   // the ron_doctype variable now contains the document compatibility mode.
}

/**
 * Suivi des coordonnées des élements majeurs de la fenêtre
 */
var ron_x = -1000;
var ron_y = -1000;
var ron_X = -1000;
var ron_Y = -1000;
var ron_L = 0;
var ron_T = 0;
var ron_W = ron_ie ? ( ron_doctype > 6 ? document.documentElement.clientWidth : document.body.clientWidth ) : window.innerWidth;
var ron_H = ron_ie ? ( ron_doctype > 6 ? document.documentElement.clientHeight : document.body.clientHeight ) : window.innerHeight;

function fron_curseur(e){
	ron_x = ron_ie ? window.event.x : e.clientX;
	ron_y = ron_ie ? window.event.y : e.clientY;
	ron_X = ron_x + ron_L;
	ron_Y = ron_y + ron_T;
}
function fron_scroll(){
	ron_L = ron_ie ? ( ron_doctype > 6 ? document.documentElement.scrollLeft : document.body.scrollLeft ) : window.pageXOffset;
	ron_T = ron_ie ? ( ron_doctype > 6 ? document.documentElement.scrollTop : document.body.scrollTop ) : window.pageYOffset;
	ron_X = ron_x + ron_L;
	ron_Y = ron_y + ron_T;
}
function fron_fenetre(){
	ron_W = ron_ie ? ( ron_doctype > 6 ? document.documentElement.clientWidth : document.body.clientWidth ) : window.innerWidth;
	ron_H = ron_ie ? ( ron_doctype > 6 ? document.documentElement.clientHeight : document.body.clientHeight ) : window.innerHeight;
}

fron_winevt("resize",fron_fenetre);
fron_winevt("load",fron_scroll);
fron_winevt("scroll",fron_scroll);

function fron_cadrage(ron_action){
	fron_winevt("resize",ron_action);
	fron_winevt("scroll",ron_action);
}

/**
 * Fonction d'adjonction d'actions sur la fenêtre (objet window)
 */
function fron_winevt(ron_evt,ron_action){
	if (typeof window.addEventListener != "undefined"){
		window.addEventListener(ron_evt, ron_action, false);
	}else if (typeof document.addEventListener != "undefined"){
		document.addEventListener(ron_evt, ron_action, false);
	}else if (typeof window.attachEvent != "undefined"){
		window.attachEvent("on"+ron_evt, ron_action);
	}else{
		if (ron_evt="load"){fron_winonload(ron_action);}
		if (ron_evt="resize"){fron_winonresize(ron_action);}
	}
}
function fron_winonload(ron_action){
	var oldwinon = window.onload;
	if (typeof oldwinon == "function"){
	window.onload = function(){
			if (oldwinon){
				oldwinon();
			}
			ron_action();
		}
	}else{
		window.onload = ron_action;
	}
}
function fron_winonresize(ron_action){
	var oldwinon = window.onresize;
	if (typeof oldwinon == "function"){
	window.onresize = function(){
			if (oldwinon){
				oldwinon();
			}
			ron_action();
		}
	}else{
		window.onresize = ron_action;
	}
}

/**
 * Coordonnées ron_cX, ron_cY d'un objet ron_objet
 */
  var ron_cX = 0;
  var ron_cY = 0;
function fron_coordobj(ron_objet){
	objet = document.getElementById(ron_objet);
  ron_cX = 0;
  ron_cY = 0;
  while(objet){
    ron_cX += objet.offsetLeft;
    ron_cY += objet.offsetTop;
    objet = objet.offsetParent
  }
}

/**
 * Affichage popup
 */
function Fenpop(page,nom,option,addpopup){
	getpopup = addpopup == 0 ? 0 : 1;
	if (page.indexOf("popup=1")<0 && getpopup == 1){
		if (page.indexOf(".php?")<0){
			page = page+'?popup=1';
		}else{
			page = page+'&popup=1';
		}
	}
	var w=window.open(page,nom,option);
	w.focus();
}

/**
 * Fermeture de la fenêtre
 */
function fermer(){
	window.close();
}

/**
 * Pour utilisation des select comme d'un menu d'accès *
 */
function menuselect(s){
	var d = s.options[s.selectedIndex].value;
	window.location.href = d;
}

/**
 * Compare date1 à date2 (format mm/dd/aaaa return 1 si date1 > date2, 2 si date2 < date1, 0 si date1 = date2
 */
function compdates(date1,date2){
	var d = 0;
	var tdate1 = date1.split('/');
	var tdate2 = date2.split('/');
	if (tdate1[2]> tdate2[2]){d = 1}else if(tdate2[2]> tdate1[2]){d = 2}else if(tdate1[0]> tdate2[0]){d = 1}else if(tdate2[0]> tdate1[0]){d = 2}else if(tdate1[1]> tdate2[1]){d = 1}else if(tdate2[1]> tdate1[1]){d = 2}
	return d;
}

/**
*Création d'un objet  XHR (XHTMLhttpRequest)
*/

function Requete() {
	var requete = null;
	try {
		requete = new XMLHttpRequest();
	}
	catch (microsoft) {
		try {
			requete = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch(autremicrosoft) {
			try {
				requete = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch(echec) {
				requete = null;
			}
		}
	}
	if(requete == null) {
		alert('Ton navigateur ne semble pas supporter les object XMLHttpRequest.');
	}
	return requete;
}

function centrediv(iddiv){
	centredivhor(iddiv);
	centredivvert(iddiv);
}

function centredivhor(iddiv){
	fron_coordobj(iddiv);
	largeurdiv = parseInt(document.getElementById(iddiv).style.width);
	xdiv = Math.round((ron_W-largeurdiv)/2);
	xdiv = xdiv < 0 ? 0 : xdiv;
	document.getElementById(iddiv).style.left = xdiv+ron_L+'px';
}

function centredivvert(iddiv){
	fron_coordobj(iddiv);
	hauteurdiv = parseInt(document.getElementById(iddiv).style.height);
	ydiv = Math.round((ron_H-hauteurdiv)/2);
	ydiv = ydiv < 0 ? 0 : ydiv;
	document.getElementById(iddiv).style.top = ydiv+ron_T+'px';
}

function ininterval(valeur,debut,fin){
	if(valeur < debut){return false;}
	if(valeur > fin){return false;}
	return true;
}

function Remplace(expr,a,b) {
	var i=0
	while (i!=-1) {
		i=expr.indexOf(a,i);
		if (i>=0) {
			expr=expr.substring(0,i)+b+expr.substring(i+a.length);
			i+=b.length;
		}
	}
	return expr
 }

function Afflibelle(idlibelle,text,xlibelle,ylibelle){
	document.getElementById("span"+idlibelle).innerHTML = Remplace(text,'*BR*','<br />');
	var finalPosX = ron_X-xlibelle;
	if (finalPosX<0) finalPosX=0;
	document.getElementById(idlibelle+"span").style.top=ron_Y+ylibelle+'px';
	document.getElementById(idlibelle+"span").style.left=finalPosX+'px';
	document.getElementById(idlibelle+"span").style.visibility="visible";
}

function Hidelibelle(idlibelle) {
	document.getElementById(idlibelle+"span").style.visibility="hidden";
}

/**
* récupérer valeur bouton radio *** Warning : Il doit y avoir au moins 2 boutons radio  ***
 */
function valradio(radio) {
	var valeur = null;
	for (var i=0; i<radio.length;i++) {
		if (radio[i].checked) {
			valeur = radio[i].value;
		}
	}
	return valeur
}

/**
*Adjonction de méthodes sur une chaîne de caractères
*/

// suppression des blancs en tête et en fin
String.prototype.trim = function(){
	return this.replace(/^\s*|\s*$/,"");
}
// remplacer les chaînes de blancs par un blanc unique
String.prototype.simplify = function(){
	return this.replace(/\s+/g," ");
}
String.prototype.cleanblancs= function(){
	chaine = this.trim();
	return chaine.simplify();
}
