function setVisible ( divId , value )
{
	var element = document.getElementById ( divId );
	if ( value )
		element.style.display = "block";
	else
		element.style.display = "none";

}

function setDepartmentsPositions ( departmentsArray )
{
	var departmentsNumber = departmentsArray.length;
	var logoPosition;
	var labelPosition;
	var areaWidth = 890 / departmentsNumber;
	var labelWidth = areaWidth - 70;
	var element;

	for ( var i = 0 ; i < departmentsNumber ; ++i )
	{
		logoPosition = 10 + i * areaWidth;
		labelPosition = logoPosition + 55;

		document.getElementById ( departmentsArray[i] + "Logo" ).style.marginLeft = logoPosition.toString() + "px";
		element = document.getElementById ( departmentsArray[i] + "Label" );
		element.style.marginLeft = labelPosition.toString() + "px";
		element.style.width = labelWidth.toString() + "px";
	}
}

function setProgressiveColor ( divId , startColor , endColor )
{
	if ( startColor != endColor )
	{
		var max = startColor.length;

		if ( max != endColor.length )
			return endColor;
		else if ( max == 3 )
		{
			max = 6;
			startColor = startColor.charAt ( 0 ) + startColor.charAt ( 0 ) + startColor.charAt ( 1 ) + startColor.charAt ( 1 ) + startColor.charAt ( 2 ) + startColor.charAt ( 2 );
			endColor = endColor.charAt ( 0 ) + endColor.charAt ( 0 ) + endColor.charAt ( 1 ) + endColor.charAt ( 1 ) + endColor.charAt ( 2 ) + endColor.charAt ( 2 );
		}
		else if ( max != 6 )
			return endColor;

		var inc =  new Array ( 1 , 1 , 1 );;

		var startHexValue;
		var startDecValue;
		var endHexValue;
		var endDecValue;
		for ( var i = 0 ; i < max ; i += 2 )
		{
			startHexValue = startColor.substr ( i , 2 );
			startDecValue = parseInt ( startHexValue , 16 ) + 1;
			endHexValue = endColor.substr ( i , 2 );
			endDecValue = parseInt ( endHexValue , 16 ) + 1;

			if ( startDecValue > endDecValue )
				inc[i/2] = -inc[i/2];
			else if ( startDecValue == endDecValue )
				inc[i/2] = 0;

		}

		var currentColor = "";
		var currentHexValue;
		var currentDecValue;
		for ( var i = 0 ; i < max ; i += 2 )
		{
			currentHexValue = startColor.substr ( i , 2 );
			currentDecValue = parseInt ( currentHexValue , 16 ) + inc[i/2];
			currentHexValue = currentDecValue.toString ( 16 );
			currentColor += ( currentHexValue.length < 2 ? "0" : "" ) + currentDecValue.toString ( 16 );
		}


		document.getElementById ( divId ).style.background = "#" + currentColor;

		window.setTimeout ( "setProgressiveColor ( '" + divId + "' , '" + currentColor + "' , '" + endColor + "' )" , 30 );
	}
}

function onSubmitClick()
{
	document.forms["searchForm"].submit();
}


function onSearchClick()
{
	if ( document.getElementById('recherche').value == 'Rechercher...' )
		document.getElementById('recherche').value = '';
}

function onSearchMouseOver()
{
	if ( document.getElementById('recherche').value == '' )
		document.getElementById('recherche').value='Rechercher...';
}

