﻿// JScript File
 
    // Globals
    ////////////////
    var gnStepPeriod;
    var gnSteps;
    
    // Opacity
    var gnOpacity;
    var gnOpacityChange;
    var gsImageID;


    
    // Init
    /////////////////
    function OnPageLoad( sImageID )
    {
       //debugger;
       gsImageID = sImageID;
        // Setup for fadeout
        gnAnimSequenceState = 2;
        AnimSequencer();
    }


    // Set parameters for given object/s . Obj and Params are given as string arguments to the function
    // in groups of 3. ie 'ID', 'Method', 'Arg' ect. 
    /////////////////////////////////
    function SetParamsOfObjects()
    {
        // Loop through the additional arguments
        for (var i=0; i<(arguments.length); i+=3)
        {
            // Build str in the form of ID.Method.Arg
            var Str = 'document.getElementById(\'' + arguments[i] + '\').' + arguments[i+1] + ' = ' + '\'' + arguments[i+2] + '\''; 
            eval( Str ); // Run str as java code
        }
    } 
    

    // Core styles are.
    // ImageObj.style.filters.alpha.opacity=90  // For IE4 syntax
    // ImageObj.style.MozOpacity=0.9            // For NS6 syntax
    //
    function SetOpacity(sObjID, nOpacity)
    {
        oImageObj = document.getElementById( sObjID );
        if (navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion)>=5)
            oImageObj.style.MozOpacity = nOpacity/100;
        else if (navigator.appName.indexOf("Microsoft")!= -1 && parseInt(navigator.appVersion)>=4)
            oImageObj.style.filter = "alpha(opacity:" + nOpacity + ")";
    }


    //  Sequence animation.
    //////////////////////////////////////
    function AnimSequencer()
    {
        switch( gnAnimSequenceState )
        {
            case 1: 
                document.getElementById('LinkButtonSkipIntro').style.visibility = "hidden";
                gnSteps = 20;           // Num of fade steps
                gnStepPeriod = 60;     // 100Ms timer period
                gnOpacity = 100;        // 100% starting opacity
                gnOpacityDelta = -5;   // Opacity change per step
                Animate();
                gnAnimSequenceState = 0;
            break;
            case 2: 
                DelayAnimation( 4000 ); // Hold initial image
                gnAnimSequenceState = 1;
            break;
            
            case 0:                     // Nothing left to animate
            default:
                clearTimeout();         // Finished animation
                document.location.href = 'Home.aspx';
            break;
        } 
    }


    function Animate()
    {
        //debugger;
        if( gnSteps <= 0 )
        {
            // Finished so pick the sequencer
            setTimeout ( "AnimSequencer()", gnStepPeriod );
        }
        else
        {
            gnSteps--;                  // Dec loop count
            gnOpacity += gnOpacityDelta;
            // 
            SetOpacity( gsImageID, gnOpacity );
            setTimeout ( "Animate()", gnStepPeriod );
        }
    }
    
    //
    // Delay for given Period 
    function DelayAnimation( nDelayMs )
    {
        setTimeout ( "AnimSequencer()", nDelayMs );
    }





