//
// Generated Tue Feb 17 2015 14:49:13 GMT+0600
//

//
//==================== White Teeth ==============
//
function WhiteTeeth() {
  // Make
  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(PSClass.AdjustmentLayer);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
    var desc4 = new ActionDescriptor();
    desc4.putUnitDouble(PSKey.Red, PSUnit.Percent, 100);
    desc3.putObject(PSKey.Red, PSClass.ChannelMatrix, desc4);
    var desc5 = new ActionDescriptor();
    desc5.putUnitDouble(PSKey.Green, PSUnit.Percent, 100);
    desc3.putObject(PSKey.Green, PSClass.ChannelMatrix, desc5);
    var desc6 = new ActionDescriptor();
    desc6.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 100);
    desc3.putObject(PSEnum.Blue, PSClass.ChannelMatrix, desc6);
    desc2.putObject(PSKey.Type, PSClass.ChannelMixer, desc3);
    desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
    executeAction(PSEvent.Make, desc1, dialogMode);
  };

  // Set
  function step2(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
    desc2.putBoolean(PSKey.Monochromatic, true);
    var desc3 = new ActionDescriptor();
    desc3.putUnitDouble(PSKey.Red, PSUnit.Percent, -125);
    desc3.putUnitDouble(PSKey.Green, PSUnit.Percent, 130);
    desc3.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 60);
    desc3.putUnitDouble(PSKey.Constrain, PSUnit.Percent, 0);
    desc2.putObject(PSKey.Gray, PSClass.ChannelMatrix, desc3);
    desc1.putObject(PSKey.To, PSClass.ChannelMixer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Select
  function step3(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
    desc1.putReference(PSString.Null, ref1);
    desc1.putBoolean(PSKey.MakeVisible, false);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Set
  function step4(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putString(PSKey.Name, "Ch_M");
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Set
  function step5(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Screen);
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Make
  function step6(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(PSClass.AdjustmentLayer);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
    desc3.putBoolean(PSKey.Colorize, false);
    desc2.putObject(PSKey.Type, PSClass.HueSaturation, desc3);
    desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
    executeAction(PSEvent.Make, desc1, dialogMode);
  };

  // Set
  function step7(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
    var list1 = new ActionList();
    var desc3 = new ActionDescriptor();
    desc3.putInteger(PSKey.LocalRange, 2);
    desc3.putInteger(PSKey.BeginRamp, 15);
    desc3.putInteger(PSKey.BeginSustain, 45);
    desc3.putInteger(PSKey.EndSustain, 75);
    desc3.putInteger(PSKey.EndRamp, 105);
    desc3.putInteger(PSKey.Hue, 10);
    desc3.putInteger(PSKey.Start, -70);
    desc3.putInteger(PSKey.Lightness, 80);
    list1.putObject(PSClass.HueSatAdjustmentV2, desc3);
    desc2.putList(PSKey.Adjustment, list1);
    desc1.putObject(PSKey.To, PSClass.HueSaturation, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Select
  function step8(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
    desc1.putReference(PSString.Null, ref1);
    desc1.putBoolean(PSKey.MakeVisible, false);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Set
  function step9(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putString(PSKey.Name, "Hue");
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Select
  function step10(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putName(PSClass.Layer, "Ch_M");
    desc1.putReference(PSString.Null, ref1);
    desc1.putEnumerated(PSString.selectionModifier, PSString.selectionModifierType, PSString.addToSelectionContinuous);
    desc1.putBoolean(PSKey.MakeVisible, false);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Make
  function step11(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(PSString.layerGroup);
    desc1.putReference(PSString.Null, ref1);
    var ref2 = new ActionReference();
    ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSKey.From, ref2);
    executeAction(PSEvent.Make, desc1, dialogMode);
  };

  // Set
  function step12(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putString(PSKey.Name, "White_Teeth");
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Make
  function step13(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putClass(PSKey.New, PSClass.Channel);
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
    desc1.putReference(PSKey.At, ref1);
    desc1.putEnumerated(PSKey.Using, PSType.UserMaskOptions, PSEnum.HideAll);
    executeAction(PSEvent.Make, desc1, dialogMode);
  };

  // Select
  function step14(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(PSClass.PaintbrushTool);
    desc1.putReference(PSString.Null, ref1);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Set
  function step15(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  step1();      // Make
  step2();      // Set
  step3();      // Select
  step4();      // Set
  step5();      // Set
  step6();      // Make
  step7();      // Set
  step8();      // Select
  step9();      // Set
  step10();      // Select
  step11();      // Make
  step12();      // Set
  step13();      // Make
  step14();      // Select
  step15();      // Set
};



cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
// WhiteTeeth.loadSymbols
//   Loading up the symbol definitions like this makes it possible
//   to include several of these generated files in one master file
//   provided a prefix is specified other than the default. It also
//   skips the definitions if PSConstants has already been loaded.
//
WhiteTeeth.loadSymbols = function() {
  var dbgLevel = $.level;
  $.level = 0;
  try {
    PSConstants;
    return; // only if PSConstants is defined
  } catch (e) {
  } finally {
    $.level = dbgLevel;
  }
  var needDefs = true;
  $.level = 0;
  try {
    PSClass;
    needDefs = false;
  } catch (e) {
  } finally {
    $.level = dbgLevel;
  }
  if (needDefs) {
    PSClass = function() {};
    PSEnum = function() {};
    PSEvent = function() {};
    PSForm = function() {};
    PSKey = function() {};
    PSType = function() {};
    PSUnit = function() {};
    PSString = function() {};
  }

  // We may still end up duplicating some of the following definitions
  // but at least we don't redefine PSClass, etc... and wipe out others
  PSClass.AdjustmentLayer = cTID('AdjL');
  PSClass.Calculation = cTID('Clcl');
  PSClass.Channel = cTID('Chnl');
  PSClass.ChannelMatrix = cTID('ChMx');
  PSClass.ChannelMixer = cTID('ChnM');
  PSClass.Curves = cTID('Crvs');
  PSClass.CurvesAdjustment = cTID('CrvA');
  PSClass.HueSatAdjustmentV2 = cTID('Hst2');
  PSClass.HueSaturation = cTID('HStr');
  PSClass.Layer = cTID('Lyr ');
  PSClass.Mask = cTID('Msk ');
  PSClass.PaintbrushTool = cTID('PbTl');
  PSClass.Point = cTID('Pnt ');
  PSClass.RGBColor = cTID('RGBC');
  PSClass.Version = cTID('Vrsn');
  PSEnum.Best = cTID('Bst ');
  PSEnum.Blue = cTID('Bl  ');
  PSEnum.ColorBurn = cTID('CBrn');
  PSEnum.Composite = cTID('Cmps');
  PSEnum.HideAll = cTID('HdAl');
  PSEnum.Luminosity = cTID('Lmns');
  PSEnum.Merged = cTID('Mrgd');
  PSEnum.Midtones = cTID('Mdtn');
  PSEnum.None = cTID('None');
  PSEnum.Overlay = cTID('Ovrl');
  PSEnum.RGB = cTID('RGB ');
  PSEnum.Screen = cTID('Scrn');
  PSEnum.SoftLight = cTID('SftL');
  PSEnum.Target = cTID('Trgt');
  PSEnum.Zoom = cTID('Zm  ');
  PSEvent.Delete = cTID('Dlt ');
  PSEvent.Duplicate = cTID('Dplc');
  PSEvent.Hide = cTID('Hd  ');
  PSEvent.Invert = cTID('Invr');
  PSEvent.Make = cTID('Mk  ');
  PSEvent.Select = cTID('slct');
  PSEvent.Set = cTID('setd');
  PSEvent.Show = cTID('Shw ');
  PSKey.Adjustment = cTID('Adjs');
  PSKey.Amount = cTID('Amnt');
  PSKey.At = cTID('At  ');
  PSKey.BeginRamp = cTID('BgnR');
  PSKey.BeginSustain = cTID('BgnS');
  PSKey.BlurMethod = cTID('BlrM');
  PSKey.BlurQuality = cTID('BlrQ');
  PSKey.Color = cTID('Clr ');
  PSKey.Colorize = cTID('Clrz');
  PSKey.Colors = cTID('Clrs');
  PSKey.Constrain = cTID('Cnst');
  PSKey.Curve = cTID('Crv ');
  PSKey.EndRamp = cTID('EndR');
  PSKey.EndSustain = cTID('EndS');
  PSKey.FillNeutral = cTID('FlNt');
  PSKey.From = cTID('From');
  PSKey.Gray = cTID('Gry ');
  PSKey.Green = cTID('Grn ');
  PSKey.Horizontal = cTID('Hrzn');
  PSKey.Hue = cTID('H   ');
  PSKey.Lightness = cTID('Lght');
  PSKey.LocalRange = cTID('LclR');
  PSKey.MakeVisible = cTID('MkVs');
  PSKey.Mode = cTID('Md  ');
  PSKey.Monochromatic = cTID('Mnch');
  PSKey.Name = cTID('Nm  ');
  PSKey.New = cTID('Nw  ');
  PSKey.Opacity = cTID('Opct');
  PSKey.Radius = cTID('Rds ');
  PSKey.Red = cTID('Rd  ');
  PSKey.Start = cTID('Strt');
  PSKey.Threshold = cTID('Thsh');
  PSKey.To = cTID('T   ');
  PSKey.Type = cTID('Type');
  PSKey.Using = cTID('Usng');
  PSKey.Vertical = cTID('Vrtc');
  PSKey.With = cTID('With');
  PSString.Null = sTID('null');
  PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
  PSString.contentLayer = sTID('contentLayer');
  PSString.layerGroup = sTID('layerSection');
  PSString.presetKind = sTID('presetKind');
  PSString.presetKindCustom = sTID('presetKindCustom');
  PSString.presetKindDefault = sTID('presetKindDefault');
  PSString.presetKindType = sTID('presetKindType');
  PSString.selection = sTID('selection');
  PSString.selectionModifier = sTID('selectionModifier');
  PSString.selectionModifierType = sTID('selectionModifierType');
  PSString.solidColorLayer = sTID('solidColorLayer');
  PSType.BlendMode = cTID('BlnM');
  PSType.Ordinal = cTID('Ordn');
  PSType.UserMaskOptions = cTID('UsrM');
  PSUnit.Percent = cTID('#Prc');
  PSUnit.Pixels = cTID('#Pxl');
};

WhiteTeeth.loadSymbols(); // load up our symbols



//=========================================
//                    WhiteTeeth.main
//=========================================
//

WhiteTeeth.main = function () {
  WhiteTeeth();
};

WhiteTeeth.main();

// EOF
