
function Get_RefFonction( o_, fct_){
  return( function(){o_[ fct_]()});
}

function getLeft(htmlElementToLocate) {
	var htmlElement = htmlElementToLocate;
	var ElemLeft = htmlElement.offsetLeft;           
	while(htmlElement.offsetParent!=null) {   
		var ElemParent = htmlElement.offsetParent ;   
		ElemLeft += ElemParent.offsetLeft;
		htmlElement = ElemParent;
	}
	return ElemLeft;
}


function getTop(htmlElementToLocate) {
	var htmlElement = htmlElementToLocate;
	var ElemTop = htmlElement.offsetTop;            
	while(htmlElement.offsetParent!=null) {   
		var ElemParent = htmlElement.offsetParent;   
		ElemTop += ElemParent.offsetTop;
		htmlElement = ElemParent;
	}
	return ElemTop;
}




/*  Classe element placer */



function ElementPlacer (bkImage)
{
	this.screenWidth = screen.width;
	
	this.imageSize = this.screenWidth;
	this.imgWidth = this.screenWidth + "px";
	this.divName = new Array ();
	this.divLeft = new Array ();
	this.divTop = new Array (); 
	this.nbDiv = 0;
	this.image = bkImage;
	
	
	
	this.getImageWidth = getWidth;
	this.addDiv = addDiv;
	this.placeAll = placeAll;
}



function getWidth (percent)
{
	with (this)
	{
		imageSize = parseInt(screenWidth * percent/100);
		imgWidth = imageSize + "px";
		return (imageSize);
	}
}

function addDiv (divId,leftPerc,topPerc)
{
	with (this)
	{
		divName[nbDiv] = divId;
		divLeft[nbDiv] = leftPerc;
		divTop[nbDiv] = topPerc;
		nbDiv++;
		return nbDiv;
	}
}

function placeAll ()
{	
	with (this)
	{
		var HTMLImage = document.getElementById (image);
		var offSetL = getLeft (HTMLImage);
		var offSetT = getTop (HTMLImage);
		var i; 
		for (i=0; i < nbDiv; i++)
		{
			document.getElementById (divName[i]).style.position = "absolute";
			if (divLeft[i] == "c"){
				document.getElementById (divName[i]).style.left = (offSetL + parseInt (imageSize / 2) - parseInt (document.getElementById (divName[i]).offsetWidth) / 2) +"px";}
			else{
				document.getElementById (divName[i]).style.left = (offSetL + parseInt (divLeft[i] * imageSize / 100))+"px";}
			document.getElementById (divName[i]).style.top = (offSetT + parseInt (divTop[i] * imageSize / 100))+"px";
		}
	}
}

