//
// Generated Wed Jun 17 2015 11:34:37 GMT+0600
//

//
//==================== Horizontal ==============
//
function Horizontal() {
  // Duplicate
  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.putEnumerated(PSClass.Document, PSType.Ordinal, PSEnum.First);
    desc1.putReference(PSString.Null, ref1);
    desc1.putString(PSKey.Name, "Horizontal Save");
    desc1.putBoolean(PSKey.Merged, true);
    executeAction(PSEvent.Duplicate, desc1, dialogMode);
  };

  // Image Size
  function step2(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putUnitDouble(PSKey.Width, PSUnit.Distance, 360);
    desc1.putUnitDouble(PSKey.Resolution, PSUnit.Density, 300);
    desc1.putBoolean(PSString.scaleStyles, true);
    desc1.putBoolean(PSKey.ConstrainProportions, true);
    desc1.putEnumerated(PSKey.Interpolation, PSType.Interpolation, PSString.bicubicSharper);
    executeAction(sTID('imageSize'), desc1, dialogMode);
  };

  // Image Size
  function step3(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putUnitDouble(PSKey.Width, PSUnit.Pixels, 1300);
    desc1.putBoolean(PSString.scaleStyles, true);
    desc1.putBoolean(PSKey.ConstrainProportions, true);
    desc1.putEnumerated(PSKey.Interpolation, PSType.Interpolation, PSEnum.Bicubic);
    executeAction(sTID('imageSize'), desc1, dialogMode);
  };

  // Save
  function step4(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var desc2 = new ActionDescriptor();
    desc2.putInteger(PSKey.ExtendedQuality, 12);
    desc2.putEnumerated(PSKey.MatteColor, PSKey.MatteColor, PSEnum.None);
    desc1.putObject(PSKey.As, PSClass.JPEGFormat, desc2);
    desc1.putPath(PSKey.In, new File("~/Desktop/Vertical Save.jpg"));
    desc1.putInteger(PSKey.DocumentID, 1130);
    executeAction(PSEvent.Save, desc1, dialogMode);
  };

  // Close
  function step5(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putEnumerated(PSKey.Saving, PSType.YesNo, PSEnum.No);
    executeAction(PSEvent.Close, desc1, dialogMode);
  };

  step1();      // Duplicate
  step2();      // Image Size
  step3();      // Image Size
  step4(true, true);      // Save
  step5();      // Close
};



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

//
// Horizontal.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.
//
Horizontal.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.Channel = cTID('Chnl');
  PSClass.Curves = cTID('Crvs');
  PSClass.CurvesAdjustment = cTID('CrvA');
  PSClass.Document = cTID('Dcmn');
  PSClass.JPEGFormat = cTID('JPEG');
  PSClass.Layer = cTID('Lyr ');
  PSClass.Mask = cTID('Msk ');
  PSClass.PaintbrushTool = cTID('PbTl');
  PSClass.Point = cTID('Pnt ');
  PSClass.RGBColor = cTID('RGBC');
  PSEnum.Bicubic = cTID('Bcbc');
  PSEnum.Blue = cTID('Bl  ');
  PSEnum.Composite = cTID('Cmps');
  PSEnum.Exclusion = cTID('Xclu');
  PSEnum.First = cTID('Frst');
  PSEnum.HideAll = cTID('HdAl');
  PSEnum.Luminosity = cTID('Lmns');
  PSEnum.No = cTID('N   ');
  PSEnum.None = cTID('None');
  PSEnum.Overlay = cTID('Ovrl');
  PSEnum.RGB = cTID('RGB ');
  PSEnum.Target = cTID('Trgt');
  PSEnum.Violet = cTID('Vlt ');
  PSEvent.Close = cTID('Cls ');
  PSEvent.Delete = cTID('Dlt ');
  PSEvent.Duplicate = cTID('Dplc');
  PSEvent.Invert = cTID('Invr');
  PSEvent.Make = cTID('Mk  ');
  PSEvent.Save = cTID('save');
  PSEvent.Select = cTID('slct');
  PSEvent.Set = cTID('setd');
  PSKey.Adjustment = cTID('Adjs');
  PSKey.Amount = cTID('Amnt');
  PSKey.As = cTID('As  ');
  PSKey.At = cTID('At  ');
  PSKey.Color = cTID('Clr ');
  PSKey.ConstrainProportions = cTID('CnsP');
  PSKey.Curve = cTID('Crv ');
  PSKey.DocumentID = cTID('DocI');
  PSKey.ExtendedQuality = cTID('EQlt');
  PSKey.From = cTID('From');
  PSKey.Green = cTID('Grn ');
  PSKey.Horizontal = cTID('Hrzn');
  PSKey.In = cTID('In  ');
  PSKey.Interpolation = cTID('Intr');
  PSKey.MakeVisible = cTID('MkVs');
  PSKey.MatteColor = cTID('MttC');
  PSKey.Merged = cTID('Mrgd');
  PSKey.Mode = cTID('Md  ');
  PSKey.Name = cTID('Nm  ');
  PSKey.New = cTID('Nw  ');
  PSKey.Opacity = cTID('Opct');
  PSKey.Radius = cTID('Rds ');
  PSKey.Red = cTID('Rd  ');
  PSKey.Resolution = cTID('Rslt');
  PSKey.Saving = cTID('Svng');
  PSKey.Threshold = cTID('Thsh');
  PSKey.To = cTID('T   ');
  PSKey.Type = cTID('Type');
  PSKey.Using = cTID('Usng');
  PSKey.Vertical = cTID('Vrtc');
  PSKey.Width = cTID('Wdth');
  PSString.Null = sTID('null');
  PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
  PSString.bicubicSharper = sTID('bicubicSharper');
  PSString.contentLayer = sTID('contentLayer');
  PSString.layerGroup = sTID('layerSection');
  PSString.presetKind = sTID('presetKind');
  PSString.presetKindDefault = sTID('presetKindDefault');
  PSString.presetKindType = sTID('presetKindType');
  PSString.scaleStyles = sTID('scaleStyles');
  PSString.selectionModifier = sTID('selectionModifier');
  PSString.selectionModifierType = sTID('selectionModifierType');
  PSString.solidColorLayer = sTID('solidColorLayer');
  PSType.BlendMode = cTID('BlnM');
  PSType.Interpolation = cTID('Intp');
  PSType.Ordinal = cTID('Ordn');
  PSType.UserMaskOptions = cTID('UsrM');
  PSType.YesNo = cTID('YsN ');
  PSUnit.Density = cTID('#Rsl');
  PSUnit.Distance = cTID('#Rlt');
  PSUnit.Percent = cTID('#Prc');
  PSUnit.Pixels = cTID('#Pxl');
};

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



//=========================================
//                    Horizontal.main
//=========================================
//

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

Horizontal.main();

// EOF
