/***  Copyright 2015 Tony Kuyper  */

/*** This is the code for action loading script */

$._ext_ISACTIONLOADED={
    run : function(actn, actnSet) {
        
        var actionSetLoaded = true;
        
    	try
        {
           app.displayDialogs = DialogModes.NO
           app.doAction (actn, actnSet);
        }
        catch(e)
        {
             actionSetLoaded = false;
        }
		
		if(actionSetLoaded)
			return "true";
		else
			return "false";
    },
};

$._ext_LOADACTION={
    run : function(uri) {
        
        try
        {
            var file = new File(uri);
            app.open( file );
        }
        catch(e)
        {
            var errMsg = e.toString();
            if( errMsg.indexOf ("options are incorrect") < 0 )
                throw new Error(errMsg);
        }
    
        return true;
    },
};

    /*** This is the code for selection monitoring script */
    
$._ext_ISSELECTIONACTIVE={
    run : function() {
    
    	var isBoundsSelected = false;
        
        try
        {
            var bounds = app.activeDocument.selection.bounds;
            
            if(bounds)
                isBoundsSelected = true;
            
        } catch(e){}
        
        return isBoundsSelected;
    },
};

    								/*** Start "Open" button of the top part of the panel. */    
$._ext_OPEN={
    run : function() { 
       
var DocToOpen = File.openDialog();
try {
       app.open(DocToOpen);
      }
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Fit" button of the top part of the panel. */    
$._ext_FIT={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)

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

function Fit() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('FtOn'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.NO);
  };

  Fit();

}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "100%" button of the top part of the panel. */    
$._ext_100PERCENT={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)

cTID = function(s) { return app.charIDToTypeID(s); };
function ActP() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ActP'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.NO);
  };
  ActP();
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Print Size" button of the top part of the panel. */    
$._ext_PRINTSIZE={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)

cTID = function(s) { return app.charIDToTypeID(s); };
function PrintSize() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('PrnS'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.NO);
  };
  PrintSize();
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Zoom-in" button of the top part of the panel. */    
$._ext_ZOOMIN={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)

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

function Zoom_in() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ZmIn'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.NO);
  };
  Zoom_in();

}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "New" button of the top part of the panel. */    
$._ext_NEW={
    run : function() {    
    	
try {

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

function New() {
    var desc1 = new ActionDescriptor();
    desc1.putClass(cTID('Nw  '), cTID('Dcmn'));
    executeAction(cTID('Mk  '), desc1, DialogModes.ALL);
  };
  New();
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Stroke" button of the top part of the panel. */    
$._ext_STROKE={
    run : function() {    
    
try {
var documentOpen = app.activeDocument
if(documentOpen)
var layerRef = app.activeDocument.activeLayer.kind
if(layerRef !== LayerKind.NORMAL) 
// ==================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );   }
catch(e) {}

try {
var documentOpen = app.activeDocument
if(documentOpen)

var layerRef = app.activeDocument.activeLayer.kind

function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
}

var bounds = app.activeDocument.selection.bounds;
            
if(bounds)

if((layerRef == LayerKind.SMARTOBJECT) && (hasLayerMask() == false)) {}

else {

if((hasLayerMask() == true)|| (layerRef == LayerKind.NORMAL)) {

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

function Stroke() {
    executeAction(cTID('Strk'), undefined, DialogModes.ALL);
  };

  Stroke();
}
}
}
catch(e) {}
									app.bringToFront();
    },
};

							    	/*** Start "Fill" button of the top part of the panel. */							    
$._ext_FILL={
    run : function() {    
    
try {
var documentOpen = app.activeDocument
if(documentOpen)
var layerRef = app.activeDocument.activeLayer.kind
if(layerRef !== LayerKind.NORMAL) 
// ==================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );   }
catch(e) {}
try {
var documentOpen = app.activeDocument
if(documentOpen)

var layerRef = app.activeDocument.activeLayer.kind
// Test for presence of layer mask and assign true or false
function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
}
// Assign condition for opening Fill dialog
if((hasLayerMask() == true)|| (layerRef == LayerKind.NORMAL))  {
cTID = function(s) { return app.charIDToTypeID(s); };
function Fill() {
    executeAction(cTID('Fl  '), undefined, DialogModes.ALL);
  };
  Fill(); }
}

catch(e) {}
						app.bringToFront();
    },
};

   								 /*** Start "Blur" button of the top part of the panel. */    
$._ext_BLUR={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)
var layerRef = app.activeDocument.activeLayer.kind
if((layerRef !== LayerKind.NORMAL) && (layerRef !== LayerKind.SMARTOBJECT)) 
// ==================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );   }
catch(e) {}
try {
var documentOpen = app.activeDocument
if(documentOpen)

var layerRef = app.activeDocument.activeLayer.kind

function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
}

if((hasLayerMask() == true)|| (layerRef == LayerKind.NORMAL)|| (layerRef == LayerKind.SMARTOBJECT))  {

sTID = function(s) { return app.stringIDToTypeID(s); };
function Blur() {
    executeAction(sTID('gaussianBlur'), undefined, DialogModes.ALL);
  };
 Blur();
}
}

catch(e) {}
									app.bringToFront();
    },
};


    								/*** Start "Zoom-out" button of the top part of the panel. */    
$._ext_ZOOMOUT={
    run : function() {    
    	
try {
var documentOpen = app.activeDocument
if(documentOpen)

cTID = function(s) { return app.charIDToTypeID(s); };
function Zoom_out() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ZmOt'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.NO);
  };
  Zoom_out();

}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Black" button of the top part of the panel. */    
$._ext_BLACK={
    run : function() {    

try {
//determine if layer mask is present    
function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
}    

//determine kind of layer
var layerRef = app.activeDocument.activeLayer.kind

//if layer has a layer mask and it is a non-pixel, non-smart-object layer . . .

if ((hasLayerMask() == true)&& (layerRef != LayerKind.NORMAL)&& (layerRef != LayerKind.SMARTOBJECT)) {

// . . . make the mask the active object when/if the property is the active object
try {
    var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );}

catch(e) {}
}
// else equals do nothing
else {}

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );

// ====================Create a solid color for Black foreground
var black = new SolidColor();
black.rgb.hexValue = '000000';
app.foregroundColor = black;

// ====================Create a solid color for White background
var white = new SolidColor();
white.rgb.hexValue = 'ffffff';
app.backgroundColor = white;  } 

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "White" button of the top part of the panel. */    
$._ext_WHITE={
    run : function() {    

try {
//determine if layer mask is present    
function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
}    

//determine kind of layer
var layerRef = app.activeDocument.activeLayer.kind

//if layer has a layer mask and it is a non-pixel, non-smart-object layer . . .

if ((hasLayerMask() == true)&& (layerRef != LayerKind.NORMAL)&& (layerRef != LayerKind.SMARTOBJECT)) {

// . . . make the mask the active object when/if the property is the active object
try {
    var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );}

catch(e) {}
}
// else equals do nothing
else {}

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );

// ====================Create a solid color for White foreground
var white = new SolidColor();
white.rgb.hexValue = 'ffffff';
app.foregroundColor = white;

