<!--

function _div_object(div)
{
	var cdiv = null;

	if(typeof(div)==="string")
	{
		cdiv = document.getElementById(div);
	}
	else
	{
		cdiv = div;
	}
	
	return cdiv;
}


function _div_table_removeRow(tableReference,rowReference)
{
	
}

function _div_table_addRow(tableReference,rowReference,columns,classNames)
{
	var nColumns = columns.length;

	var table = document.getElementById(tableReference);
	var tr = document.createElement("tr");
	tr.setAttribute('id', rowReference);
	
	for(var i=0; i<nColumns; i++)
	{	
		var td = document.createElement("td");

		if(classNames[i]!=null)
		{
			td.className = classNames[i];
		}
		
		td.innerHTML = columns[i];
	
	//var txt = document.createTextNode(columns[i]);
		//td.appendChild(txt);
		tr.appendChild(td);
	}
	
	table.appendChild(tr);
}

function _div_centerX(div)
{
	var posx = parseInt(document.body.clientWidth/2) - parseInt(_div_getWidth(div)/2);

	_div_moveX(_div_object(div),posx);
}

function _div_center(div)
{
	var posx = parseInt(document.body.clientWidth/2) - parseInt(_div_getWidth(div)/2);
	//var posy = parseInt(document.body.clientHeight/2) - parseInt(_div_getHeight(div)/2);
	
	//alert(posx+' '+posy);
	
	_div_move(div,posx);
}

function _div_transform_translate(div,x,y)
{	
	if(x==undefined)
	{
		_div_setStyleProperty(div,'-webkit-transform','translateY('+y+'px)');
	}
	else if(y==undefined)
	{
		_div_setStyleProperty(div,'-webkit-transform','translateX('+x+'px)');
	}
	else
	{
		_div_setStyleProperty(div,'-webkit-transform','translate('+x+'px '+y+'px)');
	}
}


function _div_resize(id,width,height)
{
	//alert('_div_resize('+width+' '+height+')');

	if(width!=undefined) _div_setStyleProperty(id,'width',width+'px');
	if(height!=undefined) _div_setStyleProperty(id,'height',height+'px');
}

function _div_setParent(id,newParentNode)
{
	//alert('_div_setParent()'+id+' '+newParentNode);
	var div = _div_object(id);
	var newParentNode = _div_object(newParentNode);
	
	var oldParent = _div_getParent(div);
	
	if(typeof(oldParent)!=='undefined')
	{
		oldParent.removeChild(div);
	}
	
	newParentNode.appendChild(div);
}

function _div_getParent(id)
{
	var element = document.getElementById(id);
		
	if( element != undefined )
    {
    	return document.getElementById(id).parentNode;
	}
}

function _div_setBackgroundColor(divname,color)
{
	var div = document.getElementById(divname);
	
	div.style.backgroundColor = color;
}

function _div_setBackgroundImage(divname,imagePath)
{
	var div = document.getElementById(divname);
	
	//alert(div);
	
	div.style.backgroundImage = 'url('+imagePath+')';
}

function _div_setContent(div,content)
{
	//alert('setContent() div='+div);
	
	cdiv = _div_object(div);
	
	cdiv.innerHTML = content;
}

function _div_changeId(divname,newname)
{
	var div = document.getElementById('divname');
	div.setAttribute('id', newname);
}

function _div_move(div,xpos,ypos)
{
	//alert('_div_move() '+div+' xpos='+xpos+' ypos='+ypos );
	
	
	var cdiv = _div_object(div);


	if(typeof(xpos)!=='undefined') _div_setStyleProperty(div,'left',xpos+'px');
	if(typeof(ypos)!=='undefined') _div_setStyleProperty(div,'top',ypos+'px');
}

function _div_moveX(div,xpos)
{
	div.style.setProperty('left',xpos+'px',null);
	//_div_setStyleProperty('left',xpos+'px');
}

function _div_remove(div)
{
	//alert('_div_remove('+div+')');

	var cdiv = null;
	
	if(typeof(div)==='string')
	{
    	cdiv = document.getElementById(div);
    }
    else
    {
    	cdiv = div;
    }
    
	//var parent = cdiv.parentNode.id;
	var parent = cdiv.parentNode;
	//alert(parent);
	
	parent.removeChild(cdiv);
}


function _div_create2(parentdiv,classname,position)
{
	var newdiv = document.createElement('div');
	
	if(classname!='')
	{
		//alert(document.styleSheets[classname]);
	}
	
	//newdiv.setAttribute('id', id);
	
	newdiv.className = classname;
	
	if(typeof(position)!=='undefined')
	{
		newdiv.style.position = position;
	}
	else
	{
		newdiv.style.position = "absolute";
	}
	
	if(typeof(parentdiv)==="string")
	{
		if(parentdiv=='')
		{
			// aucun rattachement
		}	
		else if(parentdiv=='body')
		{
			document.body.appendChild(newdiv);
		}
		else
		{
			parentdiv = document.getElementById(parentdiv);
			parentdiv.appendChild(newdiv);
		}
	}
	else
	{
		parentdiv.appendChild(newdiv);
	}
	
	return newdiv;
}


