var FSI = (function (name) {return name;}(FSI || {}));
FSI.Model.Content = (function(){
   
    var locale = "something from the URL";
    var content = {
        currentViewId : "heritage",
        views : ["heritage", "built_in_canada", "stylish_features", "star_safety_system",  "toyota_matrix", "model_lineup", "audio", "thank_you"]
    };
    var numViews = content.views.length;
    var getViewIndex = function(v){
        var view = v || content.currentViewId;
        var indx;
        $.each(content.views,function(i){ view == this ? indx = i : 0;});
        return indx;
    };
    var doGet = function(n){
        var viewIndex = getViewIndex();
        if(n && n === "next"){
            viewIndex = (viewIndex+1 < numViews) ? viewIndex+1 : 0;
        }
        else if (n && n === "prev"){
            viewIndex = (viewIndex-1 < 0) ? numViews-1 : viewIndex-1;
        }
        else if (n){
            throw "Argument must be \"next\" or \"prev\"";
        }        
        content.currentViewId = content.views[viewIndex];
        return content.currentViewId;
    };
    
    
    return{
        set:function(view){
            content.currentViewId = view;
        },
        get:function(n){
            return doGet(n);
        },
        getNext:function(){
            var indx = getViewIndex();
            var nextIndx = indx == numViews-1 ? 0 : indx + 1;
            return content.views[nextIndx];
        },
        getPrev:function(){
            var indx = getViewIndex();
            var prevIndx = indx == 0 ? numViews-1 : indx - 1;
            return content.views[prevIndx];
        },
        getIndex:function(view){
            return getViewIndex(view);
        }
    };
}());

