function deriveRoot()
{
  var root = window.location.protocol+'//'+window.location.hostname+'/';
  
  if ( ( pos = window.location.pathname.search('public_html') ) != -1 )
  {
    root += window.location.pathname.substring(1,pos+12);
  }
  
  return root;
}

function improveNavigation( root ) // Improve Upon CSS Implementation for JS-enabled browsers
{
  // Highlight Current Nav Item...
  area = $('body').attr('id');
  
  $('li#nav'+area+' a:first').append('<img src="'+root+'media/img/nav_current.gif" alt="current" />');
}

function improveBGforHighRes()
{
  var browser = $(window).width();
  
  if ( browser >= 1478 )
  {
    $('body').append( '<div id="flagLeft"><!-- cosmetic --></div>' )
    .append( '<div id="flagRight"><!-- cosmetic --></div>' );
    
    $('div#flagLeft,div#flagRight').width( ( Math.ceil(( browser - 1478 ) / 2 ) ));
  }
  else
  {
    $('div#flagLeft,div#flagRight').remove();
  }
}

function rolloverImages() {
    $(".rolloverImage").hover(
        function() { this.src = this.src.replace("_off.", "_on."); }
        ,
        function() { this.src = this.src.replace("_on.", "_off."); }
        );
}

function rotateExhibitorPanel() {
    $("a.exhibitorRotate").cycle({
            fx: 'fade',
            speed: 1000
        });
}

$(document).ready(function() {
    var root = deriveRoot();

    improveNavigation(root);

    $('div#header ul').superfish({});
    rolloverImages();
    rotateExhibitorPanel();

    improveBGforHighRes();

    $(window).resize(function() {
        improveBGforHighRes();
    });
});