



var ReponseRequis=true;


function SortListe(sortExpression ,noContenu)
{
	document.all.item("SortExpression_" + noContenu).value = sortExpression;
	document.all.item("frmRecherche_" + noContenu).submit();
}



function MyEditor(champs)
{
	this.containedValue = document.all.item(champs).value;
}

function OpenRAD(champs) 
{   
	var ParmTexte = new MyEditor(champs);
	
    var WinSettings = "center:yes;resizable:no;status:no;dialogHeight:500px;dialogWidth:620px"
    //ALTER BELOW LINE - supply correct URL for Child Form

    var MyArgs = window.showModalDialog("../RADEditor/RADEditor.aspx", ParmTexte, WinSettings);
    if (MyArgs == null)
    {
        
    }
    else
    {
        document.all.item(champs).value= MyArgs.toString();
       
    }
}

function completeTab(NoTableau,NoContenu,NoQuestion)
{
if ((document.all(NoContenu + '~tab~1_' + NoQuestion).value != '') && (document.all(NoContenu + '~tab~2_' + NoQuestion).value != '') && (document.all(NoContenu + '~tab~3_' + NoQuestion).value != '') && (document.all(NoContenu + '~tab~4_' + NoQuestion).value != ''))
         {
         a = parseInt(document.all(NoContenu + '~tab~1_' + NoQuestion).value);
         b = parseInt(document.all(NoContenu + '~tab~2_' + NoQuestion).value);
         c = parseInt(document.all(NoContenu + '~tab~3_' + NoQuestion).value);
         d = parseInt(document.all(NoContenu + '~tab~4_' + NoQuestion).value);
        prevalence = ((a+c)/(a+b+c+d)*100);
          sensibilite = ((a/(a+c))*100);
          specificite = ((d/(b+d))*100);
          valeurppos = ((a/(a+b))*100);
          valeurpneg = ((d/(d+c))*100);
          rapportvpos = (a/(a+c))/(1-(d/(b+d)));
          rapportvneg = (1-(a/(a+c)))/(d/(b+d));
        document.all('Quest' + NoTableau + 'table2x2pre').value = Math.round(prevalence);
         document.all('Quest' + NoTableau + 'table2x2sen').value = Math.round(sensibilite);
         document.all('Quest' + NoTableau + 'table2x2spe').value = Math.round(specificite);
         document.all('Quest' + NoTableau + 'table2x2vpp').value = Math.round(valeurppos);
         document.all('Quest' + NoTableau + 'table2x2vpn').value = Math.round(valeurpneg);
         document.all('Quest' + NoTableau + 'table2x2rvp').value = Math.round(rapportvpos * 100)/100;
         document.all('Quest' + NoTableau + 'table2x2rvn').value = Math.round(rapportvneg * 100)/100;         
         }
         else
         {
         alert("Vous devez fournir une valeur dans les 4 champs gris avant de demander une r\u00E9troaction.");
         }
         }


function loadPopUpMessage(NoMessage,Hauteur,Largeur)
    {
    var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "500";
		height = "400";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
    
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/AffichePopUpMessage.aspx?Id=" + NoMessage,"msgWindow", styleStr);
}
    
//M    
function loadPopUp(NoPopUp,Hauteur,Largeur)
    {
    var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "500";
		height = "400";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
    
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/AffichePopUp.aspx?Id=" + NoPopUp,"msgWindow", styleStr);
}
    
function loadPopUpLien(Lien,Hauteur,Largeur)
    {
    var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "500";
		height = "400";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
    
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open (Lien,"msgWindow", styleStr);
    }

function resetForm(what,NoContenu) 
{
	
	document.all.item("btnSubmit" + NoContenu ).style.display= "block";
	document.all.item("btnReset" + NoContenu ).style.display= "none";
	document.all.item("btnRetroAnt" + NoContenu ).style.display= "none";
	
	
    for (var i=0, j=what.elements.length; i<j; i++) 
    {
        
        myType = what.elements[i].type;
        
               
        if (myType == 'checkbox' || myType == 'radio')
            what.elements[i].checked = false;
        else if (myType == 'text' || myType == 'textarea')
            what.elements[i].value = "";
        else if (myType == 'select-one' || myType == 'select-multiple')
			what.elements[i].options[0].selected = true;
	 }
}

