//
// Generated Fri May 01 2015 07:28:02 GMT+0600
//

//
//==================== Solar Curve ==============
//
function SolarCurve() {
  // 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);
    desc2.putObject(PSKey.Type, PSClass.Curves, desc3);
    desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
    executeAction(PSEvent.Make, desc1, dialogMode);
  };

  // Select
  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.Channel, PSClass.Channel, PSEnum.RGB);
    desc1.putReference(PSString.Null, ref1);
    desc1.putBoolean(PSKey.MakeVisible, false);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Set
  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.Layer, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    var desc2 = new ActionDescriptor();
    desc2.putString(PSKey.Name, "Solar_Curve");
    desc1.putObject(PSKey.To, PSClass.Layer, desc2);
    executeAction(PSEvent.Set, desc1, dialogMode);
  };

  // Select
  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.Channel, PSClass.Channel, PSClass.Mask);
    desc1.putReference(PSString.Null, ref1);
    desc1.putBoolean(PSKey.MakeVisible, false);
    executeAction(PSEvent.Select, desc1, dialogMode);
  };

  // Delete
  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.Channel, PSType.Ordinal, PSEnum.Target);
    desc1.putReference(PSString.Null, ref1);
    executeAction(PSEvent.Delete, desc1, dialogMode);
  };

  // Set
  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.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();
    var ref2 = new ActionReference();
    ref2.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Red);
    desc3.putReference(PSClass.Channel, ref2);
    var list2 = new ActionList();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(PSKey.Horizontal, 0);
    desc4.putDouble(PSKey.Vertical, 0);
    list2.putObject(PSClass.Point, desc4);
    var desc5 = new ActionDescriptor();
    desc5.putDouble(PSKey.Horizontal, 41);
    desc5.putDouble(PSKey.Vertical, 255);
    list2.putObject(PSClass.Point, desc5);
    var desc6 = new ActionDescriptor();
    desc6.putDouble(PSKey.Horizontal, 92);
    desc6.putDouble(PSKey.Vertical, 0);
    list2.putObject(PSClass.Point, desc6);
    var desc7 = new ActionDescriptor();
    desc7.putDouble(PSKey.Horizontal, 143);
    desc7.putDouble(PSKey.Vertical, 255);
    list2.putObject(PSClass.Point, desc7);
    var desc8 = new ActionDescriptor();
    desc8.putDouble(PSKey.Horizontal, 194);
    desc8.putDouble(PSKey.Vertical, 0);
    list2.putObject(PSClass.Point, desc8);
    var desc9 = new ActionDescriptor();
    desc9.putDouble(PSKey.Horizontal, 255);
    desc9.putDouble(PSKey.Vertical, 255);
    list2.putObject(PSClass.Point, desc9);
    desc3.putList(PSKey.Curve, list2);
    list1.putObject(PSClass.CurvesAdjustment, desc3);
    var desc10 = new ActionDescriptor();
    var ref3 = new ActionReference();
    ref3.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Green);
    desc10.putReference(PSClass.Channel, ref3);
    var list3 = new ActionList();
    var desc11 = new ActionDescriptor();
    desc11.putDouble(PSKey.Horizontal, 0);
    desc11.putDouble(PSKey.Vertical, 0);
    list3.putObject(PSClass.Point, desc11);
    var desc12 = new ActionDescriptor();
    desc12.putDouble(PSKey.Horizontal, 51);
    desc12.putDouble(PSKey.Vertical, 255);
    list3.putObject(PSClass.Point, desc12);
    var desc13 = new ActionDescriptor();
    desc13.putDouble(PSKey.Horizontal, 102);
    desc13.putDouble(PSKey.Vertical, 0);
    list3.putObject(PSClass.Point, desc13);
    var desc14 = new ActionDescriptor();
    desc14.putDouble(PSKey.Horizontal, 153);
    desc14.putDouble(PSKey.Vertical, 255);
    list3.putObject(PSClass.Point, desc14);
    var desc15 = new ActionDescriptor();
    desc15.putDouble(PSKey.Horizontal, 204);
    desc15.putDouble(PSKey.Vertical, 0);
    list3.putObject(PSClass.Point, desc15);
    var desc16 = new ActionDescriptor();
    desc16.putDouble(PSKey.Horizontal, 255);
    desc16.putDouble(PSKey.Vertical, 255);
    list3.putObject(PSClass.Point, desc16);
    desc10.putList(PSKey.Curve, list3);
    list1.putObject(PSClass.CurvesAdjustment, desc10);
    var desc17 = new ActionDescriptor();
    var ref4 = new ActionReference();
    ref4.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Blue);
    desc17.putReference(PSClass.Channel, ref4);
    var list4 = new ActionList();
    var desc18 = new ActionDescriptor();
    desc18.putDouble(PSKey.Horizontal, 0);
    desc18.putDouble(PSKey.Vertical, 0);
    list4.putObject(PSClass.Point, desc18);
    var desc19 = new ActionDescriptor();
    desc19.putDouble(PSKey.Horizontal, 61);
    desc19.putDouble(PSKey.Vertical, 255);
    list4.putObject(PSClass.Point, desc19);
    var desc20 = new ActionDescriptor();
    desc20.putDouble(PSKey.Horizontal, 112);
    desc20.putDouble(PSKey.Vertical, 0);
    list4.putObject(PSClass.Point, desc20);
    var desc21 = new ActionDescriptor();
    desc21.putDouble(PSKey.Horizontal, 163);
    desc21.putDouble(PSKey.Vertical, 255);
    list4.putObject(PSClass.Point, desc21);
    var desc22 = new ActionDescriptor();
    desc22.putDouble(PSKey.Horizontal, 214);
    desc22.putDouble(PSKey.Vertical, 0);
    list4.putObject(PSClass.Point, desc22);
    var desc23 = new ActionDescriptor();
    desc23.putDouble(PSKey.Horizontal, 255);
    desc23.putDouble(PSKey.Vertical, 255);
    list4.putObject(PSClass.Point, desc23);
    desc17.putList(PSKey.Curve, list4);
    list1.putObject(PSClass.CurvesAdjustment, desc17);
    desc2.putList(PSKey.Adjustment, list1);
    desc1.putObject(PSKey.To, PSClass.Curves, desc2);
    executeAction(PSEvent.Set, 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.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();      // Select
  step3();      // Set
  step4();      // Select
  step5();      // Delete
  step6();      // Set
  step7();      // Set
};



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

