//	utilities

function prompt (s)
{
	window.status = s
};

function rgb(r, g, b)
{
	return r * 65536 + g * 256 + b;
};

function newImage(arg)
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	};
};

function dump(obj, withValues, withBreaks)
{
	var breakSequence = breakTag;
	if (!withBreaks) breakSequence = semiCol;
	
	if (withValues == undefined) withValues = false;
	var tmp = "";
	for (var prop in obj)
	{
		if (tmp != "") tmp += breakSequence;
		tmp += prop;
		if (withValues) tmp += "=" + obj[prop];
	};
	return tmp;
};

function max(a, b)
{
	if (a > b)
		return a;
	else
		return b;
};

function approxOk(a, b, tolerance)
{
	if (tolerance == undefined) tolerance = 0.1;
	//return (Math.abs((a - b) / max(a, b)) <= rate)
	return (Math.abs((a - b)) <= tolerance);
};

function callPopup(fileName, w, h, l, t, attr)
{
	var l, t, st;

	if (l == undefined) l = 0;
	if (t == undefined) t = 0;
	st = 'width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	if (attr != undefined) st += attr;
	window.open(fileName, '', st);
};

//	browser

var isNewGen = (document.getElementById);
var versionAgent = 0;
var strAgent = 0;

//	version du navigateur

function getAgent(st)
{
	strAgent = window.navigator.userAgent;
	var intIndex = strAgent.indexOf(st);
	if (intIndex != -1)
		versionAgent = parseInt(strAgent.substring(intIndex + st.length, intIndex + st.length + 1));
    else
    	versionAgent = 0;
	return (intIndex != -1);
};

function isIE()
{
	return getAgent("MSIE ");
};

function isNS()
{
	var tmp1, tmp2;

	tmp2 = isIE();
	tmp1 = getAgent("Netscape/");
	if ((!tmp1) && (!tmp2)) tmp1 = getAgent("Mozilla/");
	return tmp1;
};

//	dhtml

function findId(id, doc)
{
	if (doc == undefined) doc = document;
	for (var i = 0; i < doc.all.length; i++)
	{
		if (doc.all.item(i).id == id) return doc.all.item(i)
	}
}

function getEl(id, doc)
{
	if (doc == undefined) doc = document;
    if (isNewGen)
		return doc.getElementById(id);
    else
		if (isIE())
		{
			if (versionAgent <= 4)
				return findId(id, doc)
			else
				return doc.all[id];
		}
		if (isNS())
			return doc.layers[id];
};

function xgoto(url)
{
	window.location = url;
}
