function voirVinBig ( vinSmall, id )
{
		 var vinBig = vinSmall.replace('Small', 'Big')

var pathBig = window.document.forms[0].varUserImage.value + vinBig;
		 cacher()
		 document.ImgBig.src = pathBig;
		 document.getElementById("ImgBig").style.visibility = "visible";
//		 document.ImgBig.style.visibility = "visible";

		 checkLocation();
		 		 
}

function voir ( vinSmall, id )
{

	var vinBig = vinSmall.replace('Small', 'Big')
	var pathBig = "/" + window.document.forms[0].dDBCurrent.value + "/0/"+id+"/$file/"+vinBig;

	cacher()

	document.ImgBig.src = pathBig;
	document.getElementById("ImgBig").style.visibility = "visible";
//	document.ImgBig.style.visibility = "visible";

	checkLocation();
		
}

function cacher()
{

	document.ImgBig.src = "/";
	
	if(document.getElementById)
   		document.getElementById("ImgBig").style.visibility = "hidden";

}

function setVariables()
{

	if (document.layers)
	{
		v = ".top=";
		x = ".left=";
		dS = "document.";
		sD = "";
		y = "window.pageYOffset";
	}
	else if (document.all)
	{
		v = ".pixelTop=";
		x = ".pixelLeft=";
		dS = "";
		sD = ".style";
		y = "document.body.scrollTop";
	}
	else if (document.getElementById){
		y = "window.pageYOffset";
	}

}

function checkLocation()
{

	object = "ImgBig";
	yy = eval(y);

	if (document.getElementById)
	{
		document.getElementById("ImgBig").style.top = yy + 5;
		document.getElementById("ImgBig").style.left = (navigator.appName == 'Microsoft Internet Explorer') ? (window.document.body.offsetWidth - window.document.ImgBig.width) / 2 : (window.innerWidth - window.document.ImgBig.width) / 2;
	}
	else
	{
		eval(dS + object + sD + v + yy);
		eval(dS + object + sD + x + str((navigator.appName == 'Microsoft Internet Explorer') ? (window.document.body.offsetWidth - window.document.ImgBig.width) / 2 : (window.innerWidth - window.document.ImgBig.width) / 2));
	}
	
	setTimeout("checkLocation()", 5);
			
}

function openDocument(UNID)
{
	var LANG = document.getElementById('NotesLanguage').innerHTML
	var url = window.location.pathname;
	var dbpath=url.substring(0,url.indexOf(".nsf",7)+4);
	var URLDOC = dbpath + '/($Published)/' + UNID + '?OpenDocument&L=' + LANG 
	var Mid =''

	// Lecture de la chaine "Mid=xxx" et l'ajoute à l'URL
	var qs = new queryString()
	var Mid = qs.get('Mid')
	if (qs.get('Mid')!="")
	{
		Mid='&Mid='+qs.get('Mid')
	}
	window.location.href=URLDOC+Mid
}

function sendToAFriend(staticpage)
{
	var options = ',scrollbars=yes, status=yes, resizable=yes,toolbar=yes, location=yes, menubar=yes'
	var UNID = document.getElementById('NotesUNID').innerHTML
	var LANG = document.getElementById('NotesLanguage').innerHTML
	var PORTAL =  document.getElementById('WebPortal').innerHTML
	var w = 500
	var h = 300
	var pos = getMiddleScreenCoord(w,h)
	

	var url = window.location.pathname;
	var dbpath=url.substring(0,url.indexOf(".nsf",7)+4);
	var URLDOC = dbpath + '/($documents)/' + UNID + '?OpenDocument&L=' + LANG 
	window.open('/'+PORTAL + '/($page)/' + staticpage + '?OpenDocument&L=' + LANG +'&dataonly=y&url='+URLDOC,'','left='+pos[0]+', top='+pos[1]+', width='+w+', height='+h+options)

}

/****************************************************************************************************************/
/* printPreview()																								*/	
/* ==============	  																							*/
/*																												*/
/* Affiche une nouvelle fenêtre (centrée) du document, sans titre, menu et boîte de contexte					*/	
/* 																												*/
/* Version: 1.0																									*/
/* -------------------------------------------------------------------------------------------------------------*/
/* 																												*/
/* IN: 	w	= largeur de la fenêtre                             												*/
/* 		h	= hauteur de la fenêtre																				*/
/* 																												*/
/* OUT:	n/a																										*/
/* 																												*/
/****************************************************************************************************************/
function printPreview(w,h)
{
	var pos = getMiddleScreenCoord(w,h)
	var options = ',scrollbars=yes, status=yes, resizable=yes,toolbar=yes, location=yes, menubar=yes'
	var UNID = document.getElementById('NotesUNID').innerHTML
	var LANG = document.getElementById('NotesLanguage').innerHTML

	var url = window.location.pathname;
	
	var dbpath=url.substring(0,url.indexOf(".nsf",7)+4);
	window.open(dbpath + '/($documents)/' + UNID + '?OpenDocument&L=' + LANG +'&dataonly=y','','left='+pos[0]+', top='+pos[1]+', width='+w+', height='+h+options)

		
}