// ====================Create a solid color for Black  background
var black = new SolidColor();
black.rgb.hexValue = '000000';
app.backgroundColor = black;  } 

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Dup Image" button of the top part of the panel. */    
$._ext_DUPIMAGE={
    run : function() {    

try {

app.activeDocument.duplicate();}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Flatten" button of the top part of the panel. */    
$._ext_FLATTEN={
    run : function() {    

try {

app.activeDocument.flatten() }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Size" button of the top part of the panel. */    
$._ext_SIZE={
    run : function() {    

try {

var documentOpen = app.activeDocument

if(documentOpen)

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

function Resize() {
    executeAction(sTID('imageSize'), undefined, DialogModes.ALL);
  };
  Resize();
}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Normal / Lum" button of the top part of the panel. */    
$._ext_NORMALLUM={
    run : function() {    

try {

var blendingMode=app.activeDocument.activeLayer.blendMode;
if (blendingMode== BlendMode.NORMAL) {
    app.activeDocument.activeLayer.blendMode = BlendMode.LUMINOSITY;}
else {app.activeDocument.activeLayer.blendMode = BlendMode.NORMAL;}
    }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Screen" button of the top part of the panel. */    
$._ext_SCREEN={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.SCREEN;}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Multiply" button of the top part of the panel. */    
$._ext_MULTIPLY={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.MULTIPLY;}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Soft Lt" button of the top part of the panel. */    
$._ext_SOFTLIGHT={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.SOFTLIGHT;}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Hard Lt" button of the top part of the panel. */    
$._ext_HARDLIGHT={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.HARDLIGHT;}

catch(e) {}
									app.bringToFront();
    },
};


    								/*** Start "Overlay" button of the top part of the panel. */    
$._ext_OVERLAY={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.OVERLAY;}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Color" button of the top part of the panel. */    
$._ext_COLOR={
    run : function() {    

try {

app.activeDocument.activeLayer.blendMode = BlendMode.COLORBLEND;}

catch(e) {}
									app.bringToFront();
    },
};


    								/*** Start "Curves" button of the top part of the panel. */    
$._ext_CURVES={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc5.putObject( idType, idCrvs, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Brightness/Contrast" button of the top part of the panel. */    
$._ext_BRIGHTNESSCONTRAST={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var iduseLegacy = stringIDToTypeID( "useLegacy" );
            desc6.putBoolean( iduseLegacy, false );
        var idBrgC = charIDToTypeID( "BrgC" );
        desc5.putObject( idType, idBrgC, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "B&W" button of the top part of the panel. */    
$._ext_BANDW={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idRd = charIDToTypeID( "Rd  " );
            desc6.putInteger( idRd, 40 );
            var idYllw = charIDToTypeID( "Yllw" );
            desc6.putInteger( idYllw, 60 );
            var idGrn = charIDToTypeID( "Grn " );
            desc6.putInteger( idGrn, 40 );
            var idCyn = charIDToTypeID( "Cyn " );
            desc6.putInteger( idCyn, 60 );
            var idBl = charIDToTypeID( "Bl  " );
            desc6.putInteger( idBl, 20 );
            var idMgnt = charIDToTypeID( "Mgnt" );
            desc6.putInteger( idMgnt, 80 );
            var iduseTint = stringIDToTypeID( "useTint" );
            desc6.putBoolean( iduseTint, false );
            var idtintColor = stringIDToTypeID( "tintColor" );
                var desc7 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc7.putDouble( idRd, 225.000458 );
                var idGrn = charIDToTypeID( "Grn " );
                desc7.putDouble( idGrn, 211.000671 );
                var idBl = charIDToTypeID( "Bl  " );
                desc7.putDouble( idBl, 179.001160 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc6.putObject( idtintColor, idRGBC, desc7 );
        var idBanW = charIDToTypeID( "BanW" );
        desc5.putObject( idType, idBanW, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref5 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref7 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Levels" button of the top part of the panel. */   
$._ext_LEVELS={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc5.putObject( idType, idLvls, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO ); }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Hue/Saturation" button of the top part of the panel. */   
$._ext_HUESATURATION={
    run : function() {  

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc6.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc5.putObject( idType, idHStr, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Vibrance" button of the top part of the panel. */   
$._ext_VIBRANCE={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
        var idvibrance = stringIDToTypeID( "vibrance" );
        desc5.putClass( idType, idvibrance );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref5 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref7 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc8.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc8.putBoolean( idMkVs, false );
executeAction( idslct, desc8, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "+/- Clip" button of the top part of the panel. */   
$._ext_PMCLIP={
    run : function() {    

try {
// ===================================================
var idGrpL = charIDToTypeID( "GrpL" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idLyr, idOrdn, idTrgt );
    desc3.putReference( idnull, ref2 );
executeAction( idGrpL, desc3, DialogModes.NO );       }

catch(e) {
try {
// ===================================================
var idUngr = charIDToTypeID( "Ungr" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc4.putReference( idnull, ref3 );
executeAction( idUngr, desc4, DialogModes.NO );   }

catch(e) {}
}
									app.bringToFront();
    },
};

    								/*** Start "Selective Color" button of the top part of the panel. */   
$._ext_SELECTIVECOLOR={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc5.putObject( idType, idSlcC, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "+/- Layer Mask" button of the top part of the panel. */   
$._ext_PMLAYERMASK={
    run : function() {    

try {
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idChnl, idOrdn, idTrgt );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );      }

catch(e) {
try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc4.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref4.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idAt, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlS = charIDToTypeID( "RvlS" );
    desc4.putEnumerated( idUsng, idUsrM, idRvlS );
executeAction( idMk, desc4, DialogModes.NO );    }
catch(e) {
     try {
// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc3 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc3.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc3.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc3, DialogModes.NO );   }

catch(e) {}
}
}
									app.bringToFront();
    },
};

    								/*** Start "Photo Filter" button of the top part of the panel. */   
$._ext_PHOTOFILTER={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc7 = new ActionDescriptor();
                var idLmnc = charIDToTypeID( "Lmnc" );
                desc7.putDouble( idLmnc, 67.060000 );
                var idA = charIDToTypeID( "A   " );
                desc7.putDouble( idA, 32.000000 );
                var idB = charIDToTypeID( "B   " );
                desc7.putDouble( idB, 120.000000 );
            var idLbCl = charIDToTypeID( "LbCl" );
            desc6.putObject( idClr, idLbCl, desc7 );
            var idDnst = charIDToTypeID( "Dnst" );
            desc6.putInteger( idDnst, 25 );
            var idPrsL = charIDToTypeID( "PrsL" );
            desc6.putBoolean( idPrsL, true );
        var idphotoFilter = stringIDToTypeID( "photoFilter" );
        desc5.putObject( idType, idphotoFilter, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref5 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref7 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );}

catch(e) {}
						app.bringToFront();
    },
};

    								/*** Start "Color Bal" button of the top part of the panel. */   
$._ext_COLORBAL={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idShdL = charIDToTypeID( "ShdL" );
                var list1 = new ActionList();
                list1.putInteger( 0 );
                list1.putInteger( 0 );
                list1.putInteger( 0 );
            desc6.putList( idShdL, list1 );
            var idMdtL = charIDToTypeID( "MdtL" );
                var list2 = new ActionList();
                list2.putInteger( 0 );
                list2.putInteger( 0 );
                list2.putInteger( 0 );
            desc6.putList( idMdtL, list2 );
            var idHghL = charIDToTypeID( "HghL" );
                var list3 = new ActionList();
                list3.putInteger( 0 );
                list3.putInteger( 0 );
                list3.putInteger( 0 );
            desc6.putList( idHghL, list3 );
            var idPrsL = charIDToTypeID( "PrsL" );
            desc6.putBoolean( idPrsL, true );
        var idClrB = charIDToTypeID( "ClrB" );
        desc5.putObject( idType, idClrB, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref5.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref5 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref7 );
executeAction( idmove, desc8, DialogModes.NO );

// ==================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref8.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref8 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc9.putBoolean( idMkVs, false );
executeAction( idslct, desc9, DialogModes.NO );}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "New Layer" button of the top part of the panel. */   
$._ext_NEWLAYER={
    run : function() {    

try {

activeDocument.artLayers.add();  }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Merge Visible" button of the top part of the panel. */   
$._ext_MERGEVISIBLE={
    run : function() {    

try {
// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc4 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc4.putBoolean( idDplc, true );
executeAction( idMrgV, desc4, DialogModes.NO );       }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "BURN" button of the top part of the panel. */   
$._ext_BURN={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Layer", "tkaction()");

function tkaction() {

try {

//==================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref3.putClass( idLyr );
    desc6.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc7 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc7.putString( idNm, """Burn (black paint)""" );
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idSftL = charIDToTypeID( "SftL" );
        desc7.putEnumerated( idMd, idBlnM, idSftL );
    var idLyr = charIDToTypeID( "Lyr " );
    desc6.putObject( idUsng, idLyr, desc7 );
executeAction( idMk, desc6, DialogModes.NO );

//==================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

//==================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref8 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );

// ===================================================
var idRset = charIDToTypeID( "Rset" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idClr = charIDToTypeID( "Clr " );
        var idClrs = charIDToTypeID( "Clrs" );
        ref2.putProperty( idClr, idClrs );
    desc2.putReference( idnull, ref2 );
executeAction( idRset, desc2, DialogModes.NO );  }

catch(e) {}


}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Dup Layer" button of the top part of the panel. */   
$._ext_DUPLAYER={
    run : function() {    

try {

var newLayer = app.activeDocument.activeLayer.duplicate();
app.activeDocument.activeLayer = newLayer}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Smart Object" button of the top part of the panel. */   
$._ext_SMARTOBJECT={
    run : function() {    

try {
// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );       }

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Dodge" button of the top part of the panel. */   
$._ext_DODGE={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Layer", "tkaction()");

function tkaction() {

try {

//==================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref3.putClass( idLyr );
    desc6.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc7 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc7.putString( idNm, """Dodge (white paint)""" );
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idOvrl = charIDToTypeID( "Ovrl" );
        desc7.putEnumerated( idMd, idBlnM, idOvrl );
    var idLyr = charIDToTypeID( "Lyr " );
    desc6.putObject( idUsng, idLyr, desc7 );
executeAction( idMk, desc6, DialogModes.NO );

//==================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

//==================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref8 );
executeAction( idmove, desc8, DialogModes.NO ); 

// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );

// =======================================================
var idRset = charIDToTypeID( "Rset" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idClr = charIDToTypeID( "Clr " );
        var idClrs = charIDToTypeID( "Clrs" );
        ref2.putProperty( idClr, idClrs );
    desc2.putReference( idnull, ref2 );
executeAction( idRset, desc2, DialogModes.NO );

// ===================================================
var idExch = charIDToTypeID( "Exch" );
    var desc1 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idClr = charIDToTypeID( "Clr " );
        var idClrs = charIDToTypeID( "Clrs" );
        ref1.putProperty( idClr, idClrs );
    desc1.putReference( idnull, ref1 );
executeAction( idExch, desc1, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};


    								/*** Start "Delete Layer" button of the top part of the panel. */   
$._ext_DELETELAYER={
    run : function() {    

try {

app.activeDocument.activeLayer.remove();}

catch(e) {}
									app.bringToFront();
    },
};



    								/*** Start "Invert" button of the top part of the panel. */   
$._ext_INVERT={
    run : function() {    

try {

app.activeDocument.activeLayer.invert();  }

catch(e) {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
app.activeDocument.activeLayer.invert();   }

catch(e) {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref3.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref3 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ====================================================
var idInvr = charIDToTypeID( "Invr" );
executeAction( idInvr, undefined, DialogModes.NO );  }

catch (e) {}
}
}
									app.bringToFront();
    },
};



    								/*** Start "Group" button of the top part of the panel. */   
$._ext_GROUP={
    run : function() {    

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref1.putClass( idlayerSection );
    desc2.putReference( idnull, ref1 );
    var idFrom = charIDToTypeID( "From" );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idLyr, idOrdn, idTrgt );
    desc2.putReference( idFrom, ref2 );
executeAction( idMk, desc2, DialogModes.NO );   }

catch(e) {

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref2.putClass( idlayerSection );
    desc3.putReference( idnull, ref2 );
executeAction( idMk, desc3, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc4.putReference( idT, ref4 );
executeAction( idmove, desc4, DialogModes.NO );  }

catch(e) {}

}
									app.bringToFront();
    },
};

    								/*** Start "+/- Ants" button of the top part of the panel. */   
$._ext_PMANTS={
    run : function() {    

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

function Ants() {
  // Select
  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(cTID('Mn  '), cTID('MnIt'), sTID("toggleShowExtras"));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, dialogMode);
  };

  step1();      // Select
};

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

Ants.main();
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Inverse" button of the top part of the panel. */   
$._ext_INVERSE={
    run : function() {    

try {

 var bounds = app.activeDocument.selection.bounds;
            
            if(bounds)
app.activeDocument.selection.invert();}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "Refine" button of the top part of the panel. */   
$._ext_REFINE={
    run : function() {    

try {
    //determine if selection edges present
        var bounds = app.activeDocument.selection.bounds;
    if(bounds)
    //if selection edges are present, open Refine Edge dialog
    sTID = function(s) { return app.stringIDToTypeID(s); };

function RefineEdge() {
executeAction(sTID('refineSelectionEdge'), undefined, DialogModes.ALL);
  };

  RefineEdge();  }

catch(e) {    //starts what to do if no selection edges are present    
     
    //determine if layer mask is present    
function hasLayerMask() {   
var hasLayerMask = false;   
try {   
var ref = new ActionReference();   
var keyUserMaskEnabled = app.charIDToTypeID( 'UsrM' );   
ref.putProperty( app.charIDToTypeID( 'Prpr' ), keyUserMaskEnabled );   
ref.putEnumerated( app.charIDToTypeID( 'Lyr ' ), app.charIDToTypeID( 'Ordn' ), app.charIDToTypeID( 'Trgt' ) );   
var desc = executeActionGet( ref );   
if ( desc.hasKey( keyUserMaskEnabled ))  {   
hasLayerMask = true;   
}   
}catch(e) {   
hasLayerMask = false;   
}   
return hasLayerMask;   
} 

if((hasLayerMask() == true) && (!bounds)) {
    //if layer mask is present and no selection edgtes, try to make the layer mask the active object
    try {
        var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc3.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc3.putBoolean( idMkVs, false );
executeAction( idslct, desc3, DialogModes.NO ); }
    catch(e) {}  //do nothing if the layer mask is absent or is already the active object
    //and then try to open the Refine Mask dialog
    try {
        sTID = function(s) { return app.stringIDToTypeID(s); };

function RefineEdge() {
executeAction(sTID('refineSelectionEdge'), undefined, DialogModes.ALL);
  };

  RefineEdge();    }
     catch(e) {}
    }  //end of if statement
  }
					app.bringToFront();
    },
};

    								/*** Start "Save Selection" button of the top part of the panel. */   
$._ext_SAVESELECTION={
    run : function() {    

try {

var bounds = app.activeDocument.selection.bounds;
            
if(bounds)
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function SaveSelection() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Chnl'), sTID("selection"));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('Dplc'), desc1, DialogModes.ALL);
  };

  SaveSelection();

}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "+/- View" button of the top part of the panel. */   
$._ext_PMVIEW={
    run : function() {    

try {

var bounds = app.activeDocument.selection.bounds;
if(bounds)

app.activeDocument.suspendHistory("Mask View On", "tkaction()");

function tkaction() {
    
// ===================================================
var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    
    writeToFile(layerIdentifier); 
    
    function writeToFile(invalue)
{  
    // define the file you are going to want to save the data too. 
    var loc = Folder.userData ;
    var cmdFile = new File (loc + "/layerIdentifierForView.ini");
    // does the file exist?  if it does, then delete it because we are going to want to create a new one when we are done. 
    if (cmdFile.exists) cmdFile.remove();
    var str = invalue ;
  // writing the string to the batch file
  if( !cmdFile.open("w") ){ throw new Error("Unable to open \"" + cmdFile + "\".\r" + cmdFile.error); }
    cmdFile.write(str);
    cmdFile.close();
// done creating temp file. 
}

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc3.putReference( idnull, ref3 );
    var idNm = charIDToTypeID( "Nm  " );
    desc3.putString( idNm, """View Selection--saved""" );
executeAction( idDplc, desc3, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref4.putClass( idlayerSection );
    desc4.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc5.putString( idNm, """View Selection group""" );
    var idlayerSection = stringIDToTypeID( "layerSection" );
    desc4.putObject( idUsng, idlayerSection, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref6 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref7.putClass( idcontentLayer );
    desc7.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc8 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc8.putString( idNm, """View Selection fill layer""" );
        var idType = charIDToTypeID( "Type" );
            var desc9 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc10 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc10.putDouble( idRd, 161.997528 );
                var idGrn = charIDToTypeID( "Grn " );
                desc10.putDouble( idGrn, 65.002899 );
                var idBl = charIDToTypeID( "Bl  " );
                desc10.putDouble( idBl, 65.002899 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc9.putObject( idClr, idRGBC, desc10 );
        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
        desc8.putObject( idType, idsolidColorLayer, desc9 );
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    desc7.putObject( idUsng, idcontentLayer, desc8 );
executeAction( idMk, desc7, DialogModes.NO );


// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """View Selection desaturation layer""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc4.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc3.putObject( idType, idHStr, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc5.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc6 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idAdjs = charIDToTypeID( "Adjs" );
            var list1 = new ActionList();
                var desc7 = new ActionDescriptor();
                var idH = charIDToTypeID( "H   " );
                desc7.putInteger( idH, 0 );
                var idStrt = charIDToTypeID( "Strt" );
                desc7.putInteger( idStrt, -100 );
                var idLght = charIDToTypeID( "Lght" );
                desc7.putInteger( idLght, 0 );
            var idHsttwo = charIDToTypeID( "Hst2" );
            list1.putObject( idHsttwo, desc7 );
        desc6.putList( idAdjs, list1 );
    var idHStr = charIDToTypeID( "HStr" );
    desc5.putObject( idT, idHStr, desc6 );
executeAction( idsetd, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc15 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idLyr, idOrdn, idTrgt );
    desc15.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idPrvs = charIDToTypeID( "Prvs" );
        ref10.putEnumerated( idLyr, idOrdn, idPrvs );
    desc15.putReference( idT, ref10 );
executeAction( idmove, desc15, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc16.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """View Selection curves layer""" );
        var idType = charIDToTypeID( "Type" );
            var desc18 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc18.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc17.putObject( idType, idCrvs, desc18 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc16.putObject( idUsng, idAdjL, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc19.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc20.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idAdjs = charIDToTypeID( "Adjs" );
            var list1 = new ActionList();
                var desc21 = new ActionDescriptor();
                var idChnl = charIDToTypeID( "Chnl" );
                    var ref13 = new ActionReference();
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idCmps = charIDToTypeID( "Cmps" );
                    ref13.putEnumerated( idChnl, idChnl, idCmps );
                desc21.putReference( idChnl, ref13 );
                var idCrv = charIDToTypeID( "Crv " );
                    var list2 = new ActionList();
                        var desc22 = new ActionDescriptor();
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        desc22.putDouble( idHrzn, 0.000000 );
                        var idVrtc = charIDToTypeID( "Vrtc" );
                        desc22.putDouble( idVrtc, 192.000000 );
                    var idPnt = charIDToTypeID( "Pnt " );
                    list2.putObject( idPnt, desc22 );
                        var desc23 = new ActionDescriptor();
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        desc23.putDouble( idHrzn, 64.000000 );
                        var idVrtc = charIDToTypeID( "Vrtc" );
                        desc23.putDouble( idVrtc, 128.000000 );
                    var idPnt = charIDToTypeID( "Pnt " );
                    list2.putObject( idPnt, desc23 );
                        var desc24 = new ActionDescriptor();
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        desc24.putDouble( idHrzn, 192.000000 );
                        var idVrtc = charIDToTypeID( "Vrtc" );
                        desc24.putDouble( idVrtc, 192.000000 );
                    var idPnt = charIDToTypeID( "Pnt " );
                    list2.putObject( idPnt, desc24 );
                        var desc25 = new ActionDescriptor();
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        desc25.putDouble( idHrzn, 255.000000 );
                        var idVrtc = charIDToTypeID( "Vrtc" );
                        desc25.putDouble( idVrtc, 128.000000 );
                    var idPnt = charIDToTypeID( "Pnt " );
                    list2.putObject( idPnt, desc25 );
                desc21.putList( idCrv, list2 );
            var idCrvA = charIDToTypeID( "CrvA" );
            list1.putObject( idCrvA, desc21 );
        desc20.putList( idAdjs, list1 );
    var idCrvs = charIDToTypeID( "Crvs" );
    desc19.putObject( idT, idCrvs, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc1 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref1.putName( idLyr, "View Selection group" );
    desc1.putReference( idnull, ref1 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc1.putBoolean( idMkVs, false );
executeAction( idslct, desc1, DialogModes.NO );

// === Select View Selection fill layer ===
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref2.putName( idLyr, "View Selection fill layer" );
    desc2.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc2.putBoolean( idMkVs, false );
executeAction( idslct, desc2, DialogModes.NO );

// === Make Hue/Sat layer ===
var idMk = charIDToTypeID( "Mk  " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc3.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc4 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc4.putString( idNm, """View Selection Hue/Saturation""" );
        var idType = charIDToTypeID( "Type" );
            var desc5 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc5.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc5.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc4.putObject( idType, idHStr, desc5 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc3.putObject( idUsng, idAdjL, desc4 );
executeAction( idMk, desc3, DialogModes.NO );

// === Adjust Hue/Sat properties ===
var idsetd = charIDToTypeID( "setd" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref4.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc6.putReference( idnull, ref4 );
    var idT = charIDToTypeID( "T   " );
        var desc7 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idAdjs = charIDToTypeID( "Adjs" );
            var list1 = new ActionList();
                var desc8 = new ActionDescriptor();
                var idH = charIDToTypeID( "H   " );
                desc8.putInteger( idH, -117 );
                var idStrt = charIDToTypeID( "Strt" );
                desc8.putInteger( idStrt, 57 );
                var idLght = charIDToTypeID( "Lght" );
                desc8.putInteger( idLght, 0 );
            var idHsttwo = charIDToTypeID( "Hst2" );
            list1.putObject( idHsttwo, desc8 );
        desc7.putList( idAdjs, list1 );
    var idHStr = charIDToTypeID( "HStr" );
    desc6.putObject( idT, idHStr, desc7 );
executeAction( idsetd, desc6, DialogModes.NO );

// === Clip to layer below ===
var idGrpL = charIDToTypeID( "GrpL" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref5 );
executeAction( idGrpL, desc9, DialogModes.NO );

// === Hide Hue/Sat layer ===
var idHd = charIDToTypeID( "Hd  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var list2 = new ActionList();
            var ref6 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref6.putEnumerated( idLyr, idOrdn, idTrgt );
        list2.putReference( ref6 );
    desc10.putList( idnull, list2 );
executeAction( idHd, desc10, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref14.putName( idLyr, "View Selection group" );
    desc26.putReference( idnull, ref14 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc26.putBoolean( idMkVs, false );
executeAction( idslct, desc26, DialogModes.NO );    }  //end tkaction function

}  //end try

catch(e) {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "View Selection--saved" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Mask View Off", "tkaction()");    
    
function tkaction() {    
 
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref1.putName( idLyr, "View Selection group" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref2.putProperty( idChnl, idfsel );
    desc3.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "View Selection--saved" );
    desc3.putReference( idT, ref3 );
executeAction( idsetd, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "View Selection--saved" );
    desc4.putReference( idnull, ref4 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref5.putEnumerated( idChnl, idChnl, idRGB );
    desc5.putReference( idnull, ref5 );
executeAction( idslct, desc5, DialogModes.NO );  

    var layerIdentifier = getSavedSettings();
    
function getSavedSettings() 
{
    var loc = Folder.userData ;
    var SavedSettingsFileLoc =loc + "/layerIdentifierForView.ini";
    var SavedSettingsFile = new File(SavedSettingsFileLoc);
    // does the file exist and can you read it? 
	if ( SavedSettingsFile.open('r') )
	{
        // If so, open it for reading then...
        var SavedSettings = SavedSettingsFile.readln();
        SavedSettingsFile.close();
        //and return the contents. 
        return SavedSettings;
    }
        else {}
}   //end getSavedSettings() function

// ===================================================
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );

}//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Select" button of the top part of the panel. */   
$._ext_PMSELECT={
    run : function() {    

try {

var bounds = app.activeDocument.selection.bounds;
            
if(bounds)

app.activeDocument.selection.deselect();}

catch(e) {

try {

var documentOpen = app.activeDocument

if(documentOpen)

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function Reselect() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Chnl'), sTID("selection"));
    desc1.putReference(cTID('null'), ref1);
    desc1.putEnumerated(cTID('T   '), cTID('Ordn'), cTID('Prvs'));
    executeAction(cTID('setd'), desc1, DialogModes.NO);
  };

  Reselect();

 }

catch(e) {}

}
								app.bringToFront();
    },
};

   								 /*** Start "Clear Channels" button of the top part of the panel. */    
$._ext_CLEARCHANNELS={
    run : function() {    
    	
if (app.activeDocument.channels.length>3)
  
    app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

while(app.activeDocument.channels.length>3)  {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref9.putIndex( idChnl, 4 );
    desc9.putReference( idnull, ref9 );
executeAction( idslct, desc9, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc12.putReference( idnull, ref12 );
executeAction( idDlt, desc12, DialogModes.NO );   }  //end while

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref13.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref13 );
executeAction( idslct, desc13, DialogModes.NO );
        
        }  //end function
									app.bringToFront();
    },
};

    								/*** Start "Darks-1" button of the "Spectrum" tab of the panel. */   
$._ext_DARKS1={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-1" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );


// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  // close catch(e) for loading selection from Channels panel 
									app.bringToFront();
    },
};

    								/*** Start "MT1" button of the "Spectrum" tab of the panel. */   
$._ext_MT1={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-1" button of the "Spectrum" tab of the panel. */   
$._ext_LIGHTS1={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-1" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "Darks-2" button of the "Spectrum" tab of the panel. */   
$._ext_DARKS2={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-2" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "MT-2" button of the "Spectrum" tab of the panel. */   
$._ext_MT2={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idT, ref11 );
        var idInvr = charIDToTypeID( "Invr" );
        desc17.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-2 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref16.putProperty( idChnl, idfsel );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idT, ref17 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Darks-2 temp" );
    desc25.putReference( idnull, ref19 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-2 temp" );
    desc26.putReference( idnull, ref20 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-1 temp" );
    desc27.putReference( idnull, ref21 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref22 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref23 );
executeAction( idslct, desc29, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-2" button of the "Spectrum" tab of the panel. */   
$._ext_LIGHTS2={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-2" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {


try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "Darks-3" button of the "Spectrum" tab of the panel. */   
$._ext_DARKS3={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-3" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref10.putProperty( idChnl, idfsel );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idT, ref11 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Darks-2" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idLyr, idOrdn, idTrgt );
    desc17.putReference( idnull, ref14 );
executeAction( idDlt, desc17, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "Midtones-3" button of the "Spectrum" tab of the panel. */   
$._ext_MT3={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Lights-2 temp" );
    desc36.putReference( idnull, ref28 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Lights-1 temp" );
    desc37.putReference( idnull, ref29 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Darks-2 temp" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref22.putProperty( idChnl, idfsel );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idT, ref23 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idChnl, idOrdn, idTrgt );
    desc31.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var desc32 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc32.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putObject( idT, idChnl, desc32 );
executeAction( idsetd, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-3 temp" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref27.putName( idChnl, "Lights-3 temp" );
    desc35.putReference( idnull, ref27 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref30.putEnumerated( idLyr, idOrdn, idTrgt );
    desc38.putReference( idnull, ref30 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref31.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref31 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "LIGHTS-3" button of the "Spectrum" tab of the panel. */   
$._ext_LIGHTS3={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-3" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref10.putProperty( idChnl, idfsel );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idT, ref11 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idLyr, idOrdn, idTrgt );
    desc17.putReference( idnull, ref14 );
executeAction( idDlt, desc17, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "D-4" button of the "Spectrum" tab of the panel. */   
$._ext_DARKS4={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-4" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idT, ref15 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "Midtones-4" button of the "Spectrum" tab of the panel. */   
$._ext_MT4={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-1 temp" );
        desc27.putReference( idT, ref19 );
        var idInvr = charIDToTypeID( "Invr" );
        desc27.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1 temp" );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Lights-1 temp" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc32 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc32.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc32.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc32.putReference( idSrctwo, ref24 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc31.putObject( idUsng, idClcl, desc32 );
executeAction( idMk, desc31, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc33.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc34 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc34.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc33.putObject( idT, idChnl, desc34 );
executeAction( idsetd, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Darks-2 temp" );
    desc35.putReference( idnull, ref26 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref27 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref28 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref28.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref28 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref29 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref30.putName( idChnl, "Darks-3 temp" );
    desc40.putReference( idnull, ref30 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc41 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc41.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc42 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref31 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref31.putEnumerated( idChnl, idOrdn, idTrgt );
        desc42.putReference( idT, ref31 );
        var idInvr = charIDToTypeID( "Invr" );
        desc42.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc42.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref32.putName( idChnl, "Lights-4 temp" );
        desc42.putReference( idSrctwo, ref32 );
        var idInvS = charIDToTypeID( "InvS" );
        desc42.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc41.putObject( idUsng, idClcl, desc42 );
executeAction( idMk, desc41, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref33.putProperty( idChnl, idfsel );
    desc43.putReference( idnull, ref33 );
    var idT = charIDToTypeID( "T   " );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref34.putEnumerated( idChnl, idOrdn, idTrgt );
    desc43.putReference( idT, ref34 );
executeAction( idsetd, desc43, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref35.putEnumerated( idChnl, idOrdn, idTrgt );
    desc44.putReference( idnull, ref35 );
    var idT = charIDToTypeID( "T   " );
        var desc45 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc45.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putObject( idT, idChnl, desc45 );
executeAction( idsetd, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Darks-4 temp" );
    desc46.putReference( idnull, ref36 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Lights-4 temp" );
    desc47.putReference( idnull, ref37 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc48.putReference( idnull, ref38 );
executeAction( idDlt, desc48, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc49 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc49.putReference( idnull, ref39 );
executeAction( idslct, desc49, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "L-4" button of the "Spectrum" tab of the panel. */   
$._ext_LIGHTS4={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-4" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idT, ref15 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel 
									app.bringToFront();
    },
};

    								/*** Start "D5" button of the "Spectrum" tab of the panel. */   
$._ext_DARKS5={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-5" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref18.putProperty( idChnl, idfsel );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idT, ref19 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "Midtones-5" button of the "Spectrum" tab of the panel. */   
$._ext_MT5={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Lights-4 temp" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc32 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref23.putName( idChnl, "Lights-1 temp" );
        desc32.putReference( idT, ref23 );
        var idInvr = charIDToTypeID( "Invr" );
        desc32.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc32.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Lights-1 temp" );
        desc32.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc32.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc31.putObject( idUsng, idClcl, desc32 );
executeAction( idMk, desc31, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc33.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc34 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc34.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc33.putObject( idT, idChnl, desc34 );
executeAction( idsetd, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Lights-1 temp" );
    desc35.putReference( idnull, ref26 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref27 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref28 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref28.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref28 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref29 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref30.putName( idChnl, "Darks-2 temp" );
    desc40.putReference( idnull, ref30 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc41 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc41.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc42 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref31 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref31.putEnumerated( idChnl, idOrdn, idTrgt );
        desc42.putReference( idT, ref31 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc42.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref32.putEnumerated( idChnl, idOrdn, idTrgt );
        desc42.putReference( idSrctwo, ref32 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc41.putObject( idUsng, idClcl, desc42 );
executeAction( idMk, desc41, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref33.putEnumerated( idChnl, idOrdn, idTrgt );
    desc43.putReference( idnull, ref33 );
    var idT = charIDToTypeID( "T   " );
        var desc44 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc44.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc43.putObject( idT, idChnl, desc44 );
executeAction( idsetd, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Darks-3 temp" );
    desc45.putReference( idnull, ref34 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc46 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc47 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref35.putEnumerated( idChnl, idOrdn, idTrgt );
        desc47.putReference( idT, ref35 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc47.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref36.putEnumerated( idChnl, idOrdn, idTrgt );
        desc47.putReference( idSrctwo, ref36 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc46.putObject( idUsng, idClcl, desc47 );
executeAction( idMk, desc46, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc48.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc49 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc49.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putObject( idT, idChnl, desc49 );
executeAction( idsetd, desc48, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref38.putName( idChnl, "Darks-4 temp" );
    desc50.putReference( idnull, ref38 );
executeAction( idDlt, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc51 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc51.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc52 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref39.putEnumerated( idChnl, idOrdn, idTrgt );
        desc52.putReference( idT, ref39 );
        var idInvr = charIDToTypeID( "Invr" );
        desc52.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc52.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref40 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref40.putName( idChnl, "Lights-5 temp" );
        desc52.putReference( idSrctwo, ref40 );
        var idInvS = charIDToTypeID( "InvS" );
        desc52.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc51.putObject( idUsng, idClcl, desc52 );
executeAction( idMk, desc51, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc53 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref41 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref41.putProperty( idChnl, idfsel );
    desc53.putReference( idnull, ref41 );
    var idT = charIDToTypeID( "T   " );
        var ref42 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref42.putEnumerated( idChnl, idOrdn, idTrgt );
    desc53.putReference( idT, ref42 );
executeAction( idsetd, desc53, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc54 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc54.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc55 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc55.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putObject( idT, idChnl, desc55 );
executeAction( idsetd, desc54, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc56 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref44 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref44.putName( idChnl, "Darks-5 temp" );
    desc56.putReference( idnull, ref44 );
executeAction( idDlt, desc56, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc57 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref45 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref45.putName( idChnl, "Lights-5 temp" );
    desc57.putReference( idnull, ref45 );
executeAction( idDlt, desc57, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idLyr, idOrdn, idTrgt );
    desc58.putReference( idnull, ref46 );
executeAction( idDlt, desc58, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc59 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref47 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref47.putEnumerated( idChnl, idChnl, idRGB );
    desc59.putReference( idnull, ref47 );
executeAction( idslct, desc59, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "L5" button of the "Spectrum" tab of the panel. */   
$._ext_LIGHTS5={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-5" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref18.putProperty( idChnl, idfsel );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idT, ref19 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel  
									app.bringToFront();
    },
};

    								/*** Start "1 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_112={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-6 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Darks-3 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Darks-5 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Darks-6 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """TK-temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Darks-2 temp" );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "TK-temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Darks-6 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Darks-5 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Darks-4 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Darks-3 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Darks-2 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "2 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_212={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Darks-2 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Darks-4 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Darks-5 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """TK-temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Darks-1 temp" );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "TK-temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Darks-5 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Darks-4 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Darks-3 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Darks-2 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Darks-1 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "3 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_312={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idInvr = charIDToTypeID( "Invr" );
        desc13.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
        var idInvS = charIDToTypeID( "InvS" );
        desc13.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Darks-1 temp" );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Darks-1 temp" );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Darks-1 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Darks-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Darks-4 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """TK-temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Lights-2 temp" );
        desc37.putReference( idSrctwo, ref27 );
        var idInvS = charIDToTypeID( "InvS" );
        desc37.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "TK-temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Darks-4 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Darks-3 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Darks-2 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Lights-2 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Darks-1 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Alt-5" button of the "Spectrum" tab of the panel. */     
$._ext_ALT5={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-2 temp" );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Darks-2 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Darks-3 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """TK-temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Lights-3 temp" );
        desc37.putReference( idSrctwo, ref27 );
        var idInvS = charIDToTypeID( "InvS" );
        desc37.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "TK-temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Darks-3 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Darks-2 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Lights-3 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Lights-2 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Lights-1 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
}; 

    								/*** Start "6 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_612={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref17.putName( idChnl, "Lights-1 temp" );
        desc25.putReference( idT, ref17 );
        var idInvr = charIDToTypeID( "Invr" );
        desc25.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref18.putName( idChnl, "Lights-1 temp" );
        desc25.putReference( idSrctwo, ref18 );
        var idInvS = charIDToTypeID( "InvS" );
        desc25.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Lights-4 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Tk-temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Darks-2 temp" );
        desc37.putReference( idSrctwo, ref27 );
        var idInvS = charIDToTypeID( "InvS" );
        desc37.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "Tk-temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Darks-2 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Lights-4 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Lights-3 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Lights-2 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Lights-1 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "7 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_712={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-2 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-4 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-Temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Lights-5 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Tk-Temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Lights-1 temp" );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "Tk-Temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-Temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Lights-5 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Lights-4 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Lights-3 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Lights-2 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Lights-1 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "8 1/2" button of the "Spectrum" tab of the panel. */   
$._ext_812={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-6 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-5 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """TK-Temp-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref24.putName( idChnl, "Lights-6 temp" );
        desc33.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc33.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """TK-Temp-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Lights-2 temp" );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref28.putProperty( idChnl, idfsel );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idT, ref29 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "TK-Temp-2" );
    desc40.putReference( idnull, ref31 );
executeAction( idDlt, desc40, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc41 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "TK-Temp-1" );
    desc41.putReference( idnull, ref32 );
executeAction( idDlt, desc41, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Lights-6 temp" );
    desc42.putReference( idnull, ref33 );
executeAction( idDlt, desc42, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc43 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Lights-5 temp" );
    desc43.putReference( idnull, ref34 );
executeAction( idDlt, desc43, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref35 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref35.putName( idChnl, "Lights-4 temp" );
    desc44.putReference( idnull, ref35 );
executeAction( idDlt, desc44, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc45 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref36 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref36.putName( idChnl, "Lights-3 temp" );
    desc45.putReference( idnull, ref36 );
executeAction( idDlt, desc45, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref37.putName( idChnl, "Lights-2 temp" );
    desc46.putReference( idnull, ref37 );
executeAction( idDlt, desc46, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc47 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref38 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref38.putEnumerated( idLyr, idOrdn, idTrgt );
    desc47.putReference( idnull, ref38 );
executeAction( idDlt, desc47, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref39 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref39.putEnumerated( idChnl, idChnl, idRGB );
    desc48.putReference( idnull, ref39 );
executeAction( idslct, desc48, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "1" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_1={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 1" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-4 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-5 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-4 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "2" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_2={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 2" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Darks-3 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Darks-4 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-3 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  

}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "3" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_3={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 3" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Darks-2 temp" );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref13.putProperty( idChnl, idfsel );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idT, ref14 );
executeAction( idsetd, desc18, DialogModes.NO );
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref16.putName( idChnl, "Darks-3 temp" );
    desc20.putReference( idnull, ref16 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-2 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "4" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_4={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 4" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putObject( idT, idChnl, desc17 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Darks-1 temp" );
        desc19.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc19.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idSrctwo, ref13 );
        var idInvS = charIDToTypeID( "InvS" );
        desc19.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc18.putObject( idUsng, idClcl, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc20.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idT, ref15 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-2 temp" );
    desc22.putReference( idnull, ref17 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Darks-1 temp" );
    desc23.putReference( idnull, ref18 );
executeAction( idDlt, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc24.putReference( idnull, ref19 );
executeAction( idDlt, desc24, DialogModes.NO );


// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc25.putReference( idnull, ref20 );
executeAction( idslct, desc25, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "5" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_5={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 5" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel  
									app.bringToFront();
    },
};

    								/*** Start "6" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_6={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 6" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref13.putProperty( idChnl, idfsel );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idT, ref14 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref16.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref16 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-1 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "7" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_7={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 7" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-2 temp" );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref13.putProperty( idChnl, idfsel );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idT, ref14 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref16.putName( idChnl, "Lights-3 temp" );
    desc20.putReference( idnull, ref16 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-2 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "8" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_8={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 8" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-3 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-4 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-3 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "9" button of the Zone section of the "Spectrum" tab of the panel. */   
$._ext_9={
    run : function() {    

try {      //loading selection from Channel mask
    
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Zone 9" );
    desc2.putReference( idT, ref2 );
executeAction( idsetd, desc2, DialogModes.NO );    }

catch(e) {

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lightts-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-4 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Lightts-5 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Lights-4 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );


// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
}  //close catch(e) for loading selection from Channels panel
									app.bringToFront();
    },
};

    								/*** Start "1+2+3+4" button of the "Spectrum" tab of the panel. */   
$._ext_1TO4={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc32 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref23.putName( idChnl, "Darks-1 temp" );
        desc32.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc32.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc32.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc32.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc31.putObject( idUsng, idClcl, desc32 );
executeAction( idMk, desc31, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref25.putProperty( idChnl, idfsel );
    desc33.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idChnl, idOrdn, idTrgt );
    desc33.putReference( idT, ref26 );
executeAction( idsetd, desc33, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Darks-5 temp" );
    desc35.putReference( idnull, ref28 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Darks-4 temp" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Darks-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Darks-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Darks-1 temp" );
    desc36.putReference( idnull, ref29 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref30.putEnumerated( idLyr, idOrdn, idTrgt );
    desc37.putReference( idnull, ref30 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref31.putEnumerated( idChnl, idChnl, idRGB );
    desc38.putReference( idnull, ref31 );
executeAction( idslct, desc38, DialogModes.NO );  }

catch (e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "2+3+4" button of the "Spectrum" tab of the panel. */   
$._ext_2TO4={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-1 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-4 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Darks-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Darks-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-1 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e)  {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "3+4" button of the "Spectrum" tab of the panel. */   
$._ext_3TO4={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Darks-1 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Darks-3 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Darks-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-1 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );


// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "X" button of "Spectrum" tab of the panel. */   
$._ext_XBUTTON={
    run : function() {    

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}
									app.bringToFront();
    },
};    								

    								/*** Start "6+7+8+9" button of the "Spectrum" tab of the panel. */   
$._ext_6TO9={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc32 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref23.putName( idChnl, "Lights-1 temp" );
        desc32.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc32.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc32.putReference( idSrctwo, ref24 );
        var idInvS = charIDToTypeID( "InvS" );
        desc32.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc31.putObject( idUsng, idClcl, desc32 );
executeAction( idMk, desc31, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref25.putProperty( idChnl, idfsel );
    desc33.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idChnl, idOrdn, idTrgt );
    desc33.putReference( idT, ref26 );
executeAction( idsetd, desc33, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Lights-5 temp" );
    desc35.putReference( idnull, ref28 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Lights-4 temp" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Lights-1 temp" );
    desc36.putReference( idnull, ref29 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref30.putEnumerated( idLyr, idOrdn, idTrgt );
    desc37.putReference( idnull, ref30 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref31.putEnumerated( idChnl, idChnl, idRGB );
    desc38.putReference( idnull, ref31 );
executeAction( idslct, desc38, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "6+7+8" button of the "Spectrum" tab of the panel. */   
$._ext_6TO8={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-1 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Lights-4 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-3 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Lights-1 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "6+7" button of the "Spectrum" tab of the panel. */   
$._ext_6TO7={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-3 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-2 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-1 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO ); }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "1+2+3" button of the "Spectrum" tab of the panel. */   
$._ext_1TO3={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try{

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-2 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-5 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Darks-4 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Darks-3 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-2 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "2+3" button of the "Spectrum" tab of the panel. */   
$._ext_2TO3={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Darks-2 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Darks-4 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Darks-3 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-2 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "7+8+9" button of the "Spectrum" tab of the panel. */   
$._ext_7TO9={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-2 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );
// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Lights-5 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-4 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-3 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Lights-2 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}   
									app.bringToFront();
    },
};

    								/*** Start "7+8" button of the "Spectrum" tab of the panel. */   
$._ext_7TO8={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-2 temp" );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
        var idInvS = charIDToTypeID( "InvS" );
        desc22.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref17.putProperty( idChnl, idfsel );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idT, ref18 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-4 temp" );
    desc25.putReference( idnull, ref20 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref14.putName( idChnl, "Lights-3 temp" );
    desc20.putReference( idnull, ref14 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-2 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "1+2" button of the "Spectrum" tab of the panel. */   
$._ext_1TO2={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc21 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc22 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc22.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc21.putObject( idUsng, idClcl, desc22 );
executeAction( idMk, desc21, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-3 temp" );
        desc27.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref20 );
        var idInvS = charIDToTypeID( "InvS" );
        desc27.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref21.putProperty( idChnl, idfsel );
    desc28.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idT, ref22 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-5 temp" );
    desc30.putReference( idnull, ref24 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Darks-4 temp" );
    desc25.putReference( idnull, ref18 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-3 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( idLyr, idOrdn, idTrgt );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref27.putEnumerated( idChnl, idChnl, idRGB );
    desc33.putReference( idnull, ref27 );
executeAction( idslct, desc33, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "8+9" button of the "Spectrum" tab of the panel. */   
$._ext_8TO9={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc27 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc27.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc28 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-3 temp" );
        desc28.putReference( idT, ref20 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc28.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref21.putEnumerated( idChnl, idOrdn, idTrgt );
        desc28.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc28.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc27.putObject( idUsng, idClcl, desc28 );
executeAction( idMk, desc27, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref22.putProperty( idChnl, idfsel );
    desc29.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idChnl, idOrdn, idTrgt );
    desc29.putReference( idT, ref23 );
executeAction( idsetd, desc29, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Lights-5 temp" );
    desc31.putReference( idnull, ref25 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Lights-4 temp" );
    desc26.putReference( idnull, ref19 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Lights-3 temp" );
    desc32.putReference( idnull, ref26 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref27.putEnumerated( idLyr, idOrdn, idTrgt );
    desc33.putReference( idnull, ref27 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref28.putEnumerated( idChnl, idChnl, idRGB );
    desc34.putReference( idnull, ref28 );
executeAction( idslct, desc34, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "+/- Darks" button of the "Spectrum" tab of the panel. */   
$._ext_PMDARKS={
    run : function() {    

try {
      
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Darks-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Darks-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Darks-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Darks-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );  

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO )   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Infinity Darks" button of the "Spectrum" tab of the panel. */   
$._ext_INFINITYDARKS={
    run : function() {    

if (documents.length !== 0)
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {
    
try {
// to remove New Selection channel=============================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}  //do nothing

var bookmarkedLayer = bookmark()
deselect()
selectRGB()
makeInfinityGroup ()
moveGroup()
makeVibrance()
adjustVibrance()
makeLevels()
selectRGB()
var levelsResult = adjustLevels()
    if (levelsResult !== "canceled")  {    
    calculateSelection()
    renameChannel()
    loadSelection()
        }
deleteInfinityGroup()
selectBookmark()
selectRGB()

//+++++++++++ Functions start below ++++++++++++++++

function bookmark() {
    // === Bookmark current layer ===
    var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    return layerIdentifier;
    } 

function deselect() {
// ===================================================
app.activeDocument.selection.deselect()
    }

function selectRGB() {
    // === Select RGB ===
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );
    }

function makeInfinityGroup () {
    // === Make Infinity group ===
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref1.putClass( idlayerSection );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """TK Infinity Mask""" );
    var idlayerSection = stringIDToTypeID( "layerSection" );
    desc2.putObject( idUsng, idlayerSection, desc3 );
executeAction( idMk, desc2, DialogModes.NO );
    }

function moveGroup() {
    // === Move group to front ===
var idmove = charIDToTypeID( "move" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idLyr, idOrdn, idTrgt );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref2.putEnumerated( idLyr, idOrdn, idFrnt );
    desc2.putReference( idT, ref2 );
executeAction( idmove, desc2, DialogModes.NO );
    }

function makeVibrance() {
    // === Make Vibrance layer to remove color saturation ===
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Infinity Saturation""" );
        var idType = charIDToTypeID( "Type" );
        var idvibrance = stringIDToTypeID( "vibrance" );
        desc3.putClass( idType, idvibrance );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );
    }

function adjustVibrance() {
    // === Adjust Vibrance layer ===
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc4.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc5 = new ActionDescriptor();
        var idStrt = charIDToTypeID( "Strt" );
        desc5.putInteger( idStrt, -100 );
    var idvibrance = stringIDToTypeID( "vibrance" );
    desc4.putObject( idT, idvibrance, desc5 );
executeAction( idsetd, desc4, DialogModes.NO );
    }

function makeLevels() {
    // === Make Levels adjustment layer ===
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc24.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Infinity Adjust""" );
        var idType = charIDToTypeID( "Type" );
            var desc26 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc26.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc25.putObject( idType, idLvls, desc26 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc24.putObject( idUsng, idAdjL, desc25 );
executeAction( idMk, desc24, DialogModes.NO );
    }
    
function adjustLevels() {    
    // === Open Levels dialog ===
var idsetd = charIDToTypeID( "setd" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc29.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc30 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc30.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idAdjs = charIDToTypeID( "Adjs" );
            var list1 = new ActionList();
                var desc31 = new ActionDescriptor();
                var idChnl = charIDToTypeID( "Chnl" );
                    var ref14 = new ActionReference();
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idCmps = charIDToTypeID( "Cmps" );
                    ref14.putEnumerated( idChnl, idChnl, idCmps );
                desc31.putReference( idChnl, ref14 );
                var idOtpt = charIDToTypeID( "Otpt" );
                    var list2 = new ActionList();
                    list2.putInteger( 255 );
                    list2.putInteger( 0 );
                desc31.putList( idOtpt, list2 );
            var idLvlA = charIDToTypeID( "LvlA" );
            list1.putObject( idLvlA, desc31 );
        desc30.putList( idAdjs, list1 );
    var idLvls = charIDToTypeID( "Lvls" );
    desc29.putObject( idT, idLvls, desc30 );    
            try {
        executeAction( idsetd, desc29, DialogModes.ALL );
        }
    catch(e) {
        var canceledDialog = "canceled"
        return canceledDialog;
        }     //end catch(e)
    }  //end adjustLevels() function

function calculateSelection() {
    // === Calculate selection and mask ===
var idMk = charIDToTypeID( "Mk  " );
    var desc54 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc55 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref19.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref19.putEnumerated( idLyr, idOrdn, idMrgd );
        desc55.putReference( idT, ref19 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref20.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref20.putEnumerated( idLyr, idOrdn, idMrgd );
        desc55.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc54.putObject( idUsng, idClcl, desc55 );
executeAction( idMk, desc54, DialogModes.NO );
    }

function renameChannel() {
    // === Rename channel to New Selection ===
var idsetd = charIDToTypeID( "setd" );
    var desc56 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc56.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc57 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc57.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putObject( idT, idChnl, desc57 );
executeAction( idsetd, desc56, DialogModes.NO );
    }

function loadSelection() {
    // === Load channel as selection ===
var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref22.putProperty( idChnl, idfsel );
    desc58.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idT, ref23 );
executeAction( idsetd, desc58, DialogModes.NO );
     }

function deleteInfinityGroup() {
    // === Delete Infinity group ===
var idDlt = charIDToTypeID( "Dlt " );
    var desc59 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref24.putName( idLyr, "TK Infinity Mask" );
    desc59.putReference( idnull, ref24 );
executeAction( idDlt, desc59, DialogModes.NO );
    }

function selectBookmark() {
    // === Make bookmarked layer active ===
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), bookmarkedLayer);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  
       }

}  //end tkaction() function
									app.bringToFront();
    },
};

    								/*** Start "+/- ZONES" button of the "Spectrum" tab of the panel. */   
$._ext_PMZONES={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Zone 10" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc156 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref121 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref121.putName( idChnl, "Zone 10" );
    desc156.putReference( idnull, ref121 );
executeAction( idDlt, desc156, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc157 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref122 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref122.putName( idChnl, "Zone 9" );
    desc157.putReference( idnull, ref122 );
executeAction( idDlt, desc157, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc158 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref123 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref123.putName( idChnl, "Zone 8" );
    desc158.putReference( idnull, ref123 );
executeAction( idDlt, desc158, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc159 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref124 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref124.putName( idChnl, "Zone 7" );
    desc159.putReference( idnull, ref124 );
executeAction( idDlt, desc159, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc160 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref125 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref125.putName( idChnl, "Zone 6" );
    desc160.putReference( idnull, ref125 );
executeAction( idDlt, desc160, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc161 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref126 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref126.putName( idChnl, "Zone 5" );
    desc161.putReference( idnull, ref126 );
executeAction( idDlt, desc161, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc162 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref127 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref127.putName( idChnl, "Zone 4" );
    desc162.putReference( idnull, ref127 );
executeAction( idDlt, desc162, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc163 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref128 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref128.putName( idChnl, "Zone 3" );
    desc163.putReference( idnull, ref128 );
executeAction( idDlt, desc163, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc164 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref129 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref129.putName( idChnl, "Zone 2" );
    desc164.putReference( idnull, ref129 );
executeAction( idDlt, desc164, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc165 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref130 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref130.putName( idChnl, "Zone 1" );
    desc165.putReference( idnull, ref130 );
executeAction( idDlt, desc165, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc166 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref131 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref131.putName( idChnl, "Zone 0" );
    desc166.putReference( idnull, ref131 );
executeAction( idDlt, desc166, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc50 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc50.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc51 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref35.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref35.putEnumerated( idLyr, idOrdn, idMrgd );
        desc51.putReference( idT, ref35 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref36.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref36.putEnumerated( idLyr, idOrdn, idMrgd );
        desc51.putReference( idSrctwo, ref36 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc50.putObject( idUsng, idClcl, desc51 );
executeAction( idMk, desc50, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc52 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc52.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc53 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc53.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc52.putObject( idT, idChnl, desc53 );
executeAction( idsetd, desc52, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc54 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc55 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref38 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref38.putEnumerated( idChnl, idOrdn, idTrgt );
        desc55.putReference( idT, ref38 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc55.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref39.putEnumerated( idChnl, idOrdn, idTrgt );
        desc55.putReference( idSrctwo, ref39 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc54.putObject( idUsng, idClcl, desc55 );
executeAction( idMk, desc54, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc56 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref40 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref40.putEnumerated( idChnl, idOrdn, idTrgt );
    desc56.putReference( idnull, ref40 );
    var idT = charIDToTypeID( "T   " );
        var desc57 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc57.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putObject( idT, idChnl, desc57 );
executeAction( idsetd, desc56, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc58 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc58.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc59 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref41 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref41.putEnumerated( idChnl, idOrdn, idTrgt );
        desc59.putReference( idT, ref41 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc59.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref42 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref42.putEnumerated( idChnl, idOrdn, idTrgt );
        desc59.putReference( idSrctwo, ref42 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc58.putObject( idUsng, idClcl, desc59 );
executeAction( idMk, desc58, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc60 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc60.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc61 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc61.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc60.putObject( idT, idChnl, desc61 );
executeAction( idsetd, desc60, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc62 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc63 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref44 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref44.putEnumerated( idChnl, idOrdn, idTrgt );
        desc63.putReference( idT, ref44 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc63.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref45 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref45.putEnumerated( idChnl, idOrdn, idTrgt );
        desc63.putReference( idSrctwo, ref45 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc62.putObject( idUsng, idClcl, desc63 );
executeAction( idMk, desc62, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc64 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idChnl, idOrdn, idTrgt );
    desc64.putReference( idnull, ref46 );
    var idT = charIDToTypeID( "T   " );
        var desc65 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc65.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc64.putObject( idT, idChnl, desc65 );
executeAction( idsetd, desc64, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc66 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc66.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc67 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref47 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref47.putEnumerated( idChnl, idOrdn, idTrgt );
        desc67.putReference( idT, ref47 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc67.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref48.putEnumerated( idChnl, idOrdn, idTrgt );
        desc67.putReference( idSrctwo, ref48 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc66.putObject( idUsng, idClcl, desc67 );
executeAction( idMk, desc66, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref49 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref49.putEnumerated( idChnl, idOrdn, idTrgt );
    desc68.putReference( idnull, ref49 );
    var idT = charIDToTypeID( "T   " );
        var desc69 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc69.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc68.putObject( idT, idChnl, desc69 );
executeAction( idsetd, desc68, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc70 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc70.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc71 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref50 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref50.putName( idChnl, "Lights-1 temp" );
        desc71.putReference( idT, ref50 );
        var idInvr = charIDToTypeID( "Invr" );
        desc71.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref51 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref51.putName( idChnl, "Lights-1 temp" );
        desc71.putReference( idSrctwo, ref51 );
        var idInvS = charIDToTypeID( "InvS" );
        desc71.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc70.putObject( idUsng, idClcl, desc71 );
executeAction( idMk, desc70, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc72 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref52 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref52.putEnumerated( idChnl, idOrdn, idTrgt );
    desc72.putReference( idnull, ref52 );
    var idT = charIDToTypeID( "T   " );
        var desc73 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc73.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc72.putObject( idT, idChnl, desc73 );
executeAction( idsetd, desc72, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc74 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc74.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc75 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref53 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref53.putEnumerated( idChnl, idOrdn, idTrgt );
        desc75.putReference( idT, ref53 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc75.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref54 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref54.putEnumerated( idChnl, idOrdn, idTrgt );
        desc75.putReference( idSrctwo, ref54 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc74.putObject( idUsng, idClcl, desc75 );
executeAction( idMk, desc74, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc76 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref55 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref55.putEnumerated( idChnl, idOrdn, idTrgt );
    desc76.putReference( idnull, ref55 );
    var idT = charIDToTypeID( "T   " );
        var desc77 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc77.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc76.putObject( idT, idChnl, desc77 );
executeAction( idsetd, desc76, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc78 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc78.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc79 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref56 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref56.putEnumerated( idChnl, idOrdn, idTrgt );
        desc79.putReference( idT, ref56 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc79.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref57 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref57.putEnumerated( idChnl, idOrdn, idTrgt );
        desc79.putReference( idSrctwo, ref57 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc78.putObject( idUsng, idClcl, desc79 );
executeAction( idMk, desc78, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc80 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref58 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref58.putEnumerated( idChnl, idOrdn, idTrgt );
    desc80.putReference( idnull, ref58 );
    var idT = charIDToTypeID( "T   " );
        var desc81 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc81.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc80.putObject( idT, idChnl, desc81 );
executeAction( idsetd, desc80, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc82 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc82.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc83 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref59 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref59.putEnumerated( idChnl, idOrdn, idTrgt );
        desc83.putReference( idT, ref59 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc83.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref60 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref60.putEnumerated( idChnl, idOrdn, idTrgt );
        desc83.putReference( idSrctwo, ref60 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc82.putObject( idUsng, idClcl, desc83 );
executeAction( idMk, desc82, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc84 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref61 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref61.putEnumerated( idChnl, idOrdn, idTrgt );
    desc84.putReference( idnull, ref61 );
    var idT = charIDToTypeID( "T   " );
        var desc85 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc85.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc84.putObject( idT, idChnl, desc85 );
executeAction( idsetd, desc84, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc86 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc86.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc87 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref62 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref62.putEnumerated( idChnl, idOrdn, idTrgt );
        desc87.putReference( idT, ref62 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc87.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref63 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref63.putEnumerated( idChnl, idOrdn, idTrgt );
        desc87.putReference( idSrctwo, ref63 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc86.putObject( idUsng, idClcl, desc87 );
executeAction( idMk, desc86, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc88 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref64 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref64.putEnumerated( idChnl, idOrdn, idTrgt );
    desc88.putReference( idnull, ref64 );
    var idT = charIDToTypeID( "T   " );
        var desc89 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc89.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc88.putObject( idT, idChnl, desc89 );
executeAction( idsetd, desc88, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc90 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc90.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc91 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref65 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref65.putName( idChnl, "Darks-4 temp" );
        desc91.putReference( idT, ref65 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc91.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref66 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref66.putEnumerated( idChnl, idOrdn, idTrgt );
        desc91.putReference( idSrctwo, ref66 );
        var idInvS = charIDToTypeID( "InvS" );
        desc91.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc90.putObject( idUsng, idClcl, desc91 );
executeAction( idMk, desc90, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc92 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref67 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref67.putEnumerated( idChnl, idOrdn, idTrgt );
    desc92.putReference( idnull, ref67 );
    var idT = charIDToTypeID( "T   " );
        var desc93 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc93.putString( idNm, """Zone 1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc92.putObject( idT, idChnl, desc93 );
executeAction( idsetd, desc92, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc94 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc94.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc95 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref68 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref68.putName( idChnl, "Darks-3 temp" );
        desc95.putReference( idT, ref68 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc95.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref69 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref69.putName( idChnl, "Darks-4 temp" );
        desc95.putReference( idSrctwo, ref69 );
        var idInvS = charIDToTypeID( "InvS" );
        desc95.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc94.putObject( idUsng, idClcl, desc95 );
executeAction( idMk, desc94, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc96 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref70 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref70.putEnumerated( idChnl, idOrdn, idTrgt );
    desc96.putReference( idnull, ref70 );
    var idT = charIDToTypeID( "T   " );
        var desc97 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc97.putString( idNm, """Zone 2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc96.putObject( idT, idChnl, desc97 );
executeAction( idsetd, desc96, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc98 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc98.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc99 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref71 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref71.putName( idChnl, "Darks-2 temp" );
        desc99.putReference( idT, ref71 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc99.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref72 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref72.putName( idChnl, "Darks-3 temp" );
        desc99.putReference( idSrctwo, ref72 );
        var idInvS = charIDToTypeID( "InvS" );
        desc99.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc98.putObject( idUsng, idClcl, desc99 );
executeAction( idMk, desc98, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc100 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref73 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref73.putEnumerated( idChnl, idOrdn, idTrgt );
    desc100.putReference( idnull, ref73 );
    var idT = charIDToTypeID( "T   " );
        var desc101 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc101.putString( idNm, """Zone 3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc100.putObject( idT, idChnl, desc101 );
executeAction( idsetd, desc100, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc102 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc102.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc103 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref74 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref74.putName( idChnl, "Darks-1 temp" );
        desc103.putReference( idT, ref74 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc103.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref75 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref75.putName( idChnl, "Darks-2 temp" );
        desc103.putReference( idSrctwo, ref75 );
        var idInvS = charIDToTypeID( "InvS" );
        desc103.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc102.putObject( idUsng, idClcl, desc103 );
executeAction( idMk, desc102, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc104 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref76 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref76.putEnumerated( idChnl, idOrdn, idTrgt );
    desc104.putReference( idnull, ref76 );
    var idT = charIDToTypeID( "T   " );
        var desc105 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc105.putString( idNm, """Zone 4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc104.putObject( idT, idChnl, desc105 );
executeAction( idsetd, desc104, DialogModes.NO );
// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc119 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc119.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc120 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref90 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref90.putName( idChnl, "Lights-1 temp" );
        desc120.putReference( idT, ref90 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc120.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref91 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref91.putName( idChnl, "Darks-1 temp" );
        desc120.putReference( idSrctwo, ref91 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc119.putObject( idUsng, idClcl, desc120 );
executeAction( idMk, desc119, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc121 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref92 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref92.putEnumerated( idChnl, idOrdn, idTrgt );
    desc121.putReference( idnull, ref92 );
    var idT = charIDToTypeID( "T   " );
        var desc122 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc122.putString( idNm, """Zone 5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc121.putObject( idT, idChnl, desc122 );
executeAction( idsetd, desc121, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc123 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc123.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc124 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref93 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref93.putName( idChnl, "Lights-1 temp" );
        desc124.putReference( idT, ref93 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc124.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref94 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref94.putName( idChnl, "Lights-2 temp" );
        desc124.putReference( idSrctwo, ref94 );
        var idInvS = charIDToTypeID( "InvS" );
        desc124.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc123.putObject( idUsng, idClcl, desc124 );
executeAction( idMk, desc123, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc125 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref95 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref95.putEnumerated( idChnl, idOrdn, idTrgt );
    desc125.putReference( idnull, ref95 );
    var idT = charIDToTypeID( "T   " );
        var desc126 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc126.putString( idNm, """Zone 6""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc125.putObject( idT, idChnl, desc126 );
executeAction( idsetd, desc125, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc127 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc127.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc128 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref96 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref96.putName( idChnl, "Lights-2 temp" );
        desc128.putReference( idT, ref96 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc128.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref97 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref97.putName( idChnl, "Lights-3 temp" );
        desc128.putReference( idSrctwo, ref97 );
        var idInvS = charIDToTypeID( "InvS" );
        desc128.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc127.putObject( idUsng, idClcl, desc128 );
executeAction( idMk, desc127, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc129 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref98 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref98.putEnumerated( idChnl, idOrdn, idTrgt );
    desc129.putReference( idnull, ref98 );
    var idT = charIDToTypeID( "T   " );
        var desc130 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc130.putString( idNm, """Zone 7""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc129.putObject( idT, idChnl, desc130 );
executeAction( idsetd, desc129, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc131 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc131.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc132 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref99 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref99.putName( idChnl, "Lights-3 temp" );
        desc132.putReference( idT, ref99 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc132.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref100 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref100.putName( idChnl, "Lights-4 temp" );
        desc132.putReference( idSrctwo, ref100 );
        var idInvS = charIDToTypeID( "InvS" );
        desc132.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc131.putObject( idUsng, idClcl, desc132 );
executeAction( idMk, desc131, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc133 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref101 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref101.putEnumerated( idChnl, idOrdn, idTrgt );
    desc133.putReference( idnull, ref101 );
    var idT = charIDToTypeID( "T   " );
        var desc134 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc134.putString( idNm, """Zone 8""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc133.putObject( idT, idChnl, desc134 );
executeAction( idsetd, desc133, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc6 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc6.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc7 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "Lights-4 temp" );
        desc7.putReference( idT, ref3 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc7.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref4.putName( idChnl, "Lights-5 temp" );
        desc7.putReference( idSrctwo, ref4 );
        var idInvS = charIDToTypeID( "InvS" );
        desc7.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc6.putObject( idUsng, idClcl, desc7 );
executeAction( idMk, desc6, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Zone 9""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc139 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref105 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref105.putName( idChnl, "Lights-5 temp" );
    desc139.putReference( idnull, ref105 );
executeAction( idslct, desc139, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc140 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref106 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref106.putEnumerated( idChnl, idOrdn, idTrgt );
    desc140.putReference( idnull, ref106 );
    var idNm = charIDToTypeID( "Nm  " );
    desc140.putString( idNm, """Zone 10""" );
executeAction( idDplc, desc140, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc141 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref107 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref107.putName( idChnl, "Darks-5 temp" );
    desc141.putReference( idnull, ref107 );
executeAction( idslct, desc141, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc142 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref108 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref108.putEnumerated( idChnl, idOrdn, idTrgt );
    desc142.putReference( idnull, ref108 );
    var idT = charIDToTypeID( "T   " );
        var desc143 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc143.putString( idNm, """Zone 0""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc142.putObject( idT, idChnl, desc143 );
executeAction( idsetd, desc142, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc144 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref109 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref109.putName( idChnl, "Darks-4 temp" );
    desc144.putReference( idnull, ref109 );
executeAction( idslct, desc144, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc145 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref110 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref110.putProperty( idChnl, idfsel );
    desc145.putReference( idnull, ref110 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc145.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc145, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc146 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref111 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref111.putEnumerated( idChnl, idOrdn, idTrgt );
    desc146.putReference( idnull, ref111 );
executeAction( idDlt, desc146, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc147 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref112 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref112.putName( idChnl, "Darks-3 temp" );
    desc147.putReference( idnull, ref112 );
executeAction( idDlt, desc147, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc148 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref113 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref113.putName( idChnl, "Darks-2 temp" );
    desc148.putReference( idnull, ref113 );
executeAction( idDlt, desc148, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc149 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref114 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref114.putName( idChnl, "Darks-1 temp" );
    desc149.putReference( idnull, ref114 );
executeAction( idDlt, desc149, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc150 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref115 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref115.putName( idChnl, "Lights-5 temp" );
    desc150.putReference( idnull, ref115 );
executeAction( idDlt, desc150, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc151 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref116 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref116.putName( idChnl, "Lights-4 temp" );
    desc151.putReference( idnull, ref116 );
executeAction( idDlt, desc151, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc152 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref117 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref117.putName( idChnl, "Lights-3 temp" );
    desc152.putReference( idnull, ref117 );
executeAction( idDlt, desc152, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc153 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref118 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref118.putName( idChnl, "Lights-2 temp" );
    desc153.putReference( idnull, ref118 );
executeAction( idDlt, desc153, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc154 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref119 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref119.putName( idChnl, "Lights-1 temp" );
    desc154.putReference( idnull, ref119 );
executeAction( idDlt, desc154, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc155 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref120 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref120.putEnumerated( idChnl, idChnl, idRGB );
    desc155.putReference( idnull, ref120 );
executeAction( idslct, desc155, DialogModes.NO );   }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)

									app.bringToFront();
    },
};
 
    								/*** Start "Zone Picker" button of the "Spectrum" tab of the panel. */   
$._ext_ZONEPICKER={
    run : function() {    

if (app.documents.length !== 0)
    
selectColor()

function selectColor() {    
selectRGB()
var newColor = showColorPicker()
if (newColor === true) {
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");
    }
else {}
}  //end selectColor() 

function tkaction() {
//=== Use Color Picker's value to calculate luminosity ===
var luminosity = app.foregroundColor.lab.l
//Determine zone corresponding to luminosity value
if (luminosity >= 0 && luminosity <= 0.29) darkEnd()
if (luminosity > 0.29 && luminosity <= 1.263) zoneZero()
if (luminosity > 1.263 && luminosity <= 2.313) zoneHalf()
if (luminosity > 2.313 && luminosity <= 4.263) zoneOne()
if (luminosity > 4.263 && luminosity <= 7.739) zoneOneHalf()
if (luminosity > 7.739 && luminosity <= 13.034) zoneTwo()
if (luminosity > 13.034 && luminosity <= 19.156) zoneTwoHalf()
if (luminosity > 19.156 && luminosity <= 26.673) zoneThree()
if (luminosity > 26.673 && luminosity <= 35.211) zoneThreeHalf()
if (luminosity > 35.211 && luminosity <= 44.907) zoneFour()
if (luminosity > 44.907 && luminosity <= 55.362) zoneFourHalf()
if (luminosity > 55.362 && luminosity <= 65.396) zoneFive()
if (luminosity > 65.396 && luminosity <= 74.213) zoneFiveHalf()
if (luminosity > 74.213 && luminosity <= 81.122) zoneSix()
if (luminosity > 81.122 && luminosity <= 86.6) zoneSixHalf()
if (luminosity > 86.6 && luminosity <= 90.14) zoneSeven()
if (luminosity > 90.14 && luminosity <= 92.896) zoneSevenHalf()
if (luminosity > 92.896 && luminosity <= 94.946) zoneEight()
if (luminosity > 94.946 && luminosity <= 96.393) zoneEightHalf()
if (luminosity > 96.393 && luminosity <= 97.437) zoneNine()         
if (luminosity > 97.437 && luminosity <= 98.178) zoneNineHalf()
if (luminosity > 98.178 && luminosity <= 99.277) zoneTen()
if (luminosity > 99.277 && luminosity <= 100) lightEnd()
}  //end tkactoin() function

//++++++++  Functions start below ++++++++++++++

function darkEnd() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")  
    createSeriesLuminosityMask("Darks-4 temp", """Darks-5 temp""")
    createSeriesLuminosityMask("Darks-5 temp", """Darks-6 temp""")
    lightsOrDarks("Darks-6 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    deleteChannel("Darks-5 temp")
    deleteChannel("Darks-6 temp")
    selectRGB()
    }  //end darkEnd() function

function zoneZero() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")  
    createSeriesLuminosityMask("Darks-4 temp", """Darks-5 temp""")
    createSeriesLuminosityMask("Darks-5 temp", """Darks-6 temp""")
    singleZone("Darks-6 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    deleteChannel("Darks-5 temp")
    deleteChannel("Darks-6 temp")
    selectRGB()
    }  //end zoneZero() function

function zoneHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")
    createSeriesLuminosityMask("Darks-4 temp", """Darks-5 temp""")
    createSeriesLuminosityMask("Darks-5 temp", """Darks-6 temp""")
    multiZone("Darks-6 temp", "Darks-5 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    deleteChannel("Darks-5 temp")
    deleteChannel("Darks-6 temp")
    selectRGB()
    }  //end zoneHalf() function

function zoneOne() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")
    createSeriesLuminosityMask("Darks-4 temp", """Darks-5 temp""")
    singleZone("Darks-5 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    deleteChannel("Darks-5 temp")
    selectRGB()
    }  //end zoneOne() function

function zoneOneHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")
    createSeriesLuminosityMask("Darks-4 temp", """Darks-5 temp""")
    multiZone("Darks-5 temp", "Darks-4 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    deleteChannel("Darks-5 temp")
    selectRGB()
    }  //end zoneOneHalf() function

function zoneTwo() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")
    singleZone("Darks-4 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    selectRGB()
    }  //end zoneTwo() function

function zoneTwoHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    createSeriesLuminosityMask("Darks-3 temp", """Darks-4 temp""")
    multiZone("Darks-4 temp", "Darks-3 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    deleteChannel("Darks-4 temp")
    selectRGB()
    }  //end zoneTwoHalf() function

function zoneThree() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    singleZone("Darks-3 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    selectRGB()
    }  //end zoneThree() function

function zoneThreeHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    createSeriesLuminosityMask("Darks-2 temp", """Darks-3 temp""")
    multiZone("Darks-3 temp", "Darks-2 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    deleteChannel("Darks-3 temp")
    selectRGB()
    }  //end zoneThreeHalf() function

function zoneFour() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    singleZone("Darks-2 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    selectRGB()
    }  //end zoneFour() function

function zoneFourHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createDarks1()
    createSeriesLuminosityMask("Darks-1 temp", """Darks-2 temp""")
    multiZone("Darks-2 temp", "Darks-1 temp")
    loadZoneChannel()
    deleteChannel("Darks-1 temp")
    deleteChannel("Darks-2 temp")
    selectRGB()
    }  //end zoneFourHalf() function

function zoneFive() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    singleZone("Lights-1 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    selectRGB()
    }  //end zoneFive() function

function zoneFiveHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    multiZone("Lights-1 temp", "Lights-2 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    selectRGB()
    }  //end zoneFiveHalf() function

function zoneSix() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    singleZone("Lights-2 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    selectRGB()
    }  //end zoneSix() function

function zoneSixHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    multiZone("Lights-2 temp", "Lights-3 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    selectRGB()
    }  //end zoneSixHalf() function

function zoneSeven() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    singleZone("Lights-3 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    selectRGB()
    }  //end zoneSeven() function

function zoneSevenHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    multiZone("Lights-3 temp", "Lights-4 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    selectRGB()
    }  //end zoneSevenHalf() function

function zoneEight() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    singleZone("Lights-4 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    selectRGB()
    }  //end zoneEight() function

function zoneEightHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    createSeriesLuminosityMask("Lights-4 temp", """Lights-5 temp""")
    multiZone("Lights-4 temp", "Lights-5 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    deleteChannel("Lights-5 temp")
    selectRGB()
    }  //end zoneEightHalf() function

function zoneNine() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    createSeriesLuminosityMask("Lights-4 temp", """Lights-5 temp""")
    singleZone("Lights-5 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    deleteChannel("Lights-5 temp")
    selectRGB()
    }  //end zoneNine() function

function zoneNineHalf() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    createSeriesLuminosityMask("Lights-4 temp", """Lights-5 temp""")
    createSeriesLuminosityMask("Lights-5 temp", """Lights-6 temp""")
    multiZone("Lights-5 temp", "Lights-6 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    deleteChannel("Lights-5 temp")
    deleteChannel("Lights-6 temp")
    selectRGB()
    }  //end zoneNineHalf() function

function zoneTen() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    createSeriesLuminosityMask("Lights-4 temp", """Lights-5 temp""")
    createSeriesLuminosityMask("Lights-5 temp", """Lights-6 temp""")
    singleZone("Lights-6 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    deleteChannel("Lights-5 temp")
    deleteChannel("Lights-6 temp")
    selectRGB()
    }  //end zoneTen() function

function lightEnd() {
    reorganizeChannels()
    deselect()
    evaluateLayer()
    createLights1()
    createSeriesLuminosityMask("Lights-1 temp", """Lights-2 temp""")
    createSeriesLuminosityMask("Lights-2 temp", """Lights-3 temp""")
    createSeriesLuminosityMask("Lights-3 temp", """Lights-4 temp""")
    createSeriesLuminosityMask("Lights-4 temp", """Lights-5 temp""")
    createSeriesLuminosityMask("Lights-5 temp", """Lights-6 temp""")
    lightsOrDarks("Lights-6 temp")
    loadZoneChannel()
    deleteChannel("Lights-1 temp")
    deleteChannel("Lights-2 temp")
    deleteChannel("Lights-3 temp")
    deleteChannel("Lights-4 temp")
    deleteChannel("Lights-5 temp")
    deleteChannel("Lights-6 temp")
    selectRGB()
    }  //end lightEnd() function


function selectRGB() {
// === Select RGB ===
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );
}

function reorganizeChannels() {
    try {
    // === Delete New Selecton channel ===
var idDlt = charIDToTypeID( "Dlt " );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "New Selection" );
    desc17.putReference( idnull, ref17 );
executeAction( idDlt, desc17, DialogModes.NO );
    }
    catch(e) {}
    }  //end reorganizeChannels() function  

function deselect() {
// === Deselect ===
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );
}

function multiZone(mask1, mask2) {
    // === Create multi-zone mask ===
var idMk = charIDToTypeID( "Mk  " );
    var desc59 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc59.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc60 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref48.putName( idChnl, mask1 );
        desc60.putReference( idT, ref48 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idXclu = charIDToTypeID( "Xclu" );
        desc60.putEnumerated( idClcl, idClcn, idXclu );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref49 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref49.putName( idChnl, mask2 );
        desc60.putReference( idSrctwo, ref49 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc59.putObject( idUsng, idClcl, desc60 );
executeAction( idMk, desc59, DialogModes.NO );
}

function singleZone(mask) {
// === Create single-zone mask ===
var idMk = charIDToTypeID( "Mk  " );
    var desc49 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc49.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc50 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref39.putName( idChnl, mask );
        desc50.putReference( idT, ref39 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idXclu = charIDToTypeID( "Xclu" );
        desc50.putEnumerated( idClcl, idClcn, idXclu );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref40 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref40.putName( idChnl, mask );
        desc50.putReference( idSrctwo, ref40 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc49.putObject( idUsng, idClcl, desc50 );
executeAction( idMk, desc49, DialogModes.NO );
}

function  lightsOrDarks(mask) {
// === Create a Lights or Darks series mask ===
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc4.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, mask );
        desc5.putReference( idT, ref3 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref4.putName( idChnl, mask );
        desc5.putReference( idSrctwo, ref4 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc4.putObject( idUsng, idClcl, desc5 );
executeAction( idMk, desc4, DialogModes.NO );    
    }

function evaluateLayer() {
    // evaluate if layer is a group or text layer
var layerRef = app.activeDocument.activeLayer.kind
if (layerRef === undefined)
try {
    // === to select layer mask ===
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc2.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc2.putBoolean( idMkVs, false );
executeAction( idslct, desc2, DialogModes.NO );
    }
catch(e) {
    // === make layer mask if one is not present===
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );
    }  //end catch(e)
    }  //end evaluateLayer() function

function createDarks1() {
//=== Calculate Darks-1 ===
var idMk = charIDToTypeID( "Mk  " );
    var desc9 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc9.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc10 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref7.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref7.putEnumerated( idLyr, idOrdn, idMrgd );
        desc10.putReference( idT, ref7 );
        var idInvr = charIDToTypeID( "Invr" );
        desc10.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref8.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref8.putEnumerated( idLyr, idOrdn, idMrgd );
        desc10.putReference( idSrctwo, ref8 );
        var idInvS = charIDToTypeID( "InvS" );
        desc10.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc9.putObject( idUsng, idClcl, desc10 );
executeAction( idMk, desc9, DialogModes.NO );

// === Rename channel Darks-1 temp ===
var idsetd = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc11.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc12 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc12.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putObject( idT, idChnl, desc12 );
executeAction( idsetd, desc11, DialogModes.NO );
}

function createSeriesLuminosityMask(startingMask, maskName) {
// === Calculate a series mask===
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc14 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref9.putName( idChnl, startingMask );
        desc14.putReference( idT, ref9 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc14.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, startingMask );
        desc14.putReference( idSrctwo, ref10 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc13.putObject( idUsng, idClcl, desc14 );
executeAction( idMk, desc13, DialogModes.NO );

// === Rename new channe to match the mask created ===
var idsetd = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc15.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc16.putString( idNm, maskName );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putObject( idT, idChnl, desc16 );
executeAction( idsetd, desc15, DialogModes.NO );
    }

function loadZoneChannel() {
// === Load zone channel as selection ===
var idsetd = charIDToTypeID( "setd" );
    var desc61 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref50.putProperty( idChnl, idfsel );
    desc61.putReference( idnull, ref50 );
    var idT = charIDToTypeID( "T   " );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref51.putEnumerated( idChnl, idOrdn, idTrgt );
    desc61.putReference( idT, ref51 );
executeAction( idsetd, desc61, DialogModes.NO );

// === Rename zone channel New Selection ===
var idsetd = charIDToTypeID( "setd" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref52 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref52.putEnumerated( idChnl, idOrdn, idTrgt );
    desc62.putReference( idnull, ref52 );
    var idT = charIDToTypeID( "T   " );
        var desc63 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc63.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putObject( idT, idChnl, desc63 );
executeAction( idsetd, desc62, DialogModes.NO );
}

function deleteChannel(channel) {
// === Delete a channel replacing the variable "channel" with the channel to delete===
var idDlt = charIDToTypeID( "Dlt " );
    var desc61 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref51.putName( idChnl, channel );
    desc61.putReference( idnull, ref51 );
executeAction( idDlt, desc61, DialogModes.NO );
}

function createLights1() {
//=== Calculate Lights-1 ===
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// === Rename channel Lights-1 temp ===
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );
}									app.bringToFront();
    },
};
 
    								/*** Start "+/- Lights" button of the "Spectrum" tab of the panel. */   
$._ext_PMLIGHTS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );

        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Lights-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Lights-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Lights-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Lights-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO )    }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putObject( idT, idChnl, desc17 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc19.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc18.putObject( idUsng, idClcl, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putObject( idT, idChnl, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref18 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref19 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idLyr, idOrdn, idTrgt );
    desc30.putReference( idnull, ref21 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref22.putEnumerated( idChnl, idChnl, idRGB );
    desc31.putReference( idnull, ref22 );
executeAction( idslct, desc31, DialogModes.NO ); }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)

									app.bringToFront();
    },
};

    								/*** Start "Infinity Lights" button of the "Spectrum" tab of the panel. */   
    								
$._ext_INFINITYLIGHTS={
    run : function() {    

if (documents.length !== 0)
    
    app.activeDocument.suspendHistory("Luminosity Selection", "tkaction()");

function tkaction() {
    
try {
// to remove New Selection channel=============================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}  //do nothing

var bookmarkedLayer = bookmark()
deselect()
selectRGB()
makeInfinityGroup ()
moveGroup()
makeVibrance()
adjustVibrance()
makeLevels()
selectRGB()
var levelsResult = adjustLevels()
    if (levelsResult !== "canceled")  {    
    calculateSelection()
    renameChannel()
    loadSelection()
        }
deleteInfinityGroup()
selectBookmark()
selectRGB()

//+++++++++++ Functions start below ++++++++++++++++

function bookmark() {
    // === Bookmark current layer ===
    var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    return layerIdentifier;
    } 

function deselect() {
// ===================================================
app.activeDocument.selection.deselect()
    }

function selectRGB() {
    // === Select RGB ===
    var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );
    }

function makeInfinityGroup () {
    // === Make Infinity group ===
    var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref1.putClass( idlayerSection );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """TK Infinity Mask""" );
    var idlayerSection = stringIDToTypeID( "layerSection" );
    desc2.putObject( idUsng, idlayerSection, desc3 );
executeAction( idMk, desc2, DialogModes.NO );
    }

function moveGroup() {
    // === Move group to front ===
    var idmove = charIDToTypeID( "move" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idLyr, idOrdn, idTrgt );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref2.putEnumerated( idLyr, idOrdn, idFrnt );
    desc2.putReference( idT, ref2 );
executeAction( idmove, desc2, DialogModes.NO );
    }

function makeVibrance() {
    // === Make Vibrance layer to remove color saturation ===
    var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Infinity Saturation""" );
        var idType = charIDToTypeID( "Type" );
        var idvibrance = stringIDToTypeID( "vibrance" );
        desc3.putClass( idType, idvibrance );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );
    }

function adjustVibrance() {
    // === Adjust Vibrance layer ===
    var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc4.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc5 = new ActionDescriptor();
        var idStrt = charIDToTypeID( "Strt" );
        desc5.putInteger( idStrt, -100 );
    var idvibrance = stringIDToTypeID( "vibrance" );
    desc4.putObject( idT, idvibrance, desc5 );
executeAction( idsetd, desc4, DialogModes.NO );
    }

function makeLevels() {
    // === Make Levels adjustment layer ===
    var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc24.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Infinity Adjust""" );
        var idType = charIDToTypeID( "Type" );
            var desc26 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc26.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc25.putObject( idType, idLvls, desc26 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc24.putObject( idUsng, idAdjL, desc25 );
executeAction( idMk, desc24, DialogModes.NO );
    }
    
function adjustLevels() {    
    // === Open Levels dialog ===
    var idsetd = charIDToTypeID( "setd" );
    var desc49 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc49.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc50 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc50.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idAdjs = charIDToTypeID( "Adjs" );
            var list5 = new ActionList();
                var desc51 = new ActionDescriptor();
                var idChnl = charIDToTypeID( "Chnl" );
                    var ref16 = new ActionReference();
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idChnl = charIDToTypeID( "Chnl" );
                    var idCmps = charIDToTypeID( "Cmps" );
                    ref16.putEnumerated( idChnl, idChnl, idCmps );
                desc51.putReference( idChnl, ref16 );
                var idInpt = charIDToTypeID( "Inpt" );
                    var list6 = new ActionList();
                    list6.putInteger( 0 );
                    list6.putInteger( 255 );
                desc51.putList( idInpt, list6 );
            var idLvlA = charIDToTypeID( "LvlA" );
            list5.putObject( idLvlA, desc51 );
        desc50.putList( idAdjs, list5 );
    var idLvls = charIDToTypeID( "Lvls" );
    desc49.putObject( idT, idLvls, desc50 );
            try {
        executeAction( idsetd, desc49, DialogModes.ALL );
        }
    catch(e) {
        var canceledDialog = "canceled"
        return canceledDialog;
        }     //end catch(e)
    }  //end adjustLevels() function

function calculateSelection() {
    // === Calculate selection and mask ===
    var idMk = charIDToTypeID( "Mk  " );
    var desc54 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc55 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref19.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref19.putEnumerated( idLyr, idOrdn, idMrgd );
        desc55.putReference( idT, ref19 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref20.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref20.putEnumerated( idLyr, idOrdn, idMrgd );
        desc55.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc54.putObject( idUsng, idClcl, desc55 );
executeAction( idMk, desc54, DialogModes.NO );
    }

function renameChannel() {
    // === Rename channel to New Selection ===
    var idsetd = charIDToTypeID( "setd" );
    var desc56 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc56.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc57 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc57.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putObject( idT, idChnl, desc57 );
executeAction( idsetd, desc56, DialogModes.NO );
    }

function loadSelection() {
    // === Load channel as selection ===
    var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref22.putProperty( idChnl, idfsel );
    desc58.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idT, ref23 );
executeAction( idsetd, desc58, DialogModes.NO );
     }

function deleteInfinityGroup() {
    // === Delete Infinity group ===
    var idDlt = charIDToTypeID( "Dlt " );
    var desc59 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref24.putName( idLyr, "TK Infinity Mask" );
    desc59.putReference( idnull, ref24 );
executeAction( idDlt, desc59, DialogModes.NO );
    }

function selectBookmark() {
    // === Make bookmarked layer active ===
    var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), bookmarkedLayer);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  
       }

}  //end tkaction() function
									app.bringToFront();
    },
}; 

    								/*** Start "+/- Red Lights" button on the "Spectrum" tab of the panel. */   
$._ext_PMREDLIGHTS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Red Lights-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );

        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Red Lights-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Red Lights-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Red Lights-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Red Lights-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Red Lights-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idRd = charIDToTypeID( "Rd  " );
            ref5.putEnumerated( idChnl, idChnl, idRd );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idRd = charIDToTypeID( "Rd  " );
            ref6.putEnumerated( idChnl, idChnl, idRd );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Red Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Red Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Red Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Red Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Red Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
								app.bringToFront();
    },
};

    								/*** Start "+/- Red Darks" button on the "Spectrum" tab of the panel. */   
$._ext_PMREDDARKS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Red Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );

        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Red Darks-5" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Red Darks-4" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Red Darks-3" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Red Darks-2" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Red Darks-1" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idRd = charIDToTypeID( "Rd  " );
            ref5.putEnumerated( idChnl, idChnl, idRd );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idRd = charIDToTypeID( "Rd  " );
            ref6.putEnumerated( idChnl, idChnl, idRd );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Red Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Red Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Red Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Red Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Red Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Green Lights" button on the "Spectrum" tab of the panel. */   
$._ext_PMGREENLIGHTS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Green Lights-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );

        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Green Lights-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Green Lights-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Green Lights-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Green Lights-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Green Lights-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGrn = charIDToTypeID( "Grn " );
            ref5.putEnumerated( idChnl, idChnl, idGrn );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGrn = charIDToTypeID( "Grn " );
            ref6.putEnumerated( idChnl, idChnl, idGrn );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Green Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Green Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Green Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Green Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Green Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Green Darks" button on the "Spectrum" tab of the panel. */   
$._ext_PMGREENDARKS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Green Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );    
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Green Darks-5" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Green Darks-4" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Green Darks-3" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Green Darks-2" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Green Darks-1" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGrn = charIDToTypeID( "Grn " );
            ref5.putEnumerated( idChnl, idChnl, idGrn );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGrn = charIDToTypeID( "Grn " );
            ref6.putEnumerated( idChnl, idChnl, idGrn );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Green Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Green Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Green Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Green Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Green Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Blue Lights" button on the "Spectrum" tab of the panel. */   
$._ext_PMBLUELIGHTS={
    run : function() {    

try {
       
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Blue Lights-1" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Blue Lights-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Blue Lights-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Blue Lights-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Blue Lights-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Blue Lights-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idBl = charIDToTypeID( "Bl  " );
            ref5.putEnumerated( idChnl, idChnl, idBl );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idBl = charIDToTypeID( "Bl  " );
            ref6.putEnumerated( idChnl, idChnl, idBl );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Blue Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Blue Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Blue Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Blue Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Blue Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Blue Darks" button on the "Spectrum" tab of the panel. */   
$._ext_PMBLUEDARKS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Blue Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );

        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Blue Darks-5" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Blue Darks-4" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Blue Darks-3" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Blue Darks-2" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Blue Darks-1" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idBl = charIDToTypeID( "Bl  " );
            ref5.putEnumerated( idChnl, idChnl, idBl );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idBl = charIDToTypeID( "Bl  " );
            ref6.putEnumerated( idChnl, idChnl, idBl );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Blue Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Blue Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Blue Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Blue Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Blue Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Reds" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRREDS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Red-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Red-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Red-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Red-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Red-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Red-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idRds = charIDToTypeID( "Rds " );
    desc9.putEnumerated( idClrs, idClrs, idRds );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Red-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Red-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Red-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Red-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Red-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Cyans" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRCYANS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Cyan-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Cyan-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Cyan-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Cyan-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Cyan-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Cyan-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idCyns = charIDToTypeID( "Cyns" );
    desc9.putEnumerated( idClrs, idClrs, idCyns );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Cyan-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Cyan-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Cyan-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Cyan-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Cyan-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Greens" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRGREENS={
    run : function() {    

try {
    
    // ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Green-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
    
//===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Green-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Green-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Green-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Green-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Green-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idGrns = charIDToTypeID( "Grns" );
    desc9.putEnumerated( idClrs, idClrs, idGrns );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Green-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Green-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Green-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Green-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Green-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Magentas" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRMAGENTAS={
    run : function() {    

try {
     
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Magenta-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Magenta-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Magenta-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Magenta-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Magenta-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Magenta-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idMgnt = charIDToTypeID( "Mgnt" );
    desc9.putEnumerated( idClrs, idClrs, idMgnt );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Magenta-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Magenta-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Magenta-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Magenta-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Magenta-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)

									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Blues" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRBLUES={
    run : function() {    

try {  
   
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Blue-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
        //===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Blue-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Blue-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Blue-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Blue-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Blue-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idBls = charIDToTypeID( "Bls " );
    desc9.putEnumerated( idClrs, idClrs, idBls );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Blue-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Blue-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Blue-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Blue-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Blue-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Color Range Yellows" button on the "Spectrum" tab of the panel. */   
$._ext_PMCRYELLOWS={
    run : function() {    

try {    
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "CR Yellow-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "CR Yellow-5" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "CR Yellow-4" );
    desc30.putReference( idnull, ref22 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "CR Yellow-3" );
    desc31.putReference( idnull, ref23 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "CR Yellow-2" );
    desc32.putReference( idnull, ref24 );
executeAction( idDlt, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "CR Yellow-1" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );  }  //end tkaction function

}  //end try

catch(e) {
    
    try {
        
                app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref5.putEnumerated( idChnl, idChnl, idMsk );
    desc8.putReference( idAt, ref5 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc8.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc8, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idClrR = charIDToTypeID( "ClrR" );
    var desc9 = new ActionDescriptor();
    var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idYlws = charIDToTypeID( "Ylws" );
    desc9.putEnumerated( idClrs, idClrs, idYlws );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc9.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc9, DialogModes.NO );

// ===================================================
var idDplc = charIDToTypeID( "Dplc" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref6 );
    var idNm = charIDToTypeID( "Nm  " );
    desc10.putString( idNm, """CR Yellow-1""" );
executeAction( idDplc, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc12.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc12.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """CR Yellow-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref10.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc16.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """CR Yellow-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc20 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc20.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc20.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc19.putObject( idUsng, idClcl, desc20 );
executeAction( idMk, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc22.putString( idNm, """CR Yellow-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc21.putObject( idT, idChnl, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc24 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc24.putEnumerated( idClcl, idClcn, idScrn );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc24.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc23.putObject( idUsng, idClcl, desc24 );
executeAction( idMk, desc23, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc25.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """CR Yellow-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putObject( idT, idChnl, desc26 );
executeAction( idsetd, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref19 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref20 );
executeAction( idslct, desc28, DialogModes.NO ); }    //end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "1" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC1={
    run : function() {    

try {
app.doAction('#1', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "2" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC2={
    run : function() {    

try {
app.doAction('#2', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "3" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC3={
    run : function() {    

try {
app.doAction('#3', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "4" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC4={
    run : function() {    

try {
app.doAction('#4', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "5" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC5={
    run : function() {    

try {
app.doAction('#5', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "6" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MISC6={
    run : function() {    

try {
app.doAction('#6', 'TK-V4-Actions'); 
}
catch(e) {}
									app.bringToFront();
    },
};
    	
    								/*** Start "Orton Lights" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_ORTONLIGHTS={
    run : function() {    

if (app.documents.length !== 0)

    app.activeDocument.suspendHistory("Orton Lights", "tkaction()");

function tkaction() {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
app.activeDocument.selection.deselect()

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref4.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref4.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idT, ref4 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc6.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idSrctwo, ref5 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idUsng, idClcl, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc7.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc8 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc8.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc7.putObject( idT, idChnl, desc8 );
executeAction( idsetd, desc7, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );	
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref7.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref7 );
executeAction( idslct, desc9, DialogModes.NO );


// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref9.putClass( idAdjL );
    desc13.putReference( idnull, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """Curves (Orton Lights)""" );
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idScrn = charIDToTypeID( "Scrn" );
        desc14.putEnumerated( idMd, idBlnM, idScrn );
        var idType = charIDToTypeID( "Type" );
            var desc15 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc15.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc14.putObject( idType, idCrvs, desc15 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc13.putObject( idUsng, idAdjL, desc14 );
executeAction( idMk, desc13, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc16.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var ref11 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref11.putEnumerated( idLyr, idOrdn, idFrnt );
    desc16.putReference( idT, ref11 );
executeAction( idmove, desc16, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idLyr, idOrdn, idTrgt );
    desc17.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var ref13 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref13.putEnumerated( idLyr, idOrdn, idFrnt );
    desc17.putReference( idT, ref13 );
executeAction( idmove, desc17, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref14.putClass( idLyr );
    desc18.putReference( idnull, ref14 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Orton Lights--blurred image""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc18.putObject( idUsng, idLyr, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc20 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc20.putBoolean( idDplc, true );
executeAction( idMrgV, desc20, DialogModes.NO );

// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idLyr, idOrdn, idTrgt );
    desc21.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc22 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc22.putEnumerated( idMd, idBlnM, idMltp );
    var idLyr = charIDToTypeID( "Lyr " );
    desc21.putObject( idT, idLyr, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref16.putName( idLyr, "Curves (Orton Lights)" );
    desc23.putReference( idnull, ref16 );
    var idselectionModifier = stringIDToTypeID( "selectionModifier" );
    var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
    var idaddToSelection = stringIDToTypeID( "addToSelection" );
    desc23.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc23.putBoolean( idMkVs, false );
executeAction( idslct, desc23, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idlayerSection = stringIDToTypeID( "layerSection" );
        ref17.putClass( idlayerSection );
    desc24.putReference( idnull, ref17 );
    var idFrom = charIDToTypeID( "From" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc24.putReference( idFrom, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Orton Lights""" );
    var idlayerSection = stringIDToTypeID( "layerSection" );
    desc24.putObject( idUsng, idlayerSection, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref19.putEnumerated( idChnl, idChnl, idMsk );
    desc26.putReference( idAt, ref19 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc26.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc27 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc28 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-2 temp" );
        desc28.putReference( idT, ref20 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc28.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc27.putObject( idWith, idClcl, desc28 );
executeAction( idAppI, desc27, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-2 temp" );
    desc29.putReference( idnull, ref21 );
executeAction( idDlt, desc29, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref22.putName( idLyr, "Orton Lights--blurred image" );
    desc30.putReference( idnull, ref22 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc30.putBoolean( idMkVs, false );
executeAction( idslct, desc30, DialogModes.NO );

// ===================================================
var idGsnB = charIDToTypeID( "GsnB" );
    var desc31 = new ActionDescriptor();
    var idRds = charIDToTypeID( "Rds " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc31.putUnitDouble( idRds, idPxl, 20.000000 );
    try {  //to execute High Pass Filler
executeAction( idGsnB, desc31, DialogModes.ALL );    }
catch(e){  //delete layer if Cancel chosen in High Pass Filter dialog
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref4.putName( idLyr, "Orton Lights" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );  }  //end catch(e)          
    


}  //end tkaction() function
						app.bringToFront();
    },
};

    								/*** Start "Color Clone" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_COLORCLONE={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Color Clone", "tkaction()");

function tkaction() {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

activeDocument.artLayers.add();  

app.activeDocument.activeLayer.name = "Color Clone"

app.activeDocument.activeLayer.blendMode = BlendMode.COLORBLEND;  

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Make-It-Glow" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_MAKEITGLOW={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("Make-It-Glow", "tkaction()");

function tkaction() {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref4.putClass( idLyr );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Make-It-Glow""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc5.putObject( idUsng, idLyr, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref8 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc9 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc9.putBoolean( idDplc, true );
executeAction( idMrgV, desc9, DialogModes.NO );

// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

// ===================================================
var idGsnB = charIDToTypeID( "GsnB" );
    var desc10 = new ActionDescriptor();
    var idRds = charIDToTypeID( "Rds " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc10.putUnitDouble( idRds, idPxl, 35.000000 );
executeAction( idGsnB, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idfilterFX = stringIDToTypeID( "filterFX" );
        ref9.putIndex( idfilterFX, 1 );
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idLyr, idOrdn, idTrgt );
    desc11.putReference( idnull, ref9 );
    var idfilterFX = stringIDToTypeID( "filterFX" );
        var desc12 = new ActionDescriptor();
        var idblendOptions = stringIDToTypeID( "blendOptions" );
            var desc13 = new ActionDescriptor();
            var idOpct = charIDToTypeID( "Opct" );
            var idPrc = charIDToTypeID( "#Prc" );
            desc13.putUnitDouble( idOpct, idPrc, 100.000000 );
            var idMd = charIDToTypeID( "Md  " );
            var idBlnM = charIDToTypeID( "BlnM" );
            var idSftL = charIDToTypeID( "SftL" );
            desc13.putEnumerated( idMd, idBlnM, idSftL );
        var idblendOptions = stringIDToTypeID( "blendOptions" );
        desc12.putObject( idblendOptions, idblendOptions, desc13 );
    var idfilterFX = stringIDToTypeID( "filterFX" );
    desc11.putObject( idfilterFX, idfilterFX, desc12 );
executeAction( idsetd, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idClr = charIDToTypeID( "Clr " );
        desc15.putEnumerated( idMd, idBlnM, idClr );
    var idLyr = charIDToTypeID( "Lyr " );
    desc14.putObject( idT, idLyr, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};
  								
									/*** Start Tonal Clarity "Lights" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_TCLIGHTS={
    run : function() {    

if (app.documents.length !== 0)
    
    app.activeDocument.suspendHistory("Tonal Clarity", "tkaction()");

function tkaction() {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
app.activeDocument.selection.deselect()

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref4.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref4.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idT, ref4 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc6.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idSrctwo, ref5 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idUsng, idClcl, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc7.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc8 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc8.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc7.putObject( idT, idChnl, desc8 );
executeAction( idsetd, desc7, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );	
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref7.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref7 );
executeAction( idslct, desc9, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref8.putClass( idLyr );
    desc10.putReference( idnull, ref8 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Tonal Clarity--Lights""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc10.putObject( idUsng, idLyr, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref10.putEnumerated( idLyr, idOrdn, idFrnt );
    desc12.putReference( idT, ref10 );
executeAction( idmove, desc12, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idLyr, idOrdn, idTrgt );
    desc13.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var ref12 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref12.putEnumerated( idLyr, idOrdn, idFrnt );
    desc13.putReference( idT, ref12 );
executeAction( idmove, desc13, DialogModes.NO );

// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc14 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc14.putBoolean( idDplc, true );
executeAction( idMrgV, desc14, DialogModes.NO );

// ===================================================
var idDstt = charIDToTypeID( "Dstt" );
executeAction( idDstt, undefined, DialogModes.NO );

// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref13.putEnumerated( idChnl, idChnl, idMsk );
    desc15.putReference( idAt, ref13 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc15.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc16 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-2 temp" );
        desc17.putReference( idT, ref14 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc17.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idWith, idClcl, desc17 );
executeAction( idAppI, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-2 temp" );
    desc18.putReference( idnull, ref15 );
executeAction( idDlt, desc18, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref16.putEnumerated( idChnl, idChnl, idRGB );
    desc19.putReference( idnull, ref16 );
executeAction( idslct, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idLyr, idOrdn, idTrgt );
    desc20.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idSftL = charIDToTypeID( "SftL" );
        desc21.putEnumerated( idMd, idBlnM, idSftL );
    var idLyr = charIDToTypeID( "Lyr " );
    desc20.putObject( idT, idLyr, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idHghP = charIDToTypeID( "HghP" );
    var desc22 = new ActionDescriptor();
    var idRds = charIDToTypeID( "Rds " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc22.putUnitDouble( idRds, idPxl, 10.000000 );
    try {  //to execute High Pass Filler
executeAction( idHghP, desc22, DialogModes.ALL );  }
catch(e){  //delete layer if Cancel chosen in High Pass Filter dialog
    var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );  }  //end catch(e)

}  //end tkaction() function
									app.bringToFront();
    },
};   
  
    								/*** Start Tonal Clarity "Midtones" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_TCMIDTONES={
    run : function() {    

if (app.documents.length !== 0)
    
    app.activeDocument.suspendHistory("Tonal Clarity", "tkaction()");

function tkaction() {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
app.activeDocument.selection.deselect()

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref4.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref4.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idT, ref4 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idSrctwo, ref5 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idUsng, idClcl, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc7.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc8 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc8.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc7.putObject( idT, idChnl, desc8 );
executeAction( idsetd, desc7, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc9 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc9.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc10 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref7.putEnumerated( idChnl, idOrdn, idTrgt );
        desc10.putReference( idT, ref7 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc10.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc10.putReference( idSrctwo, ref8 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc9.putObject( idUsng, idClcl, desc10 );
executeAction( idMk, desc9, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idChnl, idOrdn, idTrgt );
    desc11.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc12 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc12.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putObject( idT, idChnl, desc12 );
executeAction( idsetd, desc11, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc14 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Lights-1 temp" );
        desc14.putReference( idT, ref10 );
        var idInvr = charIDToTypeID( "Invr" );
        desc14.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc14.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc14.putReference( idSrctwo, ref11 );
        var idInvS = charIDToTypeID( "InvS" );
        desc14.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc13.putObject( idUsng, idClcl, desc14 );
executeAction( idMk, desc13, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc15.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc16.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putObject( idT, idChnl, desc16 );
executeAction( idsetd, desc15, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc9 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc9.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc10 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref8.putName( idChnl, "Lights-2 temp" );
        desc10.putReference( idT, ref8 );
        var idInvr = charIDToTypeID( "Invr" );
        desc10.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc10.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc10.putReference( idSrctwo, ref9 );
        var idInvS = charIDToTypeID( "InvS" );
        desc10.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc9.putObject( idUsng, idClcl, desc10 );
executeAction( idMk, desc9, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """MT-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putObject( idT, idChnl, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-2 temp" );
    desc22.putReference( idnull, ref17 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref18.putName( idChnl, "Lights-2 temp" );
    desc23.putReference( idnull, ref18 );
executeAction( idDlt, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Lights-1 temp" );
    desc24.putReference( idnull, ref19 );
executeAction( idDlt, desc24, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );	
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref20.putEnumerated( idChnl, idChnl, idRGB );
    desc25.putReference( idnull, ref20 );
executeAction( idslct, desc25, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref21.putClass( idLyr );
    desc26.putReference( idnull, ref21 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Tonal Clarity--Midtones""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc26.putObject( idUsng, idLyr, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref23.putEnumerated( idLyr, idOrdn, idFrnt );
    desc28.putReference( idT, ref23 );
executeAction( idmove, desc28, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idLyr, idOrdn, idTrgt );
    desc29.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var ref25 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref25.putEnumerated( idLyr, idOrdn, idFrnt );
    desc29.putReference( idT, ref25 );
executeAction( idmove, desc29, DialogModes.NO );

// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc30 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc30.putBoolean( idDplc, true );
executeAction( idMrgV, desc30, DialogModes.NO );

// ===================================================
var idDstt = charIDToTypeID( "Dstt" );
executeAction( idDstt, undefined, DialogModes.NO );

// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref26.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref26 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "MT-2 temp" );
        desc33.putReference( idT, ref27 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "MT-2 temp" );
    desc34.putReference( idnull, ref28 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref29.putEnumerated( idChnl, idChnl, idRGB );
    desc35.putReference( idnull, ref29 );
executeAction( idslct, desc35, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref30.putEnumerated( idLyr, idOrdn, idTrgt );
    desc36.putReference( idnull, ref30 );
    var idT = charIDToTypeID( "T   " );
        var desc37 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idSftL = charIDToTypeID( "SftL" );
        desc37.putEnumerated( idMd, idBlnM, idSftL );
    var idLyr = charIDToTypeID( "Lyr " );
    desc36.putObject( idT, idLyr, desc37 );
executeAction( idsetd, desc36, DialogModes.NO );

// ===================================================
var idHghP = charIDToTypeID( "HghP" );
    var desc38 = new ActionDescriptor();
    var idRds = charIDToTypeID( "Rds " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc38.putUnitDouble( idRds, idPxl, 20.000000 );
    try {  //to execute High Pass Filler
executeAction( idHghP, desc38, DialogModes.ALL );     }
catch(e){  //delete layer if Cancel chosen in High Pass Filter dialog
    var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );  }  //end catch(e)        
    
    }  //end tkaction() function
									app.bringToFront();
    },
};

									/*** Start Tonal Clarity "Darks" button of the "MISCELLANEOUS" section "Actions" tab of the panel. */   
$._ext_TCDARKS={
    run : function() {    

if (app.documents.length !== 0)
    
    app.activeDocument.suspendHistory("Tonal Clarity", "tkaction()");

function tkaction() {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
app.activeDocument.selection.deselect()

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref4 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref4.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref4.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idT, ref4 );
        var idInvr = charIDToTypeID( "Invr" );
        desc6.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc6.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc6.putReference( idSrctwo, ref5 );
        var idInvS = charIDToTypeID( "InvS" );
        desc6.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idUsng, idClcl, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc7.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc8 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc8.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc7.putObject( idT, idChnl, desc8 );
executeAction( idsetd, desc7, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );	
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref7.putEnumerated( idChnl, idChnl, idRGB );
    desc9.putReference( idnull, ref7 );
executeAction( idslct, desc9, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref8.putClass( idLyr );
    desc10.putReference( idnull, ref8 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Tonal Clarity--Darks""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc10.putObject( idUsng, idLyr, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref10.putEnumerated( idLyr, idOrdn, idFrnt );
    desc12.putReference( idT, ref10 );
executeAction( idmove, desc12, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idLyr, idOrdn, idTrgt );
    desc13.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var ref12 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref12.putEnumerated( idLyr, idOrdn, idFrnt );
    desc13.putReference( idT, ref12 );
executeAction( idmove, desc13, DialogModes.NO );

// ===================================================
var idMrgV = charIDToTypeID( "MrgV" );
    var desc14 = new ActionDescriptor();
    var idDplc = charIDToTypeID( "Dplc" );
    desc14.putBoolean( idDplc, true );
executeAction( idMrgV, desc14, DialogModes.NO );

// ===================================================
var idDstt = charIDToTypeID( "Dstt" );
executeAction( idDstt, undefined, DialogModes.NO );

// ===================================================
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref13.putEnumerated( idChnl, idChnl, idMsk );
    desc15.putReference( idAt, ref13 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc15.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc16 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Darks-2 temp" );
        desc17.putReference( idT, ref14 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc17.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idWith, idClcl, desc17 );
executeAction( idAppI, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-2 temp" );
    desc18.putReference( idnull, ref15 );
executeAction( idDlt, desc18, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref16.putEnumerated( idChnl, idChnl, idRGB );
    desc19.putReference( idnull, ref16 );
executeAction( idslct, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idLyr, idOrdn, idTrgt );
    desc20.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idSftL = charIDToTypeID( "SftL" );
        desc21.putEnumerated( idMd, idBlnM, idSftL );
    var idLyr = charIDToTypeID( "Lyr " );
    desc20.putObject( idT, idLyr, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idHghP = charIDToTypeID( "HghP" );
    var desc22 = new ActionDescriptor();
    var idRds = charIDToTypeID( "Rds " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc22.putUnitDouble( idRds, idPxl, 30.000000 );
    try {  //to execute High Pass Filler
executeAction( idHghP, desc22, DialogModes.ALL );   }
catch(e){  //delete layer if Cancel chosen in High Pass Filter dialog
    var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );  }  //end catch(e)      
 
}  //end tkaction() function
									app.bringToFront();
    },
};

    								/*** Start "Sat Layers" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_SATLAYERS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idT, ref10 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """Saturation temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc16.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """Focused Saturation temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idLyr, idOrdn, idTrgt );
    desc19.putReference( idnull, ref16 );
executeAction( idDlt, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref17.putClass( idAdjL );
    desc20.putReference( idnull, ref17 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """Focused Saturation""" );
        var idType = charIDToTypeID( "Type" );
            var desc22 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc22.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc22.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc21.putObject( idType, idHStr, desc22 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc20.putObject( idUsng, idAdjL, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
app.activeDocument.activeLayer.blendMode=BlendMode.SATURATION;

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc23 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc23.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc23.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc23, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc24 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Focused Saturation temp" );
        desc25.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc25.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idWith, idClcl, desc25 );
executeAction( idAppI, desc24, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Focused Saturation temp" );
    desc26.putReference( idnull, ref20 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref21.putClass( idAdjL );
    desc27.putReference( idnull, ref21 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc28 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc28.putString( idNm, """Saturation""" );
        var idType = charIDToTypeID( "Type" );
            var desc29 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc29.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc29.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc28.putObject( idType, idHStr, desc29 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc27.putObject( idUsng, idAdjL, desc28 );
executeAction( idMk, desc27, DialogModes.NO );

// ===================================================
app.activeDocument.activeLayer.blendMode=BlendMode.SATURATION;

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc30 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref22.putEnumerated( idChnl, idChnl, idMsk );
    desc30.putReference( idAt, ref22 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc30.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc30, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc31 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc32 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref23.putName( idChnl, "Saturation temp" );
        desc32.putReference( idT, ref23 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc32.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc31.putObject( idWith, idClcl, desc32 );
executeAction( idAppI, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Saturation temp" );
    desc33.putReference( idnull, ref24 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc34.putReference( idnull, ref25 );
executeAction( idslct, desc34, DialogModes.NO ); }

catch(e) {}


}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
}; 

    								/*** Start "Saturation Painting" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_SATURATIONPAINTING={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Layer", "tkaction()");

function tkaction() {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref4.putClass( idLyr );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Saturation Painting""" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc5.putObject( idUsng, idLyr, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idLyr, idOrdn, idTrgt );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var desc3 = new ActionDescriptor();
        var idMd = charIDToTypeID( "Md  " );
        var idBlnM = charIDToTypeID( "BlnM" );
        var idStrt = charIDToTypeID( "Strt" );
        desc3.putEnumerated( idMd, idBlnM, idStrt );
    var idLyr = charIDToTypeID( "Lyr " );
    desc2.putObject( idT, idLyr, desc3 );
executeAction( idsetd, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref8 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idClr = charIDToTypeID( "Clr " );
        var idFrgC = charIDToTypeID( "FrgC" );
        ref9.putProperty( idClr, idFrgC );
    desc9.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc10 = new ActionDescriptor();
        var idRd = charIDToTypeID( "Rd  " );
        desc10.putDouble( idRd, 127.996109 );
        var idGrn = charIDToTypeID( "Grn " );
        desc10.putDouble( idGrn, 127.996109 );
        var idBl = charIDToTypeID( "Bl  " );
        desc10.putDouble( idBl, 127.996109 );
    var idRGBC = charIDToTypeID( "RGBC" );
    desc9.putObject( idT, idRGBC, desc10 );
executeAction( idsetd, desc9, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idClr = charIDToTypeID( "Clr " );
        var idBckC = charIDToTypeID( "BckC" );
        ref10.putProperty( idClr, idBckC );
    desc11.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc12 = new ActionDescriptor();
        var idH = charIDToTypeID( "H   " );
        var idAng = charIDToTypeID( "#Ang" );
        desc12.putUnitDouble( idH, idAng, 0.000000 );
        var idStrt = charIDToTypeID( "Strt" );
        desc12.putDouble( idStrt, 100.000000 );
        var idBrgh = charIDToTypeID( "Brgh" );
        desc12.putDouble( idBrgh, 100.000000 );
    var idHSBC = charIDToTypeID( "HSBC" );
    desc11.putObject( idT, idHSBC, desc12 );
executeAction( idsetd, desc11, DialogModes.NO ); 

// ==================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPbTl = charIDToTypeID( "PbTl" );
        ref1.putClass( idPbTl );
    desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Vib Layers" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_VIBLAYERS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc12.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """Vibrance-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc16.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """Vibrance temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref16.putName( idChnl, "Vibrance-2 temp" );
    desc19.putReference( idnull, ref16 );
executeAction( idDlt, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Focused Vibrance temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc24.putReference( idnull, ref20 );
executeAction( idDlt, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref21.putClass( idAdjL );
    desc25.putReference( idnull, ref21 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc26 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc26.putString( idNm, """Focused Vibrance""" );
        var idType = charIDToTypeID( "Type" );
            var desc27 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc27.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc27.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc26.putObject( idType, idHStr, desc27 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc25.putObject( idUsng, idAdjL, desc26 );
executeAction( idMk, desc25, DialogModes.NO );

// ===================================================
app.activeDocument.activeLayer.blendMode=BlendMode.SATURATION;

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref22.putEnumerated( idChnl, idChnl, idMsk );
    desc28.putReference( idAt, ref22 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc28.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc28, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc29 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc30 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref23.putName( idChnl, "Focused Vibrance temp" );
        desc30.putReference( idT, ref23 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc30.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc29.putObject( idWith, idClcl, desc30 );
executeAction( idAppI, desc29, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Focused Vibrance temp" );
    desc31.putReference( idnull, ref24 );
executeAction( idDlt, desc31, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref25.putClass( idAdjL );
    desc32.putReference( idnull, ref25 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc33.putString( idNm, """Vibrance""" );
        var idType = charIDToTypeID( "Type" );
            var desc34 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc34.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idClrz = charIDToTypeID( "Clrz" );
            desc34.putBoolean( idClrz, false );
        var idHStr = charIDToTypeID( "HStr" );
        desc33.putObject( idType, idHStr, desc34 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc32.putObject( idUsng, idAdjL, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
app.activeDocument.activeLayer.blendMode=BlendMode.SATURATION;

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc35 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc35.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref26.putEnumerated( idChnl, idChnl, idMsk );
    desc35.putReference( idAt, ref26 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc35.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc35, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc36 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref27.putName( idChnl, "Vibrance temp" );
        desc37.putReference( idT, ref27 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc37.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idWith, idClcl, desc37 );
executeAction( idAppI, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Vibrance temp" );
    desc38.putReference( idnull, ref28 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref29.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref29 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "+/- Sat" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_PMSAT={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Saturation" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Saturation" );
    desc18.putReference( idnull, ref17 );
executeAction( idDlt, desc18, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    

var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref5.putEnumerated( idChnl, idChnl, idRGB );
    desc8.putReference( idnull, ref5 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc8.putBoolean( idMkVs, false );
executeAction( idslct, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref7.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref7 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idLyr, idOrdn, idTrgt );
    desc10.putReference( idnull, ref8 );
    var idT = charIDToTypeID( "T   " );
        var ref9 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref9.putEnumerated( idLyr, idOrdn, idFrnt );
    desc10.putReference( idT, ref9 );
executeAction( idmove, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idT, ref10 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref12.putProperty( idChnl, idfsel );
    desc13.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idT, ref13 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Saturation""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idLyr, idOrdn, idTrgt );
    desc16.putReference( idnull, ref15 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref16.putEnumerated( idChnl, idChnl, idRGB );
    desc17.putReference( idnull, ref16 );
executeAction( idslct, desc17, DialogModes.NO );

// ===================================================   
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Focused Sat" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_PMFOCUSEDSAT={
    run : function() {    

try {    
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Focused Saturation" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Focused Saturation" );
    desc18.putReference( idnull, ref17 );
executeAction( idDlt, desc18, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {   

// ===================================================
var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc12.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref12.putProperty( idChnl, idfsel );
    desc13.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idT, ref13 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Focused Saturation""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idLyr, idOrdn, idTrgt );
    desc16.putReference( idnull, ref15 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref16.putEnumerated( idChnl, idChnl, idRGB );
    desc17.putReference( idnull, ref16 );
executeAction( idslct, desc17, DialogModes.NO );  

// ===================================================   
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );   }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};
    
    								/*** Start "+/- Channels" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_PMCHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Focused Vibrance" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc57 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref31.putName( idChnl, "Focused Vibrance" );
    desc57.putReference( idnull, ref31 );
executeAction( idDlt, desc57, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref32 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref32.putName( idChnl, "Vibrance" );
    desc58.putReference( idnull, ref32 );
executeAction( idDlt, desc58, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc59 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref33 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref33.putName( idChnl, "Focused Saturation" );
    desc59.putReference( idnull, ref33 );
executeAction( idDlt, desc59, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc60 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref34.putName( idChnl, "Saturation" );
    desc60.putReference( idnull, ref34 );
executeAction( idDlt, desc60, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {   

// ===================================================
var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));   
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc23.putReference( idT, ref11 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref12.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref12.putEnumerated( idLyr, idOrdn, idMrgd );
        desc23.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Saturation""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Focused Saturation""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref17.putEnumerated( idChnl, idChnl, idRGB );
    desc30.putReference( idnull, ref17 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc30.putBoolean( idMkVs, false );
executeAction( idslct, desc30, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc42 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc42.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc43 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref19.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref19.putEnumerated( idLyr, idOrdn, idMrgd );
        desc43.putReference( idT, ref19 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc43.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref20.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref20.putEnumerated( idLyr, idOrdn, idMrgd );
        desc43.putReference( idSrctwo, ref20 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc42.putObject( idUsng, idClcl, desc43 );
executeAction( idMk, desc42, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc44 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc44.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc45 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc45.putString( idNm, """Vibrance-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putObject( idT, idChnl, desc45 );
executeAction( idsetd, desc44, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc46 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc47 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref22 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref22.putEnumerated( idChnl, idOrdn, idTrgt );
        desc47.putReference( idT, ref22 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc47.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc47.putReference( idSrctwo, ref23 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc46.putObject( idUsng, idClcl, desc47 );
executeAction( idMk, desc46, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idChnl, idOrdn, idTrgt );
    desc48.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var desc49 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc49.putString( idNm, """Vibrance""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putObject( idT, idChnl, desc49 );
executeAction( idsetd, desc48, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Vibrance-2 temp" );
    desc50.putReference( idnull, ref25 );
executeAction( idDlt, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc51 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc51.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc52 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc52.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc52.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc52.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc51.putObject( idUsng, idClcl, desc52 );
executeAction( idMk, desc51, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc53 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref28.putEnumerated( idChnl, idOrdn, idTrgt );
    desc53.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var desc54 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc54.putString( idNm, """Focused Vibrance""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc53.putObject( idT, idChnl, desc54 );
executeAction( idsetd, desc53, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc55 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref29.putEnumerated( idLyr, idOrdn, idTrgt );
    desc55.putReference( idnull, ref29 );
executeAction( idDlt, desc55, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc56 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref30.putEnumerated( idChnl, idChnl, idRGB );
    desc56.putReference( idnull, ref30 );
executeAction( idslct, desc56, DialogModes.NO );  

// ===================================================   
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Vib" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_PMVIB={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Vibrance" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ==================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Vibrance" );
    desc22.putReference( idnull, ref20 );
executeAction( idDlt, desc22, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    

// ===================================================
var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref5.putEnumerated( idChnl, idChnl, idRGB );
    desc8.putReference( idnull, ref5 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc8.putBoolean( idMkVs, false );
executeAction( idslct, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref9.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref9.putEnumerated( idLyr, idOrdn, idMrgd );
        desc11.putReference( idT, ref9 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc11.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc11.putReference( idSrctwo, ref10 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc10.putObject( idUsng, idClcl, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc12.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc13 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc13.putString( idNm, """Vibrance-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putObject( idT, idChnl, desc13 );
executeAction( idsetd, desc12, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc14 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc15.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc15.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc15.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idUsng, idClcl, desc15 );
executeAction( idMk, desc14, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc16.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idT, ref15 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """Vibrance""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Vibrance-2 temp" );
    desc19.putReference( idnull, ref17 );
executeAction( idDlt, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc20.putReference( idnull, ref18 );
executeAction( idDlt, desc20, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc21.putReference( idnull, ref19 );
executeAction( idslct, desc21, DialogModes.NO );  

// ===================================================   
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "+/- Focused Vib" button of the "SATURATION/VIBRANCE" section "Actions" tab of the panel. */   
$._ext_PMFOCUSEDVIB={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Focused Vibrance" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Focused Vibrance" );
    desc28.putReference( idnull, ref25 );
executeAction( idDlt, desc28, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    

// ===================================================
var ref = new ActionReference();   
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));   
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
    var layerIdentifier=executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));  
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK Sat/Vib masks""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idSlcC = charIDToTypeID( "SlcC" );
        desc6.putObject( idType, idSlcC, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref9.putEnumerated( idChnl, idChnl, idRGB );
    desc10.putReference( idnull, ref9 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc10.putBoolean( idMkVs, false );
executeAction( idslct, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref9.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc11.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMthd = charIDToTypeID( "Mthd" );
        var idCrcM = charIDToTypeID( "CrcM" );
        var idAbsl = charIDToTypeID( "Absl" );
        desc11.putEnumerated( idMthd, idCrcM, idAbsl );
        var idClrC = charIDToTypeID( "ClrC" );
            var list1 = new ActionList();
                var desc12 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idRds = charIDToTypeID( "Rds " );
                desc12.putEnumerated( idClrs, idClrs, idRds );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc12.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc12 );
                var desc13 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idYlws = charIDToTypeID( "Ylws" );
                desc13.putEnumerated( idClrs, idClrs, idYlws );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc13.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc13 );
                var desc14 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idGrns = charIDToTypeID( "Grns" );
                desc14.putEnumerated( idClrs, idClrs, idGrns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc14.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc14 );
                var desc15 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idCyns = charIDToTypeID( "Cyns" );
                desc15.putEnumerated( idClrs, idClrs, idCyns );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc15.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc15 );
                var desc16 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBls = charIDToTypeID( "Bls " );
                desc16.putEnumerated( idClrs, idClrs, idBls );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc16.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc16 );
                var desc17 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idMgnt = charIDToTypeID( "Mgnt" );
                desc17.putEnumerated( idClrs, idClrs, idMgnt );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc17.putUnitDouble( idBlck, idPrc, 100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc17 );
                var desc18 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idWhts = charIDToTypeID( "Whts" );
                desc18.putEnumerated( idClrs, idClrs, idWhts );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc18.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc18 );
                var desc19 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idNtrl = charIDToTypeID( "Ntrl" );
                desc19.putEnumerated( idClrs, idClrs, idNtrl );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc19.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc19 );
                var desc20 = new ActionDescriptor();
                var idClrs = charIDToTypeID( "Clrs" );
                var idClrs = charIDToTypeID( "Clrs" );
                var idBlks = charIDToTypeID( "Blks" );
                desc20.putEnumerated( idClrs, idClrs, idBlks );
                var idBlck = charIDToTypeID( "Blck" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc20.putUnitDouble( idBlck, idPrc, -100.000000 );
            var idClrC = charIDToTypeID( "ClrC" );
            list1.putObject( idClrC, desc20 );
        desc11.putList( idClrC, list1 );
    var idSlcC = charIDToTypeID( "SlcC" );
    desc10.putObject( idT, idSlcC, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc11 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc11.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc12 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref10.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref10.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idT, ref10 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc12.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref11.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref11.putEnumerated( idLyr, idOrdn, idMrgd );
        desc12.putReference( idSrctwo, ref11 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc11.putObject( idUsng, idClcl, desc12 );
executeAction( idMk, desc11, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref12.putEnumerated( idChnl, idOrdn, idTrgt );
    desc13.putReference( idnull, ref12 );
    var idT = charIDToTypeID( "T   " );
        var desc14 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc14.putString( idNm, """Vibrance-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putObject( idT, idChnl, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc15 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc15.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc16 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idT, ref13 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc16.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc16.putReference( idSrctwo, ref14 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc15.putObject( idUsng, idClcl, desc16 );
executeAction( idMk, desc15, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc17.putReference( idnull, ref15 );
    var idT = charIDToTypeID( "T   " );
        var desc18 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc18.putString( idNm, """Vibrance-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putObject( idT, idChnl, desc18 );
executeAction( idsetd, desc17, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref16.putName( idChnl, "Vibrance-2 temp" );
    desc19.putReference( idnull, ref16 );
executeAction( idDlt, desc19, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref19.putProperty( idChnl, idfsel );
    desc22.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idT, ref20 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref21 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Focused Vibrance""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Vibrance-3 temp" );
    desc25.putReference( idnull, ref22 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idLyr, idOrdn, idTrgt );
    desc26.putReference( idnull, ref23 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref24.putEnumerated( idChnl, idChnl, idRGB );
    desc27.putReference( idnull, ref24 );
executeAction( idslct, desc27, DialogModes.NO );  

// ===================================================   
var idslct = charIDToTypeID( "slct" );
   var desc1 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref1 = new ActionReference;
   ref1.putIdentifier(app.stringIDToTypeID('layer'), layerIdentifier);
   desc1.putReference( idnull, ref1 );
   var idMkVs = charIDToTypeID( "MkVs" );
   desc1.putBoolean( idMkVs, false );
   executeAction( idslct, desc1, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Save for Web" button of the "WEB-SHARPENING" section "Actions" tab of the panel. */   
$._ext_SAVEFORWEB={
    run : function() {    

try {

var documentOpen = app.activeDocument

if(documentOpen)
cTID = function(s) { return app.charIDToTypeID(s); };

function SaveforWeb() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('Svfw'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, DialogModes.ALL);
  };

  SaveforWeb();

}

catch(e) {}
									app.bringToFront();
    },
};

    								/*** Start "+/- All Masks" button of the "Basic" tab of the panel. */   
$._ext_ALLMASKSCHANNELS={
    run : function() {    

try {    
  
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Midtones-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc70 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref52 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref52.putName( idChnl, "Midtones-5" );
    desc70.putReference( idnull, ref52 );
executeAction( idDlt, desc70, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc71 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref53 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref53.putName( idChnl, "Midtones-4" );
    desc71.putReference( idnull, ref53 );
executeAction( idDlt, desc71, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc72 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref54 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref54.putName( idChnl, "Midtones-3" );
    desc72.putReference( idnull, ref54 );
executeAction( idDlt, desc72, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc73 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref55 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref55.putName( idChnl, "Midtones-2" );
    desc73.putReference( idnull, ref55 );
executeAction( idDlt, desc73, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc74 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref56 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref56.putName( idChnl, "Midtones-1" );
    desc74.putReference( idnull, ref56 );
executeAction( idDlt, desc74, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc75 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref57 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref57.putName( idChnl, "Darks-5" );
    desc75.putReference( idnull, ref57 );
executeAction( idDlt, desc75, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc76 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref58 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref58.putName( idChnl, "Darks-4" );
    desc76.putReference( idnull, ref58 );
executeAction( idDlt, desc76, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc77 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref59 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref59.putName( idChnl, "Darks-3" );
    desc77.putReference( idnull, ref59 );
executeAction( idDlt, desc77, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc78 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref60 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref60.putName( idChnl, "Darks-2" );
    desc78.putReference( idnull, ref60 );
executeAction( idDlt, desc78, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc79 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref61 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref61.putName( idChnl, "Darks-1" );
    desc79.putReference( idnull, ref61 );
executeAction( idDlt, desc79, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc80 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref62 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref62.putName( idChnl, "Lights-5" );
    desc80.putReference( idnull, ref62 );
executeAction( idDlt, desc80, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc81 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref63 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref63.putName( idChnl, "Lights-4" );
    desc81.putReference( idnull, ref63 );
executeAction( idDlt, desc81, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc82 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref64 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref64.putName( idChnl, "Lights-3" );
    desc82.putReference( idnull, ref64 );
executeAction( idDlt, desc82, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc83 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref65 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref65.putName( idChnl, "Lights-2" );
    desc83.putReference( idnull, ref65 );
executeAction( idDlt, desc83, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc84 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref66 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref66.putName( idChnl, "Lights-1" );
    desc84.putReference( idnull, ref66 );
executeAction( idDlt, desc84, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1" );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-1" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idSrctwo, ref24 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref28.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc40.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc41 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref29 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref29.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idT, ref29 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc41.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref30 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref30.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idSrctwo, ref30 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc40.putObject( idUsng, idClcl, desc41 );
executeAction( idMk, desc40, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref31.putEnumerated( idChnl, idOrdn, idTrgt );
    desc42.putReference( idnull, ref31 );
    var idT = charIDToTypeID( "T   " );
        var desc43 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc43.putString( idNm, """Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc42.putObject( idT, idChnl, desc43 );
executeAction( idsetd, desc42, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc44 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc45 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref32.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idT, ref32 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc45.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref33 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref33.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idSrctwo, ref33 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc44.putObject( idUsng, idClcl, desc45 );
executeAction( idMk, desc44, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref34.putEnumerated( idChnl, idOrdn, idTrgt );
    desc46.putReference( idnull, ref34 );
    var idT = charIDToTypeID( "T   " );
        var desc47 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc47.putString( idNm, """Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putObject( idT, idChnl, desc47 );
executeAction( idsetd, desc46, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc48 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc49 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref35.putName( idChnl, "Lights-1" );
        desc49.putReference( idT, ref35 );
        var idInvr = charIDToTypeID( "Invr" );
        desc49.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc49.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref36.putName( idChnl, "Darks-1" );
        desc49.putReference( idSrctwo, ref36 );
        var idInvS = charIDToTypeID( "InvS" );
        desc49.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc48.putObject( idUsng, idClcl, desc49 );
executeAction( idMk, desc48, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc50.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc51 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc51.putString( idNm, """Midtones-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc50.putObject( idT, idChnl, desc51 );
executeAction( idsetd, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc52 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc52.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc53 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref38 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref38.putName( idChnl, "Lights-2" );
        desc53.putReference( idT, ref38 );
        var idInvr = charIDToTypeID( "Invr" );
        desc53.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc53.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref39.putName( idChnl, "Darks-2" );
        desc53.putReference( idSrctwo, ref39 );
        var idInvS = charIDToTypeID( "InvS" );
        desc53.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc52.putObject( idUsng, idClcl, desc53 );
executeAction( idMk, desc52, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc54 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref40 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref40.putEnumerated( idChnl, idOrdn, idTrgt );
    desc54.putReference( idnull, ref40 );
    var idT = charIDToTypeID( "T   " );
        var desc55 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc55.putString( idNm, """Midtones-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putObject( idT, idChnl, desc55 );
executeAction( idsetd, desc54, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc56 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc57 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref41 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref41.putName( idChnl, "Lights-3" );
        desc57.putReference( idT, ref41 );
        var idInvr = charIDToTypeID( "Invr" );
        desc57.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc57.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref42 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref42.putName( idChnl, "Darks-3" );
        desc57.putReference( idSrctwo, ref42 );
        var idInvS = charIDToTypeID( "InvS" );
        desc57.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc56.putObject( idUsng, idClcl, desc57 );
executeAction( idMk, desc56, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc59 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc59.putString( idNm, """Midtones-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc58.putObject( idT, idChnl, desc59 );
executeAction( idsetd, desc58, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc60 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc60.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc61 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref44 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref44.putName( idChnl, "Lights-4" );
        desc61.putReference( idT, ref44 );
        var idInvr = charIDToTypeID( "Invr" );
        desc61.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc61.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref45 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref45.putName( idChnl, "Darks-4" );
        desc61.putReference( idSrctwo, ref45 );
        var idInvS = charIDToTypeID( "InvS" );
        desc61.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc60.putObject( idUsng, idClcl, desc61 );
executeAction( idMk, desc60, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idChnl, idOrdn, idTrgt );
    desc62.putReference( idnull, ref46 );
    var idT = charIDToTypeID( "T   " );
        var desc63 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc63.putString( idNm, """Midtones-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putObject( idT, idChnl, desc63 );
executeAction( idsetd, desc62, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc64 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc64.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc65 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref47 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref47.putName( idChnl, "Lights-5" );
        desc65.putReference( idT, ref47 );
        var idInvr = charIDToTypeID( "Invr" );
        desc65.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc65.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref48.putName( idChnl, "Darks-5" );
        desc65.putReference( idSrctwo, ref48 );
        var idInvS = charIDToTypeID( "InvS" );
        desc65.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc64.putObject( idUsng, idClcl, desc65 );
executeAction( idMk, desc64, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc66 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref49 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref49.putEnumerated( idChnl, idOrdn, idTrgt );
    desc66.putReference( idnull, ref49 );
    var idT = charIDToTypeID( "T   " );
        var desc67 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc67.putString( idNm, """Midtones-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc66.putObject( idT, idChnl, desc67 );
executeAction( idsetd, desc66, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc69 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref51.putEnumerated( idChnl, idChnl, idRGB );
    desc69.putReference( idnull, ref51 );
executeAction( idslct, desc69, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
}; 

    								/*** Start "All Lights Curves" button of the "Basic" tab of the panel. */   
$._ext_ALLLIGHTSCURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putObject( idT, idChnl, desc17 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc19.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc18.putObject( idUsng, idClcl, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putObject( idT, idChnl, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref18 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref19 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idLyr, idOrdn, idTrgt );
    desc30.putReference( idnull, ref21 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref22.putEnumerated( idChnl, idChnl, idRGB );
    desc31.putReference( idnull, ref22 );
executeAction( idslct, desc31, DialogModes.NO ); 

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc3.putObject( idType, idCrvs, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Lights-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref8.putClass( idAdjL );
    desc10.putReference( idnull, ref8 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc11.putObject( idType, idCrvs, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA ); 
executeAction( idMk, desc13, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Lights-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc16.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Lights-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc18 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc18.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc17.putObject( idType, idCrvs, desc18 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc16.putObject( idUsng, idAdjL, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Lights-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref14.putClass( idAdjL );
    desc22.putReference( idnull, ref14 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc24 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc24.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc23.putObject( idType, idCrvs, desc24 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc22.putObject( idUsng, idAdjL, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Lights-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref17.putClass( idAdjL );
    desc28.putReference( idnull, ref17 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc30 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc30.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc29.putObject( idType, idCrvs, desc30 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc28.putObject( idUsng, idAdjL, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Lights-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Lights-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Lights-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );   }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Lights Levels" button of the "Basic" tab of the panel. */   
$._ext_ALLLIGHTSLEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putObject( idT, idChnl, desc17 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc19.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc18.putObject( idUsng, idClcl, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putObject( idT, idChnl, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref18 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref19 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idLyr, idOrdn, idTrgt );
    desc30.putReference( idnull, ref21 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref22.putEnumerated( idChnl, idChnl, idRGB );
    desc31.putReference( idnull, ref22 );
executeAction( idslct, desc31, DialogModes.NO ); 

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Lights-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA ); 
executeAction( idMk, desc13, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Lights-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Lights-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Lights-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Lights-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Lights-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Lights-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Lights-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );   }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Lights Channels" button of the "Basic" tab of the panel. */   
$._ext_ALLLIGHTSCHANNELS={
    run : function() {    

try {
        
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Lights-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Lights-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Lights-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Lights-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Lights-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO )   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc16.putReference( idnull, ref11 );
    var idT = charIDToTypeID( "T   " );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putObject( idT, idChnl, desc17 );
executeAction( idsetd, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc18 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc19 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc19.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc19.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc18.putObject( idUsng, idClcl, desc19 );
executeAction( idMk, desc18, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc20.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc21 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc21.putString( idNm, """Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putObject( idT, idChnl, desc21 );
executeAction( idsetd, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref15 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref16 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc25 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc25.putString( idNm, """Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putObject( idT, idChnl, desc25 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc26 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idT, ref18 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc27.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref19.putEnumerated( idChnl, idOrdn, idTrgt );
        desc27.putReference( idSrctwo, ref19 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idUsng, idClcl, desc27 );
executeAction( idMk, desc26, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idChnl, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
    var idT = charIDToTypeID( "T   " );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putObject( idT, idChnl, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref21.putEnumerated( idLyr, idOrdn, idTrgt );
    desc30.putReference( idnull, ref21 );
executeAction( idDlt, desc30, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref22.putEnumerated( idChnl, idChnl, idRGB );
    desc31.putReference( idnull, ref22 );
executeAction( idslct, desc31, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Lights-1 Curves" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS1CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Lights-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-1 Levels" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS1LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-1 Channel" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS1CHANNELS={
    run : function() {    

try {    
   
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-1" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Lights-1" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Lights-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Lights-2 Curves" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS2CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Lights-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-2 Levels" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS2LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-2 Channel" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS2CHANNELS={
    run : function() {    

try {    
  
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-2" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Lights-2" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Lights-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Lights-3 Curves" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS3CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Lights-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-3 Levels" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS3LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-3 Channel" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS3CHANNELS={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-3" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Lights-3" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref10.putProperty( idChnl, idfsel );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idT, ref11 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Lights-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idLyr, idOrdn, idTrgt );
    desc17.putReference( idnull, ref14 );
executeAction( idDlt, desc17, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Lights-4 Curves" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS4CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Lights-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-4 Levels" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS4LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-4 Channel" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS4CHANNELS={
    run : function() {    

try {
       
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-4" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Lights-4" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idT, ref15 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Lights-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Lights-5 Curves" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS5CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Lights-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-5 Levels" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS5LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Lights-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Lights-5 Channel" button of the "Basic" tab of the panel. */   
$._ext_LIGHTS5CHANNELS={
    run : function() {    

try {   
   
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Lights-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Lights-5" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Lights-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Lights-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref18.putProperty( idChnl, idfsel );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idT, ref19 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Lights-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "All Midtones Masks Curves" button of the "Basic" tab of the panel. */   
$._ext_ALLMIDTONESCURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idSrctwo, ref24 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref28.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc40.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc41 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref29 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref29.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idT, ref29 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc41.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref30 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref30.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idSrctwo, ref30 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc40.putObject( idUsng, idClcl, desc41 );
executeAction( idMk, desc40, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref31.putEnumerated( idChnl, idOrdn, idTrgt );
    desc42.putReference( idnull, ref31 );
    var idT = charIDToTypeID( "T   " );
        var desc43 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc43.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc42.putObject( idT, idChnl, desc43 );
executeAction( idsetd, desc42, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc44 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc45 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref32.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idT, ref32 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc45.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref33 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref33.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idSrctwo, ref33 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc44.putObject( idUsng, idClcl, desc45 );
executeAction( idMk, desc44, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref34.putEnumerated( idChnl, idOrdn, idTrgt );
    desc46.putReference( idnull, ref34 );
    var idT = charIDToTypeID( "T   " );
        var desc47 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc47.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putObject( idT, idChnl, desc47 );
executeAction( idsetd, desc46, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc48 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc49 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref35.putName( idChnl, "Lights-1 temp" );
        desc49.putReference( idT, ref35 );
        var idInvr = charIDToTypeID( "Invr" );
        desc49.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc49.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref36.putName( idChnl, "Darks-1 temp" );
        desc49.putReference( idSrctwo, ref36 );
        var idInvS = charIDToTypeID( "InvS" );
        desc49.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc48.putObject( idUsng, idClcl, desc49 );
executeAction( idMk, desc48, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc50.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc51 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc51.putString( idNm, """Midtones-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc50.putObject( idT, idChnl, desc51 );
executeAction( idsetd, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc52 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc52.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc53 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref38 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref38.putName( idChnl, "Lights-2 temp" );
        desc53.putReference( idT, ref38 );
        var idInvr = charIDToTypeID( "Invr" );
        desc53.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc53.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref39.putName( idChnl, "Darks-2 temp" );
        desc53.putReference( idSrctwo, ref39 );
        var idInvS = charIDToTypeID( "InvS" );
        desc53.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc52.putObject( idUsng, idClcl, desc53 );
executeAction( idMk, desc52, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc54 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref40 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref40.putEnumerated( idChnl, idOrdn, idTrgt );
    desc54.putReference( idnull, ref40 );
    var idT = charIDToTypeID( "T   " );
        var desc55 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc55.putString( idNm, """Midtones-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putObject( idT, idChnl, desc55 );
executeAction( idsetd, desc54, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc56 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc57 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref41 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref41.putName( idChnl, "Lights-3 temp" );
        desc57.putReference( idT, ref41 );
        var idInvr = charIDToTypeID( "Invr" );
        desc57.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc57.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref42 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref42.putName( idChnl, "Darks-3 temp" );
        desc57.putReference( idSrctwo, ref42 );
        var idInvS = charIDToTypeID( "InvS" );
        desc57.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc56.putObject( idUsng, idClcl, desc57 );
executeAction( idMk, desc56, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc59 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc59.putString( idNm, """Midtones-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc58.putObject( idT, idChnl, desc59 );
executeAction( idsetd, desc58, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc60 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc60.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc61 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref44 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref44.putName( idChnl, "Lights-4 temp" );
        desc61.putReference( idT, ref44 );
        var idInvr = charIDToTypeID( "Invr" );
        desc61.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc61.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref45 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref45.putName( idChnl, "Darks-4 temp" );
        desc61.putReference( idSrctwo, ref45 );
        var idInvS = charIDToTypeID( "InvS" );
        desc61.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc60.putObject( idUsng, idClcl, desc61 );
executeAction( idMk, desc60, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idChnl, idOrdn, idTrgt );
    desc62.putReference( idnull, ref46 );
    var idT = charIDToTypeID( "T   " );
        var desc63 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc63.putString( idNm, """Midtones-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putObject( idT, idChnl, desc63 );
executeAction( idsetd, desc62, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc64 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc64.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc65 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref47 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref47.putName( idChnl, "Lights-5 temp" );
        desc65.putReference( idT, ref47 );
        var idInvr = charIDToTypeID( "Invr" );
        desc65.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc65.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref48.putName( idChnl, "Darks-5 temp" );
        desc65.putReference( idSrctwo, ref48 );
        var idInvS = charIDToTypeID( "InvS" );
        desc65.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc64.putObject( idUsng, idClcl, desc65 );
executeAction( idMk, desc64, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc66 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref49 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref49.putEnumerated( idChnl, idOrdn, idTrgt );
    desc66.putReference( idnull, ref49 );
    var idT = charIDToTypeID( "T   " );
        var desc67 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc67.putString( idNm, """Midtones-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc66.putObject( idT, idChnl, desc67 );
executeAction( idsetd, desc66, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc75 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref57 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref57.putName( idChnl, "Darks-5 temp" );
    desc75.putReference( idnull, ref57 );
executeAction( idDlt, desc75, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc76 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref58 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref58.putName( idChnl, "Darks-4 temp" );
    desc76.putReference( idnull, ref58 );
executeAction( idDlt, desc76, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc77 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref59 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref59.putName( idChnl, "Darks-3 temp" );
    desc77.putReference( idnull, ref59 );
executeAction( idDlt, desc77, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc78 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref60 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref60.putName( idChnl, "Darks-2 temp" );
    desc78.putReference( idnull, ref60 );
executeAction( idDlt, desc78, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc79 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref61 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref61.putName( idChnl, "Darks-1 temp" );
    desc79.putReference( idnull, ref61 );
executeAction( idDlt, desc79, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc80 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref62 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref62.putName( idChnl, "Lights-5 temp" );
    desc80.putReference( idnull, ref62 );
executeAction( idDlt, desc80, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc81 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref63 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref63.putName( idChnl, "Lights-4 temp" );
    desc81.putReference( idnull, ref63 );
executeAction( idDlt, desc81, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc82 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref64 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref64.putName( idChnl, "Lights-3 temp" );
    desc82.putReference( idnull, ref64 );
executeAction( idDlt, desc82, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc83 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref65 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref65.putName( idChnl, "Lights-2 temp" );
    desc83.putReference( idnull, ref65 );
executeAction( idDlt, desc83, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc84 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref66 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref66.putName( idChnl, "Lights-1 temp" );
    desc84.putReference( idnull, ref66 );
executeAction( idDlt, desc84, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc69 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref51.putEnumerated( idChnl, idChnl, idRGB );
    desc69.putReference( idnull, ref51 );
executeAction( idslct, desc69, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Midtones-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc3.putObject( idType, idCrvs, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Midtones-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref8.putClass( idAdjL );
    desc10.putReference( idnull, ref8 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc11.putObject( idType, idCrvs, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc13, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Midtones-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc16.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Midtones-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc18 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc18.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc17.putObject( idType, idCrvs, desc18 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc16.putObject( idUsng, idAdjL, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Midtones-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref14.putClass( idAdjL );
    desc22.putReference( idnull, ref14 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Midtones-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc24 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc24.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc23.putObject( idType, idCrvs, desc24 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc22.putObject( idUsng, idAdjL, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Midtones-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref17.putClass( idAdjL );
    desc28.putReference( idnull, ref17 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Midtones-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc30 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc30.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc29.putObject( idType, idCrvs, desc30 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc28.putObject( idUsng, idAdjL, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Midtones-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Midtones-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Midtones-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Midtones-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Midtones-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Midtones-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Midtones Masks Levels" button of the "Basic" tab of the panel. */   
$._ext_ALLMIDTONESLEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idSrctwo, ref24 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref28.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc40.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc41 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref29 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref29.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idT, ref29 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc41.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref30 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref30.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idSrctwo, ref30 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc40.putObject( idUsng, idClcl, desc41 );
executeAction( idMk, desc40, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref31.putEnumerated( idChnl, idOrdn, idTrgt );
    desc42.putReference( idnull, ref31 );
    var idT = charIDToTypeID( "T   " );
        var desc43 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc43.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc42.putObject( idT, idChnl, desc43 );
executeAction( idsetd, desc42, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc44 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc45 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref32.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idT, ref32 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc45.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref33 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref33.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idSrctwo, ref33 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc44.putObject( idUsng, idClcl, desc45 );
executeAction( idMk, desc44, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref34.putEnumerated( idChnl, idOrdn, idTrgt );
    desc46.putReference( idnull, ref34 );
    var idT = charIDToTypeID( "T   " );
        var desc47 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc47.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putObject( idT, idChnl, desc47 );
executeAction( idsetd, desc46, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc48 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc49 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref35.putName( idChnl, "Lights-1 temp" );
        desc49.putReference( idT, ref35 );
        var idInvr = charIDToTypeID( "Invr" );
        desc49.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc49.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref36.putName( idChnl, "Darks-1 temp" );
        desc49.putReference( idSrctwo, ref36 );
        var idInvS = charIDToTypeID( "InvS" );
        desc49.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc48.putObject( idUsng, idClcl, desc49 );
executeAction( idMk, desc48, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc50.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc51 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc51.putString( idNm, """Midtones-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc50.putObject( idT, idChnl, desc51 );
executeAction( idsetd, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc52 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc52.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc53 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref38 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref38.putName( idChnl, "Lights-2 temp" );
        desc53.putReference( idT, ref38 );
        var idInvr = charIDToTypeID( "Invr" );
        desc53.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc53.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref39.putName( idChnl, "Darks-2 temp" );
        desc53.putReference( idSrctwo, ref39 );
        var idInvS = charIDToTypeID( "InvS" );
        desc53.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc52.putObject( idUsng, idClcl, desc53 );
executeAction( idMk, desc52, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc54 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref40 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref40.putEnumerated( idChnl, idOrdn, idTrgt );
    desc54.putReference( idnull, ref40 );
    var idT = charIDToTypeID( "T   " );
        var desc55 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc55.putString( idNm, """Midtones-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putObject( idT, idChnl, desc55 );
executeAction( idsetd, desc54, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc56 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc57 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref41 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref41.putName( idChnl, "Lights-3 temp" );
        desc57.putReference( idT, ref41 );
        var idInvr = charIDToTypeID( "Invr" );
        desc57.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc57.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref42 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref42.putName( idChnl, "Darks-3 temp" );
        desc57.putReference( idSrctwo, ref42 );
        var idInvS = charIDToTypeID( "InvS" );
        desc57.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc56.putObject( idUsng, idClcl, desc57 );
executeAction( idMk, desc56, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc59 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc59.putString( idNm, """Midtones-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc58.putObject( idT, idChnl, desc59 );
executeAction( idsetd, desc58, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc60 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc60.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc61 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref44 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref44.putName( idChnl, "Lights-4 temp" );
        desc61.putReference( idT, ref44 );
        var idInvr = charIDToTypeID( "Invr" );
        desc61.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc61.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref45 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref45.putName( idChnl, "Darks-4 temp" );
        desc61.putReference( idSrctwo, ref45 );
        var idInvS = charIDToTypeID( "InvS" );
        desc61.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc60.putObject( idUsng, idClcl, desc61 );
executeAction( idMk, desc60, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idChnl, idOrdn, idTrgt );
    desc62.putReference( idnull, ref46 );
    var idT = charIDToTypeID( "T   " );
        var desc63 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc63.putString( idNm, """Midtones-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putObject( idT, idChnl, desc63 );
executeAction( idsetd, desc62, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc64 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc64.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc65 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref47 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref47.putName( idChnl, "Lights-5 temp" );
        desc65.putReference( idT, ref47 );
        var idInvr = charIDToTypeID( "Invr" );
        desc65.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc65.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref48.putName( idChnl, "Darks-5 temp" );
        desc65.putReference( idSrctwo, ref48 );
        var idInvS = charIDToTypeID( "InvS" );
        desc65.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc64.putObject( idUsng, idClcl, desc65 );
executeAction( idMk, desc64, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc66 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref49 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref49.putEnumerated( idChnl, idOrdn, idTrgt );
    desc66.putReference( idnull, ref49 );
    var idT = charIDToTypeID( "T   " );
        var desc67 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc67.putString( idNm, """Midtones-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc66.putObject( idT, idChnl, desc67 );
executeAction( idsetd, desc66, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc75 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref57 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref57.putName( idChnl, "Darks-5 temp" );
    desc75.putReference( idnull, ref57 );
executeAction( idDlt, desc75, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc76 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref58 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref58.putName( idChnl, "Darks-4 temp" );
    desc76.putReference( idnull, ref58 );
executeAction( idDlt, desc76, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc77 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref59 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref59.putName( idChnl, "Darks-3 temp" );
    desc77.putReference( idnull, ref59 );
executeAction( idDlt, desc77, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc78 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref60 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref60.putName( idChnl, "Darks-2 temp" );
    desc78.putReference( idnull, ref60 );
executeAction( idDlt, desc78, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc79 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref61 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref61.putName( idChnl, "Darks-1 temp" );
    desc79.putReference( idnull, ref61 );
executeAction( idDlt, desc79, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc80 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref62 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref62.putName( idChnl, "Lights-5 temp" );
    desc80.putReference( idnull, ref62 );
executeAction( idDlt, desc80, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc81 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref63 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref63.putName( idChnl, "Lights-4 temp" );
    desc81.putReference( idnull, ref63 );
executeAction( idDlt, desc81, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc82 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref64 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref64.putName( idChnl, "Lights-3 temp" );
    desc82.putReference( idnull, ref64 );
executeAction( idDlt, desc82, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc83 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref65 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref65.putName( idChnl, "Lights-2 temp" );
    desc83.putReference( idnull, ref65 );
executeAction( idDlt, desc83, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc84 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref66 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref66.putName( idChnl, "Lights-1 temp" );
    desc84.putReference( idnull, ref66 );
executeAction( idDlt, desc84, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc69 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref51.putEnumerated( idChnl, idChnl, idRGB );
    desc69.putReference( idnull, ref51 );
executeAction( idslct, desc69, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Midtones-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc13, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Midtones-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Midtones-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Midtones-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Midtones-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Midtones-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Midtones-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Midtones-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Midtones-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Midtones-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Midtones-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Midtones Masks Channel" button of the "Basic" tab of the panel. */   
$._ext_ALLMIDTONESCHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Midtones-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc70 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref52 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref52.putName( idChnl, "Midtones-5" );
    desc70.putReference( idnull, ref52 );
executeAction( idDlt, desc70, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc71 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref53 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref53.putName( idChnl, "Midtones-4" );
    desc71.putReference( idnull, ref53 );
executeAction( idDlt, desc71, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc72 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref54 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref54.putName( idChnl, "Midtones-3" );
    desc72.putReference( idnull, ref54 );
executeAction( idDlt, desc72, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc73 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref55 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref55.putName( idChnl, "Midtones-2" );
    desc73.putReference( idnull, ref55 );
executeAction( idDlt, desc73, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc74 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref56 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref56.putName( idChnl, "Midtones-1" );
    desc74.putReference( idnull, ref56 );
executeAction( idDlt, desc74, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO )   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Lights-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Lights-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref20.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-1 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var desc31 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc31.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc30.putObject( idT, idChnl, desc31 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc32 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc32.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref23 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref23.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idT, ref23 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc33.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref24 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref24.putEnumerated( idChnl, idOrdn, idTrgt );
        desc33.putReference( idSrctwo, ref24 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idUsng, idClcl, desc33 );
executeAction( idMk, desc32, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref25.putEnumerated( idChnl, idOrdn, idTrgt );
    desc34.putReference( idnull, ref25 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc35.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc34.putObject( idT, idChnl, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc36 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc36.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc37 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref26 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref26.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idT, ref26 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc37.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref27 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref27.putEnumerated( idChnl, idOrdn, idTrgt );
        desc37.putReference( idSrctwo, ref27 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc36.putObject( idUsng, idClcl, desc37 );
executeAction( idMk, desc36, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref28.putEnumerated( idChnl, idOrdn, idTrgt );
    desc38.putReference( idnull, ref28 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc39.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc38.putObject( idT, idChnl, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc40.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc41 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref29 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref29.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idT, ref29 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc41.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref30 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref30.putEnumerated( idChnl, idOrdn, idTrgt );
        desc41.putReference( idSrctwo, ref30 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc40.putObject( idUsng, idClcl, desc41 );
executeAction( idMk, desc40, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc42 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref31.putEnumerated( idChnl, idOrdn, idTrgt );
    desc42.putReference( idnull, ref31 );
    var idT = charIDToTypeID( "T   " );
        var desc43 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc43.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc42.putObject( idT, idChnl, desc43 );
executeAction( idsetd, desc42, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc44 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc44.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc45 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref32 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref32.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idT, ref32 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc45.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref33 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref33.putEnumerated( idChnl, idOrdn, idTrgt );
        desc45.putReference( idSrctwo, ref33 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc44.putObject( idUsng, idClcl, desc45 );
executeAction( idMk, desc44, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc46 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref34 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref34.putEnumerated( idChnl, idOrdn, idTrgt );
    desc46.putReference( idnull, ref34 );
    var idT = charIDToTypeID( "T   " );
        var desc47 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc47.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc46.putObject( idT, idChnl, desc47 );
executeAction( idsetd, desc46, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc48 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc48.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc49 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref35 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref35.putName( idChnl, "Lights-1 temp" );
        desc49.putReference( idT, ref35 );
        var idInvr = charIDToTypeID( "Invr" );
        desc49.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc49.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref36 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref36.putName( idChnl, "Darks-1 temp" );
        desc49.putReference( idSrctwo, ref36 );
        var idInvS = charIDToTypeID( "InvS" );
        desc49.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc48.putObject( idUsng, idClcl, desc49 );
executeAction( idMk, desc48, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc50 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref37 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref37.putEnumerated( idChnl, idOrdn, idTrgt );
    desc50.putReference( idnull, ref37 );
    var idT = charIDToTypeID( "T   " );
        var desc51 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc51.putString( idNm, """Midtones-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc50.putObject( idT, idChnl, desc51 );
executeAction( idsetd, desc50, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc52 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc52.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc53 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref38 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref38.putName( idChnl, "Lights-2 temp" );
        desc53.putReference( idT, ref38 );
        var idInvr = charIDToTypeID( "Invr" );
        desc53.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc53.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref39 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref39.putName( idChnl, "Darks-2 temp" );
        desc53.putReference( idSrctwo, ref39 );
        var idInvS = charIDToTypeID( "InvS" );
        desc53.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc52.putObject( idUsng, idClcl, desc53 );
executeAction( idMk, desc52, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc54 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref40 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref40.putEnumerated( idChnl, idOrdn, idTrgt );
    desc54.putReference( idnull, ref40 );
    var idT = charIDToTypeID( "T   " );
        var desc55 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc55.putString( idNm, """Midtones-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc54.putObject( idT, idChnl, desc55 );
executeAction( idsetd, desc54, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc56 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc56.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc57 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref41 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref41.putName( idChnl, "Lights-3 temp" );
        desc57.putReference( idT, ref41 );
        var idInvr = charIDToTypeID( "Invr" );
        desc57.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc57.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref42 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref42.putName( idChnl, "Darks-3 temp" );
        desc57.putReference( idSrctwo, ref42 );
        var idInvS = charIDToTypeID( "InvS" );
        desc57.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc56.putObject( idUsng, idClcl, desc57 );
executeAction( idMk, desc56, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc58 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref43 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref43.putEnumerated( idChnl, idOrdn, idTrgt );
    desc58.putReference( idnull, ref43 );
    var idT = charIDToTypeID( "T   " );
        var desc59 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc59.putString( idNm, """Midtones-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc58.putObject( idT, idChnl, desc59 );
executeAction( idsetd, desc58, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc60 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc60.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc61 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref44 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref44.putName( idChnl, "Lights-4 temp" );
        desc61.putReference( idT, ref44 );
        var idInvr = charIDToTypeID( "Invr" );
        desc61.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc61.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref45 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref45.putName( idChnl, "Darks-4 temp" );
        desc61.putReference( idSrctwo, ref45 );
        var idInvS = charIDToTypeID( "InvS" );
        desc61.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc60.putObject( idUsng, idClcl, desc61 );
executeAction( idMk, desc60, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref46 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref46.putEnumerated( idChnl, idOrdn, idTrgt );
    desc62.putReference( idnull, ref46 );
    var idT = charIDToTypeID( "T   " );
        var desc63 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc63.putString( idNm, """Midtones-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc62.putObject( idT, idChnl, desc63 );
executeAction( idsetd, desc62, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc64 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc64.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc65 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref47 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref47.putName( idChnl, "Lights-5 temp" );
        desc65.putReference( idT, ref47 );
        var idInvr = charIDToTypeID( "Invr" );
        desc65.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc65.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref48 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref48.putName( idChnl, "Darks-5 temp" );
        desc65.putReference( idSrctwo, ref48 );
        var idInvS = charIDToTypeID( "InvS" );
        desc65.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc64.putObject( idUsng, idClcl, desc65 );
executeAction( idMk, desc64, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc66 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref49 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref49.putEnumerated( idChnl, idOrdn, idTrgt );
    desc66.putReference( idnull, ref49 );
    var idT = charIDToTypeID( "T   " );
        var desc67 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc67.putString( idNm, """Midtones-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc66.putObject( idT, idChnl, desc67 );
executeAction( idsetd, desc66, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc75 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref57 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref57.putName( idChnl, "Darks-5 temp" );
    desc75.putReference( idnull, ref57 );
executeAction( idDlt, desc75, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc76 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref58 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref58.putName( idChnl, "Darks-4 temp" );
    desc76.putReference( idnull, ref58 );
executeAction( idDlt, desc76, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc77 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref59 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref59.putName( idChnl, "Darks-3 temp" );
    desc77.putReference( idnull, ref59 );
executeAction( idDlt, desc77, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc78 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref60 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref60.putName( idChnl, "Darks-2 temp" );
    desc78.putReference( idnull, ref60 );
executeAction( idDlt, desc78, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc79 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref61 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref61.putName( idChnl, "Darks-1 temp" );
    desc79.putReference( idnull, ref61 );
executeAction( idDlt, desc79, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc80 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref62 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref62.putName( idChnl, "Lights-5 temp" );
    desc80.putReference( idnull, ref62 );
executeAction( idDlt, desc80, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc81 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref63 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref63.putName( idChnl, "Lights-4 temp" );
    desc81.putReference( idnull, ref63 );
executeAction( idDlt, desc81, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc82 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref64 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref64.putName( idChnl, "Lights-3 temp" );
    desc82.putReference( idnull, ref64 );
executeAction( idDlt, desc82, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc83 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref65 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref65.putName( idChnl, "Lights-2 temp" );
    desc83.putReference( idnull, ref65 );
executeAction( idDlt, desc83, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc84 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref66 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref66.putName( idChnl, "Lights-1 temp" );
    desc84.putReference( idnull, ref66 );
executeAction( idDlt, desc84, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc68 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref50 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref50.putEnumerated( idLyr, idOrdn, idTrgt );
    desc68.putReference( idnull, ref50 );
executeAction( idDlt, desc68, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc69 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref51 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref51.putEnumerated( idChnl, idChnl, idRGB );
    desc69.putReference( idnull, ref51 );
executeAction( idslct, desc69, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Midtones-1 Curves" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES1CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Midtones-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-1 Levels" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES1LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Midtones-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-1 Channel" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES1CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Midtones-1" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Midtones-1" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Midtones-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
							app.bringToFront();
    },
};

    								/*** Start "Midtones-2 Curves" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES2CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Midtones-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idT, ref11 );
        var idInvr = charIDToTypeID( "Invr" );
        desc17.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-2 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Darks-2 temp" );
    desc25.putReference( idnull, ref19 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-2 temp" );
    desc26.putReference( idnull, ref20 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-1 temp" );
    desc27.putReference( idnull, ref21 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-2 Levels" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES2LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Midtones-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );
// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idT, ref11 );
        var idInvr = charIDToTypeID( "Invr" );
        desc17.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-2 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Darks-2 temp" );
    desc25.putReference( idnull, ref19 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-2 temp" );
    desc26.putReference( idnull, ref20 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-1 temp" );
    desc27.putReference( idnull, ref21 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-2 Channel" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES2CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Midtones-2" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Midtones-2" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref11.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idT, ref11 );
        var idInvr = charIDToTypeID( "Invr" );
        desc17.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref12.putName( idChnl, "Lights-1 temp" );
        desc17.putReference( idSrctwo, ref12 );
        var idInvS = charIDToTypeID( "InvS" );
        desc17.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-2 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref16.putProperty( idChnl, idfsel );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idT, ref17 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idChnl, idOrdn, idTrgt );
    desc23.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var desc24 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc24.putString( idNm, """Midtones-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc23.putObject( idT, idChnl, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref19.putName( idChnl, "Darks-2 temp" );
    desc25.putReference( idnull, ref19 );
executeAction( idDlt, desc25, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Lights-2 temp" );
    desc26.putReference( idnull, ref20 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Lights-1 temp" );
    desc27.putReference( idnull, ref21 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref22 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref23 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)

									app.bringToFront();
    },
};

    								/*** Start "Midtones-3 Curves" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES3CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Midtones-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Lights-2 temp" );
    desc36.putReference( idnull, ref28 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Lights-1 temp" );
    desc37.putReference( idnull, ref29 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Darks-2 temp" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idChnl, idOrdn, idTrgt );
    desc31.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var desc32 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc32.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putObject( idT, idChnl, desc32 );
executeAction( idsetd, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-3 temp" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref27.putName( idChnl, "Lights-3 temp" );
    desc35.putReference( idnull, ref27 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-3 Levels" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES3LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Midtones-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Lights-2 temp" );
    desc36.putReference( idnull, ref28 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Lights-1 temp" );
    desc37.putReference( idnull, ref29 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Darks-2 temp" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idChnl, idOrdn, idTrgt );
    desc31.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var desc32 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc32.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putObject( idT, idChnl, desc32 );
executeAction( idsetd, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-3 temp" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref27.putName( idChnl, "Lights-3 temp" );
    desc35.putReference( idnull, ref27 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Midtones-3 Channel" button of the "Basic" tab of the panel. */   
$._ext_MIDTONES3CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Midtones-3" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Midtones-3" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Lights-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Lights-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Lights-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref28.putName( idChnl, "Lights-2 temp" );
    desc36.putReference( idnull, ref28 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref14.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idT, ref14 );
        var idInvr = charIDToTypeID( "Invr" );
        desc21.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref15.putName( idChnl, "Lights-1 temp" );
        desc21.putReference( idSrctwo, ref15 );
        var idInvS = charIDToTypeID( "InvS" );
        desc21.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref29 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref29.putName( idChnl, "Lights-1 temp" );
    desc37.putReference( idnull, ref29 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref26.putName( idChnl, "Darks-2 temp" );
    desc34.putReference( idnull, ref26 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc28.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref20 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref20.putEnumerated( idChnl, idOrdn, idTrgt );
        desc29.putReference( idT, ref20 );
        var idInvr = charIDToTypeID( "Invr" );
        desc29.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc29.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref21 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref21.putName( idChnl, "Lights-3 temp" );
        desc29.putReference( idSrctwo, ref21 );
        var idInvS = charIDToTypeID( "InvS" );
        desc29.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc28.putObject( idUsng, idClcl, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc30 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref22.putProperty( idChnl, idfsel );
    desc30.putReference( idnull, ref22 );
    var idT = charIDToTypeID( "T   " );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref23.putEnumerated( idChnl, idOrdn, idTrgt );
    desc30.putReference( idT, ref23 );
executeAction( idsetd, desc30, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc31 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idChnl, idOrdn, idTrgt );
    desc31.putReference( idnull, ref24 );
    var idT = charIDToTypeID( "T   " );
        var desc32 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc32.putString( idNm, """Midtones-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putObject( idT, idChnl, desc32 );
executeAction( idsetd, desc31, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc33 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Darks-3 temp" );
    desc33.putReference( idnull, ref25 );
executeAction( idDlt, desc33, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref27.putName( idChnl, "Lights-3 temp" );
    desc35.putReference( idnull, ref27 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref30.putEnumerated( idLyr, idOrdn, idTrgt );
    desc38.putReference( idnull, ref30 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref31 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref31.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref31 );
executeAction( idslct, desc39, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "All Darks Masks Curves" button of the "Basic" tab of the panel. */   
$._ext_ALLDARKSCURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc3.putObject( idType, idCrvs, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Darks-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref8.putClass( idAdjL );
    desc10.putReference( idnull, ref8 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc11.putObject( idType, idCrvs, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA ); 
executeAction( idMk, desc13, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Darks-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref11.putClass( idAdjL );
    desc16.putReference( idnull, ref11 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc17.putString( idNm, """Darks-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc18 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc18.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc17.putObject( idType, idCrvs, desc18 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc16.putObject( idUsng, idAdjL, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Darks-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref14.putClass( idAdjL );
    desc22.putReference( idnull, ref14 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc24 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc24.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc23.putObject( idType, idCrvs, desc24 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc22.putObject( idUsng, idAdjL, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Darks-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref17.putClass( idAdjL );
    desc28.putReference( idnull, ref17 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc29 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc29.putString( idNm, """Darks-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc30 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc30.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc29.putObject( idType, idCrvs, desc30 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc28.putObject( idUsng, idAdjL, desc29 );
executeAction( idMk, desc28, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Darks-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Darks-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Darks-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Darks Masks Levels" button of the "Basic" tab of the panel. */   
$._ext_ALLDARKSLEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layers", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-5 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc5.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc5.putReference( idAt, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc5.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc5, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref3.putEnumerated( idLyr, idOrdn, idTrgt );
    desc6.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
        var ref4 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref4.putEnumerated( idLyr, idOrdn, idFrnt );
    desc6.putReference( idT, ref4 );
executeAction( idmove, desc6, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc7.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc7.putReference( idT, ref6 );
executeAction( idmove, desc7, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc8 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref7 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref7.putName( idChnl, "Darks-5 temp" );
        desc9.putReference( idT, ref7 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc9.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idWith, idClcl, desc9 );
executeAction( idAppI, desc8, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc13 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc13.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc13.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc13.putEnumerated( idUsng, idUsrM, idRvlA ); 
executeAction( idMk, desc13, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc14 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc15 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref10 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref10.putName( idChnl, "Darks-4 temp" );
        desc15.putReference( idT, ref10 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc15.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc14.putObject( idWith, idClcl, desc15 );
executeAction( idAppI, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc19 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref12 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref12.putEnumerated( idChnl, idChnl, idMsk );
    desc19.putReference( idAt, ref12 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc19.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc19, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc20 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref13.putName( idChnl, "Darks-3 temp" );
        desc21.putReference( idT, ref13 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc21.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idWith, idClcl, desc21 );
executeAction( idAppI, desc20, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc25 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc25.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref15.putEnumerated( idChnl, idChnl, idMsk );
    desc25.putReference( idAt, ref15 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc25.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc25, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc26 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc27 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref16.putName( idChnl, "Darks-2 temp" );
        desc27.putReference( idT, ref16 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc27.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc26.putObject( idWith, idClcl, desc27 );
executeAction( idAppI, desc26, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref7.putClass( idAdjL );
    desc10.putReference( idnull, ref7 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc12 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc12.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc11.putObject( idType, idLvls, desc12 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc10.putObject( idUsng, idAdjL, desc11 );
executeAction( idMk, desc10, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc31 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc31.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref18.putEnumerated( idChnl, idChnl, idMsk );
    desc31.putReference( idAt, ref18 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc31.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc31, DialogModes.NO );  }

catch (e) {}

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc32 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc33 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref19 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref19.putName( idChnl, "Darks-1 temp" );
        desc33.putReference( idT, ref19 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc33.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc32.putObject( idWith, idClcl, desc33 );
executeAction( idAppI, desc32, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref20.putName( idChnl, "Darks-5 temp" );
    desc34.putReference( idnull, ref20 );
executeAction( idDlt, desc34, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc35 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc35.putReference( idnull, ref21 );
executeAction( idDlt, desc35, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref22.putName( idChnl, "Darks-3 temp" );
    desc36.putReference( idnull, ref22 );
executeAction( idDlt, desc36, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc37 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref23.putName( idChnl, "Darks-2 temp" );
    desc37.putReference( idnull, ref23 );
executeAction( idDlt, desc37, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref24.putName( idChnl, "Darks-1 temp" );
    desc38.putReference( idnull, ref24 );
executeAction( idDlt, desc38, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc39 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref25.putEnumerated( idChnl, idChnl, idRGB );
    desc39.putReference( idnull, ref25 );
executeAction( idslct, desc39, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "All Darks Masks Channel" button of the "Basic" tab of the panel. */   
$._ext_ALLDARKSCHANNELS={
    run : function() {    

try {

    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );   
 
        app.activeDocument.suspendHistory("Delete Channels", "tkaction()");

function tkaction() {


// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref1.putName( idChnl, "Darks-5" );
    desc2.putReference( idnull, ref1 );
executeAction( idDlt, desc2, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref2.putName( idChnl, "Darks-4" );
    desc3.putReference( idnull, ref2 );
executeAction( idDlt, desc3, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref3.putName( idChnl, "Darks-3" );
    desc4.putReference( idnull, ref3 );
executeAction( idDlt, desc4, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "Darks-2" );
    desc5.putReference( idnull, ref4 );
executeAction( idDlt, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref5.putName( idChnl, "Darks-1" );
    desc6.putReference( idnull, ref5 );
executeAction( idDlt, desc6, DialogModes.NO );  

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO )   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Create Channel Masks", "tkaction()");

function tkaction() {    
    
try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc16 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc16.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc17 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref11 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idT, ref11 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc17.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc17.putReference( idSrctwo, ref12 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc16.putObject( idUsng, idClcl, desc17 );
executeAction( idMk, desc16, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idChnl, idOrdn, idTrgt );
    desc18.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc19 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc19.putString( idNm, """Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc18.putObject( idT, idChnl, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc20 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc20.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc21 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref14.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idT, ref14 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc21.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref15 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref15.putEnumerated( idChnl, idOrdn, idTrgt );
        desc21.putReference( idSrctwo, ref15 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc20.putObject( idUsng, idClcl, desc21 );
executeAction( idMk, desc20, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref16 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref16.putEnumerated( idChnl, idOrdn, idTrgt );
    desc22.putReference( idnull, ref16 );
    var idT = charIDToTypeID( "T   " );
        var desc23 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc23.putString( idNm, """Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putObject( idT, idChnl, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc24 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc24.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc25 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idT, ref17 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc25.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref18 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref18.putEnumerated( idChnl, idOrdn, idTrgt );
        desc25.putReference( idSrctwo, ref18 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc24.putObject( idUsng, idClcl, desc25 );
executeAction( idMk, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc26.putReference( idnull, ref19 );
    var idT = charIDToTypeID( "T   " );
        var desc27 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc27.putString( idNm, """Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc26.putObject( idT, idChnl, desc27 );
executeAction( idsetd, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref20 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref20.putEnumerated( idLyr, idOrdn, idTrgt );
    desc28.putReference( idnull, ref20 );
executeAction( idDlt, desc28, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc29 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref21.putEnumerated( idChnl, idChnl, idRGB );
    desc29.putReference( idnull, ref21 );
executeAction( idslct, desc29, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Darks-1 Curves" button of the "Basic" tab of the panel. */   
$._ext_DARKS1CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Darks-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );


// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-1 Levels" button of the "Basic" tab of the panel. */   
$._ext_DARKS1LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-1""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );


// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-1 Channel" button of the "Basic" tab of the panel. */   
$._ext_DARKS1CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-1" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );  
   
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Darks-1" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );


// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Darks-1""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Darks-2 Curves" button of the "Basic" tab of the panel. */   
$._ext_DARKS2CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Darks-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-2 Levels" button of the "Basic" tab of the panel. */   
$._ext_DARKS2LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-2""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-2 Channel" button of the "Basic" tab of the panel. */   
$._ext_DARKS2CHANNELS={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-2" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );  
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Darks-2" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref7.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref8.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idT, ref8 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref10 );
executeAction( idDlt, desc12, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref11.putEnumerated( idChnl, idChnl, idRGB );
    desc13.putReference( idnull, ref11 );
executeAction( idslct, desc13, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Darks-3 Curves" button of the "Basic" tab of the panel. */   
$._ext_DARKS3CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Darks-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Darks-2" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-3 Levels" button of the "Basic" tab of the panel. */   
$._ext_DARKS3LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-3""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Darks-2" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-3 Channel" button of the "Basic" tab of the panel. */   
$._ext_DARKS3CHANNELS={
    run : function() {    

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-3" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );  
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Darks-3" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref10.putProperty( idChnl, idfsel );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref11.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idT, ref11 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Darks-3""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref13.putName( idChnl, "Darks-2" );
    desc16.putReference( idnull, ref13 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idLyr, idOrdn, idTrgt );
    desc17.putReference( idnull, ref14 );
executeAction( idDlt, desc17, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref15.putEnumerated( idChnl, idChnl, idRGB );
    desc18.putReference( idnull, ref15 );
executeAction( idslct, desc18, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Darks-4 Curves" button of the "Basic" tab of the panel. */   
$._ext_DARKS4CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Darks-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-4 Levels" button of the "Basic" tab of the panel. */   
$._ext_DARKS4LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-4""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-4 Channel" button of the "Basic" tab of the panel. */   
$._ext_DARKS4CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-4" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );  
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Darks-4" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref14.putProperty( idChnl, idfsel );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref15.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idT, ref15 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Darks-4""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref17.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref17 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref18.putEnumerated( idLyr, idOrdn, idTrgt );
    desc22.putReference( idnull, ref18 );
executeAction( idDlt, desc22, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Darks-5 Curves" button of the "Basic" tab of the panel. */   
$._ext_DARKS5CURVES={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref4.putClass( idAdjL );
    desc5.putReference( idnull, ref4 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """Darks-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc6.putObject( idType, idCrvs, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-5 Levels" button of the "Basic" tab of the panel. */   
$._ext_DARKS5LEVELS={
    run : function() {    

try {
    
    app.activeDocument.suspendHistory("New Adjustment Layer", "tkaction()");

function tkaction() {

try {
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {}

try {

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref1.putClass( idAdjL );
    desc2.putReference( idnull, ref1 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc3.putString( idNm, """Darks-5""" );
        var idType = charIDToTypeID( "Type" );
            var desc4 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc4.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc3.putObject( idType, idLvls, desc4 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc2.putObject( idUsng, idAdjL, desc3 );
executeAction( idMk, desc2, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idLyr, idOrdn, idTrgt );
    desc8.putReference( idnull, ref5 );
    var idT = charIDToTypeID( "T   " );
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref6.putEnumerated( idLyr, idOrdn, idFrnt );
    desc8.putReference( idT, ref6 );
executeAction( idmove, desc8, DialogModes.NO );

// ===================================================
var idmove = charIDToTypeID( "move" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc9.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var ref8 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idFrnt = charIDToTypeID( "Frnt" );
        ref8.putEnumerated( idLyr, idOrdn, idFrnt );
    desc9.putReference( idT, ref8 );
executeAction( idmove, desc9, DialogModes.NO );

try {

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putClass( idNw, idChnl );
    var idAt = charIDToTypeID( "At  " );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref9.putEnumerated( idChnl, idChnl, idMsk );
    desc10.putReference( idAt, ref9 );
    var idUsng = charIDToTypeID( "Usng" );
    var idUsrM = charIDToTypeID( "UsrM" );
    var idRvlA = charIDToTypeID( "RvlA" );
    desc10.putEnumerated( idUsng, idUsrM, idRvlA );
executeAction( idMk, desc10, DialogModes.NO );  }

catch(e) {}

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """New Selection""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idMsk = charIDToTypeID( "Msk " );
        ref2.putEnumerated( idChnl, idChnl, idMsk );
    desc4.putReference( idnull, ref2 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc4.putBoolean( idMkVs, false );
executeAction( idslct, desc4, DialogModes.NO );

// ===================================================
var idAppI = charIDToTypeID( "AppI" );
    var desc5 = new ActionDescriptor();
    var idWith = charIDToTypeID( "With" );
        var desc6 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref3 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            ref3.putName( idChnl, "New Selection" );
        desc6.putReference( idT, ref3 );
        var idPrsT = charIDToTypeID( "PrsT" );
        desc6.putBoolean( idPrsT, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc5.putObject( idWith, idClcl, desc6 );
executeAction( idAppI, desc5, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref4.putName( idChnl, "New Selection" );
    desc7.putReference( idnull, ref4 );
executeAction( idDlt, desc7, DialogModes.NO ); 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc23 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref19.putEnumerated( idChnl, idChnl, idRGB );
    desc23.putReference( idnull, ref19 );
executeAction( idslct, desc23, DialogModes.NO );  }

catch(e) {}

}  //end tkaction() function
}  //end first try
catch(e) {}  
									app.bringToFront();
    },
};

    								/*** Start "Darks-5 Channel" button of the "Basic" tab of the panel. */   
$._ext_DARKS5CHANNELS={
    run : function() {    

try {
    
// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref7.putName( idChnl, "Darks-5" );
    desc10.putReference( idnull, ref7 );
executeAction( idslct, desc10, DialogModes.NO );  
    
        app.activeDocument.suspendHistory("Delete Channel", "tkaction()");

function tkaction() {

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Darks-5" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );   }  //end tkaction function

}  //end try

catch(e) {

try {
    
app.activeDocument.suspendHistory("Selection/Channel Mask", "tkaction()");

function tkaction() {    
    
try {
    
// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "New Selection" );
    desc11.putReference( idnull, ref8 );
executeAction( idDlt, desc11, DialogModes.NO );
}
catch(e) {} 

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref2.putEnumerated( idChnl, idChnl, idRGB );
    desc3.putReference( idnull, ref2 );
executeAction( idslct, desc3, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref3.putProperty( idChnl, idfsel );
    desc4.putReference( idnull, ref3 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc4.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc4, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc5.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc6.putString( idNm, """TK selection creation""" );
        var idType = charIDToTypeID( "Type" );
            var desc7 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idLvls = charIDToTypeID( "Lvls" );
        desc6.putObject( idType, idLvls, desc7 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc5.putObject( idUsng, idAdjL, desc6 );
executeAction( idMk, desc5, DialogModes.NO );;

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref5 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref5.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref5.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idT, ref5 );
        var idInvr = charIDToTypeID( "Invr" );
        desc9.putBoolean( idInvr, true );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc9.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref6 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idGry = charIDToTypeID( "Gry " );
            ref6.putEnumerated( idChnl, idChnl, idGry );
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idMrgd = charIDToTypeID( "Mrgd" );
            ref6.putEnumerated( idLyr, idOrdn, idMrgd );
        desc9.putReference( idSrctwo, ref6 );
        var idInvS = charIDToTypeID( "InvS" );
        desc9.putBoolean( idInvS, true );
    var idClcl = charIDToTypeID( "Clcl" );
    desc8.putObject( idUsng, idClcl, desc9 );
executeAction( idMk, desc8, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc10.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc11 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc11.putString( idNm, """Darks-2 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc10.putObject( idT, idChnl, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc12 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc12.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc13 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref8 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref8.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idT, ref8 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc13.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref9 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref9.putEnumerated( idChnl, idOrdn, idTrgt );
        desc13.putReference( idSrctwo, ref9 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc12.putObject( idUsng, idClcl, desc13 );
executeAction( idMk, desc12, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref10.putEnumerated( idChnl, idOrdn, idTrgt );
    desc14.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
        var desc15 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc15.putString( idNm, """Darks-3 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc14.putObject( idT, idChnl, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc16 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref11 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref11.putName( idChnl, "Darks-2 temp" );
    desc16.putReference( idnull, ref11 );
executeAction( idDlt, desc16, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc17 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc17.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc18 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref12 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref12.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idT, ref12 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc18.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref13 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idChnl, idOrdn, idTrgt );
        desc18.putReference( idSrctwo, ref13 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc17.putObject( idUsng, idClcl, desc18 );
executeAction( idMk, desc17, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc19 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref14 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref14.putEnumerated( idChnl, idOrdn, idTrgt );
    desc19.putReference( idnull, ref14 );
    var idT = charIDToTypeID( "T   " );
        var desc20 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc20.putString( idNm, """Darks-4 temp""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc19.putObject( idT, idChnl, desc20 );
executeAction( idsetd, desc19, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref15 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref15.putName( idChnl, "Darks-3 temp" );
    desc21.putReference( idnull, ref15 );
executeAction( idDlt, desc21, DialogModes.NO );

// ===================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc22 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
    var idChnl = charIDToTypeID( "Chnl" );
    desc22.putClass( idNw, idChnl );
    var idUsng = charIDToTypeID( "Usng" );
        var desc23 = new ActionDescriptor();
        var idT = charIDToTypeID( "T   " );
            var ref16 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref16.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idT, ref16 );
        var idClcl = charIDToTypeID( "Clcl" );
        var idClcn = charIDToTypeID( "Clcn" );
        var idMltp = charIDToTypeID( "Mltp" );
        desc23.putEnumerated( idClcl, idClcn, idMltp );
        var idSrctwo = charIDToTypeID( "Src2" );
            var ref17 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref17.putEnumerated( idChnl, idOrdn, idTrgt );
        desc23.putReference( idSrctwo, ref17 );
    var idClcl = charIDToTypeID( "Clcl" );
    desc22.putObject( idUsng, idClcl, desc23 );
executeAction( idMk, desc22, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc24 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref18 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref18.putProperty( idChnl, idfsel );
    desc24.putReference( idnull, ref18 );
    var idT = charIDToTypeID( "T   " );
        var ref19 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref19.putEnumerated( idChnl, idOrdn, idTrgt );
    desc24.putReference( idT, ref19 );
executeAction( idsetd, desc24, DialogModes.NO );

// ===================================================
var idsetd = charIDToTypeID( "setd" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref6 );
    var idT = charIDToTypeID( "T   " );
        var desc9 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc9.putString( idNm, """Darks-5""" );
    var idChnl = charIDToTypeID( "Chnl" );
    desc8.putObject( idT, idChnl, desc9 );
executeAction( idsetd, desc8, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref21.putName( idChnl, "Darks-4 temp" );
    desc26.putReference( idnull, ref21 );
executeAction( idDlt, desc26, DialogModes.NO );

// ===================================================
var idDlt = charIDToTypeID( "Dlt " );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref22 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref22.putEnumerated( idLyr, idOrdn, idTrgt );
    desc27.putReference( idnull, ref22 );
executeAction( idDlt, desc27, DialogModes.NO );

// ===================================================
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref23 );
executeAction( idslct, desc28, DialogModes.NO );  }//end tkaction function

}  //end try

catch(e) {}
}  //end catch(e)
									app.bringToFront();
    },
};

    								/*** Start "Copyright" button at the bottom of the panel.*/   
$._ext_COPYRIGHT={
    run : function() {    

alert(
'The TKActionsV4 panel is copyrighted by Tony Kuyper (©Tony Kuyper) and is protected under United States copyright law and the Berne International Copyright Convention.  Transfer or sale is prohibited.\n\n' +

'Use of the panel is governed by the end-user license agreement (EULA) that you agreed to prior to purchasing and downloading the panel. A quick summary of the EULA includes:\n\n' +

'--Everything is copyrighted.\n' +
'--The product is provided "As is" and there is no warranty.\n' +
'--Installation is OK on only two computers.\n' +
'--Redistribution is not permitted.\n' +
'--Creating a similar product through reverse engineering or other means is prohibited.\n\n' +

'Thank you for respecting the time and effort required to produce this panel and for showing the appropriate consideration for the intellectual property of others.  Your support has made this panel possible, and I sincerely appreciate it.  I hope this tool helps expand your creative efforts in Photoshop. \n\n' +

'You may contact me at tony.kuyper@hotmail.com if you have questions, comments, or suggestions about the panel.  The "Help / User Guides" button in the lower right of the panel has links to a detailed Instructions PDF and written and video tutorials that teach how to use the panel and integrate luminosity masks into your workflow.  \n\n' +


'--Tony Kuyper '

		);
									app.bringToFront();
    },
}; 

    								/*** Start "Test" button of the "Test" tab of the panel. This is the templat for the other funcitons */   
$._ext_TEST={
    run : function() {    

var DocToOpen = File.openDialog();
try {
       app.open(DocToOpen);
      }
catch(e) {}
									app.bringToFront();
    },
}; 