// variables pour les messages d'erreur
var gstrMessages;
var gstrNomChamp;

// Associe un nombre au nom pour faciliter l'appel des fonctions...
// UTILISE dans la fonction fg_validMisc sauf regDate
var regInteger = 0;
var regSignedInteger = 1;
var regFloat = 2;
var regSignedFloat = 3;
var regEmail = 4;
var regMonnaie = 5;
var regMonnaieCent = 6;
var regCP = 7;
var regPhone = 8;
var regDate = 9;
var regTaux = 10;
var gstrChildWindow = "";
var regIntegerWithZero = 11;
var regNAS = 12;
var regPhone800 = 13;
var regZIP_US = 14;
var regZIP_CODE = 15;

// caractères permis lors de la saisie  ("onkeypress")
var EXP_ADRESSE =/^\d|[^ç]$/;							    
var EXP_CODE_POSTAL = /^\d|[a-zA-Z]| $/;
var EXP_CONTACT = /^\d|.$/;
var EXP_DATE = /^\d|\\|\/|-|-| $/;
var EXP_EMAIL = /^\d|[.]|@|[a-zA-Z]|-|-|[_]$/;
var EXP_IDENTIFIANT = /^\d|[a-zA-Z]$/;
var EXP_MOT_PASSE = /^\d|[a-zA-Z]$/;
var EXP_NAS = /^\d| $/;
var EXP_NOM = /^\d|.$/;
var EXP_NO_CERTIFICAT = /^\d$/;
var EXP_NO_COMPTE = /^\d$/;
var EXP_NO_GROUPE = /^\d$/;
var EXP_NO_REGIME = /^\d$/;
var EXP_NOMBRE = /^\d|[.]|[,]| $/;
var EXP_PRENOM = /^\d|.$/;
var EXP_RAPPEL_MOT_PASSE = /^\d|.$/;
var EXP_TELEPHONE_CDN = /^\d|-|-|[(]|[)]| $/;
var EXP_TELEPHONE_EXT = /^\d$/;
var EXP_VILLE = /^\d|.$/;
var EXP_TYPE_REGIME = /^\d|.$/;
var EXP_ZIP_CODE = /^\d$/;
var EXP_SIGNED_FLOAT =/[+]|[-]|^\d|[.]$/;
var EXP_FLOAT =/[+]|^\d|[.]$/;
var EXP_INTEGER =/[+]|^\d$/;
var EXP_SIGNED_INTEGER =/[+]|[-]|^\d$/;
var EXP_ZIP_US = /^\d$/;
var EXP_ZIP_CODE = /^\d| $/;

var CO_LANG_FR = 2
var CO_LANG_AN = 1

var gintLang = 2

if (gintLang==CO_LANG_FR) {
	var EXP_MONNAIE =/^\d| $/;
	var EXP_MONNAIE_AVEC_SOUS =/^\d| |[.]$/;
	var EXP_POURCENTAGE = /^\d|[,]$/;
}
if (gintLang==CO_LANG_AN) {
	var EXP_MONNAIE =/^\d|,$/;
	var EXP_MONNAIE_AVEC_SOUS =/^\d|,|[.]$/;
	var EXP_POURCENTAGE = /^\d|[.]$/;
}

// tableau de "regular expressions"
var regExp = new Array() 
	regExp[regInteger] = /^(\+)?\d+$/
	regExp[regSignedInteger] = /^(\+|-)?\d+$/
	regExp[regFloat] = /^(\+)?((\d+(\.\d*)?)|((\d*\.)?\d+))$/
	regExp[regSignedFloat] = /^(((\+|-)?\d+(\.\d*)?)|((\+|-)?(\d*\.)?\d+))$/
	regExp[regMonnaie] = /^(\+|-)?\d+(\.\d{0,2})?$/
	regExp[regMonnaieCent] = /^(\+|-)?\d+(\.\d{0,2})?$/
	regExp[regEmail] = /^.+\@.+\..+$/
	regExp[regCP] = /^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/
	regExp[regPhone] = /^\d{10}$/
//regIntegerWithZero garde les zeros non significatifs
	regExp[regIntegerWithZero] =  /^(\+)?\d+$/ 
	regExp[regNAS] = /^\d{9}$/   
	regExp[regPhone800] =  /^\d{11}$/
	regExp[regZIP_US] =  /^\d{5}$/
	regExp[regZIP_CODE] =  /^\d{10}$/

