
function Page(params, scripts)
{
    this.params  =  params;
    this.scripts =  scripts;
}

Page.prototype.loadScripts = function(files)
{
    var path = '//' + location.hostname + '/js/';

    for(var x in files) {
        $.ajax({url: path + files[x], dataType: 'script', async: false, cache: true});        
    }        
}


Page.prototype.init = function()
{                
    this.page = (this.getLevel(2) != '') ? this.getLevel(1) + '-' + this.getLevel(2) : this.getLevel(1);    
    this.cleanUpView();
    this.loadJsFiles();           
}


Page.prototype.cleanUpView = function()
{
    if (this.page == 'login') {
        $('header').removeAttr('id'); 
    }  else {
        $('#content').empty();
        $('header').attr('id', 'header');
        $('body').attr('id', this.page);
    }
}

Page.prototype.loadJsFiles = function()
{
    if (auth_obj == false) {        
        auth_obj = new SSO();
        auth_obj.getStatus();               
    }    
        
    if (auth_obj.getRole() == educator) {        
        this.loadScripts(this.scripts.educator);
    }
    
}

Page.prototype.getLevel = function(level)
{
    var route = ($.browser.msie && $.browser.version == 7.0) ? level : level - 1;
    return (mvlRouter.getRoute(route)) ? mvlRouter.getRoute(route) : '';
}

Page.prototype.show = function()
{       
    this.init();
    
    var mvlHeader = new Header();
        mvlHeader.show();
            
    for(var x in this.params) {        
        if (x == this.page) {            
            for (var y in this.params[x]) {                
                if (y == this.getLevel(this.params[x][y].level)) { 
                    log('Calling: ',x+'-'+y);
                    return this.params[x][y].on();
                    break;
                }
            }                        
            return this.params[x].on();
            break;
        }
    }           
}
