// Adds a console global object to browsers which have none (ie6)
// the console checks for the value of the hsp.log variable, if logging is turned off (see .htaccess) console.log() does nothing
// Otherwise a overlay logging window is added to the page, where logging statements are displayed
$(function () {
  if (typeof (console) === 'undefined') {
    // configure logging here
    // a reasonable way to do this is to 
    var log = fff.log;
    if (log) {
      $('body').append(
        '<div id="logging-div">'+
        '<div id="logging-header" style="border-bottom: 1px solid black;padding: 1px 2px;">'+
        'Logging Window, click to close or toggle with \'L\''+
        '</div>'+
        '</div>'
        );
      $('#logging-div').css({
        display: 'block',
        position: 'absolute',
        zIndex: 5000,
        top: '20px',
        left: '20px',
        backgroundColor: '#eeeeee',
        height: '200px',
        overflow: 'auto',
        width: '400px',
        border: '1px solid black',
        opacity: '0.7'
      }).click(function () {
        $(this).fadeOut();
      });
    }


   
    console = {
      log : function (x) {
        // if logging is not turned on, the concole object just eats the console.log() calls
        if (!log) return;
        $('#logging-div').append(x+'<br/>');
      }
    }

    if (log) {
      $(document).keyup(function(e){
        if (e.keyCode === 76)
        {
          var display = $('#logging-div').css('display');
          if (display === 'block') {
            $('#logging-div').fadeOut(200);
          } else {
            $('#logging-div').fadeIn(200);
          }

        }
      });
    }
  }
});