if (gintLang==CO_LANG_FR) {
	regExp[regDate] = /^\d{4}(\/|-|\\| )?\d{1,2}(\/|-|\\| )?\d{1,2}$/
	regExp[regTaux] = /^\d{0,3}(\,(\d)?)?$/
}
if (gintLang==CO_LANG_AN) {
	regExp[regDate] = /^\d{1,2}(\/|-|\\| )?\d{1,2}(\/|-|\\| )?\d{4}$/
	regExp[regTaux] = /^\d{0,3}(\.(\d)?)?$/
}

// Autres caracteres permis dans les champs
var strCarPermis = new Array()
	strCarPermis[regInteger] = "+ "; 
	strCarPermis[regSignedInteger] = "+ ";
	strCarPermis[regFloat] = "+ ";
	strCarPermis[regSignedFloat] = "+ ";
	strCarPermis[regMonnaie] = "+$, ";
	strCarPermis[regMonnaieCent] = "+,$ ";	
	strCarPermis[regEmail] = "";
	strCarPermis[regCP] = " ";
	strCarPermis[regPhone] = "()- ";	
	strCarPermis[regDate] = "/\- ";
	strCarPermis[regTaux] = "+ ";		
	strCarPermis[regIntegerWithZero] = ""; 	
	strCarPermis[regNAS] = " ";
	strCarPermis[regPhone800] = " -";
	strCarPermis[regZIP_US] = "";

var strMsg = new Array();
	strMsg[regPhone] = "Le numéro de téléphone doit être de format valide. (ex.: (418) 456-5678)";
	strMsg[regEmail] = "L'adresse de courriel doit être de format valide. (ex.: webmaster@dojo-quebec.com)";
	strMsg[regCP] = "Le code postal doit être de format valide. (ex.: G1S 2Y6)";
	strMsg[regDate] = "La date doit être de format valide. (ex.: 2001-08-25)";
	strMsg[regMonnaie] = "Le montant doit être de format valide. (ex.: 199 999)";
	strMsg[regMonnaieCent] = "regMonnaieCent";
	strMsg[regInteger] = "regInteger";
	strMsg[regSignedInteger] = "regSignedInteger";
	strMsg[regFloat] = "regFloat";
	strMsg[regSignedFloat] = "regSignedFloat";
	strMsg[regTaux] = "regTaux";
	strMsg[regIntegerWithZero] = "regIntegerWithZero";
	strMsg[regNAS] = "Le NAS doit être de format valide. (ex.: 999 999 999)";
	strMsg[regPhone800] = "Le numéro de téléphone en format 1 800 doit être de format valide. (ex.1 800 456-5678)";
	strMsg[regZIP_US] = "regZIP_US";

	
var daysInMonth = new Array(12);
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;


function tmt_reFormat(f,re,s){
	fv=MM_findObj(f).value;var rex=new RegExp(unescape(re),"g");
	if(rex.test(fv)){MM_findObj(f).value=fv.replace(rex,unescape(s));}
}

function popAlert(m) {
alert(m);
}


function replaceChars(out,add,entry) {
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}

function splitDate(part,date,field){
	fdate = MM_findObj(date).value;
	if (part =="A"){
	MM_findObj(field).value = fdate.substring(0,4); 
	}
	if (part =="M"){
	MM_findObj(field).value = fdate.substring(5,7); 
	}
	if (part =="J"){
	MM_findObj(field).value = fdate.substring(8,10); 
	}
	return true;
}



function genMemberId(code,nom,prenom,date){
	fnom = replaceChars('\'','',replaceChars(' ','',replaceChars('-','',MM_findObj(nom).value)));
	fprenom = MM_findObj(prenom).value;
	fdate = MM_findObj(date).value;
	MM_findObj(code).value = fprenom.substring(0,1).toUpperCase() + fnom.substring(0,3).toUpperCase() + fdate.substring(2,4) + fdate.substring(5,7) + fdate.substring(8,10);
	return true;
}

 function LTrim(str){
	var whitespace = new String("- \t\n\r");
	var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
		 var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			j++;
		s = s.substring(j, i);
	}
	return s;
}

function RTrim(str){
	var whitespace = new String("- \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;       // Get length of string
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
		s = s.substring(0, i+1);
	}
	return s;
}
function Len(str)
      {  return String(str).length;  }
function Mid(str, start, len)
        {
                 if (start < 0 || len < 0) return "";
                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;
                return String(str).substring(start,iEnd);
        }


