var FrameSheetModel = (function() { var inst; var frames = []; var width; var height; var createEmptyFrame_ = function() { var emptyFrame = new Array(width); for (var columnIndex=0; columnIndex < width; columnIndex++) { emptyFrame[columnIndex] = new Array(height); } return emptyFrame; }; return { validate: function() { return true; // I'm always right dude }, // Could be use to pass around model using long GET param (good enough for simple models) and // do some temporary locastorage serialize: function() { throw "FrameSheet.serialize Not implemented" }, addEmptyFrame: function() { frames.push(createEmptyFrame_()); }, getFrameCount: function() { return frames.length; }, getFrameByIndex: function(index) { if (isNaN(index)) { throw "Bad argument value for getFrameByIndex method: <" + index + ">" } else if (index < 0 || index > frames.length) { throw "Out of bound index for frameSheet object." } return frames[index]; }, removeFrameByIndex: function(index) { if(index < 0 || index > inst.getFrameCount()) { throw "Bad index value for removeFrameByIndex."; } frames.splice(index, 1); }, duplicateFrameByIndex: function(frameToDuplicateIndex) { var frame = inst.getFrameByIndex(frameToDuplicateIndex); var clonedFrame = []; for(var i=0, l=frame.length; i