// --------------------------------------------------------------------------------------
//  Navigator Class
//
//  author      todd schultz
//  version:    
//  
// --------------------------------------------------------------------------------------
//

function Navigator(  )
{

    //------------------------------------------------------------------
    // set section
    this.setSection = function( sectionNo )
    {
        //alert(" section:" + sectionNo );
        SECTION_NO = sectionNo;
    }
    //------------------------------------------------------------------
    // set page
    this.setPage = function( pageNo )
    {
        //alert(" page:" + pageNo );
        PAGE_NO = pageNo;

    }
    //------------------------------------------------------------------
    // set html file
    this.setHTMLFile = function( _loc )
    {
        
        for(cMark = 0; cMark < hashMarks.length; cMark++){
            if(hashMarks[cMark] == _loc){
            
                HTML_FILE = htmlPages[cMark];
                break;
            }

        }
        getHTMLContent ();
        
        if( SECTION_NO )
        {
	        // set up the icons
	        setIcon( sectionData[ Number( SECTION_NO ) - 1 ].icon, true );
	    }

        // set page header"
        var sectionContentData = sectionData[ Number( SECTION_NO )-1 ];
        
        if ( sectionContentData.page.length > 1 )
        {
            agControl.content.findName("header0").UnicodeString = sectionContentData.page[ Number( PAGE_NO )-1 ].header;
        }
        else
        {
            agControl.content.findName("header0").UnicodeString = sectionContentData.page.header;
        }
        
        checkVideoCanvas();
        

    }
    //------------------------------------------------------------------
     // set the current location in the history
    this.setLocation = function( _loc )
     {
        var _locArr = _loc.split("_");
        
        var navBtn = agControl.content.findName("nav_" + _locArr[ 0 ]);
        NavButtonOver(navBtn);
        NavButtonRelease(navBtn);
        
        if(Number(_locArr[1]) > 1){
        
            var subNavBtn1 = agControl.content.findName("subnavbtn_" + _locArr[0] + "_1");
            var subNavBtn = agControl.content.findName("subnavbtn_" + _locArr[0] + "_" + _locArr[1]);
            SubNavButtonOut(subNavBtn1);
            SubNavButtonOver(subNavBtn);
            SubNavButtonRelease(subNavBtn);
            
        
        }
         
        this.setSection( _locArr[ 0 ] );
        this.setPage( _locArr[ 1 ] );
        this.setHTMLFile( _loc );
        
        window.location.hash = _loc;
        unFocus.History.addHistory( _loc );
    }
    //------------------------------------------------------------------

    /*
    // check location and update app accordingly
    this.checkLocation = function()
    {
        // get the current location
        var _loc = unFocus.History.getCurrent();
            _loc = ( _loc.indexOf("#") > -1 ) ? _loc.split("#").join("") : _loc;
            
        var _SecPage = SECTION_NO + "_" + PAGE_NO;
               
        // there is a pre-existing location, deal with it
        if( _loc != "" && _loc != _SecPage )
        {
            appNavigator.setLocation( _loc );
        }
        else if ( _loc == "" )
        {
           
            //navBtn1 = agControl.content.findName("nav_1");
            
            
            //NavButtonOver(navBtn1);
            //NavButtonRelease(navBtn1);
            
            
        }
    }
    */
    //------------------------------------------------------------------
    return this;
}
