function ebCPosParams(){this.nType=-1;this.nStartX=-1;this.nStartY=-1;this.nEndX=-1;this.nEndY=-1;this.nTime=-1;this.nWidthScale=-1;this.nScaleRef=0;this.nResWidth=0;this.nResHeight=0;this.fPosByBR=false;this.nBottom=-1;this.nRight=-1;this.fAutoSetBR=false;this.fUseCAForMovPoints=false;this.fCenteredPage=false;this.nPageWidth=-1;this.nRightAlignement=-1;this.fLimitVerSize=false;this.strRefObj="";this.refObj=null;this.nRefCorner=-1;this.fKeepProportions=true;this.print=printParams;function printParams(){var str="ebCPosParams: <br>"+"nType: " + this.nType + "<br>"+"nStartX: " + this.nStartX + "<br>"+"nStartY: " + this.nStartY + "<br>"+"nEndX: " + this.nEndX + "<br>"+"nEndY: " + this.nEndY + "<br>"+"nTime: " + this.nTime + "<br>"+"nWidthScale: " + this.nWidthScale + "<br>"+"nScaleRef: " + this.nScaleRef + "<br>"+"nResWidth: " + this.nResWidth + "<br>"+"nResHeight: " + this.nResHeight + "<br>"+"fPosByBR: " + this.fPosByBR + "<br>"+"nBottom: " + this.nBottom + "<br>"+"nRight: " + this.nRight + "<br>"+"fAutoSetBR: " + this.fAutoSetBR + "<br>"+"fUseCAForMovPoints: " + this.fUseCAForMovPoints + "<br>"+"fCenteredPage: " + this.fCenteredPage + "<br>"+"nPageWidth: " + this.nPageWidth + "<br>"+"fLimitVerSize: " + this.fLimitVerSize + "<br>"+"strRefObj: " + this.strRefObj + "<br>"+"refObj: " + this.refObj + "<br>"+"nRefCorner: " + this.nRefCorner + "<br>"+"fKeepProportions: "+this.fKeepProportions;gEbDbg.debug(str);}}function ebCPoint(){this.nX=-1;this.nY=-1;this.isEqual=isEqual;this.print=print;function isEqual(point){return((this.nX==point.nX)&&(this.nY==point.nY));}function print(){gEbDbg.debug("x="+this.nX + " y="+this.nY);}}function ebCMovementSection(objName){this.obj=null;this.startPos=null;this.endPos=null;this.fNoMovemet=false;this.currPos=new ebCPoint();this.nTime=-1;this.dtStartTime=null;this.dtEndTime=null;this.nSteps=1;this.nXStep=0;this.nYStep=0;this.nInterval=100;this.strTimeoutId="";this.strCBFunc="";this.strObjName=objName;this.start=start;this.update=update;this.clear=clear;this.move=move;this.end=end;this.print=function(){gEbDbg.debug("ebCMovementSection");};this.updateTime=updateTime;this.updateMovement=updateMovement;function start(obj,startPos,endPos,time,cbFunc){try{this.strCBFunc=cbFunc;this.startPos=startPos;this.endPos=endPos;this.obj=obj;this.nTime=time;this.nSteps=time/this.nInterval;if(startPos.isEqual(endPos))this.fNoMovemet=true;else this.fNoMovemet=false;setSteps(this);this.dtStartTime=(new Date()).getTime();this.dtEndTime=this.dtStartTime+time;gEbDbg.attention("Eyeblaster starting position (x,y): (" + startPos.nX + "," + startPos.nY +")");gEbDbg.debug("startPos.nX : " + startPos.nX + " startPos.nY: "+startPos.nY);this.currPos.nX=startPos.nX;this.currPos.nY=startPos.nY;this.move();}catch(e){gEbDbg.fatal("start: "+e.description);}}function update(startPos,endPos){this.startPos=startPos;this.endPos=endPos;setSteps(this);updatePos(this);}function clear(){try{if(this.strTimeoutId!="-1")window.clearTimeout(this.strTimeoutId);}catch(e){gEbDbg.info("ebCMovementSection.clear: fail on clearring the time out "+e.description);}}function move(){try{updatePos(this);if(this.fNoMovemet){if(this.nTime>=0)this.strTimeoutId=window.setTimeout(this.strObjName+".end()",this.nTime);return;}ebOnResMove(this.obj);var stCurrentTime=(new Date()).getTime();if(stCurrentTime>=this.dtEndTime){this.end();}else {gEbDbg.attention("movement time is not over, call "+this.strObjName + ".move() in " + this.nInterval + "millisec");this.strTimeoutId=window.setTimeout(this.strObjName+".move()",this.nInterval);}}catch(e){gEbDbg.fatal("move: "+e.description);}}function end(){this.strTimeoutId="-1";gEbDbg.debug("end: the movement should end, call the call back function (strCBFunc=" + this.strCBFunc +")");eval(this.strCBFunc);}function updateTime(){this.dtStartTime=(new Date()).getTime();this.nTime=this.dtEndTime-this.dtStartTime;this.nSteps=this.nTime/this.nInterval;}function updateMovement(){this.updateTime();if(this.fNoMovemet){this.fNoMovemet=false;this.clear();this.move();}}function updatePos(movObj){try{var dtCurrTime=(new Date()).getTime();var nCurrStep=(dtCurrTime-movObj.dtStartTime)/movObj.nInterval;if(nCurrStep>movObj.nSteps)nCurrStep=movObj.nSteps;var nCurrX=movObj.startPos.nX+nCurrStep*movObj.nXStep;var nCurrY=movObj.startPos.nY+nCurrStep*movObj.nYStep;gEbDbg.debug("ebCMovementSection.updatePos: nX=" + movObj.startPos.nX + ": nY="+movObj.startPos.nY);gEbDbg.attention("Eyeblaster updated position (x,y): (" + movObj.startPos.nX + "," + movObj.startPos.nY +")");movObj.obj.style.left=nCurrX+"px";movObj.obj.style.top=nCurrY+"px";gEbDbg.debug("ebCMovementSection.updatePos: the object position was set to " + movObj.obj.style.left + ":"+movObj.obj.style.top);}catch(e){gEbDbg.fatal("ebCMovementSection.updatePos: "+e.description);}}function setSteps(movObj){var nXDist=movObj.endPos.nX-movObj.startPos.nX;movObj.nXStep=nXDist/movObj.nSteps;var nYDist=movObj.endPos.nY-movObj.startPos.nY;movObj.nYStep=nYDist/movObj.nSteps;}}function ebCPosition(objName,adTI){var browser=new ebCBrowserCheck();this.movementSection=null;this.clientArea=null;this.obj=null;this.refObj=null;this.params=null;this.strCBFunc="";this.nMovAreaWidth=1;this.nMovAreaHeight=1;this.startPos=new ebCPoint();this.endPos=new ebCPoint();this.nResWidth=-1;this.nResHeight=-1;this.strObjName=objName;this.set=set;this.reset=reset;this.clear=clear;this.setMovementArea=setMovementArea;this.setSyncAdMovement=setSyncAdMovement;this.clientArea=new ebCClientArea(adTI);this.movementSection=new ebCMovementSection(this.strObjName+".movementSection");function set(params,container,obj,cbFunc){try{gEbDbg.debug("set: setting position for resource '"+obj.name+"'");this.params=params;this.obj=obj;this.strCBFunc=cbFunc;var nCenteredPageWidth=-1;if(this.params.fCenteredPage)nCenteredPageWidth=this.params.nPageWidth;this.clientArea.calc(container,this.params.nRightAlignement,nCenteredPageWidth);setResSize(this);this.setMovementArea();setMovementPoints(this);if(this.params.strRefObj!="")adjustCorner(this);this.movementSection.start(this.obj,this.startPos,this.endPos,this.params.nTime,this.strCBFunc);}catch(e){gEbDbg.fatal("ebCPosition.set: "+e.description);}}function reset(container){gEbDbg.debug2("<br>" + this.strObjName + ".reset()");if(typeof(container)!="undefined")this.clientArea.calc(container);else this.clientArea.calc();setResSize(this);this.setMovementArea();setMovementPoints(this);if(this.params.strRefObj!="")adjustCorner(this);this.movementSection.update(this.startPos,this.endPos);}function clear(){this.movementSection.clear();}function setMovementArea(posObj){if(typeof(posObj)=="undefined")posObj=this;posObj.nMovAreaWidth=posObj.clientArea.nWidth-posObj.nResWidth;posObj.nMovAreaHeight=posObj.clientArea.nHeight-posObj.nResHeight;gEbDbg.debug("setMovementArea: clientArea.nWidth:" + posObj.clientArea.nWidth + " nResWidth:"+posObj.nResWidth);if(posObj.nMovAreaWidth<=0)posObj.nMovAreaWidth=1;if(posObj.nMovAreaHeight<=0)posObj.nMovAreaHeight=1;gEbDbg.debug("setMovementArea: width:" + posObj.nMovAreaWidth + " height:"+posObj.nMovAreaHeight);}function setSyncAdMovement(destFlashObj){gEbDbg.debug("setSyncAdMovement");if(!this.params.nEndOffsetX)this.params.nEndOffsetX=0;if(!this.params.nEndOffsetY)this.params.nEndOffsetY=0;if(!this.params.nOffsetType)this.params.nOffsetType="px";var nOffsetX=this.params.nEndOffsetX;var nOffsetY=this.params.nEndOffsetY;if(this.params.nOffsetType=="%"){var nDestResWidth=destFlashObj.offsetWidth;var nDestResHeight=destFlashObj.offsetHeight;nOffsetX=(nOffsetX/100)*nDestResWidth;nOffsetY=(nOffsetY/100)*nDestResHeight;}var nDestResX=destFlashObj.offsetLeft;var nDestResY=destFlashObj.offsetTop;if((destFlashObj.style.position!="absolute")){nDestResX=ebGetRealLeft(destFlashObj);nDestResY=ebGetRealTop(destFlashObj);}var nEndX=nDestResX+nOffsetX;var nEndY=nDestResY+nOffsetY;if((this.params.nEndX!=nEndX)||(this.params.nEndY!=nEndY)){this.params.nStartX=this.obj.offsetLeft;this.params.nStartY=this.obj.offsetTop;this.params.nEndX=nEndX;this.params.nEndY=nEndY;this.movementSection.updateMovement();this.reset();}else{gEbDbg.debug("the position didn't change");}}function setResSize(posObj){try{var params=posObj.params;var nScale=params.nWidthScale;if(params.fPosByBR)resSizeByBR(posObj);else resSizeByWH(posObj);posObj.obj.style.height=posObj.nResHeight+"px";posObj.obj.style.width=posObj.nResWidth+"px";gEbDbg.debug("setResSize: " + " reference:" + posObj.params.nScaleRef + " width:" + posObj.nResWidth + " height:"+posObj.nResHeight);}catch(e){gEbDbg.error("setResSize "+e.description);}}function resSizeByBR(posObj){gEbDbg.debug("resSizeByBR");var params=posObj.params;var nBottom=params.nBottom;var nRight=params.nRight;if(params.fAutoSetBR){if(params.nType==1){nBottom=posObj.clientArea.nHeight;nRight=posObj.clientArea.nWidth;}else {nBottom=100;nRight=100;}}gEbDbg.debug("resSizeByBR: nBottom=" + nBottom + " right="+nRight);if(params.nType==1){posObj.nResWidth=nRight-params.nLeft;posObj.nResHeight=nBottom-params.nTop;}else {var nClientWidth=posObj.clientArea.nWidth;var nClientHeight=posObj.clientArea.nHeight;var nWidthScale=nRight-params.nLeft;var nHeightScale=nBottom-params.nTop;posObj.nResWidth=nWidthScale/100*nClientWidth;posObj.nResHeight=nHeightScale/100*nClientHeight;}params.fUseCAForMovPoints=true;gEbDbg.debug("resSizeByBR: nResWidth=" + posObj.nResWidth + " nResHeight="+posObj.nResHeight);}function resSizeByWH(posObj){var params=posObj.params;var nScale=params.nWidthScale;if(params.nScaleRef==0){gEbDbg.debug2("resSizeByWH: nResWidth=" + params.nResWidth + " nResHeight="+params.nResHeight);posObj.nResWidth=params.nResWidth*nScale/100;posObj.nResHeight=params.nResHeight*nScale/100;}else {gEbDbg.info("Resizable");var nClientWidth=posObj.clientArea.nWidth;var nClientHeight=posObj.clientArea.nHeight;var proportion=params.nResWidth/params.nResHeight;posObj.nResWidth=nClientWidth*nScale/100;posObj.nResHeight=posObj.nResWidth/proportion;if(!params.fKeepProportions){posObj.nResHeight=nClientHeight*nScale/100;}if(params.fLimitVerSize)limitVerSize(posObj);}gEbDbg.debug2("resSizeByWH: after calculating res size: nResWidth=" + posObj.nResWidth + " nResHeight="+posObj.nResHeight);}function limitVerSize(posObj){var nAreaHeight=posObj.clientArea.nHeight;if(posObj.params.nType==1)nAreaHeight-=posObj.params.nStartY;gEbDbg.debug("limitVerSize: nAreaHeight" + nAreaHeight + " posObj.params.nStartY: "+posObj.params.nStartY);if(posObj.nResHeight<=nAreaHeight)return;gEbDbg.info("limit the vertical size");var nProportions=posObj.nResWidth/posObj.nResHeight;posObj.nResHeight=nAreaHeight;posObj.nResWidth=posObj.nResHeight*nProportions;}function setMovementPoints(posObj){var x0=posObj.params.nStartX;var y0=posObj.params.nStartY;var x1=posObj.params.nEndX;var y1=posObj.params.nEndY;var nOffset=posObj.clientArea.nOffset;var areaWidth=posObj.nMovAreaWidth;var areaHeight=posObj.nMovAreaHeight;if(posObj.params.fUseCAForMovPoints){areaWidth=posObj.clientArea.nWidth;areaHeight=posObj.clientArea.nHeight;}if(posObj.params.nType==0){var nScrollLeft=posObj.clientArea.nScrollLeft;var nScrollTop=posObj.clientArea.nScrollTop;nOffset+=nScrollLeft;posObj.startPos.nX=x0/100*areaWidth+nOffset;posObj.startPos.nY=y0/100*areaHeight+nScrollTop;posObj.endPos.nX=x1/100*areaWidth+nOffset;posObj.endPos.nY=y1/100*areaHeight+nScrollTop;}else {if(posObj.params.nRightAlignement>-1){x0=areaWidth-x0;x1=areaWidth-x1;}posObj.startPos.nX=x0+nOffset;posObj.startPos.nY=y0;posObj.endPos.nX=x1+nOffset;posObj.endPos.nY=y1;}}function calcOffset(posObj){var offset=0;if((posObj.clientArea.fDefaultContainer)&&(posObj.params.fCenteredPage)){var nClientWidth=posObj.clientArea.nWidth;if(posObj.params.nPageWidth==-1)posObj.params.nPageWidth=nClientWidth;var nPageWidth=posObj.params.nPageWidth;if(nClientWidth<=nPageWidth)offset=0;else {offset=(nClientWidth-nPageWidth)/2.0;posObj.clientArea.nWidth=nPageWidth;}}gEbDbg.info("calcOffset: the offset needed to position the object (in case of a centered page) is "+offset);return offset;}function setAbsPoints(posObj){posObj.startPos.nX=posObj.params.nStartX;posObj.startPos.nY=posObj.params.nStartY;posObj.endPos.nX=posObj.params.nEndX;posObj.endPos.nY=posObj.params.nEndY;posObj.startPos.print();posObj.endPos.print();}function adjustCorner(posObj){gEbDbg.debug("set the reference corner");var offsetLeft=0;var offsetTop=0;switch(posObj.params.nRefCorner){case 1:break;case 2:offsetLeft=-posObj.nResWidth;break;case 3:offsetTop=-posObj.nResHeight;break;case 4:offsetLeft=-posObj.nResWidth;offsetTop=-posObj.nResHeight;break;default:gEbDbg.info("Illegal reference corner "+posObj.params.nRefCorner);break;}posObj.startPos.nX+=offsetLeft;posObj.endPos.nX+=offsetLeft;posObj.startPos.nY+=offsetTop;posObj.endPos.nY+=offsetTop;}}if(typeof(ebScriptLoaded)!="undefined")ebScriptLoaded("Position");if(typeof(ebOnScriptLoaded)!="undefined")ebOnScriptLoaded("Position");