function OpenDiaporama(num){
	Player = window.open('page/diaporama.php?num='+num,'photos','resizable=1,width=650,height=600');
	Player.focus();
}

function OpenCalendar(fields) {
	Calendar = window.open("page/calendar.php?fields=" + fields + "&no_title=Y", "Calendrier", 'width=180,height=170,toolbar=0,status=0,scrollbars=0,resizable=0');
	Calendar.focus();
}
function UserManage(num){
	Fenetre = window.open('user_edit.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=400,height=400');
	Fenetre.focus();
}
function NewsManage(num){
	Fenetre = window.open('page/admin/news_edit.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=520');
	Fenetre.focus();
}
function ProjetsManage(num){
	Fenetre = window.open('page/admin/projets_edit.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=400');
	Fenetre.focus();
}
function ProjetsAffect(num){
	Fenetre = window.open('page/admin/projets_affect.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=400');
	Fenetre.focus();
}
function CompanyEdit(id_client){
	Fenetre = window.open('page/admin/company_edit.php?id_client='+id_client,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=500,height=200');
	Fenetre.focus();
}
function ProfilEdit(profil_code){
	Fenetre = window.open('page/admin/profil_edit.php?profil_code='+profil_code,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=500,height=200');
	Fenetre.focus();
}
function ProfilUserAffect(profil_code){
	Fenetre = window.open('page/admin/profil_user_affect.php?profil_code='+profil_code,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=400,height=350');
	Fenetre.focus();
}
function ProfilAuthAffect(profil_code){
	Fenetre = window.open('page/admin/profil_auth_affect.php?profil_code='+profil_code,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=400,height=400');
	Fenetre.focus();
}
function DemandesAffect(num){
	Fenetre = window.open('page/admin/demandes_affect.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=400');
	Fenetre.focus();
}
function DemandesManage(num){
	Fenetre = window.open('page/admin/demandes_edit.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=500');
	Fenetre.focus();
}
function TemoignagesManage(num){
	Fenetre = window.open('page/temoignages-edit.php?num='+num,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=600,height=500');
	Fenetre.focus();
}
function AuthEdit(auth_code){
	Fenetre = window.open('page/admin/auth_edit.php?auth_code='+auth_code,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=430,height=230');
	Fenetre.focus();
}
function AuthProfilAffect(auth_code,titre_fr){
	Fenetre = window.open('page/admin/auth_profil_affect.php?auth_code='+auth_code,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=400,height=280');
	Fenetre.focus();
}
function NewsletterEdit(){
	Fenetre = window.open('page/admin/newsletter_edit.php','admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=500,height=240');
	Fenetre.focus();
}
function f_submit(dest){
	document.forms['autodiagnostic'].elements['dest'].value=dest;
	document.forms['autodiagnostic'].submit();
}
function PdfCreate(categ){
	pdf = window.open('page/boite-outils-details.php?categ='+categ+'&pdf=1','pdf','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=800,height=560');
	pdf.focus();
}

function f_help(contenu,www){
	document.getElementById("bulle").innerHTML = "<div id='arriere'><img src='"+www+"img/infobulle.gif'><p>"+contenu+"</p>";
}
function f_suivresouris(e){
	if (navigator.appName=="Microsoft Internet Explorer"){
		var x = event.x + document.body.scrollLeft;	var y = event.y + document.body.scrollTop;
	}
	else{
		var x =  e.pageX;var y =  e.pageY;
	}
	document.getElementById("bulle").style.left = x + decal_x; document.getElementById("bulle").style.top  = y + decal_y;
}
function f_help_out(){
	document.getElementById("bulle").innerHTML = '';
}


var RCArray = new Array();

function Radio_CheckBox( inIMAGES, inDATA ) {
 this.uID = document.uniqueID;
 this.imgPath = inIMAGES[0];
 this.img = new RC_Images(inIMAGES, this);
 this.data = new RC_Read(inDATA, this);
 RCArray[this.uID] = this;
 this.SwapImage = function( inDIV, inIMG, inOBJ)
 {
  if (document.images) {
   if (document.layers && inDIV != null) {
    eval("document." + inDIV + ".document.images['" + inIMG + "'].src = " + inOBJ + ".src;");
   } else {
    document.images[inIMG].src  = eval(inOBJ + ".src");
   }
  }
 };
 this.ToggleCheckBox = function( inINDX )
 {
  var oCB, iObj;
  oCB = this.data.aRead[inINDX];
  if (oCB.state == 1) {
   oCB.state = 0;
   eval("document." + oCB.oForm + "." + oCB.oInput + ".value = '" + oCB.off + "';");
   iObj = this.img.aImg[1][0];
  } else { 
   oCB.state = 1;
   eval("document." + oCB.oForm + "." + oCB.oInput + ".value = '" + oCB.on + "';");
   iObj = this.img.aImg[1][1];
  }
  this.SwapImage(oCB.oDiv, "chkb_" + this.uID + "_" + inINDX, "this.img." + iObj);
 };
 this.ToggleRadio = function( inINDX, inRDO, inVALUE)
 {
  var oRdo, i;
  oRdo = this.data.aRead[inINDX];
  eval("document." + oRdo.oForm + "." + oRdo.oInput + ".value = '" + inVALUE + "';");
  for (i = 0; i < oRdo.nb; i++) {
   this.SwapImage(oRdo.oDiv, "rdo_" + this.uID + "_" + inINDX + "_" + i, "this.img." + this.img.aImg[0][0]);
  };
  this.SwapImage(oRdo.oDiv, "rdo_" + this.uID + "_" + inINDX + "_" + inRDO, "this.img." + this.img.aImg[0][1]);
 };
 this.Init = function()
 {
  var i = 0, iDiv;
  for (i = 0; i < this.data.aRead.length; i++) {
   iDiv = document.getElementById(this.data.aRead[i].oDiv);
   if (iDiv.innerHTML != "") {
    iDiv.insertAdjacentHTML("beforeend", "<br>" + this.data.aRead[i].str);
   } else {
    iDiv.innerHTML = this.data.aRead[i].str;
   }
  };
 };
 this.Init();
};

function RC_Images( inIMAGES, inOBJ ) {
 this.rc = inOBJ;
 this.aImg = new Array();
 this.Preload = function()
 {
  var i = 0;
  if (document.images) {
   for (i = 1; i < inIMAGES.length; i++) {
    eval("this." + (inIMAGES[i][0].substring(0, inIMAGES[i][0].indexOf('.'))) + " = new Image();");
    eval("this." + (inIMAGES[i][1].substring(0, inIMAGES[i][1].indexOf('.'))) + " = new Image();");
    eval("this." + (inIMAGES[i][0].substring(0, inIMAGES[i][0].indexOf('.'))) + ".src = '" + this.rc.imgPath + inIMAGES[i][0] + "';");
    eval("this." + (inIMAGES[i][1].substring(0, inIMAGES[i][1].indexOf('.'))) + ".src = '" + this.rc.imgPath + inIMAGES[i][1] + "';");
    this.aImg[this.aImg.length] = new Array((inIMAGES[i][0].substring(0, inIMAGES[i][0].indexOf('.'))), (inIMAGES[i][1].substring(0, inIMAGES[i][1].indexOf('.'))));
   };
  }
 };
 this.Preload();
};

function RC_Read( inDATA, inOBJ) {
 this.rc = inOBJ;
 this.aRead = new Array();
 this.Read = function()
 {
  var i = 0;
  for (i = 0; i < inDATA.length; i++) {
   switch (inDATA[i][0].toUpperCase()) {
    case "CHECKBOX": this.aRead[this.aRead.length] = new RC_CheckBox(inDATA[i], this.rc, this.aRead.length);break;
    case "RADIO": this.aRead[this.aRead.length] = new RC_Radio(inDATA[i], this.rc, this.aRead.length);break;
   }
  };
 };
 this.Read();
};

function RC_CheckBox(inDATA, inOBJ, inINDX) {
 this.rc = inOBJ;
 this.indx = inINDX;
 this.oForm = inDATA[1];
 this.oInput = inDATA[2];
 this.oDiv = inDATA[3];
 this.str = "";
 this.state = -1;
 this.on = inDATA[5][0][1];
 this.off = inDATA[5][0][2];
 this.Init = function()
 {
  var h_value, i_value;
  if (inDATA[5][0][3].toUpperCase() == "TRUE") {
   h_value = inDATA[5][0][1];
   i_value = this.rc.img.aImg[1][1];
   this.state = 1;
  } else {
   h_value = inDATA[5][0][2];
   i_value = this.rc.img.aImg[1][0];
   this.state = 0;
  }
  this.str += "<a href=\"javascript:RCArray['" + this.rc.uID + "'].ToggleCheckBox(" + this.indx + ");\"";
  this.str += " border=\"0\"";
  if (inDATA[4] != "") {
   this.str += " class=\"" + inDATA[4] + "\"";
  }
  this.str += " onMouseOver=\"window.status=' ';return true;\"";
  this.str += " onMouseOut=\"window.status=' ';return true;\">";
  this.str += "<img name=\"chkb_" + this.rc.uID + "_" + this.indx + "\" src=\"" + eval("this.rc.img." + i_value + ".src") + "\" border=\"0\" align=\"absmiddle\">";
  this.str += "&nbsp;" + inDATA[5][0][0];
  this.str += "</a>";
  this.str += "<input type=\"hidden\" name=\"" + this.oInput + "\" value=\"" + h_value + "\">";
 };
 this.Init();
};

function RC_Radio(inDATA, inOBJ, inINDX) {
 this.rc = inOBJ;
 this.indx = inINDX;
 this.oForm = inDATA[1];
 this.oInput = inDATA[2];
 this.oDiv = inDATA[3];
 this.nb = inDATA[5].length;
 this.str = "";
 this.Init = function()
 {
  var i = 0, i_value, h_value, isSelected = 0;
  for (i = 0; i < inDATA[5].length; i++) {
   if (inDATA[5][i][2].toUpperCase() == "SELECTED") {
    if (isSelected == 0) {
     i_value = this.rc.img.aImg[0][1];
     h_value = inDATA[5][i][1];
     isSelected = 1;
    } else {
     i_value = this.rc.img.aImg[0][0];
    }
   } else {
    i_value = this.rc.img.aImg[0][0];
   }
   this.str += "<a href=\"javascript:RCArray['" + this.rc.uID + "'].ToggleRadio(" + this.indx + ", " + i + ", '" + inDATA[5][i][1] + "');\"";
   this.str += " border=\"0\"";
   if (inDATA[4] != "") {
    this.str += " class=\"" + inDATA[4] + "\"";
   }
   this.str += " onMouseOver=\"window.status=' ';return true;\"";
   this.str += " onMouseOut=\"window.status=' ';return true;\">";
   this.str += "<img name=\"rdo_" + this.rc.uID + "_" + this.indx + "_" + i + "\" src=\"" + eval("this.rc.img." + i_value + ".src") + "\" border=\"0\" align=\"absmiddle\">";
   this.str += "&nbsp;" + inDATA[5][i][0];
   this.str += "</a>";
   this.str += "<br>";
  };
  this.str += "<input type=\"hidden\" name=\"" + this.oInput + "\" value=\"" + h_value + "\">";
 };
 this.Init();
};