//
// SolarCurve.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.
//
SolarCurve.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.Curves = cTID('Crvs');
  PSClass.CurvesAdjustment = cTID('CrvA');
  PSClass.Layer = cTID('Lyr ');
  PSClass.Mask = cTID('Msk ');
  PSClass.Point = cTID('Pnt ');
  PSClass.RGBColor = cTID('RGBC');
  PSEnum.Blue = cTID('Bl  ');
  PSEnum.Composite = cTID('Cmps');
  PSEnum.Green = cTID('Grn ');
  PSEnum.HideAll = cTID('HdAl');
  PSEnum.Luminosity = cTID('Lmns');
  PSEnum.Merged = cTID('Mrgd');
  PSEnum.Overlay = cTID('Ovrl');
  PSEnum.RGB = cTID('RGB ');
  PSEnum.Red = cTID('Rd  ');
  PSEnum.Target = cTID('Trgt');
  PSEvent.Delete = cTID('Dlt ');
  PSEvent.Desaturate = cTID('Dstt');
  PSEvent.Make = cTID('Mk  ');
  PSEvent.Select = cTID('slct');
  PSEvent.Set = cTID('setd');
  PSKey.Adjustment = cTID('Adjs');
  PSKey.At = cTID('At  ');
  PSKey.Color = cTID('Clr ');
  PSKey.Curve = cTID('Crv ');
  PSKey.Exposure = cTID('Exps');
  PSKey.From = cTID('From');
  PSKey.Horizontal = cTID('Hrzn');
  PSKey.MakeVisible = cTID('MkVs');
  PSKey.Mode = cTID('Md  ');
  PSKey.Name = cTID('Nm  ');
  PSKey.New = cTID('Nw  ');
  PSKey.Offset = cTID('Ofst');
  PSKey.Opacity = cTID('Opct');
  PSKey.Radius = cTID('Rds ');
  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.gammaCorrection = sTID('gammaCorrection');
  PSString.layerGroup = sTID('layerSection');
  PSString.presetKind = sTID('presetKind');
  PSString.presetKindCustom = sTID('presetKindCustom');
  PSString.presetKindDefault = sTID('presetKindDefault');
  PSString.presetKindType = sTID('presetKindType');
  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');
};

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



//=========================================
//                    SolarCurve.main
//=========================================
//

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

SolarCurve.main();

// EOF
