﻿DefaultMaster=new function(){
    var _this=this;
    var _evtManager;
    var $;
    
    //constructor
    new function DefaultMaster(){
        _evtManager=new Inrix.Dom.EventManager();
        _evtManager.add(new Inrix.Event(window,'onload',initialize));
        _evtManager.add(new Inrix.Event(window,'onunload',dispose));
    }

    function initialize(){
        $=Inrix.Dom.get;
        sizeMainContent();
        _evtManager.add(new Inrix.Event(window,'onresize',sizeMainContent));
        startSession();
    }
    
    function dispose(){
        if(_evtManager)_evtManager.dispose();
        _this=_evtManager=$=null;
        endSession();
    }
    
    this.resize=sizeMainContent;
    
    function sizeMainContent(){
        var header=$('inrix:header');
        var navigation=$('inrix:navigation');
        var content=$('inrix:main');
        var footer=$('inrix:footer');
        
        var dims=Inrix.Dom.getScreenSize();
        
        var offsetTop=content.offsetTop;
        var offsetBottom=footer?footer.offsetHeight:0;

        var height=dims.height-offsetTop-offsetBottom;
        Object.Set(content,{style:{height:String.Format("{0}px",height)}});
    }
    
    function startSession(){
        new Inrix.Request({Action:"StartSession",p:location.href},null,null,-1).beginRequest();
    }

    function endSession(){
        new Inrix.Request({Action:"EndSession",p:location.href},null,null,-1).sendRequest();
    }
    
}
