/**
 *
 * @access public
 * @return void
 **/
function print_r(elementID)
{
	//element = document.getElementById(elementID);
	element = elementID;
	for (i in element)
	{
		document.getElementById('print_r').innerHTML += i + " = " + element[i] + "<br/>";
	}
}

/**
 *
 * @access public
 * @return void
 **/
String.prototype.getWidth = function(font, size, weight)
{
	var oText, oSpan, width;
	oText = document.createTextNode(this);
	oSpan = document.createElement("span");
	oSpan.style.position = "absolute";
	oSpan.style.fontFamily = font;
	oSpan.style.fontSize = size;
	oSpan.style.fontWeight = (weight ? weight : 'normal');
	oSpan.appendChild(oText);
	document.body.appendChild(oSpan);
	width = oSpan.offsetWidth;
	document.body.removeChild(oSpan);
	return width;
}

/**
 *
 * @access public
 * @return void
 **/
function showFullText(obj , offsetX, offsetY)
{
	objProp = get2DProperties(obj);
	ddrivetip(obj.fullValue, '', '', '', objProp._x + offsetX, objProp._y + offsetY);
	document.getElementById('dhtmltooltip').onmouseout = function()
	{
		hideddrivetip();
		this.onmouseout = '';
	}
}

/**
 *
 * @access public
 * @return void
 **/
function minimizeText(textValue, font, size, weight, maxWidth)
{
	points = '...';
	pointsWidth = points.getWidth(font, size, weight);
	while(textValue.getWidth(font, size, weight) + pointsWidth > maxWidth)
	{
		textValue = textValue.substr(0, textValue.length - 1);
	}
	return textValue + points;
}

/**
 *
 * @access public
 * @return void
 **/
function stringToNumber(strNumber)
{
	return parseFloat(strNumber.replace(' ', '').replace(',', '.'));
}

/**
 *
 * @access public
 * @return void
 **/
function number_format(number, decimals, dec_point, thousands_sep)
{
	//----o Conversion du nombre en chaine
	//--o Calcul d'arrondi
	number = (isNaN(number) ? '0' : (Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals)) + '');

	//----o Séparation entier et décimals
	arrIntegerDecimal = number.split('.');
	integer = arrIntegerDecimal[0];
	decimal = (arrIntegerDecimal.length > 1 ? arrIntegerDecimal[1] : '');

	//----o Formate décimals
	strDecimal = (decimal.length > 0 ? decimal.substr(0, decimals) : '');
	decimalLength = strDecimal.length
	if (decimalLength < decimals)
		for (i = 0; i < decimals - decimalLength; i++)
			strDecimal+= "0";

	//----o Formate entier
	strInteger = '';
	reste = integer + '';
	pos = reste.length - 3;
	while (pos > 0)
	{
		strInteger+= thousands_sep + reste.substr(pos);
		reste = reste.substr(0, pos);
		pos-= 3;
	}
	strInteger = reste + strInteger;

	//----o Assemblage number
	dec_point = (decimals > 0 ? dec_point : '');
	return strInteger + dec_point + strDecimal;
}

/**
 *
 * @access public
 * @return void
 **/
function openTab(divTabsPrefix, divTabContentPrefix, clickedTabNumber, clickedTabClass, divTabsClass)
{
	document.getElementById(divTabsPrefix + clickedTabNumber).blur();
	i = 1;
	while(document.getElementById(divTabsPrefix + i) != undefined)
	{
		document.getElementById(divTabsPrefix + i).className = divTabsClass;
		document.getElementById(divTabContentPrefix + i).style.display = 'none';
		i++;
	}
	document.getElementById(divTabsPrefix + clickedTabNumber).className = clickedTabClass;
	document.getElementById(divTabContentPrefix + clickedTabNumber).style.display = 'block';

}

/**
 *
 * @access public
 * @return void
 **/
function popup(file, filename, width, height)
{
	winpopup = window.open(file, filename, 'directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=' + width + 'px,height=' + height + 'px');
	winpopup.focus();
}