//-----------------------------------------
function ActionController() {
    this.name      ='';
    this.action  ='';
    this.callback  ='';
    this.func='';
    this.view=null;
}

ActionController.prototype.execute=function(action,name,callback){
    this.name      =name;
    this.action  =action;
    this.callback  =callback;
    //alert(this.name);
    eval(action);
    this.func="actionController.check()";
    setTimeout(this.func,1000);
}

ActionController.prototype.check=function(){
   var view=new ViewExtents();

   var sp=ApplicationGE.Get_StreamingProgressPercentage();
   if (view.isEqual(this.view) && (sp==100)){
      try{
         //alert(this.callback);
         if (this.callback!=undefined){
            eval(this.callback+"()");
         }
      }catch(e){
      }
   }else{
      this.view=view;
      setTimeout(this.func,1000);
   }
}

// a ActionController for GoogleEarthAirlines plugin
//test
var actionController=new ActionController();

// must includes:
// <script type="text/javascript" src="geapi.js"></script>
// <script type="text/javascript" src="ViewExtents.js"></script>
// usage :
//    actionController.open("http://somefile.kml","Name","callbackfunc");


// Version 1.0.0
//
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
//
// Alternatively, you may redistribute this library, use and/or modify it under the terms of the
// GNU Lesser General Public License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
// You may obtain a copy of the LGPL at http://www.gnu.org/copyleft/.
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
// specific language governing rights and limitations under the License.
//
// The original code is ActionController.js, released April 10, 2007.
//
// The initial developer of the original code is Luca Rocchi (Rome, Italy, www.googleearthairlines.com),
// (lr1313@gmail.com,luca.rocchi@tin.it).

