﻿
        var companyCode;
        var GraphimgId;
        var LastId;

            

        function LoadGraph(code, idPrefix, numItems, imgId, control, hidId) {   
            //alert('code: ' + code + ' Prefix: ' + idPrefix + ' ContNum: ' + numItems + ' imageid: ' + imgId + ' control: ' + control.id);
            //companyCode = code;
            var checker = document.getElementById(hidId)
            checker.value = code;
            $('#' + hidId).value = code;
            

        for (var i = 1; i <= numItems; i++) {
            $('#' + idPrefix + i).css('background-color', '#CCCCCC');

        }
        
        $('#' + control.id).css('background-color', '#FFFFFF');
        
        
        $('#IntraDay').css('font-weight', 'normal');
        $('#ThreeMonth').css('font-weight', 'bold');
        $('#OneYear').css('font-weight', 'normal');
        $('#ThreeYear').css('font-weight', 'normal');
        $('#FiveYear').css('font-weight', 'normal');
        
        ChangeGraph('ThreeMonth', 'ThreeMonth', imgId, hidId)
        }


        function ChangeGraph(graph, id, ImageId, hidId) {
            
            var checker = document.getElementById(hidId)
            var companyCode = checker.value;
            $('#' + LastId).css('font-weight', 'normal');
            $('#IntraDay').css('font-weight', 'normal');
            $('#ThreeMonth').css('font-weight', 'normal');
            $('#OneYear').css('font-weight', 'normal');
            $('#ThreeYear').css('font-weight', 'normal');
            $('#FiveYear').css('font-weight', 'normal');
            LastId = id;
            if(graph == 'IntraDay') {
                
                var todaysDate = new Date();
                var day = todaysDate.getDate();
                var year  = todaysDate.getFullYear();
                var month = todaysDate.getMonth();
                
                month++;
                
                if(day < 10)
                {   
                    day = '0' + day;
                }
                if(month < 10)
                {
                    month = '0' + month;
                }
                
                var date = year + '-' + month + '-' + day;
                
                $('#' + id).css('font-weight', 'bold');
                $('#' + ImageId).attr('src', 'http://netassets.hosted.inet.co.za/share/bdfm_test/c/' + companyCode + '/x/g/t/area/w/275/h/181/p/15M/s/%27' + date + '%2009:00%27/e/%27' + date + '%2017:00%27/z/0.8/D/%2715%20minute%20intraday%27');
            }
            else if(graph == 'ThreeMonth') {

               
                $('#' + id).css('font-weight', 'bold');
                $('#' + ImageId).attr('src', 'http://netassets.hosted.inet.co.za/share/bdfm_test/c/' + companyCode + '/x/g/t/area/w/275/h/181/p/d/s/-90/z/0.8/D/%273%20Months%27');
            }
            else if(graph == 'OneYear') {
            
                $('#' + id).css('font-weight', 'bold');
                $('#' + ImageId).attr('src', 'http://netassets.hosted.inet.co.za/share/bdfm_test/c/' + companyCode + '/x/g/t/area/w/275/h/181/p/w/s/-50/z/0.8/D/%271%20Year%27');
            }
            else if(graph == 'ThreeYear') {
            
                $('#' + id).css('font-weight', 'bold');
                $('#' + ImageId).attr('src', 'http://netassets.hosted.inet.co.za/share/bdfm_test/c/' + companyCode + '/x/g/t/area/w/275/h/181/p/w/s/-150/z/0.8/D/%273%20Year%27');
            }
            else if(graph == 'FiveYear') {
            
                $('#' + id).css('font-weight', 'bold');
                $('#' + ImageId).attr('src', 'http://netassets.hosted.inet.co.za/share/bdfm_test/c/' + companyCode + '/x/g/t/area/w/275/h/181/p/w/s/-250/z/0.8/D/%275%20Year%27');
            }
        }

