<?xml version="1.0" encoding="UTF-8"?>
<application-components>
  <!--
			Reference: http://www.imnmotion.com/documents/html/technical/dhtml/mdiOverview.html
			The 'manager' component's mousemove code was adapted from the MDI CContainer class.
			The 'window' component's behavior and delegation to 'manager' was modeled after the MDI CWindow class.
			Much of the MDI coding guff was completely dropped

	-->

  <application-component id="manager">
    <![CDATA[
			component_destroy:function(){
				//org.cote.js.dom.event.removeEventListener(this.getContainer(),"mousemove",this._prehandle_mousemove);
			},
			component_init:function(){
				// bug note: getContainerId is coming through as an object because the component is being tied directly to the engine object
				// but, the getContainer() correctly points to the engine HTML element
				//
				
				if(typeof this.getContainerId() != "object"){
					alert("Invalid container reference.  terminating object");
					this.destroy();
					return;
				}
				
				var _s = this.getStatus();
				this.setTopWindow(null);
				this.createHandler("mousemove",0,0,1);
				this.createHandler("document_scroll",0,0,1);
				
				org.cote.js.dom.event.addEventListener(this.getContainer(),"mousemove",this._prehandle_mousemove);
				org.cote.js.dom.event.addEventListener(window,"scroll",this._prehandle_document_scroll);

				_s.mod_x = 0;
				_s.mod_y = 0;
				
				_s.animate_delay = 10;
				_s.animate_step = 40;
				_s.animate_count = 0;
        
				_s.tile_top = 10;
				_s.tile_left = 10;
				_s.tile_width = 200;
				_s.tile_height = 20;
		        _s.keep_in_view = 1;
				_s.cascade_height = 250;
				_s.cascade_width = 450;
				_s.tile_mode = 1;
		        
				this.getPointers().frame_screening = 0;
				this.getPointers().frame_screen = 0;
				this.getPointers().screen = 0;
				this.getPointers().screen_owner = 0;
				this.getPointers().windows = [];
		        
				_s.screening = 0;
				this.createHandler("window_resize",0,0,1);
				org.cote.js.dom.event.addEventListener(window,"resize",this._prehandle_window_resize);
			},
      _handle_window_resize : function(){
        this.RepositionScreen();
        this.Tile();
      },
			_handle_document_scroll : function(e){
				this.Tile();
				//this.KeepInView();
			},
			/*
	  KeepInView : function(){
	    var a = [], _p = this.getPointers(), _s = this.getStatus(), o, i = 0, _sw, iC = 0, iCT=0;
        var iDT = document.documentElement.clientHeight;
        var iDW = document.documentElement.clientWidth;
        var iVH = org.cote.js.dom.css.getAbsoluteTop(this.getContainer());
        var iOT = this.getContainer().offsetHeight;
        var iOW = this.getContainer().offsetWidth;
        for(; i < _p.windows.length; i++){
			o = org.cote.js.registry.ObjectRegistry.getObject(_p.windows[i]);
			var iUW = o.getIsBound() && iOW < iDW ? iOW : iDW;
			var iUT = o.getIsBound() && iOT < iDT ? iOT : iVH + document.documentElement.scrollTop;
			_sw = o.getStatus();

			if(!o.getIsMinimized() && !o.getStatus().is_closed){
				
				window.status = org.cote.js.dom.css.getAbsoluteTop(o.getContainer()) + ":" + o.getContainer().offsetTop + ":" + (iVH + document.documentElement.scrollTop);
			}
			
		}

	  },
	  */
      SetTileMode : function(i){
				this.getStatus().tile_mode = i;
      },
      GetWindowByName : function(n){
				var a = this.getPointers().windows, o;
				for(var i = 0; i < a.length; i++){
					o = org.cote.js.registry.ObjectRegistry.getObject(a[i]);
					if(!o || typeof o.getContainerComponentId != "function") continue;
					if(o.getContainerComponentId() == n) return o;
				}
				return 0;
      },
      GetWindowIds : function(){
				return this.getPointers().windows;
      },
      RegisterWindow : function(i){
        var a = this.getPointers().windows;
        a[a.length] = i;
      },
	  CheckAllReadyToClose : function(f){
		var i = 0, _p = this.getPointers(),b = 1,w;
		for(; i < _p.windows.length;i++ ){
			w = org.cote.js.registry.ObjectRegistry.getObject(_p.windows[i]);
			if(!this.CheckReadyToClose(w)){
				b = 0;
				if(f){
					w.restore();
					w.getFocus();
				}
				break;
			}
		}
		return b;
	  },
	  CheckReadyToClose : function(o){
		if(typeof o == "string") o = this.GetWindowByName(o);
		if(!o) return 1;
		if(o.GetChangeCount() > 0) return 0;
		return 1;
	  },
      UnRegisterWindow : function(d){
				var x = -1, i = 0, _p = this.getPointers();
				for(; i < _p.windows.length;i++ ){
					if(_p.windows[i] == d){
						x = i;
						break;
					}
				}
				var w = _p.windows;
				if(x >= 0){
					w.splice(x,1);
				}
      },
      
      ReturnFrameScreen: function(b){
        var _p = this.getPointers();
        this.getStatus().frame_screening = 0;
        if(!b && _p.frame_screen) _p.frame_screen.style.display = "none";
      },
      RequestFrameScreen : function(){
        var _p = this.getPointers();
        this.ReturnFrameScreen(1);
        if(!_p.frame_screen){
          _p.frame_screen = document.createElement("div");
          _p.frame_screen.style.position = "absolute";
          _p.frame_screen.style.display = "block";
          _p.frame_screen.style.zIndex = 17;
          _p.frame_screen.style.top = "0px";
          _p.frame_screen.style.left = "0px";
          // _p.frame_screen.style.backgroundColor = "#CFCFCF";
          _p.frame_screen.onselectstart = function(){return false;};
          _p.frame_screen.onmousedown = function(){return false;};
	        document.body.appendChild(_p.frame_screen);
        }
        _p.frame_screen.style.display = "block";
        this.getStatus().frame_screening = 1;
        this.RepositionFrameScreen();
      
      },
      
      RepositionFrameScreen : function(){
        if(!this.getStatus().frame_screening) return;
        var _p = this.getPointers();
        var de = document.documentElement;
        _p.frame_screen.style.width = "1px";
        _p.frame_screen.style.height = "1px";
        _p.frame_screen.style.width = ((de.scrollWidth > de.offsetWidth ? de.scrollWidth : de.offsetWidth) - 20) + "px";
        _p.frame_screen.style.height = ((de.scrollHeight > de.offsetHeight ? de.scrollHeight : de.offsetHeight) - 20) + "px";

      },
	    ReturnScreen: function(b){
        var _p = this.getPointers();
        this.getStatus().screening = 0;
        if(!b && _p.screen) _p.screen.style.display = "none";
        _p.screen_owner = 0;
      },
      RequestScreen : function(o){
        var _p = this.getPointers();
        this.ReturnScreen(1);
        _p.screen_owner = o;
        //o.getContainer().style.display = "none";
        if(!_p.screen){
          _p.screen = document.createElement("div");
          _p.screen.className = "gizmo_screen";
          _p.screen.style.display = "block";
          // _p.screen.style.width = "100%";
          // _p.screen.style.height = "100%";
          _p.screen.bound = o.getIsBound();
          if(o.getIsBound()) this.getContainer().appendChild(_p.screen);
          else document.body.appendChild(_p.screen);
        }
        _p.screen.style.display = "block";
        //o.getContainer().style.display = "block";
        this.getStatus().screening = 1;
        this.RepositionScreen();
        
      },
      RepositionScreen : function(){
        if(!this.getStatus().screening) return;
        
        var _p = this.getPointers();
        var de = document.documentElement;
        _p.screen.style.width = "1px";
        _p.screen.style.height = "1px";
        var o = de;
        if(_p.screen.bound) o = this.getContainer();
        _p.screen.style.width = (o.scrollWidth > o.offsetWidth ? o.scrollWidth : o.offsetWidth) + "px";
        _p.screen.style.height = (o.scrollHeight > o.offsetHeight ? o.scrollHeight : o.offsetHeight) + "px";

      },
		CenterWindow : function(w){
			var _p = this.getPointers();
			var de = document.documentElement;
			if(document.body.scrollTop > de.scrollTop) de = document.body;
			var iDH = document.documentElement.clientHeight;//Math.max(document.documentElement.clientHeight,document.body.clientHeight);
			var o = de;
			if(w.getIsBound()) o = this.getContainer();
			
			var iW = w.getContainer().offsetWidth;
			var iH = w.getContainer().offsetHeight;
			//alert(iW + "," + iH);
			var iTop = (iDH / 2 - iH / 2);
			
			if(de.scrollTop > 0 || (w.getIsBound() && iDH > 0 && o.offsetHeight > iDH)) iTop = de.scrollTop;
			//alert(iH + ":" + iDH + ":" + de.scrollTop + ":" + iTop);
			//alert(iDH + ":" + o.offsetHeight + ":" + de.scrollTop);
			//w.setTitle(iDH + ":" + o.offsetHeight + ":" + iTop);
			w.moveTo((o.offsetWidth / 2 - iW / 2) + "px",iTop + "px");
		},
		
			_handle_mousemove:function(e){
						
				var evt=org.cote.js.dom.event._gevt(e);
				
				if(this.getTopWindow() && (this.getTopWindow().getStatus().is_moving || this.getTopWindow().getStatus().is_resizing)){
					
					var iX = evt.clientX;
					var iY = evt.clientY;
					var oObj = this.getContainer();
					
					var oWin = this.getTopWindow();
					
					var iCW = Math.max(document.documentElement.clientWidth,document.body.clientWidth);
					var iCH = Math.max(document.documentElement.clientHeight,document.body.clientHeight);

					var oFr = oWin.getPointers().active_frame;
					if(oWin.getStatus().is_resizing){
						var oTemp= (oWin.getIsBound() ? oObj : document.documentElement);
						var iNewW=iX - oFr.offsetLeft - oTemp.offsetLeft + document.documentElement.scrollLeft;
						var iNewH=iY - oFr.offsetTop - oTemp.offsetTop + document.documentElement.scrollTop;
						if(oWin.getStatus().is_bound){
							var iTop3 = oObj.offsetTop + oObj.offsetHeight +  this.getStatus().mod_y;
							var iLeft3 = oObj.offsetLeft + oObj.offsetWidth +  this.getStatus().mod_x;
							if(iY >= iTop3 || iX >= iLeft3) return;
						}
						if(iNewH > 50 && iNewW > 50){
							oFr.style.height = iNewH + "px";
							oFr.style.width = iNewW + "px";
						}
						
					}
					if(oWin.getStatus().is_moving){
						/*
							Unbound windows should be sized against their parent.
						*/
						//var oTemp= (oWin.getIsBound() ? oObj : document.documentElement);

						/*
							Bound or unbound, windows should not be able to be moved into a position where the 
							user can't "grab" the title bar.  In this case, the window can't be moved beyond the point where
							the mouse pointer exits the frame.
						*/

						//var iX2 = org.cote.js.dom.css.getAbsoluteLeft(oTemp) + oTemp.clientWidth;
						//var iY2 = org.cote.js.dom.css.getAbsoluteTop(oTemp) + oTemp.clientHeight;
						var iX2 = 0;
						
						var iY2 = 0;
						
						if(oWin.getIsBound()){
							iX2 = org.cote.js.dom.css.getAbsoluteLeft(oObj) + oObj.clientWidth;
							iY2 = org.cote.js.dom.css.getAbsoluteTop(oObj) + oObj.clientHeight;
						}
						else{
							iX2 = iCW;
							iY2 = iCH;

						}
						
						//window.status = iX + ":" + iX2;

						iX=(iX < 0)?0:(iX > iX2)?iX2:iX;
						iY=(iY < 0)?0:(iY > iY2)?iY2:iY;
						var iNewX=iX - oWin.getStatus().track_x;
						var iNewY=iY - oWin.getStatus().track_y;
						
						if(!oWin.getIsBound()){
							iNewY=(iNewY<0)?0:iNewY;
							oFr.style.left = iNewX + "px";
							oFr.style.top = iNewY + "px";
							//document.title = "Unbound: " + iNewX + "," + iNewY;
						}
						else{
						
							var iLeft1=oFr.offsetLeft + oObj.offsetLeft;
							var iLeft2=oObj.offsetLeft;
							var iLeft3=iLeft1 + oFr.offsetWidth;
							var iLeft4=iLeft2 + oObj.offsetWidth;
							var iTop1=oFr.offsetTop + oObj.offsetTop;
							var iTop2=org.cote.js.dom.css.getAbsoluteTop(oObj);
							var iTop3=iTop1 + oFr.offsetHeight;
							var iTop4=iTop2 + oObj.offsetHeight;
							//window.status=iTop1 + ":" + iTop2 + " / " + iTop3 + ":" + iTop4 + " | " + iLeft1 + ":" + iLeft2 + " / " + iLeft3 + ":" + iLeft4;		
							//window.status = iX + ":" + oWin.getStatus().track_x;//iNewX + "," + iNewY;
							if((iLeft1>=iLeft2)&&(iLeft3<=iLeft4)){
								var iCheckFarLeft=oObj.offsetWidth - oFr.offsetWidth - this.getStatus().mod_x;
								if(iNewX<0){
									iNewX=0;
								}
								if(iNewX>iCheckFarLeft){
									iNewX=iCheckFarLeft;
								}
								oFr.style.left = iNewX + "px";
							}
							else{
								if(iLeft3>iLeft4){
									oFr.style.left = (iLeft4 - iLeft2 - oFr.offsetWidth) + "px";
								}
							}
							if((iTop1>=iTop2)&&(iTop3<=iTop4)){
								var iCheckFarTop=oObj.offsetHeight - oFr.offsetHeight - this.getStatus().mod_y;
								if(iNewY<0){
									iNewY = 0;
								}
								if(iNewY>iCheckFarTop){
									iNewY = iCheckFarTop;
								}
								oFr.style.top = iNewY + "px";
							}
							else{
								if(iTop3>iTop4){
									oFr.style.top=(iTop4 - iTop2 - oFr.offsetHeight) + "px";
								}
							}			
					 } // end if bound
					} // end if is moving
				} // end if valid window object

			},
			getTopWindow:function(){
				return this.getPointers().top_window;
			},
			setTopWindow:function(o){
			  this.getPointers().top_window = o;
			},
			setFocus:function(o){
				if(this.getTopWindow() && this.getTopWindow() != o){
					var y = this.getTopWindow()
					y.getContainer().style.zIndex = y.getStatus().lostFocusIndex;
					y._handle_lost_focus();
				}
				this.setTopWindow(o);
				if(o)
					o.getContainer().style.zIndex = (o.getStatus().is_dialog ? o.getStatus().dialogFocusIndex : o.getStatus().setFocusIndex);
				
			},
			
			Cascade : function(){
				var _p = this.getPointers(), o, i=0, iC = 0, iL = 1,l;
				var iDT = (document.body.offsetHeight > document.documentElement.offsetHeight ? document.body.offsetHeight : document.documentElement.offsetHeight);
				var iOT = this.getContainer().offsetHeight;
				
 				for(; i < _p.windows.length; i++){
					o = org.cote.js.registry.ObjectRegistry.getObject(_p.windows[i]);
					if(!o.getStatus().can_move) continue;
					var iUT = o.getIsBound() ? iOT : iDT;
					var iT = (iC * 50);
					l = (iL * 25) + (iC * 25);
					o.blur();
					if(o.getIsMinimized()){
						b = o.getStatus().manage_minimize;	
						o.getStatus().manage_minimize = 0;
						o.restore(1);
						o.getStatus().manage_minimize = b;
					}
					

					// o.resizeTo(250,250);
					if((iT + this.getStatus().cascade_height) > iUT){
						iL += 5;
						iC = 0;
						iT = 0;
						l = (iL * 25) + (iC * 25);
						
					}
					iC++;
					
					o.animate(o.getContainer().offsetLeft,o.getContainer().offsetTop,l,iT,0,0,0,1,this.getStatus().cascade_width,this.getStatus().cascade_height);
					
				}

          // _p.manager.Tile();
          // this.animate(this.getContainer().offsetLeft,this.getContainer().offsetTop,_s.last_left,_s.last_top,0,0,0,1,_s.last_width,_s.last_height);
      },
      ManageMaximize : function(o){
        var iDT = document.documentElement.clientHeight;//(document.body.offsetHeight > document.documentElement.offsetHeight && document.body.scrollHeight > document.body.offsetHeight ? document.body.offsetHeight : document.documentElement.offsetHeight);
        var iDW = document.documentElement.clientWidth;//(document.body.offsetWidth > document.documentElement.offsetWidth ? document.body.offsetWidth : document.documentElement.offsetWidth);        

        var iOT = this.getContainer().offsetHeight;
        var iOW = this.getContainer().offsetWidth;
		
				var iVH = org.cote.js.dom.css.getAbsoluteTop(this.getContainer());
        
        var iUW = o.getIsBound() && iOW < iDW ? iOW : iDW;
        var iUT = o.getIsBound() && iOT < iDT ? iOT : iDT - iVH + document.documentElement.scrollTop;
				var iTT = o.getIsBound() ? 0 : document.documentElement.scrollTop;
				//alert(o.getIsBound());
		
        this.animateMove(o,o.getContainer().offsetLeft,o.getContainer().offsetTop,0,iTT,0,0,0,1,iUW,iUT);
      },
      
      ManageMinimize : function(o){
        if(o.getMinimizeType() == "tile") this.Tile();
        else if(o.getMinimizeType() == "marker") this.TileToMark(o);
      },
      
      TileAll : function(){
				var _p = this.getPointers(), i = 0, o, b;
				for(; i < _p.windows.length; i++){
					o = org.cote.js.registry.ObjectRegistry.getObject(_p.windows[i]);
					if(!o.getIsMinimized() && o.getStatus().can_minimize){
						b = o.getStatus().manage_minimize;
						o.getStatus().manage_minimize = 0;
						o.minimize();
						o.getStatus().manage_minimize = b;
					}
				}
				this.Tile();
      },
      TileToMark : function(o){
          if(o.getIsMinimized() && !o.getStatus().is_closed && o.getStatus().manage_minimize && o.getMinimizeType() == "marker"){
						var iTT = org.cote.js.dom.css.getAbsoluteTop(o.getMinimizeMarker());
						var iTL = org.cote.js.dom.css.getAbsoluteLeft(o.getMinimizeMarker());
						var iST = org.cote.js.dom.css.getAbsoluteTop(o.getContainer());
						var iSL = org.cote.js.dom.css.getAbsoluteLeft(o.getContainer());						
            var iL = iTL + (o.getMinimizeMarker().offsetWidth/2);
            var iT = iTT + (o.getMinimizeMarker().offsetHeight/2);
            //alert(org.cote.js.dom.css.getAbsoluteTop(o.getContainer()) - o.getContainer().parentNode.offsetTop);
            //alert(o.getContainer().offsetTop + ":" + org.cote.js.dom.css.getAbsoluteTop(o.getContainer()) + ":" + iT);
            this.animateMove(o,iSL,iST,iL,iT,1,1,0,1,o.getMinimizeMarker().offsetWidth,o.getMinimizeMarker().offsetHeight);
          }
      },
      
      Tile : function(){
        var a = [], _p = this.getPointers(), _s = this.getStatus(), o, i = 0, _sw, iC = 0, iCT=0;
        var iDT = document.documentElement.clientHeight;//(document.body.offsetHeight > document.documentElement.offsetHeight && document.body.scrollHeight > document.body.offsetHeight ? document.body.offsetHeight : document.documentElement.offsetHeight);
        var iDW = document.documentElement.clientWidth;//(document.body.offsetWidth > document.documentElement.offsetWidth ? document.body.offsetWidth : document.documentElement.offsetWidth);
        var iVH = org.cote.js.dom.css.getAbsoluteTop(this.getContainer());
        var iOT = this.getContainer().offsetHeight;
        var iOW = this.getContainer().offsetWidth;
        for(; i < _p.windows.length; i++){
          o = org.cote.js.registry.ObjectRegistry.getObject(_p.windows[i]);
					var iUW = o.getIsBound() && iOW < iDW ? iOW : iDW;
					var iUT = o.getIsBound() && iOT < iDT ? iOT : iDT - iVH + (document.body.scrollTop > document.documentElement.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop);

          _sw = o.getStatus();
          if(o.getIsMinimized() && o.getStatus().can_move && !o.getStatus().is_closed && _sw.manage_minimize && o.getMinimizeType() == "tile"){
			if(_s.tile_mode == 2){
				var iL = _s.tile_left + (iCT * (_s.tile_width + 5));
				var iT = _s.tile_top + (iC * (_s.tile_height + 5));
				if((iT + _s.tile_height) > iUT){
					iCT++;
					iC = 0;
					iL = _s.tile_left + (iCT * (_s.tile_width + 5));
					iT = _s.tile_top + (iC * (_s.tile_height + 5));

				}
			}
			else{
				var iL = _s.tile_left + (iC * (_s.tile_width + 5));
				var iT = iUT - ((_s.tile_top + o.getContainer().offsetHeight) * (iCT + 1));

				if((iL + _s.tile_width) > iUW){
					iCT++;
					iC = 0;
					iL = _s.tile_left + (iC * (this.getStatus().tile_width + 5));
					iT = iUT - ((_s.tile_top + o.getContainer().offsetHeight) * (iCT + 1));
				}
			}
			this.animateMove(o,o.getContainer().offsetLeft,o.getContainer().offsetTop,iL,iT,0,0,0,1,_s.tile_width,_s.tile_height);
			iC++;

          }
        }
        
      },
			

       animateObjectTo : function(o,iX,iY){

	      var iN = Math.random();
	      iN = 1; // (iN < .5 ? -1 : 1);
	      var iN2 = Math.random();
	      iN2 = 1; //(iN2 < .5 ? -1 : 1);
	      var iTX = (Math.random() * document.documentElement.offsetWidth)  * iN;
	      var iTY = (Math.random() * document.documentElement.offsetHeight) * iN2;
	      this.animateMove(o,iTX,iTY,iX,iY);
      },

      animateMove : function(o,iCX,iCY,iDX,iDY,bHide,bFadeOut,bFadeIn,bScale,bScaleToWidth,bScaleToHeight){
       
         if(!org.cote.js.registry.ObjectRegistry.isRegistered(o)) return;
	     
         var iDistX=iDX - iCX;
	      var iDistY=iDY - iCY;
	      var iDist=Math.sqrt(Math.pow(iDistX,2) + Math.pow(iDistY,2));
	     var iSNum=iDist/this.getStatus().animate_step;
	      var iMX=iDistX/iSNum;
	      var iMY=iDistY/iSNum;
      	
				o.getStatus().expected_x = iDX;
				o.getStatus().expected_y = iDY;
        o.getStatus().expected_h = bScaleToHeight;
        o.getStatus().expected_w = bScaleToWidth;
	      this.getStatus().animate_count++;
	      this.animateMotion(o.getObjectId(),iMX,iMY,iDX,iDY,iCX,iCY,iDist,bHide,bFadeOut,bFadeIn,bScale,bScaleToWidth,bScaleToHeight);
        
      },


    animateMotion : function(sId,iMX,iMY,iDX,iDY,iCX,iCY,iOrgDist,bHide,bFadeOut,bFadeIn,bScale,bScaleToWidth,bScaleToHeight){

 			var o = org.cote.js.registry.ObjectRegistry.getObject(sId);
			if(!o || o.getReadyState() != 4 || typeof o.getContainer != "function" || o.getContainer() == null) return;

	    var iPerc = parseInt((Math.sqrt(Math.pow(iDX - iCX,2) + Math.pow(iDY - iCY,2)) / iOrgDist) * 100);

	    if(

		    Math.floor(Math.abs(iMX)) < Math.floor(Math.abs(iDX - iCX))
		    ||
		    Math.floor(Math.abs(iMY)) < Math.floor(Math.abs(iDY - iCY))
	    ){
	    
		    iCX+=iMX;
		    iCY+=iMY;
		    
		    try{

					o.getContainer().style.top = iCY + "px";
					o.getContainer().style.left = iCX + "px";
					if(bFadeOut || bFadeIn){
						o.setOpacity((bFadeIn ? 100 - iPerc : iPerc));
					}
					if(bScale){
						var iWD = o.getContainer().offsetWidth - bScaleToWidth;
						var iHD = o.getContainer().offsetHeight - bScaleToHeight;
						o.getContainer().style.width = ((o.getContainer().offsetWidth >= bScaleToWidth ? o.getContainer().offsetWidth - (iWD * (iPerc/100)) : bScaleToWidth * ((100 - iPerc)  /100))) + "px";
						o.getContainer().style.height = ((o.getContainer().offsetHeight >= bScaleToHeight ? o.getContainer().offsetHeight - (iHD * (iPerc/100)): bScaleToHeight * ((100 - iPerc)  /100))) + "px";
	    			
					}
					
					if(bFadeOut){
						if(iCY > document.documentElement.offsetHeight || iCY < 0
						||
						iCX > document.documentElement.offsetWidth || iCX < 0
						){
							if(bScale){
								o.getContainer().style.width = bScaleToWidth + "px";
								o.getContainer().style.height = bScaleToHeight + "px";
							}
							if(bHide)
							{
								o.getContainer().style.display = "none";
							}
							else if(bFadeIn){
								o.setOpacity(100);
							}
							this.getStatus().animate_count--;
							if(typeof o._handle_animation_complete == "function") o._handle_animation_complete();
							return;
						};
					}
		    }
				catch(e){
					o.setStatus("Anim Error #1: " + (e.message ? e.message : e.description));
				}
 				o.getStatus().animated = 1;
        var sAFP="org.cote.js.registry.ObjectRegistry.getObject('" + this.getObjectId() + "').animateMotion('" + sId + "'," + iMX + "," + iMY + "," + iDX + "," + iDY + "," + iCX + "," + iCY + "," + iOrgDist + "," + bHide + "," + bFadeOut + "," + bFadeIn + "," + bScale + "," + bScaleToWidth + "," + bScaleToHeight + ")";
		    window.setTimeout(sAFP,this.getStatus().animate_delay);
	    }
	    else{
		    this.getStatus().animate_count--;
		    
		    try{

					if(bScale){
						o.getContainer().style.width = bScaleToWidth + "px";
						o.getContainer().style.height = bScaleToHeight + "px";
					}

					if(bHide)
					{
						o.getContainer().style.display = "none";
					}
					else if(bFadeIn){
						o.setOpacity(100);
					}

					o.getContainer().style.top = iDY + "px";
					o.getContainer().style.left = iDX + "px";
    		}
				catch(e){
					this.setStatus("Anim Error #2: " + (e.message ? e.message : e.description));
				}
		    if(typeof o._handle_animation_complete == "function") o._handle_animation_complete();
	    }
    }
    
		]]>
  </application-component>
  
</application-components>