var old_onload = null;
if (typeof window.onload == "function")
{
	old_onload = window.onload;
}

window.isOldGecko = (		
		!document.readyState &&
		!window.opera &&
		!window.find &&
		window.home &&
		document.getElementsByTagName &&
		navigator.product &&
		(navigator.product == 'Gecko')	
);

window.onload = function()
{
	if (old_onload)
	{
		old_onload();
		old_onload = null;
	}
	// old Geckos
	if (window.isOldGecko)
	{
		var im = document.getElementsByTagName("IMG");
		for (var i = 0; i < im.length; i++)
		{
			if (im[i].className == 'nn6')
			{
				im[i].style.verticalAlign = '-100%';
			}
		}
	}
}

// copyright - begin
//
//   Copyright (C) 2005 Espace Courbe inc.
//   You are free to modify and redistribute this code as long
//   as the following message is included:
//
//   Last modified:
//   $Date: 2008-05-27 20:39:38 $
//
//   Portions Copyright (C) 2006 Espace Courbe inc.
//   Home Page: http://www.espacecourbe.com/
//
//   Author: Christian Fecteau -- christian.fecteau@espacecourbe.com
//   Creation:  2005/12/06 17:05:02
//
// copyright - end

/*

$Id: fonctions.js,v 1.24 2008-05-27 20:39:38 patrick Exp $
$Revision: 1.24 $

*/