function _div_create(id,classname,parentdiv,width,height,left,top,html)
{
	var newdiv = document.createElement('div');
	
	newdiv.setAttribute('id', id);
	
	if (width) { newdiv.style.width = width+'px'; }
	if (height) { newdiv.style.height = height+'px'; }

	if ((left || top) || (left && top))
	{
		newdiv.style.position = "absolute"; 
		if (left) { newdiv.style.left = left+'px'; }
		if (top) { newdiv.style.top = top+'px'; }
	} 
	
	newdiv.className = classname;
	
	newdiv.innerHTML = html;

	/*	
	if (html!='')
	{
		newdiv.innerHTML = html;
	}
	else
	{
		newdiv.innerHTML = "";
	}
	*/
	
	if(typeof(parentdiv)==="undefined")
	{
		document.body.appendChild(newdiv);
	}
	else if(typeof(parentdiv)==="string")
	{
		if(parentdiv=='body')
		{
			document.body.appendChild(newdiv);
		}
		else
		{
			parentdiv = document.getElementById(parentdiv);
			parentdiv.appendChild(newdiv);
		}
	}
	else
	{
		parentdiv.appendChild(newdiv);
	}
	
	return newdiv;
}

function _div_switchVisibility(divname)
{
	var visibility = _div_getStyleProperty(divname,'visibility');

	//alert(visibility);

	if(visibility=='visible')
	{
		_div_hide(divname);
	}
	else
	{
		_div_unhide(divname);
	}
}

function _div_hideAfterDisappear(div)
{

}

function _div_disappear(div,duration)
{
	//var cdiv = _div_object(div);

	var browser_preffix = _getBrowserStylesPreffix();

	_div_setStyleProperty(div,'opacity',0.0);
	_div_setStyleProperty(div,browser_preffix+'transition-duration',duration+'s');
	
	var timer = setTimeout(function(){_div_hide(div);},parseInt(1000*duration+200));
	
}

function _div_appear(div,duration)
{
	//var cdiv = _div_object(div);

	_div_unhide(div);
	_div_setStyleProperty(div,'opacity',0.0);
	
	var timer = setTimeout(function(){_div_hide(div);},duration);
	
}


function _div_unhide(divname)
{
	_div_setStyleProperty(divname,'display','block');	
	_div_setStyleProperty(divname,'visibility','visible');
	_div_setStyleProperty(divname,'opacity','1.0');
}

function _div_hide(divname)
{
	_div_setStyleProperty(divname,'display','none');
	_div_setStyleProperty(divname,'visibility','hidden');
	_div_setStyleProperty(divname,'opacity','0.0');
}

function _div_getWidth(div)
{
	var cdiv = _div_object(div);
	var width = 0;

	if(cdiv.clientWidth)
	{
		width = parseInt(cdiv.clientWidth);
	}
	else if(cdiv.innerWidth)
	{
		width = parseInt(cdiv.innerWidth);
	}
	else if(cdiv.offsetWidth)
	{
		width = parseInt(cdiv.offsetWidth);
	}
	else if(cdiv.style.width)
	{
		width = parseInt(cdiv.style.width);
	}
	else
	{
		width = 0;
	}

	//alert('width de '+div+'='+width);

	return width;
}

function _div_getHeight(div)
{
	var cdiv = _div_object(div);
	var height = 0;

	if(cdiv.innerHeight)
	{
		height = parseInt(cdiv.innerHeight);
	}
	else if(cdiv.offsetHeight)
	{
		height = parseInt(cdiv.offsetHeight);
	}
	else if(cdiv.style.height)
	{
		height = parseInt(cdiv.style.height);
	}
	else
	{
		height = 0;
	}

	return height;
}


function _div_getXPos(div)
{
	var r = 0;
	
	while( div != null )
	{
		r += div.offsetLeft;
		div = div.offsetParent;
	}
	
	return r;
}

function _div_getYPos(div)
{
	var r = 0;
	
	while( div != null )
	{
		r += div.offsetTop;
		div = div.offsetParent;
	}
	
	return r;
}

function _div_setOpacity(div,value)
{	
	try
	{
		value = value.toFixed(2);
	}
	catch(err)
	{
		//alert('_div_setOpacity('+div+' '+value+') error');
	}
	
	_div_setStyleProperty(div,'opacity',value);
}


/* Lecture d'un parametre d'un element DIV */
function _div_getStyleProperty(div,property)
{
	var cdiv = _div_object(div);

    if (cdiv)
    {
    	return cdiv.style[property];
    }
    else
    {
    	//alert('erreur'+cdiv);
    }
}

/* Change un parametre d'un element DIV */
function _div_setStyleProperty(div,property,value)
{
	var cdiv = _div_object(div);

    if (cdiv)
    {
    	if(cdiv.style[property]!=value)
       	{
			
			if(cdiv.style.setProperty)
			{				
				try
				{
					cdiv.style.setProperty(property,value,null);
				}
				catch(err)
				{
					//alert(property+'=>'+value+' error');
				}
       		}
       		else
       		{
       			cdiv.style.setAttribute(property,value);
       		}
       	}
       	else
       	{
       		//alert('valeur identique');
       	}
    }
}



//-->
