// Platform Type Menu

var perforatedButtonShape;
var gripButtonShape;

function PlatformTypeMenu(){
  var platformTypeMenu = new createjs.Container();

  var triarcLogo = new createjs.Bitmap("assets/TriArcLogo.jpg");
  triarcLogo.x = -390;
  triarcLogo.y = 720;
  platformTypeMenu.addChild(triarcLogo);

  if(VENDOR)
  {
    var graingerLogo = new createjs.Bitmap("assets/GraingerLogo.jpg");
    graingerLogo.x = 160;
    graingerLogo.y = 720;
    platformTypeMenu.addChild(graingerLogo);
  }

  var udesignLogo = new createjs.Bitmap("assets/UDesignLogo.jpg");
  udesignLogo.x = -178;
  udesignLogo.y = 30;
  platformTypeMenu.addChild(udesignLogo);

  var udesignLogoBorder = new createjs.Shape();
  udesignLogoBorder.graphics.beginStroke("#e17a0f").drawRoundRect(-184,20,368,110,5);
  platformTypeMenu.addChild(udesignLogoBorder);

  var platformTypeInstructionText = new createjs.Text("Select a Platform Tread Type", "30px sans-serif", "#444");
  platformTypeInstructionText.textAlign = "center";
  platformTypeInstructionText.x = 0;
  platformTypeInstructionText.y = 180;

  platformTypeMenu.addChild(platformTypeInstructionText);


  var perforatedButton = new createjs.Container();
  perforatedButton.x = -350;
  perforatedButton.y = 220;

  platformTypeMenu.addChild(perforatedButton);

  perforatedButtonShape = new createjs.Shape();
  perforatedButtonShape.graphics.beginFill("#494c53").beginStroke("#5f6064").drawRoundRect(0,0,300,260,5);
  perforatedButton.addChild(perforatedButtonShape);

  var perforatedButtonImage = new createjs.Bitmap("assets/perforated.jpg");
  perforatedButtonImage.scaleX = perforatedButtonImage.scaleY = 0.5;
  perforatedButtonImage.y = 20;
  perforatedButtonImage.x = 20;
  perforatedButton.addChild(perforatedButtonImage);

  var perforatedButtonText = new createjs.Text("Perforated", "16px sans-serif", "#fff");
  perforatedButtonText.textAlign = "center";
  perforatedButtonText.y = 240;
  perforatedButtonText.x = 150;
  perforatedButton.addChild(perforatedButtonText);

  var perforatedButtonHelper = new createjs.ButtonHelper(perforatedButton);
  perforatedButton.addEventListener("mouseover", handleperforatedButtonMouseOver);
  perforatedButton.addEventListener("mouseout", handleperforatedButtonMouseOut);
  perforatedButton.addEventListener("click", handleperforatedButtonClick);

  var gripButton = new createjs.Container();
  gripButton.x = 50;
  gripButton.y = 220;

  platformTypeMenu.addChild(gripButton);

  gripButtonShape = new createjs.Shape();
  gripButtonShape.graphics.beginFill("#494c53").beginStroke("#5f6064").drawRoundRect(0,0,300,260,5);
  gripButton.addChild(gripButtonShape);

  var gripButtonImage = new createjs.Bitmap("assets/grip.jpg");
  gripButtonImage.scaleX = gripButtonImage.scaleY = 0.5;
  gripButtonImage.y = 20;
  gripButtonImage.x = 20;
  gripButton.addChild(gripButtonImage);

  var gripButtonText = new createjs.Text("Grip Strut", "16px sans-serif", "#fff");
  gripButtonText.textAlign = "center";
  gripButtonText.y = 240;
  gripButtonText.x = 150;
  gripButton.addChild(gripButtonText);

  var gripButtonHelper = new createjs.ButtonHelper(gripButton);
  gripButton.addEventListener("mouseover", handlegripButtonMouseOver);
  gripButton.addEventListener("mouseout", handlegripButtonMouseOut);
  gripButton.addEventListener("click", handlegripButtonClick);

  var backButton = new createjs.Container();
  backButton.x = -430;
  backButton.y = 50;

  platformTypeMenu.addChild(backButton);

  backButtonShape = new createjs.Shape();
  backButtonShape.graphics.beginFill("#494c53").beginStroke("#5f6064").drawRoundRect(0,0,60,40,5);
  backButton.addChild(backButtonShape);

  var backButtonText = new createjs.Text("Back", "16px sans-serif", "#fff");
  backButtonText.textAlign = "center";
  backButtonText.y = 10;
  backButtonText.x = 30;
  backButton.addChild(backButtonText);

  var backButtonHelper = new createjs.ButtonHelper(backButton);
  backButton.addEventListener("click", handlePTBackButtonClick);

  return platformTypeMenu;
}

function handlePTBackButtonClick(event){
  showHeightMenu();
}

function handleperforatedButtonClick(event){
  treadType = TreadType.Perforated;
  showInclineMenu();
}

function handlegripButtonClick(event){
  treadType = TreadType.Grip;
  showInclineMenu();
}


function handleperforatedButtonMouseOver(event){
  perforatedButtonShape.graphics.beginFill("#ff9e35").beginStroke("#e17a0f").drawRoundRect(0,0,300,260,5);
}

function handleperforatedButtonMouseOut(event){
  perforatedButtonShape.graphics.beginFill("#494c53").beginStroke("#5f6064").drawRoundRect(0,0,300,260,5);
}

function handlegripButtonMouseOver(event){
  gripButtonShape.graphics.beginFill("#ff9e35").beginStroke("#e17a0f").drawRoundRect(0,0,300,260,5);
}

function handlegripButtonMouseOut(event){
  gripButtonShape.graphics.beginFill("#494c53").beginStroke("#5f6064").drawRoundRect(0,0,300,260,5);
}