/****************************************************************************************************************/
/* getMiddleScreen()																							*/	
/* =================																							*/
/*																												*/
/* retourne la position x/y pour l'affichage d'une fenêtre centrée à l'écran 									*/	
/* 																												*/
/* Version: 1.0																									*/
/* -------------------------------------------------------------------------------------------------------------*/
/* 																												*/
/* IN: 	w	= largeur de la fenêtre                             												*/
/* 		h	= hauteur de la fenêtre																				*/
/* 																												*/
/* OUT:	tableau avec les coordonnées x/y ( new array('xxx','yyy')												*/
/* 																												*/
/****************************************************************************************************************/
function getMiddleScreenCoord(width,height)
{
	//		(navigator.appName == 'Microsoft Internet Explorer') ? (window.document.body.offsetWidth - 320) / 2 : (window.innerWidth - 320) / 2;
	var x = (screen.width-width) /2
	var y = (screen.height-height)/2
	var x=x.toString()
	var y=y.toString()
	return new Array(x,y)	
}



function queryString()
{
	// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

	// parse out name/value pairs separated via &
	var args = querystring.split('&');

	// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		temp0 = temp.join(' ');
		
		temp = unescape(pair[1]).split('+');
		temp1 = temp.join(' ');
		
		this[temp0]=temp1;
	}

	this.get=queryString_get;
}

function queryString_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null){value=strDefault;}
	
	return value;
}

/*----- Fonctions de gestion de chaînes de caractères -----*/

/*
Fonction	: Indique si une chaîne de caractères est un entier
Paramètres	: n (string, ou integer, ou number): chaine ou nombre à tester
Retour		: (boolean): true ou false
Exemple		: alert(isInteger(5)) renvoie true
Utilisation	: ?
*/
function isInteger(n)
{
	if(isNaN(n))
	return false;
 
	return(parseInt("" + n) == n);
}

/*
Fonction	: Retourne tous les caractères d'une chaîne jusqu'à une position donnée
Paramètres	: chaine (string)
			: position (integer)
Retour		: (string). Caractères à gauche de "position"
Exemple		: strLeft("abdcef", 2) renvoie "ab"
Utilisation	: ?
*/
function strLeft(chaine, position)
{
	var retour = "";
	for (var i=0; i<position;i++)
	{
		retour = retour + chaine.charAt(i) ;
	}
	return(retour);
}

/*
Fonction	: Remplace une chaîne par une autre chaîne dans une chaîne de caractères
Paramètres	: fullS (string): chaîne source à traiter
			: oldS (string): chaîne à remplacer
			: newS (string): nouvelle chaîne
Retour		: (string). Chaîne traitée
Exemple		: replacesubstring("abcd abcd", "bc", "12") renvoie "a12d a12d"
Utilisation	: ?
*/
function replacesubstring(fullS,oldS,newS)
{
	for (var i=0; i < fullS.length; i++)
	{ 
		if (fullS.substring(i,i+oldS.length) == oldS)
		{ 
			fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length) 
		}
	}
	return fullS
}

/*
Fonction	: Enlève les espaces d'une chaîne de caractères, en début de chaîne, en fin de chaîne, ainsi que les espaces redondants à l'intérieur de la chaîne
Paramètres	: str (string): chaîne source à traiter
Retour		: (string). Chaîne traitée
Exemple		: str(" abcd  abcd ") renvoie "abcd abcd"
Utilisation	: V2.1.0 - Intranet
*/
function trim(str)
{
	var strTmp = str;
	strTmp = strTmp.replace(/( )+/g, " ");
	if(strTmp.indexOf(" ") == 0)
		strTmp = strTmp.substring(1, strTmp.length);
	if(strTmp.lastIndexOf(" ") == strTmp.length-1)
		strTmp = strTmp.substring(0, strTmp.length-1);
	return strTmp;
}

/*----- Fonctions de gestion des formulaires -----*/

/*
Fonction	: Permet de se connecter à Assura.net lorsque l'utilisateur appuie sur la touche Entrée dans les champs de login
Utilisation	: V2.1.0 - Internet
*/
function checkEnterAssuraNet()
{
	var code = 0;
	code = window.event.keyCode;
	if (code==13)
		{
		validateAssuraNet();
		}
}

/*
Fonction	: Lorsque l'utilisateur appuie sur la touche Entrée dans le champ de formulaire, lance une requête dans le moteur de recherche
Paramètre	: evt (event): événement lié au OnKeyPress du champ
Retour		: Redirection vers la page d'aide.
Exemple		: <INPUT NAME="Query" VALUE="Rechercher" onKeyPress="return checkEnterSearch(event);">
Utilisation	: V2.1.0 - Internet/Intranet/Extranet
Compatibilité : Firefox, IE5, IE6.
*/
function checkEnterSearch(evt)
{
	var keycode;
    if (evt)
        ;
    else if (window.event)
        evt = window.event;
    else if (event)
        evt = event;
    else
        return true;
 
    if (evt.charCode)
        keycode = evt.charCode;
    else if (evt.keyCode)
        keycode = evt.keyCode;
    else if (evt.which)
        keycode = evt.which;
    else
        keycode = 0;
 
    if (keycode == 13) {
        recherche();
        return false;
    }
    else
        return true;
}