function checkrequired(which)
{
	
	var fieldName="";
	var passOption=true;
	var pass=true;
	if (ReponseRequis)
	{
	if (document.images) 
		{
			for (i=0;i<which.length;i++)
			{
				var tempobj=which.elements[i];
				if (tempobj.name.substring(0,8)=="required")
				{
					if (tempobj.type=="checkbox" ||tempobj.type=="radio")
					{
						if (fieldName != tempobj.name.substring(8,30).toUpperCase())
						{
							if (!passOption)
							{
								pass=false;
								break;
							}
							else
							{
								passOption=false;
							}
						}
											  
						if (tempobj.checked) 
						{
							passOption=true;
						}
						
					}
					else if (((tempobj.type=="text"||tempobj.type=="textarea")&&
						tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
						tempobj.selectedIndex==0)) 
					{
						pass=false;
						break;
					}
					fieldName = tempobj.name.substring(8,30).toUpperCase();
					
				}
			}
		}
	}
	else
	{
		ReponseRequis = true;
	}
	
	if ((!pass)||(!passOption))
	{
		alert("Le test/sondage est incomplet. Assurez-vous d'avoir r\u00E9pondu \u00E0 toutes les questions.");
		return false;
	}
	else
	{
		return true;
	}
}


function EnregistrerSondage()
{
	ReponseRequis=false;
}

//M
function AffichePartageDocument(NoMenu)
{	
	var left = 0;
	var top = 0;
    var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,fullscreen=yes,width='+screen.width+',height='+screen.height+',left='+left+',top='+top; //screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../partage/documents.aspx?mid=" + NoMenu ,"Reponse", styleStr);
}

//M
function AffichePartageDiscussion(NoMenu)
{	
	var left = 0;
	var top = 0;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,fullscreen=yes,width='+screen.width+',height='+screen.height+',left='+left+',top='+top; //screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../partage/discussions.aspx?mid=" + NoMenu ,"Reponse", styleStr);
}

//M
function AfficheRetro(Contenu)
{	
	var width="700", height="500";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/AfficheReponse.aspx?NoContenu=" +Contenu,"Reponse", styleStr);

}

//M
function AfficheItemCatalogue(catalogueId,noCollection)
{	
	var width="640", height="480";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../Commerce/ShowProduct.aspx?ID=" +catalogueId+"&CollID=" + noCollection,"Catalogue", styleStr);

}

function AfficherFiche(NoFiche,NoContenu)
{	
	var width="500", height="400";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/AfficheFiche.aspx?Fiche="+NoFiche + "&Contenu="+NoContenu,"msgWindow", styleStr);
	
}

function ParamFiche(NoContenu)
{	
	var width="500", height="400";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/ParamFiche.aspx?Identifiant="+NoContenu,"msgWindow", styleStr);
	if (winReponse.opener == null)
	{
	  winReponse.opener = self;
	}
}

function AjouterFiche(NoContenu)
{	
	self.location.href =  "../../WEB/Fiche.aspx?Identifiant="+NoContenu;
}

function ModifierFiche(NoFiche,NoContenu)
{	
	self.location.href =  "../../WEB/Fiche.aspx?NoFiche="+NoFiche+"&Identifiant="+NoContenu;
}

function SupprimerFiche(NoFiche,NoContenu)
{	
	Reponse = confirm("Voulez-vous vraiment supprimer cette fiche?");
	if(Reponse)
	{
		self.location.href =  "../../WEB/Fiche.aspx?Suprimme="+NoFiche+"&Identifiant="+NoContenu;	
	}
	
}

function ValidationGroupe(Champ,NoQuestion)
{
	var Reponse = document.all.item("btnQuestion" + NoQuestion ).value;
	
	if (Champ.checked)
	{ 
	 Reponse +=  Champ.value + ",";
	}
	else
	{
	 var regexp = eval("/," + Champ.value + ",/");
	 Reponse = Reponse.replace(regexp,",");
	 
	}
	 
	document.all.item("btnQuestion" + NoQuestion ).value = Reponse;
	
}