function InStr(strSearch, charSearchFor){
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}

function toUpper(fieldName){
	var str;
	str = MM_findObj(fieldName).value;
	var str1;
	var strArr1;
	var newStr;
	if (str != "" && InStr(str," ") == -1 && InStr(str,"'") == -1) {
		str = str.toLowerCase();
		strArr1 = str.split("-");
			for(x=0;x<strArr1.length;x++) {
				strArr1[x] = strArr1[x].replace(strArr1[x].charAt(0),strArr1[x].charAt(0).toUpperCase());
				if(newStr > "") {
					newStr = newStr + strArr1[x] + "" ;
			     }else{
					newStr = strArr1[x] + "-" ;
					}
				}
		MM_findObj(fieldName).value = RTrim(LTrim(newStr));
		}
}

function rik_toUpper(f){
	fv = MM_findObj(f).value;
	MM_findObj(f).value = fv.toUpperCase();
}

function rik_toLower(f){
	fv = MM_findObj(f).value ;
	MM_findObj(f).value = fv.toLowerCase();
	}
	
function rik_toPhone(f){
var sPos = 0;
var s = "";
var sPos = 0;
	fv = MM_findObj(f).value ;
	MM_findObj(f).value = fv.toLowerCase();
}	
	
function fp_strReformat(s)
{
	var arg;
	var intPosition = 0;
	var strResultat = "";
	for (var i=1;i<fp_strReformat.arguments.length;i++)		//>
	{
		arg = fp_strReformat.arguments[i];
		if (i%2 == 1) strResultat+=arg;
		else
		{
			strResultat+=s.substring(intPosition, intPosition + arg);
			intPosition+=arg;
		}
	}
	return strResultat;
}
/***********************************************************************************
Nom de la fonction:		fp_isDateString
Description:			Retourne TRUE si "strValue" est une date valide dans le format
						YYYY/MM/DD YYYY-MM-DD YYYY\MM\DD YYYY MM DD ou YYYYMMDD
***********************************************************************************/ 
function fp_isDateString(f)
{   txtField = MM_findObj(f)
	var strTheString = new String(txtField.value);
	var strDateDelimiter;
	var strTemp;
	
	if (strTheString.indexOf('/') > 0)
		strDateDelimiter = '/'
	else if (strTheString.indexOf('-') > 0)
			strDateDelimiter = '-'
	else if (strTheString.indexOf('\\') > 0)
			strDateDelimiter = '\\'
	else if (strTheString.indexOf(' ') > 0)
			strDateDelimiter = ' '			
	else if (strTheString.length == 8)
			strDateDelimiter = ''
	else	return false;

	// Separe le string "strTheString" dans un array de string "strSplit" (il doit en avoir 3)
	// strSplit est uniformise sous forme YYYYMMJJ
	var strSplit = new Array();
	if (strDateDelimiter == '') 
	{
		if (gintLang==CO_LANG_FR) { // YYYYMMJJ
		strSplit[0] = strTheString.substring(0,4);
		strSplit[1] = strTheString.substring(4,6);
		strSplit[2] = strTheString.substring(6,8);
		}
		if (gintLang==CO_LANG_AN) { // JJMMYYYY
		strSplit[2] = strTheString.substring(0,2);
		strSplit[1] = strTheString.substring(2,4);
		strSplit[0] = strTheString.substring(4,8);
		}
	}
	else {
		strSplit = strTheString.split(strDateDelimiter);
		if (strSplit.length != 3)
			return false;
		if (gintLang==CO_LANG_AN) { // JJMMYYYY
			strTemp= strSplit[0];
			strSplit[0] = strSplit[2];
			strSplit[2] = strTemp;
		}		
	}
	
	if (strSplit[1].length == 1) strSplit[1] = "0" + strSplit[1];
	if (strSplit[2].length == 1) strSplit[2] = "0" + strSplit[2];
	
	if (fp_isDate(strSplit[0], strSplit[1], strSplit[2])) {
		var strValue;
		if (gintLang==CO_LANG_FR) { // YYYY-MM-JJ
			strValue = strSplit[0] + strSplit[1] + strSplit[2];
			txtField.value = fp_strReformat(strValue, "", 4, "-", 2, "-" , 2)
		}
		if (gintLang==CO_LANG_AN) { // JJ/MM/YYYY
			strValue = strSplit[2] + strSplit[1] + strSplit[0];
			txtField.value = fp_strReformat(strValue, "", 2, "/", 2, "/" , 4)
		}		
		return true;
	}	
	return false;
}	

