﻿        // Create a NEW 4D array called "A" that will contain a 3D array of heirarchical hyperlink values
        var A = new Array();

        // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value containing a NEW array of tier ONE hyperlinks and sublinks
        A[0] = 'SITE MAP ROOT';
        // The second element (index = 1) of this array will contain a NEW array of tier ONE hyperlinks and sublinks
        A[1] = new Array();

            // The first element (index = 0) of this NEW array will hold a tier ONE hyperlink value
            A[1][0] = 'Company';
            
            // The second element (index = 1) of this array will contain a NEW array of tier TWO hyperlinks
            A[1][1] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[1][1][0] = 'Overview';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[1][1][1] = [
                    'Location',     // A[1][1][1][0]
                    'Contact',      // A[1][1][1][1]
                    'Brochure',     // A[1][1][1][2]
                    'News Letter',  // A[1][1][1][3]
                    'Client News'   // A[1][1][1][4]
                ];

            // The third element (index = 2) of this array will contain a NEW array of tier TWO hyperlinks
            A[1][2] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[1][2][0] = 'History';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[1][2][1] = [
                    'Partnerships',     // A[1][2][1][0]
                    'Brand Integrity',  // A[1][2][1][1]
                    'Portfolio'         // A[1][2][1][2]
                ];

            // The fourth element (index = 3) of this array will contain a NEW array of tier TWO hyperlinks
            A[1][3] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[1][3][0] = 'Future';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[1][3][1] = [
                    'Konquest',     // A[1][3][1][0]
                    'Pokra',        // A[1][3][1][1]
                    'Muzic',        // A[1][3][1][2]
                    'Goog',         // A[1][3][1][3]
                    'KTest'         // A[1][3][1][4]
                ];

            // The fifth element (index = 4) of this array will contain a NEW array of tier TWO hyperlinks
            A[1][4] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[1][4][0] = 'Expertise';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[1][4][1] = [
                    'Hardware',         // A[1][4][1][0]
                    'Software',         // A[1][4][1][1]
                    'Communications',   // A[1][4][1][2]
                    'Operations',       // A[1][4][1][3]
                    'Design',           // A[1][4][1][4]
                    'Research'          // A[1][4][1][5]
                ];


        // The third element (index = 1) of this array will contain a NEW array of tier ONE hyperlinks and sublinks
        A[2] = new Array();
        
            // The first element (index = 0) of this NEW array will hold a tier ONE hyperlink value
            A[2][0] = 'Services';
            // The second element (index = 1) of this array will contain a NEW array of tier TWO hyperlinks
            A[2][1] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[2][1][0] = 'Advertising';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[2][1][1] = [
                    'Online Marketing',     // A[2][1][1][0]
                    'Public Relations',     // A[2][1][1][1]
                    'CRM',                  // A[2][1][1][2]
                    'Direct Marketing',     // A[2][1][1][3]
                    'E-Commerce'            // A[2][1][1][4]
                ];

            // The third element (index = 2) of this array will contain a NEW array of tier TWO hyperlinks
            A[2][2] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[2][2][0] = 'Design';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[2][2][1] = [
                    'Corporate Branding',   // A[2][2][1][0]
                    'Logo Design',          // A[2][2][1][1]
                    'Print Production'      // A[2][2][1][2]
                ];

            // The fourth element (index = 3) of this array will contain a NEW array of tier TWO hyperlinks
            A[2][3] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[2][3][0] = 'Development';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[2][3][1] = [
                    'Application Development',  // A[2][3][1][0]
                    'Application Integration',  // A[2][3][1][1]
                    'Application Maintenance',  // A[2][3][1][2]
                    'Website Development',      // A[2][3][1][3]
                    'SOA Initiatives'           // A[2][3][1][4]
                ];

            // The fifth element (index = 4) of this array will contain a NEW array of tier TWO hyperlinks
            A[2][4] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[2][4][0] = 'Communication';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[2][4][1] = [
                    'Voice Providers',          // A[2][4][1][0]
                    'Data Providers',           // A[2][4][1][1]
                    'Fax Providers',            // A[2][4][1][2]
                    'Voip Providers',           // A[2][4][1][3]
                    'Intranet Providers',       // A[2][4][1][4]
                    'PBX Providers',            // A[2][4][1][5]
                    'PTT Providers'             // A[2][4][1][6]
                ];
            
            // The sixth element (index = 5) of this array will contain a NEW array of tier TWO hyperlinks
            A[2][5] = new Array();
            
                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[2][5][0] = 'Training';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[2][5][1] = [
                    'Platforms',                // A[2][5][1][0]
                    'Basic Training',           // A[2][5][1][1]
                    'Academia'                  // A[2][5][1][2]
                ];


        // The fourth element of this array will contain a NEW array of tier ONE hyperlinks and sublinks
        A[3] = new Array();
            
            // The first element (index = 0) of this NEW array will hold a tier ONE hyperlink value
            A[3][0] = 'Solutions';
            // The second element (index = 1) of this array will contain a NEW array of tier TWO hyperlinks
            A[3][1] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[3][1][0] = 'Software';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[3][1][1] = [
                    'Turn-Key',                     // A[3][1][1][0]
                    'Widgets',                      // A[3][1][1][1]
                    'E-Commerce',                   // A[3][1][1][2]
                    'News'                          // A[3][1][1][3]
                ];

            // The third element (index = 2) of this array will contain a NEW array of tier TWO hyperlinks
            A[3][2] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[3][2][0] = 'Hardware';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[3][2][1] = [
                    'Computer Hardware',            // A[3][2][1][0]
                    'Computer Peripherals',         // A[3][2][1][1]
                    'Audio',                        // A[3][2][1][2]
                    'Video',                        // A[3][2][1][3]
                    'Lighting',                     // A[3][2][1][4]
                    'Communications',               // A[3][2][1][5]
                    'Print Scan Fax',               // A[3][2][1][6]
                    'Custom Systems',               // A[3][2][1][7]
                    'News'                          // A[3][2][1][8]
                ];

            // The fourth element (index = 3) of this array will contain a NEW array of tier TWO hyperlinks
            A[3][3] = new Array();

                // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
                A[3][3][0] = 'Resources';
                // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
                A[3][3][1] = [
                    'Online',                       // A[3][3][1][0]
                    'Offline & Print',              // A[3][3][1][1]
                    'Academic',                     // A[3][3][1][2]
                    'News'                          // A[3][3][1][3]
                ];

            // The fifth element (index = 4) of this array will contain a NEW array of tier TWO hyperlinks
            A[3][4] = new Array();

            // The first element (index = 0) of this NEW array will hold a tier TWO hyperlink value
            A[3][4][0] = 'Out-Sourcing';
            // The second element (index = 1) of the array will contain a NEW array of tier THREE hyperlinks
            A[3][4][1] = [
                'Offshore',                     // A[3][4][1][0]
                'Dedicated Development Server', // A[3][4][1][1]
                'Quality Assurance',            // A[3][4][1][2]
                'CRM',                          // A[3][4][1][3]
                'News'                          // A[3][4][1][4]
            ];