function InfoPlus(NoQuestion)
{
	
	var width="400", height="300";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/InfoPlus.aspx?NoQuestion="+NoQuestion,"msgWindow", styleStr);
			
}



function ValidationTexte(Champ,NoQuestion,Hauteur,Largeur)
{
	var width,height
	if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "700";
		height = "500";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
	
	var reponse = document.all.item(eval("'" + Champ + "'")).value;
	if (reponse == "")
	{
		alert("Vous devez r\u00E9pondre \u00E0 la question avant de demander la r\u00E9troaction.");
	}
	else
	{
		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
		var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
		var winReponse = window.open ("../../WEB/RetroAction.aspx?Question="+NoQuestion+"&Reponse="+reponse,"msgWindow", styleStr);
	}	
		
}

function ValidationTableau(Champ,Contenu,Question,Hauteur,Largeur)
{
	
	var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "700";
		height = "500";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
	
	var fieldValue = "";
	var pass=true;
	var nbrTab = document.all.item(eval("'" + Champ + "'")).value;
	var reponse = "";
	
	for (i=1;i<=nbrTab;i++)
	{
	   fieldValue = document.all.item(eval("'" + Contenu + "~tab~" + i + "_" + Question + "'")).value;
	   reponse = reponse + fieldValue + ";";
	   if ( fieldValue == "" )
	   {
	     alert("Vous devez compl\u00E9ter le tableau avant de demander la r\u00E9troaction.");
		 pass=false;
		 break;		
	   }
	}
		
	if (pass)
	{
	    reponse = reponse.substring(0, reponse.length - 1);

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
		var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
		var winReponse = window.open ("../../WEB/RetroAction.aspx?Question="+Question+"&Reponse="+reponse,"msgWindow", styleStr);
	}	
		
}

function ValidationMultiple(Champ,NoQuestion,Hauteur,Largeur)
{
	var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "700";
		height = "500";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
	
	var NoChoix = Champ;
	
	if (NoChoix.lastIndexOf(",") == NoChoix.length -1)
	{
	  NoChoix = NoChoix.substring(0,NoChoix.length -1);
	}
	
	  
	if (NoChoix != 0)
	{ 
	  var left = (screen.width/2) - width/2;
	  var top = (screen.height/2) - height/2;
	  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	  var winReponse = window.open ("../../WEB/RetroAction.aspx?Choix="+NoChoix+"&Question="+NoQuestion,"msgWindow", styleStr);
	}	
	else
	{
		alert("Vous devez r\u00E9pondre \u00E0 la question avant de demander la r\u00E9troaction.");
	}
}

function Validation(Champ,NoQuestion,Hauteur,Largeur)
{
	var width,height
    if ((Hauteur == undefined)||(Largeur == undefined))
    {
		width = "700";
		height = "500";
    }
    else
	{
		width = Largeur;
		height = Hauteur;
	}
	
	var NoChoix = Champ;
	
		  
	if (NoChoix != 0)
	{ 
	  var left = (screen.width/2) - width/2;
	  var top = (screen.height/2) - height/2;
	  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	  var winReponse = window.open ("../../WEB/RetroAction.aspx?Choix="+NoChoix+"&Question="+NoQuestion,"msgWindow", styleStr);
	}
	
}	

function AfficherRecherche()
{
  if(document.all.item("trRecherche").style.display == 'none')
    {
  	document.all.item("trRecherche").style.display = 'block';
	document.all.item("imgRecherche").src = "../images/lines/minus.gif";
	}	
  else
    {
    document.all.item("trRecherche").style.display = 'none';
	document.all.item("imgRecherche").src = "../images/lines/plus.gif";
	}
}

function AfficheReponseSommatif(NoContenu)
{
	var width="700", height="500";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var winReponse = window.open ("../../WEB/AfficheReponseSommatif.aspx?NoContenu=" +NoContenu,"Reponse", styleStr);

}




