/**
*
* Bibliothèque de fonctions appliquées aux boutons de validation des formulaires pour les rendre flottant.
*
* Nom du fichier : $Archive:   O:/Kernel Livraison/archives/kernel/www/scripts/floating.js-arc  $
* Version        : $Revision:   1.1  $
*
* Auteur         : SOPRA Group - $Author:   adessert  $
* Modifié le     : $Date:   Jan 22 2007 16:53:36  $
*
*/


function HtmlObject(id){this.id=id;this.top=0;this.right=0;this.bottom=0;this.left=0;this.height=0;this.width=0;}
HtmlObject.prototype={toString:function(){var debug="";debug=debug+"id :"+this.id+"\n";debug=debug+"top :"+this.top+"\n";debug=debug+"right :"+this.right+"\n";debug=debug+"bottom :"+this.bottom+"\n";debug=debug+"left :"+this.left+"\n";debug=debug+"height :"+this.height+"\n";debug=debug+"width :"+this.width+"\n";},refreshPosition:function(){elt=this._getElement();if(elt!=null){var position=getAbsolutePosition(elt);this.top=position.top;this.left=position.left;this.height=elt.offsetHeight;this.width=elt.offsetWidth;this.right=this.left+this.width;this.bottom=this.top+this.height;}},_getElement:function(){var targetLayer=(document.getElementById)?document.getElementById(this.id):document.all(this.id);return targetLayer;}};DivObject.prototype=new HtmlObject();function DivObject(id){this.parent=HtmlObject;this.parent(id);this.makeMoveable=function(){elt=this._getElement();elt.style.position="absolute";};this.makeFixed=function(){elt=this._getElement();elt.style.position="";};this.move=function(x,y,imageElement){elt=this._getElement();hideShowCovered(this.id);elt.style.left=x+"px";this.left=x;elt.style.top=y+"px";this.top=y;if(imageElement.width!=elt.style.width||imageElement.left!=elt.style.left){elt.style.width=imageElement.width;this.width=imageElement.width;elt.style.left=imageElement.left;this.left=imageElement.left;}};}
ImageObject.prototype=new HtmlObject();function ImageObject(id){this.parent=HtmlObject;this.parent(id);this.setSizeOnDivObjectWidth=function(elt){var image=this._getElement();this.width=elt.width;image.width=elt.width;this.height=elt.height+5;image.height=elt.height+5;}
this.setSizeWithDivObjectFixed=function(elt){var image=this._getElement();this.width=elt.width;image.width=elt.width;this.height=1;image.height=1;}
this.isVisible=function(container,content){if(((this.top)>=container.top)&&((this.bottom)<=(container.bottom))){return true;}else{return false;}};}
ContainerObject.prototype=new HtmlObject();function ContainerObject(id){this.parent=HtmlObject;this.parent(id);this.isVisible=function(container,content){if(((this.top+content.height)>=container.top)&&((this.top+content.height)<=(container.bottom))){return true;}
else if((this.top<=container.top)&&((this.bottom-content.height)>=(container.bottom))){return true;}
else{return false;}}}
ScreenObject.prototype=new HtmlObject();function ScreenObject(){this.parent=HtmlObject;this.parent("screen");this.refreshPosition=function(){var nn6=document.getElementById&&!document.all;this.top=nn6?pageYOffset:document.body.scrollTop;this.left=0;this.width=nn6?window.innerWidth:document.body.clientWidth;this.right=this.width;this.height=nn6?window.innerHeight:document.body.clientHeight;this.bottom=this.top+this.height;}}
function FloatingBlock(containerID,blockID){this.componentID="_"+blockID;window[this.componentID]=this;var imageID="img";imageID=imageID+blockID.substring(0,1).toUpperCase();imageID=imageID+blockID.substring(1);this.waiting=true;this.containerElement=new ContainerObject(containerID);this.screenElement=new ScreenObject();this.imgElement=new ImageObject(imageID);this.divElement=new DivObject(blockID);}
FloatingBlock.prototype={moveSmoothly:function(){this.imgElement.refreshPosition();this.divElement.refreshPosition();this.screenElement.refreshPosition();this.containerElement.refreshPosition();var temp=document.body.scrollTop;if(temp==this.screenElement.top&&this.waiting){this.waiting=false;var registeredNameobject=this.componentID;setTimeout("window[\'"+registeredNameobject+"\'].doMove()",200,"JavaScript");this.waiting=true;}},doMove:function(){this.imgElement.setSizeOnDivObjectWidth(this.divElement);if(!this.imgElement.isVisible(this.screenElement,this.divElement)){if(this.containerElement.isVisible(this.screenElement,this.divElement,this.imgElement)){this.divElement.makeMoveable();var toX=this.imgElement.left;var toY=this.screenElement.bottom-this.divElement.height;if(toY<this.divElement.top){this.scrollUp();}else{this.scrollDown();}}else{this.divElement.makeFixed();this.imgElement.setSizeWithDivObjectFixed(this.divElement);}}else{this.divElement.makeFixed();this.imgElement.setSizeWithDivObjectFixed(this.divElement);}},scrollUp:function(){var pY=this.screenElement.top+this.screenElement.height-this.divElement.height;if((pY-this.divElement.top)<0){this.divElement.top+=Math.floor((pY-this.divElement.top)/20);this.divElement.move(this.divElement.left,this.divElement.top,this.imgElement);var registeredNameobject=this.componentID;setTimeout("window[\'"+registeredNameobject+"\'].scrollUp()",20,"JavaScript");}},scrollDown:function(){var pY=this.screenElement.top+this.screenElement.height-this.divElement.height;if((pY-this.divElement.top)>0){this.divElement.top+=Math.ceil((pY-this.divElement.top)/20);this.divElement.move(this.divElement.left,this.divElement.top,this.imgElement);var registeredNameobject=this.componentID;setTimeout("window[\'"+registeredNameobject+"\'].scrollDown()",20,"JavaScript");}}};