// LOGIC
        var menu_0 = menu_1 = menu_2 = 0;
        function FlipLink( tier, link ) {
            switch(tier) {
                case 0:
                    menu_0 = link;
                    StyleLinkAt(tier, link);
                    // Set the second menu
                    FlipSet(tier, link);
                    // 0n the Second menu (case 1) flip the first link (element 0)
                    FlipLink(1,0);
                    break;

                case 1:
                    menu_1 = link;
                    StyleLinkAt(tier, link);
                    // Set the third menu 
                    FlipSet(tier, link);
                    // 0n the Third menu (case 2) flip the first link (element 0)
                    FlipLink(2,0);
                    break;
                    
                case 2:
                    menu_2 = link;
                    StyleLinkAt(tier, link);
                    FlipMain();
                    break;
            }
        }
        
        function StyleLinkAt(tier, link) {
            maxlinks = (tier==0)? A.length - 1 : (tier == 1)? A[menu_0+1].length - 1 : A[menu_0+1][menu_1+1][1].length; 
            //alert("maxlinks: " + maxlinks);

            for (i=0;i<maxlinks;i++) {
                if (document.getElementById("A" + tier + "_" + i).className == "A_OFF")
                    document.getElementById("A" + tier + "_" + i).innerHTML = '<a href="javascript:FlipLink('+ tier + ',' + i + ')">' + ((tier == 0)? A[i+1][0] : (tier == 1)? A[menu_0+1][i+1][0] : (A[menu_0+1][menu_1+1][1][i]) ) + '</a>';
                document.getElementById("A" + tier + "_" + i).className = "A_ON";
            }
            document.getElementById("A" + tier + "_" + link).innerHTML = (tier==0)? A[menu_0+1][0] : (tier==1)? A[menu_0+1][menu_1+1][0] : A[menu_0+1][menu_1+1][1][link];
            document.getElementById("A" + tier + "_" + link).className = "A_OFF";
            
            if (tier==1){
                for (i=0;i<maxlinks;i++)
                    document.getElementById("child_mdl_2_" + i).className = "child_mdl_bar_C_ON";
                document.getElementById("child_mdl_2_" + link).className = "child_mdl_bar_C_UP";
            }
        }

        function FlipSet(tier, link) {
            switch(tier) {
                case 0:
                    if(document.getElementById("child_mdl_2_5").className == "child_mdl_bar_C_OFF");
                        FlipSetContents();
                    FlipSetStyles(link);
                    break;

                case 1:
                    flippedSet = "";
                    for (i=0; i<A[menu_0+1][menu_1+1][1].length; i++) 
                        flippedSet += '<span id="A2_' + i + '" class="A_ON"><a href="javascript:FlipLink(2,' + i + ');">' + A[menu_0 + 1][menu_1 + 1][1][i] + '</a></span>&nbsp;&nbsp;&nbsp;\n';
                    document.getElementById("child_mdl_3_0").innerHTML = flippedSet;
                    break;
            }
        }
        function FlipSetContents() {
            for (i=0; i<4; i++) {
                    document.getElementById("child_mdl_2_" + i).innerHTML = '<span id="A1_' + i + '" class="A_ON"><a href="javascript:FlipLink(1,' + i + ');">' + A[menu_0+1][i+1][0] + '</a></span>';
            }
            if (A[menu_0+1][5])
                document.getElementById("child_mdl_2_4").innerHTML = '<span id="A1_' + i + '" class="A_ON"><a href="javascript:FlipLink(1,' + i + ');">' + A[menu_0+1][5][0] + '</a></span>';
            else
                document.getElementById("child_mdl_2_4").innerHTML = '&nbsp;';

            document.getElementById("child_mdl_2_5").innerHTML = '&nbsp;';
        }
        
        function FlipSetStyles(link) {
            for (i=0; i<5; i++) {
                if (i != link)
                    document.getElementById("child_mdl_2_" + i).className = "child_mdl_bar_C_ON";
                else
                    document.getElementById("child_mdl_2_" + i).className = "child_mdl_bar_C_UP";
            }
            if(A[menu_0+1][5])
                document.getElementById("child_mdl_2_4").className = "child_mdl_bar_C_ON";
            else
                document.getElementById("child_mdl_2_4").className = "child_mdl_bar_C_OFF";
            document.getElementById("child_mdl_2_5").className = "child_mdl_bar_C_OFF";

                
        }
        
        function FlipMain() {
            if (A[menu_0+1][menu_1+1][1][menu_2] == 'Konquest')
                document.getElementById("child_mdl_4_0").innerHTML = '<iframe height="100%" width="100%" src="konquest.htm" id="child_mdl_4_0_frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="yes" ></iframe>';
            else if (A[menu_0+1][menu_1+1][1][menu_2] == 'Pokra')
                document.getElementById("child_mdl_4_0").innerHTML = '<iframe height="100%" width="100%" src="pokra.htm" id="child_mdl_4_0_frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="yes" ></iframe>';
            else if (A[menu_0+1][menu_1+1][1][menu_2] == 'Muzic')
                document.getElementById("child_mdl_4_0").innerHTML = '<iframe height="100%" width="100%" src="muzic.htm" id="child_mdl_4_0_frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="yes" ></iframe>';
            else if (A[menu_0+1][menu_1+1][1][menu_2] == 'Goog')
                document.getElementById("child_mdl_4_0").innerHTML = '<iframe height="100%" width="100%" src="search.htm" id="child_mdl_4_0_frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="yes" ></iframe>';
            else if (A[menu_0+1][menu_1+1][1][menu_2] == 'KTest')
                document.getElementById("child_mdl_4_0").innerHTML = '<iframe height="100%" width="100%" src="ktest.htm" id="child_mdl_4_0_frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="yes" ></iframe>';
            else document.getElementById("child_mdl_4_0").innerHTML = A[menu_0+1][menu_1+1][1][menu_2] + ' Content';
        }
