﻿/* TO DO 
    Only change lengths of layers whose endpoint is greater or equal to the old comp end point.
    */
function getSelectedProjectItems (){
    var items = [];
    var p = app.project;
    for ( var i = 1 ; i <= p.numItems ; i ++ ){
        var item = p.item(i);
        if ( item.selected ){
            items.push(item);
        }
    }
    return items;
}

function applyNewLength( comp , newLength){
    comp.duration = newLength;
    for ( var i = 1; i <= comp.layers.length ; i ++){
        if (!comp.layers[i].locked){
            comp.layers[i].outPoint = newLength;
        }else{
            comp.layers[i].locked = false;
            comp.layers[i].outPoint = newLength;
            comp.layers[i].locked = true;
        }
    }
}

function applyNewFramerate( comp , newFrameRate){
    comp.frameRate = newFrameRate;
}

itms = getSelectedProjectItems();
 for ( var i = 0; i < itms.length ; i ++){
//    applyNewFramerate( itms[i] , 29.97);
    applyNewLength( itms[i] ,120);
}
