///////////////////////////////////////////////////////////////////////////////
//
//  navigationManager.js
//
// 
// © 2007 Microsoft Corporation. All Rights Reserved.
//
// This file is licensed as part of the Silverlight 1.0 SDK, for details look here: http://go.microsoft.com/fwlink/?LinkID=89144&clcid=0x409
//
///////////////////////////////////////////////////////////////////////////////

// Controls the navigation between pages, and keeps up-to-date state
NavigationManager = function(plugIn) {
    this.plugIn = plugIn;    
    
    this.timer = this.plugIn.content.findname("timerStoryboard");
    var delegate = Silverlight.createDelegate(this, this.onTick);
    if (delegate != null)
        this.timer.addEventListener("completed", delegate);
    
    // animation variables
    this.pageAnimationType = "none";
    this.pageAnimationDelta = 0;
    this.pageAnimationTarget = 0;
    
    // whether to track movement, and previous position if so
    this.trackMovement = false;
    this.previousMouseMovePosition = 0;
    
    this.currX1 = 880;   
    this.nextOddPage = 1;
}

NavigationManager.prototype.beginPageAnimation = function(type)
{
  if (type == "showFold")
  {    
    if (this.nextOddPage < mediaInfoArray.length-1)
    {
      this.pageAnimationType = "showFold";
      this.pageAnimationTarget = 840;
      this.pageAnimationDelta = 5;
      this.timer.begin();
    }
  }
  if (type == "hideFold")
  {
    this.pageAnimationType = "hideFold";
    this.pageAnimationTarget = 880;
    this.pageAnimationDelta = Math.abs((this.currX1 - this.pageAnimationTarget));
    this.timer.begin();
  }
  else if (type == "finishTurn")
  {
    if (this.nextOddPage < mediaInfoArray.length-1)    
    {
      this.pageAnimationType = "finishTurn";
      this.pageAnimationDelta = 10;
      this.pageAnimationTarget = 460;
      this.timer.begin();
    }
  }
  else if (type == "none")
  {
    this.pageAnimationType = "none";
    this.pageAnimationDelta = 0;
    this.pageAnimationTarget = 0;
  }
}