/***********************************************************************************
Nom de la fonction:		fp_isDate
Description:			Retourne TRUE si les arguments "pstrYear", "pstrMonth" et
						"pstrDay" forment une date valide 
***********************************************************************************/ 
function fp_isDate(pstrYear, pstrMonth, pstrDay)
{

	if (pstrMonth.charAt(0) == '0') pstrMonth = pstrMonth.substring(1, pstrMonth.length);
	if (pstrDay.charAt(0) == '0') pstrDay = pstrDay.substring(1, pstrDay.length);
	if (pstrYear.charAt(0) == '0') return false; 

	var intYear = parseInt(pstrYear);
	var intMonth = parseInt(pstrMonth);
	var intDay = parseInt(pstrDay);
	
	if (intMonth < 1 || intMonth > 12 || intDay < 1 || intDay > 31) return false;
	if (intDay>daysInMonth[intMonth]) return false; 
	if ((intMonth == 2) && (intDay>fp_daysInFebruary(intYear))) return false;
	return true;
}


/***********************************************************************************
Nom de la fonction:		fp_daysInFebruary
Description:			Recoit l'annee et retourne le nombre de jour
						qu'a fevrier dans cette annee
***********************************************************************************/ 
function fp_daysInFebruary(year)
{
	return (((year%4 == 0) && ((!(year%100 == 0)) || (year%400 == 0))) ? 29 : 28 );
}
/***********************************************************************************
Nom de la fonction:		fp_MsgBox
Description:			FONCTION POUR AVERTIR USAGER QU'ÉLÉMENT REQUIS OU MANQUANTS.
***********************************************************************************/
function fp_MsgBox(f, s)
{   
	alert(s)
	txtField = MM_findObj(f);
	txtField.focus();
	txtField.select();
	return false;
}
/***********************************************************************************
Nom de la fonction:		fg_ValidDate
Description:			Verifie que le TEXTFIELD forment une date valide
***********************************************************************************/
function fg_ValidDate(f)
{
txtField = MM_findObj(f);
	if (txtField.value == null || txtField.value == "") return true;   

	if(!(regExp[regDate].test(txtField.value)) || !(fp_isDateString(f))){
		return fp_MsgBox (f, strMsg[regDate]);
	}
	// Test...
	//var strTest;
	//strTest=fgstrUnformatDate(txtField)	
	//
	
	return true;
}

/***********************************************************************************
Nom de la fonction:		fp_CouperBonChars
Description:			Enleve tous les caracteres contenu 
						dans "bon" de la string "s"
***********************************************************************************/  
function fp_CouperBonChars (s, bon)
{
	var strResultat = "";
	for (var i=0;i<s.length;i++)			//>
	{   
		var c=s.charAt(i);
		if(bon.indexOf(c) == -1) strResultat+=c;
	}
	return strResultat;
}

