/***************************************************************************/
/*  F O N C T I O N S   D E   B A S E    V 1.1                             */
/*  Copyright 2001-2004 Resonance Informatique                             */
/*  www.resonance-informatique.fr                                          */
/*                                                                         */
/*   Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)  */
/*   Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>          */
/*   http://www.hidaho.com/cookies/cookie.txt                              */
/*   released to the public domain.                                        */
/*                                                                         */
/***************************************************************************/
/*                                                                         */
/*  Ce code peut etre re-utilise gratuitement sous reserve qu'il ne soit   */
/*  pas modifie et que cette notice ne soit pas retiree                    */
/*                                                                         */
/*  pour toute modification, suggestion, remarque ou bug                   */
/*  g.philippot@resonance-informatique.fr                                  */
/*                                                                         */									
/***************************************************************************/
/*                                                                         */
/*  This program can be used as needed freely if it stay unmodified and    */
/*  if this header is not overwrited                                       */
/*                                                                         */
/*  for update, suggestion, bugreport                                      */
/*  g.philippot@resonance-informatique.fr                                  */
/*                                                                         */									
/***************************************************************************/


/***************************************************************************/
/*  F O N C T I O N S   G E N E R A L E S                                  */
/***************************************************************************/
	

	/////////////////////////////////////////////////////////////////////////
	// Gestion des erreurs
	var msg = null
	function handleErrors(errorMessage, url, line)
	{
		msg = "There was an error on this page.\n\n";
		msg += "An internal programming error may keep\n";
		msg += "this page from displaying properly.\n";
		msg += "Click OK to continue.\n\n";
		msg += "Error File: BasicFct.js\n";
		msg += "Error message: " + errorMessage + "\n";
		msg += "URL: " + url + "\n";
		msg += "Line #: " + line;
		alert(msg);
		return true
	}
	
	/////////////////////////////////////////////////////////////////////////
	// Detection de version de navigator
	function NavVersion()
	{
		onerror = handleErrors;
		if (navigator.appVersion.indexOf("MSIE 8")!=-1) return ("IE8");
		if (navigator.appVersion.indexOf("MSIE 7")!=-1) return ("IE7");
		if (navigator.appVersion.indexOf("MSIE 6")!=-1) return ("IE6");
		if (navigator.appVersion.indexOf("MSIE 5")!=-1) return ("IE5");
		if (navigator.userAgent.indexOf("Netscape/7")!=1) return ("NS7");
		if (navigator.userAgent.indexOf("Netscape/6")!=1) return ("NS6");
		if (navigator.userAgent.indexOf("Firefox/1")!=1) return ("FF");
		if (navigator.userAgent.indexOf("Firefox/2")!=1) return ("FF");
		if (navigator.userAgent.indexOf("Firefox/3")!=1) return ("FF");
		if (navigator.userAgent.indexOf("Safari/5")!=1) return ("FF");
		if (navigator.appName.indexOf("Netscape")!=1 && parseInt(navigator.appVersion)>=5) return ("NS5");
		if (navigator.userAgent.indexOf("Mozilla/4")!=1)
			if (navigator.appName.indexOf("Netscape")!=1) return ("NS4");
			else if (navigator.appVersion.indexOf("MSIE 4")!=1) return ("IE4");
		onerror = null;
		return ("");
	}

	/////////////////////////////////////////////////////////////////////////
	// RollOver pour Image
	function displayrollover(ImgIn) 
	{
		onerror = handleErrors;
		if (typeof(document.layers)=='undefined')
		{
			image=eval(ImgIn + "_over.src");
			document.images[ImgIn].src = image;
		}
		else
		{
			image=eval(ImgIn + "_over.src");
			document.images[ImgIn].src = image;
		}
		onerror = null;
	}

	/////////////////////////////////////////////////////////////////////////
	// RollOut pour Image
	function displayrollout(Imgout) 
	{
		onerror = handleErrors;
		if (typeof(document.layers)=='undefined')
		{
			image=eval(Imgout + "_out.src");
			document.images[Imgout].src = image;
		}
		else
		{
			image=eval(Imgout + "_out.src");
			document.images[Imgout].src = image;
		}
		onerror = null;
	}
	
	/////////////////////////////////////////////////////////////////////////
	//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
	//
	//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
	//  The following functions are released to the public domain.
	
	
		//******************************************************************
		// "Internal" function to return the decoded value of a cookie
		function getCookieVal (offset) {
		onerror = handleErrors;
		  var endstr = document.cookie.indexOf (";", offset);
		  if (endstr == -1)
		    endstr = document.cookie.length;
		  return unescape(document.cookie.substring(offset, endstr));
		onerror = null;
		}
		
		//******************************************************************
		//  Function to correct for 2.x Mac date bug.
		function FixCookieDate (date) {
			onerror = handleErrors;
			var base = new Date(0);
			var skew = base.getTime(); // dawn of (Unix) time - should be 0
			if (skew > 0)  // Except on the Mac - ahead of its time
				date.setTime (date.getTime() - skew);
		onerror = null;
		}
		
		//******************************************************************
		//  Function to return the value of the cookie specified by "name".
		function GetCookie (name) {
			onerror = handleErrors;
			var arg = name + "=";
			var alen = arg.length;
			var clen = document.cookie.length;
			var i = 0;

			while (i < clen) {
				var j = i + alen;
				if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
				i = document.cookie.indexOf(" ", i) + 1;
				if (i == 0) break; 
			}
			return null;
		onerror = null;
		}

		//******************************************************************
		//  Function to create or update a cookie.
		function SetCookie (name,value,expires,path,domain,secure) {
			onerror = handleErrors;
			document.cookie = name + "=" + escape (value) +	((expires) ? "; expires=" + expires.toGMTString() : "") +
				((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") +	((secure) ? "; secure" : "");
		onerror = null;
		}

		//******************************************************************
		//  Function to delete a cookie. (Sets expiration date to start of epoch)

		function DeleteCookie (name,path,domain) 
		{
			onerror = handleErrors;
			if (GetCookie(name)) 
			{
				document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") +"; expires=Thu, 01-Jan-70 00:00:01 GMT";
			}
		onerror = null;
		}

		function startdatechange(datavalues)
		{
			onerror = handleErrors;
			for (i=0;i<document.forms.startdate.selstartdate.options.length;i++)
			{
				if (document.forms.startdate.selstartdate.options[i].selected)
				{
					document.getElementById('AlbaDate').innerHTML = datavalues[i][0];
					document.getElementById('CACDate').innerHTML = datavalues[i][1];
					document.getElementById('RelatifDate').innerHTML = datavalues[i][2];
				}
			}
		onerror = null;
		}