function getGET(s1, s2)
{
	// retrieve arguments from location
	if (location.search)
	{
		var query = unescape(location.search.substring(1));
		var pairs = query.split(s2);
		for (var i = 0; i < pairs.length; i++)
		{
			var pos = pairs[i].indexOf(s1);
			if (pos == -1) { continue; }
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			args[argname] = String(value);
		}
	}
}
function goImp(argn, se1, value, se2, targ)
{
	if (String(argn) == "undefined") { argn = arg; }
	if (String(se1) == "undefined") { se1 = sep1; }
	if (String(value) == "undefined") { value = val1; }
	if (String(se2) == "undefined") { se2 = sep2; }
	if (String(targ) == "undefined") { targ = tar; }
	var
	t = eval('window.' + targ),
	v = argn + se1 + value,
	c = argn + se1,
	w = eval("(t.location.href).replace(/" + se2 + "*$/,'')"),
	q = w.match(/\?[^#]*/),
	p = eval('/' + c + '[^' + se2 + ']*/g'),
	h = w.match(/#.*/);
	if (t.focus) t.focus();
	if (w.indexOf(c) != -1)
	{
		t.location.href = w.replace(p, v);
	}
	else if (q)
	{
		q = q[0] + se2 + v;
		t.location.href = w.replace(/\?[^#]*/, q);
	}
	else if (w.indexOf('#') != -1)
	{
		w = w.replace(/#.*/,'');
		t.location.href = w + '?' + v + h[0];
	}
	else
	{
		t.location.href = w + '?' + v;
	}
}

function ecritNav(imp, ret, onclk)
{
	if (typeof args[arg] == "string" && args[arg] == val1)
	{
		if (String(onclk) == "undefined") { onclk = 'retourEcran()'; }
		var n = '<div id="printbuttons"><form action="">';
		if (window.print)
		{
			n += '<input onclick="window.print()" ';
			n += 'value="'+imp+'" type="button">&nbsp;&nbsp;';
		}
		n += '<input onclick="'+onclk+'" value="'+ret+'" type="button" ';
		n += '/></form><hr /></div>';
		document.write(n);
	}
}
function retourEcran(targ)
{
	//history.go(-1);
	if (String(targ) == "undefined") { targ = tar; }
	var s = eval('/(\\?|\\' + sep2 + ')' + arg + sep1 + val1 + '/g');
	var t = eval('window.' + targ);
	var l = t.location.href;
	if (l.match(s))
	{
		eval("location.href = (t.location.href).replace(" + s + ",'')");
	}
	else
	{
		goImp(arg, sep1, val2, sep2);
	}
}
function checkVars()
{
	if (
		typeof href != 'undefined' &&
		typeof title != 'undefined' &&
		typeof Imp != 'undefined' &&
		typeof Ret != 'undefined'
	)
	{
		return true;
	}
	return false;
}

var args = {};

if (checkVars())
{
	if (typeof arg == 'undefined') arg = 'vi';
	if (typeof sep1 == 'undefined') sep1 = '=';
	if (typeof val1 == 'undefined') val1 = '1';
	if (typeof val2 == 'undefined') val2 = '0';
	if (typeof sep2 == 'undefined') sep2 = '&';
	if (typeof tar == 'undefined') tar = 'self';
	getGET(sep1, sep2, val1);
	if (typeof args[arg] == "string" && args[arg] == val1)
	{
		if (document.title) document.title += title;
		document.writeln('<link ');
		document.writeln('rel="stylesheet" ');
		document.writeln('type="text/css" ');
		document.writeln('charset="utf-8" ');
		document.writeln('href="' + href + '" ');
		document.writeln('/>');
		if (typeof window.onload == "function" && window.scroll)
		{
			var impressionEC_old_onload = window.onload;
			window.onload = function()
			{
				if (impressionEC_old_onload)
				{
					impressionEC_old_onload();
					impressionEC_old_onload = null;
				}
				setTimeout('window.scroll(0,0)',500);
			}
		}
	}
}




// pour images aléatoires
// imprime un élément style ou un élément img
// arguments de la fonction (obj,mode,pos,attr,sel) :
/*

obj = array de 1 ou 2 dimension(s) (object) REQUIRED

exemple 1 dimension:

	var logosInterne = [
	  "../../images/iu/bandeau-secondaire/defaut.jpg",
	  "../../images/iu/bandeau-secondaire/img01.jpg",
	  "../../images/iu/bandeau-secondaire/img02.jpg",
	  "../../images/iu/bandeau-secondaire/img03.jpg"
	];


exemple 2 dimensions:

	var logosAccueil = [
	  {
	    "milieu":"../images/iu/accueil/phare/01-milieu.jpg",
	    "bas":"../images/iu/accueil/phare/01-bas.jpg",
	    "haut":"../images/iu/bandeaupiv/bandeaux/accueil/01-haut.jpg"
	  },
	  {
	    "milieu":"../images/iu/accueil/phare/02-milieu.jpg",
	    "bas":"../images/iu/accueil/phare/02-bas.jpg",
	    "haut":"../images/iu/bandeaupiv/bandeaux/accueil/02-haut.jpg"
	  },
	  {
	    "milieu":"../images/iu/accueil/phare/03-milieu.jpg",
	    "bas":"../images/iu/accueil/phare/03-bas.jpg",
	    "haut":"../images/iu/bandeaupiv/bandeaux/accueil/03-haut.jpg"
	  },
	  {
	    "milieu":"../images/iu/accueil/phare/04-milieu.jpg",
	    "bas":"../images/iu/accueil/phare/04-bas.jpg",
	    "haut":"../images/iu/bandeaupiv/bandeaux/accueil/04-haut.jpg"
	  }
	];

*/
// mode = 'img' ou 'style' (string) REQUIRED
// pos = clé du array si 2 dimensions (string) exemple: 'haut'
// attr = array des attributs (object) OPTIONAL exemple: ['alt=""','border="0"'] ou ['type="text/css"'] ou []
// sel = sélecteur CSS si mode='style' (string) exemple: '#menu-accueil'
function imagesAleatoires(obj, mode, pos, attr, sel)
{
	var out = '';
	if (typeof obj.alea == 'undefined')
	{
		obj.alea = Math.floor(Math.random()*obj.length);
	}
	out += (mode == 'img' ? '<img src="' : "\n\n<style");
	if (attr && attr.length && mode=='style' && sel)
	{
		for (var i=0; i<attr.length; i++)
		{
			out += (' ' + attr[i] + ' ');
		}
		out += (">\n" + sel + ' {background-image:url("');
	}
	out += (pos ? obj[obj.alea][pos] : obj[obj.alea]);
	out += (mode == 'img' ? '"' : "\");}\n");
	if (attr && attr.length && mode=='img')
	{
		for (var i=0; i<attr.length; i++)
		{
			out += (' ' + attr[i] + ' ');
		}
	}
	out += (mode == 'img' ? ' />' : "</style>\n\n");
	document.writeln(out);
}