/*********************************************************************************
Fonction:		fg_ValidMisc
Description:	Vérifie que le TEXTFIELD est valide d'apres la "regular expression" 
				choisie (regE).
				ex : si regE = regEmail, vérifie que TEXTFIELD est un Email valide (a@b.c)
				Le parametre strMsgSpecf représente le message qu'il faudra afficher 
				s'il se produit une erreur à la plce du message général
*********************************************************************************/
function fg_ValidMisc(f, regE, strMsgSpecf)
{
	var strMsgSpecfTemp = ""
	txtField = MM_findObj(f);
	if (txtField.value == null)
	{
		 return true;
	}
	if (txtField.name == "")
	{
		 return true;
	}
	if (txtField.value == "")
	{
		return true;
	}
	var strValue = fp_CouperBonChars(txtField.value, strCarPermis[regE])
	
	if (strMsgSpecf && strMsgSpecf != "")
		strMsgSpecfTemp = strMsgSpecf;
	else
		strMsgSpecfTemp = strMsg[regE];
		
	if(!(regExp[regE].test(strValue)))
	{
		if (regE == regTaux){txtField.value = "";}
		return fp_MsgBox(f, strMsgSpecfTemp);
	}

	if (regE == regNAS) 
		if (! fg_ValidNAS(strValue)) return fp_MsgBox(f, strMsgSpecfTemp);
		
		
	if (regE == regMonnaie)
		strValue = fg_strFormatMonnaie(Math.round(parseFloat(strValue)),false);
	else
	if (regE == regMonnaieCent)
		strValue = fg_strFormatMonnaie(parseFloat(strValue),true);	
	else	
	
	if (regE == regTaux)
		strValue = fg_strFormatTaux(strValue);
	else
	
	if (regE == regCP)
		strValue = fp_strReformat(strValue.toUpperCase(), "", 3, " ", 3);
	else		
	
	if (regE == regNAS)
		strValue = fp_strReformat(strValue.toUpperCase(), "", 3, " ", 3, " ", 3);
	else		
	
	if (regE == regPhone)
		strValue = fp_strReformat(strValue, "(", 3, ") ", 3, "-", 4);
	else
	
	if (regE == regPhone800)
		if (gintLang==CO_LANG_FR)
		{
			strValue = fp_strReformat(strValue, "",1," ", 3, " ", 3, "-", 4);
		}
		else
		{
			strValue = fp_strReformat(strValue, "",1,"-", 3,"-", 3, "-", 4);
		}
	else
	
	if (regE == regZIP_US)
		strValue = fp_strReformat(strValue, "",5);
	else
	
	if (regE != regEmail)
		if (regE != regIntegerWithZero)
		strValue = parseFloat(strValue);	
			
	MM_findObj(f).value = strValue;
	return true;
}
/**************************************************************************
Nom de la fonction:	fgDetermineRegPhone (pthis)
But de la fonction:		dertminer le type de validation pour un champ de type telephone
								(pour savoir si on fait un regPhone ou un regPhone800)

**************************************************************************/
function fgDetermineRegPhone (f)
{
	fv = MM_findObj(f);
		if (fv.value.charAt(0) == 1)
		{
			mblnGereEvent = fg_ValidMisc(f, regPhone800);
		}
		if (fv.value.charAt(0) != "")
		{
			mblnGereEvent = fg_ValidMisc(f, regPhone);
		}	
	
}

function Refocus(f) {
  fv = MM_findObj(f);
  fv.focus();	
  }
  
function emptyField(f) {
 MM_findObj(f).value = "";

  }
  
function tmt_lenValidator(f,sp,ep,ks,eMsg){
	var str;var myErr="";var re=/^(\s*)$/;fv=MM_findObj(f).value;
	if(ks){if(re.test(fv)){fv=fv.replace(re,"");}}
	if(fv.length<sp||fv.length>ep){alert(unescape(eMsg));myErr += 'eMsg';}
	document.MM_returnValue=(myErr=="");
}
  
function tmt_regExpValidator(f,re,eMsg,ru,r){
	var myErr="";var fv=MM_findObj(f).value;var rex=new RegExp(unescape(re));
	var t=eval(ru+rex.test(fv));if(r){if(fv.length<=0||!t){alert(unescape(eMsg));myErr+="eMsg";Refocus(f);}}
	else if(fv.length>0&&!t){alert(unescape(eMsg));myErr+="eMsg";Refocus(f);}document.MM_returnValue=(myErr=="");
}
  

  
function DeleteRecord(formName,action){
	var myString = "document."+formName+"."+action+"();";
    var ActionDelete = confirm("Voulez-vous réellement supprimer l'enregistrement sélectionnée?");
	if(ActionDelete == true) {
	eval(myString);
	}
    var x = false;
}

function CancelAll(p){
	var myString = "window.history.go("+p+");";
    var ActionDelete = confirm("Voulez-vous réellement annuler l'action en cours.  Toutes données saisie seront perdues!");
	if(ActionDelete == true) {
	eval(myString);
	}
    var x = false;
}

function Delete_Record(loc){
	var myString = "location.href='"+loc+"';";
    var ActionDelete = confirm("Voulez-vous réellement supprimer l'enregistrement sélectionnée?");
	if(ActionDelete == true) {
	eval(myString);
	}
    var x = false;
}

function checkAll(theForm,cName) {
    for (i=0,n=theForm.elements.length;i<n;i++)
        if (theForm.elements[i].name.indexOf(cName) !=-1)
            theForm.elements[i].checked = true;
}

function UncheckAll(theForm,cName) {
    for (i=0,n=theForm.elements.length;i<n;i++)
        if (theForm.elements[i].name.indexOf(cName) !=-1)
            theForm.elements[i].checked = false;
}



function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4  

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Cliquer pour fermer" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}

function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