/*
Fonction	: Lance une requête dans le moteur de recherche
Retour		: Redirection vers la page de résultat de la recherche
Utilisation	: V2.1.0 - Internet/Intranet/Extranet
*/
function recherche()
{
	var nbf = document.forms.length-1;
	var langue = document.forms[nbf].dLanguage.value;

	var Query = document.forms[0].Query.value;
	var fin = parseInt(location.pathname.lastIndexOf('/'));

	var base = window.document.forms[nbf].dDBSearch.value;
	Query = replacesubstring(Query, ',', ' ');
	Query =  "*" + trim(Query) + "*";
	var keywords = Query;
	
	if(Query.indexOf(" or ") == -1 && Query.indexOf(" Or ") == -1 && Query.indexOf(" OR ") == -1)
	{
		keywords = replacesubstring(Query, ' ', '+and+');
	}

	var url = base + '/Search' + document.forms[nbf].varSite.value + langue + '?SearchView&Query=[IndexKeyword'+ langue +'] contains '+ keywords;

	if (window.document.forms[0].Query.value == "")
	{
		return;
	}
	document.location = url + "&SearchOrder=4&SearchWV=True&L=" + langue;
}

/*
Fonction	: Lance une requête dans le moteur de recherche
Retour		: Redirection vers la page de résultat de la recherche
Utilisation	: V2.1.0 - Intranet
*/
function aideRecherche()
{
	var nbf = document.forms.length-1;
	var langue = document.forms[nbf].dLanguage.value;
	var base = window.document.forms[nbf].dDBSearch.value;	
	var url = base + '/wHelp/help?OpenDocument&L=' + document.forms[nbf].dLanguage.value;

	document.location = url;
}

/*
Fonction	: Indique si un élément de formulaire est coché (radio ou checkbox)
Paramètres	: buttonGroup (object): élément de formulaire
Retour		: (variant): valeur de l'élément de formulaire
Exemple		: <input type="radio" name="Question1" value="1" checked>Oui
			: <input type="radio" name="Question1" value="0">Non
			: getSelectedButton(window.document.forms[0].Question1) renvoie 1
Utilisation	: V2.1.0 - Internet
*/
function getSelectedButton(buttonGroup)
{
	for (var i=0; i < buttonGroup.length; i++)
	{
		if (buttonGroup[i].checked)
		{
			return buttonGroup[i].value;
		}
	}		
	return -1;	
}

/*
Fonction	: Remet le texte par défaut dans le champ de formulaire
Paramètre	: BoxName (object): champ de formulaire
Exemple		: <INPUT NAME="Query" VALUE="Rechercher" onFocus="return BlurText(this);">
Utilisation	: V2.1.0 - Internet/Intranet/Extranet
*/
function BlurText(BoxName)
{
	if (BoxName.value == '')
	{
	BoxName.value = BoxName.defaultValue;
	}
}

/*
Fonction	: Vide le texte le champ de formulaire
Paramètre	: BoxName(object): champ de formulaire
Exemple		: <INPUT NAME="Query" VALUE="Rechercher" onFocus="return FocusText(this);">
Utilisation	: V2.1.0 - Internet/Intranet/Extranet
*/
function FocusText(BoxName)
{
	if (BoxName.value == BoxName.defaultValue)
	{
	BoxName.value = '';
	}
}

/*----- Fonctions diverses -----*/

/*
Fonction	: Affiche les images définies dans une NotesView (permet d'éviter les chemins en dur vers les images)
Paramètres	: prefix (string): préfixe du nom des images, utilisé dans la vue
			: objImage (image object): objet image instancié auparavant
Retour		: aucun
Exemple		: Dans la View
			: 	"<IMG NAME='imgpuce" + @NoteID + "' BORDER='0'>"
			: Dans le Form:
			: 	var prefixImageName = "imgpuce";
			: 	var objImage = new Image(4,7);
			: 	objImage.src = "/web/WebElements.nsf/objects/internet_images/$file/puce.gif";
			: 	setImages(prefixImageName, objImage);
Utilisation	: V2.1.0 - Internet/Intranet
*/
function setImages(prefix, objImage)
{
	var arrTagImages = document.getElementsByTagName("img");
	var sTagImageName;
	for(var i=0;i<arrTagImages.length;i++)
	{
		sTagImageName = arrTagImages[i].name;		
		if(	sTagImageName.indexOf(prefix) == 0)
		{
			arrTagImages[i].src = objImage.src;
		} 
	}
}
