
function Session_reset( )
{
        var d = new Date;
        var cookie = "session=" + Date.parse( d.toGMTString( ) ) + "; path=/;";

        document.cookie = cookie;
}

function Session_remember( tab )
{
        var tree = JavaScript_extractTree( );

        var regnbr = JavaScript_extractRegnbr( );
        var branch = JavaScript_extractBranch( docwin );

	if( tree || regnbr || branch )
	{
		// If you tweek something here you may have to tweek
		// MIUtils::query_recall
        	document.cookie = tab + "=" + tree + "|" + branch + "|" + regnbr + "; path=/";
	}
}

function Session_forget( authtype )
{
        var lastYear;
        var today = new Date;
        var year = today.getYear( );

        // See "Date" in JavaScript manual for explaination...
        if( year < 1000 ) year += 1900;
        today.setYear( year - 1 );
        lastYear = today.toGMTString( );

        var cookie = JavaScript_split( document.cookie, ';' );
        for( var i = 0; i < cookie.length; i++ )
        {
		//alert( cookie[ i ] );
                var parts = JavaScript_split( cookie[ i ], '=' );
                var name = JavaScript_chomp( parts[ 0 ] );

                if( name == "pass" && authtype != "site" )
                {
			document.cookie = name + "=expired; path=/; expires=" + lastYear;
                }
                if( name == "site" && authtype == 'site' )
                {
			document.cookie = name + "=expired; path=/; expires=" + lastYear;
                }
                if( name == "macname" )
                {
                                document.cookie = name + "=expired; path=/cgi-mi-auth; expires=" + lastYear;
                }
        }
	
	var url = location.protocol + "//" + location.host + location.pathname +"?tab=home&logout=1" ;
 
	location.href = url;
}

