$( document ).ready( function()
{
  /////////////////////
  // Browser support //
  /////////////////////
  if ( browserSupported() )
  {
    $( "body" ).hide();
    $( window ).load( function()
    {
      $( "body" ).fadeIn();
    });
    //if ( !$.browser.msie )
    //{
    //  var css = $( "<link/>" ).attr(
    //  {
    //    type: 'text/css',
    //    rel: 'stylesheet',
    //    href: '/css/font.css'
    //  });
    //  $( "head" ).append( css );
    //}
    //else
    if ( $.browser.msie )
    {
      $( 'input.upload-overlay' ).each( function()
      {
        $( this ).attr( 'title', 'Double click on this field to edit' );  // need a workaround for IE double click instead
      });
    }
  }
  else
  {
    if ( !$.cookie( 'browser-warning' ) )
    {
      $.cookie( 'browser-warning', 'warned' );
      var message = "You are using an unsupported version of your browser! Supported browsers are:\n\n";
      message    += "\tGoogle Chrome 4 or higher (recommended)\n";
      message    += "\tMozilla Firefox 3.5 or higher (recommended)\n";
      message    += "\tApple Safari 3.1 or higher\n";
      message    += "\tMicrosoft Internet Explorer 7 or higher.\n";
      message    += "\nWe highly recommend that you use one of these browsers in order to properly view this website.";
      //alert( message );
    }
  }
});

///////////////
// Functions //
///////////////

function browserSupported()
{
  if ( $.browser.msie )
  {
    if ( parseInt( $.browser.version ) >= 7 ) return true;
  }
  if ( $.browser.mozilla )
  {
    if ( $.browser.version >= '1.9.1' ) return true;
  }
  if ( $.browser.webkit )
  {
    if ( /chrom/.test( navigator.userAgent.toLowerCase() ) )
    {
      if ( $.browser.version >= '532.1' ) return true;
    }
    // http://www.zytrax.com/tech/web/mobile_ids.html
    else if ( /apple/.test( navigator.userAgent.toLowerCase() ) && !( /mobile/.test( navigator.userAgent.toLowerCase() ) ) ) // achtung mobile!
    {
      if ( $.browser.version >= '525' ) return true;
    }
  }
  if ( $.browser.opera )
  {
    if ( parseInt( $.browser.version ) >= 10 ) return true;
  }
  return false;
}

